From: Sébastien Villemot Date: Wed, 28 Aug 2019 19:39:51 +0000 (+0100) Subject: Import ffcall_2.2.orig.tar.gz X-Git-Tag: archive/raspbian/2.2-1+rpi1~2^2~4 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=d4aafaebb0067b0bec9751edb1422e85ef10d6cf;p=ffcall.git Import ffcall_2.2.orig.tar.gz [dgit import orig ffcall_2.2.orig.tar.gz] --- d4aafaebb0067b0bec9751edb1422e85ef10d6cf diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..a3d1815 --- /dev/null +++ b/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, 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) + + 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/ChangeLog b/ChangeLog new file mode 100644 index 0000000..7c401db --- /dev/null +++ b/ChangeLog @@ -0,0 +1,5421 @@ +2019-08-24 Bruno Haible + + Bump shared library version numbers. + * Makefile.in (LIBFFCALL_VERSION_INFO): Bump to 0:2:0. + * avcall/Makefile.in (LIBAVCALL_VERSION_INFO): Bump to 1:2:0. + * trampoline/Makefile.in (LIBTRAMPOLINE_VERSION_INFO): Likewise. + * callback/Makefile.in (LIBCALLBACK_VERSION_INFO): Likewise. + +2019-08-24 Bruno Haible + + hppa: Add comments about structure arguments. + * avcall/avcall-hppa.c: Add comment. + * avcall/avcall-internal.h (__av_struct): Likewise. + * vacall/vacall-internal.h (__va_arg_struct): Likewise. + +2019-08-24 Bruno Haible + + Add a test for by-value passing. + * testcases.c (v_clobber_K): New function. + * avcall/tests.c (by_value_tests): New function. + (main): Invoke it. + * vacall/tests.c (simulator, main): Test v_clobber_K. + * callback/tests.c (v_clobber_K_simulator): New function. + (main): Test it. + +2019-08-24 Bruno Haible + + hppa: Implement correct floating-point argument passing on Linux. + * avcall/avcall.h (__AV_ALIST_WORDS): Add comment. + * avcall/avcall-alist.h (__av_alist) [__hppa__]: Add farg_mask, + darg_mask. + * avcall/avcall-internal.h (__av_start1) [__hppa__]: Initialize + farg_mask, darg_mask. + (_av_float) [__hppa__]: Set a bit in farg_mask. + (_av_double) [__hppa__]: Set a bit in darg_mask. + * avcall/avcall-hppa.c (avcall_call): Copy floating-point arguments + among the first 4 words to %fr4L...%fr7L and %fr5,%fr7. + * vacall/vacall-internal.h (_va_arg_float, _va_arg_double) [__hppa__]: + For floating-point arguments among the first 4 words, use the value + passed in floating-point registers. + * PLATFORMS, */PLATFORMS: List the Linux/hppa ABI. + * NEWS: Mention the new port. + +2019-08-24 Bruno Haible + + hppa: Fix stack corruption in avcall. + * avcall/avcall-hppa.c (avcall_call): Don't let GCC optimize away the + stack-allocated array. + * NEWS: Mention the fix. + +2019-08-24 Bruno Haible + + Add another integer test. + * testcases.c (i17, ..., i32): New variables. + (i_i32): New function. + * avcall/tests.c (int_tests): Test it. + * vacall/tests.c (simulator, main): Likewise. + * callback/tests.c (i_i32_simulator): New function. + (main): Test it. + +2019-08-24 Bruno Haible + + cross-tools: Add support for GCC 8 and 9. + * cross-tools/cross-build.sh (func_build_gcc): Handle also GCC 8 and 9. + +2019-08-21 Bruno Haible + + mips: Change the default 32-bit ABI from fp32 to fpxx. + Reported by Sébastien Villemot + at . + He also found the trick with -fno-tree-dce. + * porting-tools/abis/mips-abis.txt: New file. + * cross-tools/cross.conf (mips): Use gcc 5 and binutils 2.27. + * common/asm-mips.sh: Eliminate .nan and .module lines. + * avcall/avcall-mipsn32.c (avcall_call): Use return value of + __builtin_alloca instead of accessing the stack pointer directly. + * avcall/Makefile.devel (avcall-mipseb-linux.s, avcall-mipsel-linux.s): + Build with gcc 5, with option -mfpxx (for compatibility with current + Debian), with -march=mips2 (required by -mfpxx), and -fno-tree-dce + (required to avoid that gcc eliminates the __builtin_alloca call). + (avcall-mipsn32eb-linux.s, avcall-mipsn32el-linux.s, + avcall-mips64eb-linux.s, avcall-mips64el-linux.s): Build with gcc 5. + * vacall/Makefile.devel (vacall-mipseb-linux.s, vacall-mipsel-linux.s): + Build with gcc 5, with option -mfpxx (for compatibility with current + Debian) and -march=mips2 (required by -mfpxx). + (vacall-mipsn32eb-linux.s, vacall-mipsn32el-linux.s, + vacall-mips64eb-linux.s, vacall-mips64el-linux.s): Build with gcc 5. + * callback/vacall_r/Makefile.devel (vacall-mipseb-linux.s, + vacall-mipsel-linux.s): Build with gcc 5, with option -mfpxx (for + compatibility with current Debian) and -march=mips2 (required by + -mfpxx). + (vacall-mipsn32eb-linux.s, vacall-mipsn32el-linux.s, + vacall-mips64eb-linux.s, vacall-mips64el-linux.s): Build with gcc 5. + * NEWS: Mention the change. + +2019-08-20 Bruno Haible + + riscv32: Add support for riscv32-ilp32d ABI. + * cross-tools/cross.conf: Add configuration for riscv32 cross tools. + * porting-tools/emulation/buildroot-riscv-2018-10-20-riscv32.config: New + file. + * porting-tools/emulation/tinyemu-riscv32.txt: New file. + * porting-tools/emulation/README: Refer to it. + * porting-tools/abis/README: Tweaks. + * porting-tools/abis/call-used-registers.txt: Add info about riscv32. + * porting-tools/abis/reg-struct-return.txt: Likewise. + * porting-tools/abis/stack-frame.txt: Likewise. + * porting-tools/execstack/voidfunc.c: Add command for riscv32. + * porting-tools/execstack/voidfunc-riscv32.o: New generated file. + * porting-tools/execstack/README: Add info about riscv32. + * ffcall-abi.h: Add support for riscv32-lp64. + * configure.ac: Check for also on riscv32. + * avcall/avcall.h (__AV_STRUCT_RETURN): Add code for __riscv32__. + * avcall/avcall-alist.h (__av_alist): Likewise. + * avcall/avcall-internal.h: Add code for __riscv32__, especially + __av_start1, __av_reg_struct_return, __av_start_struct4, __av_word, + __av_longlong, __av_ulonglong, __av_arg_longlong, _av_float, _av_double, + __av_struct. + * avcall/avcall-riscv32.c: New file. + * avcall/Makefile.devel (avcall-riscv32-ilp32d-linux.s, + avcall-riscv32-ilp32d-macro.S): New targets. + * avcall/Makefile.in (avcall-riscv32-ilp32d.lo, + avcall-riscv32-ilp32d.s): New targets. + (clean): Remove avcall-riscv32-ilp32d.s. + (SOURCE_FILES): Add avcall-riscv32.c, avcall-riscv32-ilp32d-linux.s, + avcall-riscv32-ilp32d-macro.S. + * vacall/vacall.h (__VA_STRUCT_RETURN): Add code for __riscv32__. + * vacall/vacall-internal.h: Add code for __riscv32__, especially + __va_alist, __va_reg_struct_return, __va_start_struct2, + __va_arg_leftadjusted, __va_arg_adjusted, _va_arg_longlong, + _va_arg_ulonglong, __va_arg_longlong, __va_align_double, _va_arg_float, + _va_arg_double, __va_arg_struct. + * vacall/vacall-riscv32.c: New file. + * vacall/Makefile.devel (vacall-riscv32-ilp32d-linux.s, + vacall-riscv32-ilp32d-macro.S): New targets. + * vacall/Makefile.in (vacall-riscv32-ilp32d.@OBJEXT@, + vacall-riscv32-ilp32d.s): New targets. + (clean): Remove vacall-riscv32-ilp32d.s. + (SOURCE_FILES): Add vacall-riscv32.c, vacall-riscv32-ilp32d-linux.s, + vacall-riscv32-ilp32d-macro.S. + * callback/vacall_r/vacall_r.h (__VA_STRUCT_RETURN): Add code for + __riscv32__. + * callback/vacall_r/Makefile.devel (vacall-riscv32-ilp32d-linux.s, + vacall-riscv32-ilp32d-macro.S): New targets. + * callback/vacall_r/Makefile.in (vacall-riscv32-ilp32d.lo, + vacall-riscv32-ilp32d.s): New targets. + (clean): Remove vacall-riscv32-ilp32d.s. + (SOURCE_FILES): Add vacall-riscv32-ilp32d-linux.s, + vacall-riscv32-ilp32d-macro.S. + * trampoline/Makefile.devel (proto-riscv32.s, tramp-riscv32.o): New + targets. + * trampoline/proto-riscv32.s: New generated file. + * trampoline/tramp-riscv32.old.s: New file. + * trampoline/tramp-riscv32.old.o: New generated file. + * trampoline/tramp-riscv32.s: New file. + * trampoline/tramp-riscv32.o: New generated file. + * trampoline/trampoline.c: Implement for __riscv32__. + * callback/trampoline_r/Makefile.devel (proto-riscv32.s, + tramp-riscv32.o): New targets. + * callback/trampoline_r/proto.c: Add code for __riscv32__. + * callback/trampoline_r/proto-riscv32.s: New generated file. + * callback/trampoline_r/tramp-riscv32.old.s: New file. + * callback/trampoline_r/tramp-riscv32.old.o: New generated file. + * callback/trampoline_r/tramp-riscv32.s: New file. + * callback/trampoline_r/tramp-riscv32.o: New generated file. + * callback/trampoline_r/trampoline.c: Implement for __riscv32__. + * callback/trampoline_r/test1.c: Add support for __riscv32__. + * PLATFORMS, */PLATFORMS: List the 32-bit RISC-V ABI. + * NEWS: Mention the new port. + +2019-08-19 Bruno Haible + + Add some more general-purpose args boundary tests. + * testcases.c (l_l0J, l_l1J, l_l2J, l_l3J, l_l4J, l_l5J, l_l6J, l_l7J): + New functions. + * avcall/tests.c (gpargs_boundary_tests): Test them. + * vacall/tests.c (simulator, main): Likewise. + * callback/tests.c (l_l*J_simulator): New functions. + (main): Test them. + * porting-tools/abis/gpargs*.c: Add a corresponding test here as well. + +2019-08-19 Bruno Haible + + riscv64: Fix bug regarding passing of more than 8 arguments. + * porting-tools/abis/stack-frame.txt: Correct information about riscv64 + ABI. + * avcall/avcall-alist.h (__av_alist) [__riscv64__]: Remove ianum and + iargs. + * avcall/avcall-internal.h (__av_start1, __av_start_struct4, __av_long, + __av_ulong, __av_ptr, _av_float, _av_double, __av_struct) [__riscv64__]: + Change accordingly. + * avcall/avcall-riscv64.c (avcall_call): Likewise. + * vacall/vacall-internal.h (__va_arg_adjusted): Deal with a split struct + that spans the 8th and 9th argument words. + * vacall/vacall-riscv64.c (struct gpargsequence): New type. + (vacall_receiver): Use it to make sure that room is allocated when a + struct is passed that spans the 8th and 9th argument words. + +2019-08-19 Bruno Haible + + arm64: Fix bug regarding passing of more than 8 arguments. + * vacall/vacall-internal.h (__va_arg_adjusted): Bump (LIST)->ianum when + switching from registers to the stack. + * NEWS: Mention it. + +2019-08-19 Bruno Haible + + avcall: Remove unnecessary parentheses. + * avcall/avcall-internal.h (av_double, _av_float, _av_double): Remove + unnecessary level of parentheses. + +2019-05-11 Bruno Haible + + Update bug reporting instructions. + * README: Tell users to report bugs in the bug tracker or by email. + * cross-tools/cross-build.sh (func_usage): Likewise. + +2019-04-01 Bruno Haible + + build: Separate git operations from build operations. + * gitsub.sh: New file, from gnulib. + * .gitmodules: New file. + * autogen.sh: Remove all git operations. Look at GNULIB_SRCDIR + environment variable. Ignore the GNULIB_TOOL environment variable. + * README-hacking: Explain when to use gitsub.sh. + +2019-01-19 Bruno Haible + + Record support for NetBSD/SPARC64. + * PLATFORMS, */PLATFORMS: List this platform. + +2018-05-04 Bruno Haible + + Simplify code. Drop support for Borland C++ on Windows. + * common/asm-x86_64.h, common/asm-x86_64.sh, ffcall-stdint.h: + Simplify 'defined _WIN32 || defined __WIN32__' to just 'defined _WIN32'. + * avcall/avcall.h, avcall/avcall-alist.h: Likewise. + * vacall/vacall.h, vacall/vacall-internal.h: Likewise. + * callback/vacall_r/vacall_r.h: Likewise. + * trampoline/trampoline.c: Likewise. + * callback/trampoline_r/trampoline.c: Likewise. + +2018-04-08 Bruno Haible + + riscv64: Add support for riscv64-lp64d ABI. + * cross-tools/cross-build.sh (func_build_gcc): Add support for GCC 7.2.0 + and 7.3.0. + * cross-tools/cross.conf: Add configuration for riscv64 cross tools. + * porting-tools/emulation/qemu-riscv64.txt: New file. + * porting-tools/emulation/README: Refer to it. + * porting-tools/abis/README: Tweaks. + * porting-tools/abis/call-used-registers.txt: Add info about riscv64. + * porting-tools/abis/reg-struct-return.txt: Likewise. + * porting-tools/abis/stack-frame.txt: Likewise. + * porting-tools/abis/function-pointer.txt: Clarify file locations. + * porting-tools/execstack/voidfunc.c: Add command for riscv64. + * porting-tools/execstack/voidfunc-riscv64.o: New generated file. + * porting-tools/execstack/main.c (voidfunc): Define also for riscv. + * porting-tools/execstack/README: Add info about riscv64. + * ffcall-abi.h: Add support for riscv64-lp64. + * common/asm-riscv.sh: New file. + * Makefile.in (SOURCE_FILES): Add it. + * configure.ac: Check for also on riscv64. + * avcall/avcall.h (__AV_STRUCT_RETURN, __AV_REGISTER_STRUCT_RETURN): Add + code for __riscv64__. + * avcall/avcall-alist.h (__av_alist): Likewise. + * avcall/avcall-internal.h: Add code for __riscv64__, especially + __av_start1, __av_reg_struct_return, __av_start_struct4, __av_word, + __av_long, __av_ulong, __av_ptr, __av_longlong, __av_ulonglong, + _av_float, _av_double, __av_struct. + * avcall/avcall-riscv64.c: New file. + * avcall/Makefile.devel (avcall-riscv64-lp64d-linux.s, + avcall-riscv64-lp64d-macro.S): New targets. + * avcall/Makefile.in (avcall-riscv64-lp64d.lo, avcall-riscv64-lp64d.s): + New targets. + (clean): Remove avcall-riscv64-lp64d.s. + (SOURCE_FILES): Add avcall-riscv64.c, avcall-riscv64-lp64d-linux.s, + avcall-riscv64-lp64d-macro.S. + * vacall/vacall.h (__VA_STRUCT_RETURN, __VA_REGISTER_STRUCT_RETURN): Add + code for __riscv64__. + * vacall/vacall-internal.h: Add code for __riscv64__, especially + __va_alist, __va_reg_struct_return, __va_start_struct2, + __va_arg_leftadjusted, __va_arg_adjusted, _va_arg_longlong, + _va_arg_ulonglong, __va_align_double, _va_arg_float, _va_arg_double, + __va_arg_struct, _va_return_longlong. + * vacall/vacall-riscv64.c: New file. + * vacall/Makefile.devel (vacall-riscv64-lp64d-linux.s, + vacall-riscv64-lp64d-macro.S): New targets. + * vacall/Makefile.in (vacall-riscv64-lp64d.@OBJEXT@, + vacall-riscv64-lp64d.s): New targets. + (clean): Remove vacall-riscv64-lp64d.s. + (SOURCE_FILES): Add vacall-riscv64.c, vacall-riscv64-lp64d-linux.s, + vacall-riscv64-lp64d-macro.S. + * callback/vacall_r/vacall_r.h (__VA_STRUCT_RETURN, + __VA_REGISTER_STRUCT_RETURN): Add code for __riscv64__. + * callback/vacall_r/Makefile.devel (vacall-riscv64-lp64d-linux.s, + vacall-riscv64-lp64d-macro.S): New targets. + * callback/vacall_r/Makefile.in (vacall-riscv64-lp64d.lo, + vacall-riscv64-lp64d.s): New targets. + (clean): Remove vacall-riscv64-lp64d.s. + (SOURCE_FILES): Add vacall-riscv64-lp64d-linux.s, + vacall-riscv64-lp64d-macro.S. + * trampoline/Makefile.devel (proto-riscv64.s, tramp-riscv64.o): New + targets. + * trampoline/proto-riscv64.s: New generated file. + * trampoline/tramp-riscv64.s: New file. + * trampoline/tramp-riscv64.o: New generated file. + * trampoline/trampoline.c: Implement for __riscv64__. + * callback/trampoline_r/Makefile.devel (proto-riscv64.s, + tramp-riscv64.o): New targets. + * callback/trampoline_r/proto64.c: Add code for __riscv64__. + * callback/trampoline_r/proto-riscv64.s: New generated file. + * callback/trampoline_r/tramp-riscv64.s: New file. + * callback/trampoline_r/tramp-riscv64.o: New generated file. + * callback/trampoline_r/trampoline.c: Implement for __riscv64__. + * callback/trampoline_r/test1.c: Add support for __riscv64__. + * PLATFORMS, */PLATFORMS: List the 64-bit RISC-V ABI. + * NEWS: Mention the new port. + +2018-04-08 Bruno Haible + + s390x: Trivial tweak. + * avcall/avcall-s390x.c (avcall_call): Rename result variable from 'i' + to 'iret'. + +2018-02-26 Bruno Haible + + Add support for Linux/arm on Raspberry Pi. + Reported by Simon Dales . + * avcall/Makefile.devel (avcall-armhf-macro.S): Pass option + '-march=armv6' to gcc. + * vacall/Makefile.devel (vacall-arm-linux.s, vacall-arm-linux-pic.s): + Likewise. + * callback/vacall_r/Makefile.devel (vacall-armhf-macro.S): Likewise. + * PLATFORMS, */PLATFORMS: List this platform. + * NEWS: Mention this. + +2018-02-24 Bruno Haible + + Add support for Linux/i386 with PIE-enabled gcc. + * vacall/Makefile.devel (vacall-i386-linux-pic.s): New target. + (vacall-i386-macro.S): Include code for the PIC and the non-PIC case. + * vacall/Makefile.in (SOURCE_FILES): Add vacall-i386-linux-pic.s. + +2018-02-18 Bruno Haible + + Avoid undesired compiler optimizations. + Reported by Jerry James . + * configure.ac (DISABLE_TYPE_BASED_ALIASING): New substituted variable. + * avcall/Makefile.in (avcall-libapi.lo): Use it. + * vacall/Makefile.in (vacall-libapi.o): Likewise. + * callback/vacall_r/Makefile.in (vacall-libapi.lo): Likewise. + +2018-02-17 Bruno Haible + + Bump version number. + * VERSION: Set to 2.2. + * NEWS: Open new section for 2.2. + +2018-02-17 Bruno Haible + + Bump shared library version numbers. + * Makefile.in (LIBFFCALL_VERSION_INFO): Bump to 0:1:0. + * avcall/Makefile.in (LIBAVCALL_VERSION_INFO): Bump to 1:1:0. + * trampoline/Makefile.in (LIBTRAMPOLINE_VERSION_INFO): Likewise. + * callback/Makefile.in (LIBCALLBACK_VERSION_INFO): Likewise. + +2018-02-17 Bruno Haible + + Add support for HardenedBSD. + The fix was done in gnulib today. + * NEWS: Mention this. + +2018-02-17 Bruno Haible + + Add support for Linux/arm with PIE-enabled gcc. + Reported by Nelson Beebe. + * vacall/Makefile.devel (vacall-arm-linux.s, vacall-arm-linux-pic.s, + vacall-armhf-linux.s, vacall-armhf-linux-pic.s): New targets. + (vacall-arm-macro.S, vacall-armhf-macro.S): Include code for the PIC and + the non-PIC case. + * vacall/Makefile.in (SOURCE_FILES): Add vacall-arm*-linux*.s. + +2018-02-17 Bruno Haible + + Add support for OpenBSD 6.1 and newer. + Reported by Nelson Beebe. + * m4/codeexec.m4 (FFCALL_CODEEXEC_PAX): Also test whether mprotect + returns with errno=ENOTSUP. + * NEWS: Mention this. + +2018-01-30 Bruno Haible + + Verify support for Minix/i386. + * PLATFORMS, */PLATFORMS: List this platform. + +2018-01-27 Bruno Haible + + Rename some files. + * INSTALL.windows: Renamed from README.windows. + * INSTALL.os2: Renamed from README.os2. + * Makefile.in (SOURCE_FILES): Update. + +2018-01-09 Bruno Haible + + Make processing of assembly-language files work with GNU clisp. + * common/asm-arm.sh: Don't introduce C() macro in .req lines. + * common/asm-hppa.h (DEF): Don't use token-pasting operator here, since + the result would not be a valid token. + * common/asm-hppa64.h (DEF): Likewise. + * common/asm-i386.h (INSN2SHCL): Omit the cl register only on Solaris. + All other assemblers support it. + (P2ALIGN): Use __SVR4, not __sun, to detect Solaris. + * common/asm-i386.sh: Allow spaces instead of tabs after .type and + .size. Recognize INSN2SHCL without assuming an 'shcl' macro. + +2017-11-28 Bruno Haible + + mips, mipsn32, mips64: Improvement for ELF format. + * common/asm-mips.h (DECLARE_FUNCTION): Test __ELF__, not __GNU__. + +2017-11-25 Bruno Haible + + mips64: Fix crash on some real hardware mips64el (Octeon). + Reported by Sébastien Villemot . + Reminder: Some real MIPS hardware executes the "branch delay slot" + after a branch or jump instruction. See + + + * trampoline/trampoline.c (alloc_trampoline) [__mips64__]: Store the + instructions as 32-bit words, so that the instructions come out as + expected, regardless of the endianness. + * trampoline/tramp-mips*.s: Update comments. + * callback/trampoline_r/tramp-mips*.s: Likewise. + +2017-10-29 Bruno Haible + + Verify support for Haiku/i386. + * PLATFORMS, */PLATFORMS: List this platform. + +2017-10-22 Bruno Haible + + x86_64-x32: Fix passing of pointers. + * avcall/avcall-internal.h (__av_start_struct4, __av_ptr): For pointer + values, use zero-extend instead of cast from 'void*' to '__avword'. + * vacall/vacall-x86_64.c (vacall_receiver): For pointer values, use + zero-extend instead of cast from 'void*' to '__vaword'. + +2017-10-21 Bruno Haible + + Include libtool fix for Solaris 11.3. + Reported at . + * Makefile.maint (libtool-imported-files): Download and apply said fix. + +2017-10-09 Bruno Haible + + Avoid build failures caused by parallel make. + Reported by Riccardo G Corsi . + * Makefile.in (GNUMAKEFLAGS): New variable. + +2017-09-24 Bruno Haible + + Update NEWS. + * NEWS: Mention the API changes in 2.0. + +2017-09-15 Bruno Haible + + tests: Consistency. + * avcall/tests.c (pointer_tests): Move before the mixed_number_tests. + (gpargs_boundary_tests): Fix weakness in the f_f17l3L test. + +2017-09-12 Bruno Haible + + sparc: Verify support for NetBSD. + * PLATFORMS, */PLATFORMS: List this platform. + +2017-09-11 Bruno Haible + + Bump version number. + * VERSION: Set to 2.1. + * NEWS: Open new section for 2.1. + +2017-09-10 Bruno Haible + + Install the libraries as shared libraries by default. + * configure.ac (LT_INIT): Remove option 'disable-shared'. + * README: Remove outdated text. + * NEWS: Mention the change. + +2017-09-10 Bruno Haible + + Install a library named libffcall. + * ffcall-version.c: New file. + * ffcall-version.in.h: Rename double-inclusion guard. + (ffcall_get_version): New declaration. + * Makefile.in: Add variables for using libtool. + (LIBFFCALL_EXPORTED_SYMBOLS_REGEX, LIBFFCALL_VERSION_INFO): New + variables. + (all-subdirs, ffcall-version.lo, libffcall.la): New targets. + (all): Depend on them. + (install): Install also libffcall.la. + (installdirs): Create also $(libdir). + (uninstall): Uninstall also libffcall.la. + (MOSTLYCLEANDIRS, MOSTLYCLEANFILES): New variables. + (mostlyclean, clean, distclean, maintainer-clean): Delete these. + (SOURCE_FILES): Add ffcall-version.c. + * README: Mention libffcall.{a,so}. Mark libavcall and libcallback as + deprecated. + * NEWS: Mention the change. + +2017-09-10 Bruno Haible + + Move the backward compatibility code to separate object files. + * avcall/avcall-compat.c: New file, extracted from + avcall/avcall-libapi.c. + * avcall/Makefile.in (SOURCE_FILES): Add it. + (avcall-compat.lo): New target. + (OBJECTS): Add it. + * avcall/avcall-libapi.c (__builtin_avcall): Remove function. + * callback/callback-compat.c: New file, extracted from + callback/callback-libapi.c. + * callback/Makefile.in (SOURCE_FILES): Add it. + (callback-compat.lo): New target. + (libcallback.la): Include it. + * callback/callback-libapi.c (trampoline_r_data0): Remove function. + +2017-09-10 Bruno Haible + + vacall: Fix build failure with gcc configured with --enable-default-pie. + Works around a GCC bug, reported at + . + * configure.ac (WORKAROUND_BUG_81653): New variable. + * vacall/Makefile.in (vacall-sparc.@OBJEXT@, vacall-sparc.s): Use it. + +2017-09-10 Bruno Haible + + Fix build failure "error: narrowing conversion" with g++ on arm. + * testcases.c (C5): Cast -1 to 'char' explicitly. + +2017-09-10 Bruno Haible + + Fix build failure with --enable-shared on Solaris/x86 with cc. + * common/asm-i386.h: Test __SVR4, not __svr4__. + +2017-09-10 Bruno Haible + + Support building shared libraries on native Windows. + * configure.ac (LT_INIT): Add option 'win32-dll'. + * avcall/Makefile.in (avcall-x86_64.lo): Copy object file into .libs/ + directory. + * callback/vacall_r/Makefile.in (vacall-x86_64.lo): Likewise. + +2017-09-09 Bruno Haible + + i386: Verify support for Hurd. + * NEWS: List this platform. + +2017-09-09 Bruno Haible + + x86_64: Verify support for FreeBSD, NetBSD, OpenBSD. + * PLATFORMS, */PLATFORMS: List these platforms. + * NEWS: Likewise. + +2017-09-09 Bruno Haible + + i386: Restore support for FreeBSD, NetBSD, OpenBSD, DragonFly BSD. + * avcall/avcall.h (__AV_STRUCT_RETURN): Enable __AV_SMALL_STRUCT_RETURN + on FreeBSD/i386, OpenBSD/i386, DragonFly/i386. + * vacall/vacall.h (__VA_STRUCT_RETURN): Enable __VA_SMALL_STRUCT_RETURN + on FreeBSD/i386, OpenBSD/i386, DragonFly/i386. + * callback/vacall_r/vacall_r.h: Likewise. + * avcall/avcall-i386.c: Update comments. + * vacall/vacall-i386.c (vacall_receiver): Return the structure address + in %eax also for other platforms than MSVC. + * PLATFORMS, */PLATFORMS: List these platforms. + * NEWS: Likewise. + +2017-09-09 Bruno Haible + + i386: Assume MSVC struct return convention also on 32-bit mingw. + * avcall/avcall.h (__AV_STRUCT_RETURN): Enable __AV_MSVC_STRUCT_RETURN + on 32-bit mingw. + * vacall/vacall.h (__VA_STRUCT_RETURN): Enable __VA_MSVC_STRUCT_RETURN + on 32-bit mingw. + * callback/vacall_r/vacall_r.h: Likewise. + * NEWS: Mention the fix. + +2017-09-09 Bruno Haible + + vacall: Fix warnings on DragonFly BSD. + * vacall/vacall-internal.h (__va_start, __va_arg): Undefine first. + +2017-09-09 Bruno Haible + + avcall, vacall: Optimize struct return of small structs. + * avcall/avcall-arm64.c (avcall_call): Add alternative optimized code + for struct return. + * avcall/avcall-hppa.c (avcall_call): Likewise. + * avcall/avcall-ia64.c (avcall_call): Likewise. + * avcall/avcall-mipsn32.c (avcall_call): Likewise. + * avcall/avcall-mips64.c (avcall_call): Likewise. + * avcall/avcall-powerpc64.c (avcall_call): Likewise. + * avcall/avcall-sparc64.c (avcall_call): Likewise. + * avcall/avcall-x86_64.c (avcall_call): Likewise. + * avcall/avcall-x86_64-windows.c (avcall_call): Likewise. + * avcall/avcall-hppa64.c (avcall_call): Likewise, but don't enable it. + * vacall/vacall-arm64.c (vacall_receiver): Add alternative optimized + code for struct return. + * vacall/vacall-hppa.c (vacall_receiver): Likewise. + * vacall/vacall-ia64.c (vacall_receiver): Likewise. + * vacall/vacall-mipsn32.c (vacall_receiver): Likewise. + * vacall/vacall-mips64.c (vacall_receiver): Likewise. + * vacall/vacall-powerpc64.c (vacall_receiver): Likewise. + * vacall/vacall-sparc64.c (vacall_receiver): Likewise. + * vacall/vacall-x86_64.c (vacall_receiver): Likewise. + * vacall/vacall-x86_64-windows.c (vacall_receiver): Likewise. + * vacall/vacall-hppa64.c (vacall_receiver): Likewise. + +2017-09-09 Bruno Haible + + avcall, vacall: Align code style. + * avcall/avcall-hppa.c (avcall_call): Use variable name 'iret', like + for the other ABIs. + * avcall/avcall-ia64.c: Likewise. + * avcall/avcall-arm64.c (avcall_call): Use variable names 'iret' and + 'iret2', like for the other ABIs. + * avcall/avcall-x86_64.c: Likewise. + * avcall/avcall-sparc64.c (avcall_call): Use variable names 'iret', + 'iret2', 'iret3', 'iret4', for consistency. + * vacall/vacall-sparc64 (vacall_receiver): Likewise. + +2017-09-09 Bruno Haible + + x86_64: Remove register pressure on gcc. + * avcall/avcall-x86_64.c: Don't declare iarg[1-6]. + (avcall_call): Pass the integer arguments through arguments. + * avcall/avcall-x86_64-windows.c: Don't declare iarg[1-4]. + (avcall_call): Pass the integer arguments through arguments. + * vacall/vacall-x86_64.c: Don't declare iarg[1-6]. + (vacall_receiver): Use another way to save the integer registers. + * vacall/vacall-x86_64-windows.c: Don't declare iarg[1-4]. + +2017-09-09 Bruno Haible + + Fix preprocessor warning "does not give a valid preprocessing token". + * common/asm-i386.h (NUM): Don't use token concatenation between '$' + and a possibly negative number. + * common/asm-x86_64.h (NUM): Likewise. + +2017-09-09 Bruno Haible + + hppa64: Simplify trampoline. + * trampoline/tramp-hppa64-old.s: Renamed from trampoline/tramp-hppa64.s. + * trampoline/tramp-hppa64-old.o: Renamed from trampoline/tramp-hppa64.o. + * trampoline/tramp-hppa64-macro.S: New file. + * trampoline/Makefile.in (tramp-hppa64.lo, tramp-hppa64.s): New targets. + (clean): Remove tramp-hppa64.s. + (SOURCE_FILES): Add tramp-hppa64-macro.S. + * trampoline/trampoline.c: Distinguish __hppa64old__ and __hppa64new__. + Implement trampoline for __hppa64new__. + * callback/trampoline_r/tramp-hppa64-old.s: Renamed from + callback/trampoline_r/tramp-hppa64.s. + * callback/trampoline_r/tramp-hppa64-old.o: Renamed from + callback/trampoline_r/tramp-hppa64.o. + * callback/trampoline_r/tramp-hppa64-macro.S: New file. + * callback/trampoline_r/Makefile.in (tramp-hppa64.lo, tramp-hppa64.s): + New targets. + (clean): Remove tramp-hppa64.s. + (SOURCE_FILES): Add tramp-hppa64-macro.S. + * callback/trampoline_r/trampoline.c: Distinguish __hppa64old__ and + __hppa64new__. Implement trampoline for __hppa64new__. + * configure.ac (CPU_OBJECTS): Augment with tramp-hppa64.lo. + +2017-09-09 Bruno Haible + + hppa64: Add support for HP-PA in 64-bit mode on HP-UX. + * cross-tools/cross.conf: Add configuration for hppa64 cross tools. + * porting-tools/abis/README: Add details about platforms where function + pointers are actually pointers to some struct. + * porting-tools/abis/call-used-registers.txt: Add info about hppa64. + Fix info about hppa. + * porting-tools/abis/reg-struct-return.txt: Add info about hppa64. + * porting-tools/abis/stack-frame.txt: Likewise. + * porting-tools/execstack/voidfunc-hppa64.o: New file. + * common/asm-hppa64.h: New file. + * common/asm-hppa64.sh: New file. + * Makefile.in (SOURCE_FILES): Add them. + * avcall/avcall.h (__AV_REGISTER_STRUCT_RETURN): Add code for + __hppa64__. + * avcall/avcall-alist.h (__av_alist): Likewise. + * avcall/avcall-internal.h: Add code for __hppa64__, especially + __av_start1, __av_reg_struct_return, __av_start_struct4, __av_word, + __av_longlong, __av_ulonglong, _av_float, _av_double, + __av_struct_leftadjusted, __av_struct. + * avcall/avcall-hppa64.c: New file. + * avcall/Makefile.devel (avcall-hppa64-linux.s, avcall-hppa64-macro.S): + New targets. + * avcall/Makefile.in (avcall-hppa64.lo, avcall-hppa64.s): New targets. + (clean): Remove avcall-hppa64.s. + (SOURCE_FILES): Add avcall-hppa64.c, avcall-hppa64-linux.s, + avcall-hppa64-macro.S. + * vacall/vacall.h (__VA_REGISTER_STRUCT_RETURN): Add code for + __hppa64__. + * vacall/vacall-internal.h: Add code for __hppa64__, especially + __va_alist, __va_reg_struct_return, __va_start_struct2, + __va_arg_leftadjusted, __va_arg_rightadjusted, __va_arg_adjusted, + _va_arg_longlong, _va_arg_ulonglong, __va_align_double, _va_arg_float, + _va_arg_double, __va_arg_struct, _va_return_longlong. + * vacall/vacall-hppa64.c: New file. + * vacall/Makefile.devel (vacall-hppa64-linux.s, vacall-hppa64-macro.S): + New targets. + * vacall/Makefile.in (vacall-hppa64.@OBJEXT@, vacall-hppa64.s): New + targets. + (clean): Remove vacall-hppa64.s. + (SOURCE_FILES): Add vacall-hppa64.c, vacall-hppa64-linux.s, + vacall-hppa64-macro.S. + * callback/vacall_r/vacall_r.h (__VA_REGISTER_STRUCT_RETURN): Add code + for __hppa64__. + * callback/vacall_r/Makefile.devel (vacall-hppa64-linux.s, + vacall-hppa64-macro.S): New targets. + * callback/vacall_r/Makefile.in (vacall-hppa64.lo, vacall-hppa64.s): New + targets. + (clean): Remove vacall-hppa64.s. + (SOURCE_FILES): Add vacall-hppa64-linux.s, vacall-hppa64-macro.S. + * trampoline/Makefile.devel (cache-hppa64-linux.s, + cache-hppa64-macro.S): New targets. + (proto-hppa64.s, tramp-hppa64.o): New targets. + * trampoline/proto-hppa64.s: New generated file. + * trampoline/tramp-hppa64.s: New file. + * trampoline/tramp-hppa64.o: New generated file. + * trampoline/tramp-hppa-macro.S: Fix comment. + * trampoline/cache-hppa.c: Add code for __hppa64__. + * trampoline/trampoline.c: Implement for __hppa64__. + * trampoline/Makefile.in (cache-hppa64.lo, cache-hppa64.s): New targets. + (clean): Remove cache-hppa64.s. + (SOURCE_FILES): Add cache-hppa64-linux.s, cache-hppa64-macro.S. + * callback/trampoline_r/Makefile.devel (cache-hppa64-linux.s, + cache-hppa64-macro.S): New targets. + (proto-hppa64.s, tramp-hppa64.o): New targets. + * callback/trampoline_r/proto64.c: Add code for __hppa64__. + * callback/trampoline_r/proto-hppa64.s: New generated file. + * callback/trampoline_r/tramp-hppa64.s: New file. + * callback/trampoline_r/tramp-hppa64.o: New generated file. + * callback/trampoline_r/tramp-hppa-macro.S: Fix comment. + * callback/trampoline_r/trampoline.c: Implement for __hppa64__. + * callback/trampoline_r/test1.c: Add support for __hppa64__. + * callback/trampoline_r/Makefile.in (cache-hppa64.lo, cache-hppa64.s): + New targets. + (clean): Remove cache-hppa64.s. + (SOURCE_FILES): Add cache-hppa64-linux.s, cache-hppa64-macro.S. + * configure.ac (CPU_OBJECTS): Augment also for hppa64 ABI. + * PLATFORMS, */PLATFORMS: List the 64-bit HP-PA machine. + * NEWS: Mention the new port. + +2017-09-09 Bruno Haible + + Don't violate ISO C rules. + * avcall/avcall-internal.h (__av_struct): Don't store an unaligned + pointer in (LIST).aptr. + +2017-09-09 Bruno Haible + + Assume the C preprocessor discards // comments. + * common/asm-i386.h: Renamed from common/asm-i386.hh. + * Makefile.maint (common/asm-i386.h): Remove target. + * Makefile.in (SOURCE_FILES): Add common/asm-i386.h. Remove + common/asm-i386.hh. + (GENERATED_FILES): Remove common/asm-i386.h. + +2017-09-09 Bruno Haible + + avcall: Optimize struct return of small structs. + * avcall/avcall-*.c: Cache l->raddr in a local variable. + +2017-09-09 Bruno Haible + + x86_64: Improve processing of assembly-language files. + * common/asm-x86_64.sh: Eliminate #APP and #NO_APP directives. + In the MEM* patterns, recognize all 64-bit register names. + +2017-09-09 Bruno Haible + + Fix compilation error on HP-UX (regression from 2017-09-03). + * avcall/avcall-libapi.c: Include before ffcall-stdint.h. + +2017-09-03 Bruno Haible + + i386: Align processing of assembly-language files with x86_64 case. + * common/asm-i386.hh (INSN2MOVXL): Renamed from INSN2MOVX. + * common/asm-i386.sh: Generate INSN2MOVXL instead of INSN2MOVX. + +2017-09-03 Bruno Haible + + i386: Provide disambiguating size prefixes in more cases. + * common/asm-i386.sh: Introduce size prefixes also for the second + operand of instructions with two operands. + +2017-09-03 Bruno Haible + + i386: Simplify processing of assembly-language files. + * common/asm-i386.sh: Remove unused introduction of FUNEND. Remove + no-op rule for GLOBL. + +2017-09-03 Bruno Haible + + x86_64: Add support for MSVC 14. + * common/asm-x86_64.h (R, NUM, ADDR, ADDR_PCRELATIVE, X1, X2, X4, X8, + MEM, MEM_DISP, MEM_INDEX, MEM_SHINDEX, MEM_DISP_SHINDEX0, + MEM_DISP_SHINDEX, MEM_PCRELATIVE, INDIR, INSNCONC, INSN1, INSN2, + INSN2S, INSN2MOVXL, INSN2MOVXQ, INSN2MOVXLQ, _): New macros. + (TEXT, P2ALIGN, DECLARE_FUNCTION, FUNBEGIN, FUNEND): Implement for MSVC. + * common/asm-x86_64.sh: Generate instructions as macros that may expand + into AT&T syntax or MSVC syntax. + * avcall/Makefile.in (avcall-x86_64.lo): Use a different rule for MSVC. + (clean): Remove also avcall-x86_64.asm. + * vacall/Makefile.in (vacall-x86_64.@OBJEXT@): Use a different rule for + MSVC. + (clean): Remove also vacall-x86_64.asm. + * callback/vacall_r/Makefile.in (vacall-x86_64.lo): Use a different rule + for MSVC. + (clean): Remove also vacall-x86_64.asm. + * PLATFORMS, */PLATFORMS: List the 64-bit mingw machine. + * NEWS: Mention the new port. + +2017-09-03 Bruno Haible + + x86_64: Add support for mingw. + * avcall/avcall.h (__AV_LLP64): New macro. + (__avword): Use it. + * avcall/avcall-alist.h (__av_alist): Change fields of type + 'unsigned long' to 'uintptr_t'. + * avcall/avcall-internal.h (__av_longlong): Update implementation for + LLP64 platforms. + * vacall/vacall.h (__VA_LLP64): New macro. + (__vaword): Use it. + * callback/vacall_r/vacall_r.h: Likewise. + * vacall/vacall-internal.h (__va_alist): Change fields of type + 'unsigned long' to 'uintptr_t'. Don't assume that 'long long' is the + same as 'long' on x86_64. + (_va_arg_longlong, _va_arg_ulonglong, _va_return_longlong, + _va_return_ulonglong): Update implementation for LLP64 platforms. + * PLATFORMS, */PLATFORMS: List the 64-bit mingw machine. + * NEWS: Mention the new port. + +2017-09-03 Bruno Haible + + Fix warnings on 64-bit native Windows. + * avcall/tests.c (pointer_tests): Use %p to display the value of a + pointer. + * vacall/tests.c (main): Likewise, + * callback/tests.c (main): Likewise, + +2017-09-03 Bruno Haible + + Add support for platforms where sizeof(long) < sizeof(void*). + * ffcall-stdint.h: New file. + * Makefile.in (SOURCE_FILES): Add it. + * avcall/avcall-internal.h: Include ffcall-stdint.h. Use [u]intptr_t + instead of 'long', 'unsigned long', or '__avword' where appropriate. + * vacall/vacall-internal.h: Include ffcall-stdint.h. Use [u]intptr_t + instead of 'long', 'unsigned long', or '__vaword' where appropriate. + * Makefile.maint (GNULIB_MODULES): Add stdint. + * trampoline/trampoline.c: Include . Use [u]intptr_t instead + of 'long' or 'unsigned long' where appropriate. For __x86_64__, use + 'unsigned long long' instead of 'unsigned long'. + * callback/trampoline_r/trampoline.c: Likewise. + * callback/trampoline_r/test1.c (f): Use 'void*' instead of 'long' to + access env. + +2017-09-03 Bruno Haible + + x86_64: Add support for Cygwin. + * porting-tools/abis/call-used-registers.txt: Add info about x86_64-ms + ABI. + * porting-tools/abis/reg-struct-return.txt: Likewise. + * porting-tools/abis/stack-frame.txt: Likewise. + * common/asm-x86_64.h: Add support for compilers on Windows. + (TEXT, GLOBL): New macros. + * common/asm-x86_64.sh: Truncate the EH_FRAME_SECTION also on Windows. + Eliminate .file pseudo-op. Macroize .text, .p2align, .globl directives. + * avcall/avcall-alist.h (__x86_64_ms__, __x86_64_sysv__): New macros. + (__av_alist): Add support for __x86_64_ms__. + * avcall/avcall-internal.h (__av_start1, __av_reg_struct_return, + __av_start_struct3, __av_start_struct4, __av_word, _av_float, + _av_double, __av_struct): Add support for __x86_64_ms__. + * avcall/avcall-x86_64.c: Improve comments. + * avcall/avcall-x86_64-windows.c: New file. + * avcall/Makefile.devel (avcall-x86_64-windows.s, + avcall-x86_64-windows-macro.S): New targets. + * avcall/Makefile.in (avcall-x86_64.s): On Windows, use + avcall-x86_64-windows-macro.S. + (SOURCE_FILES): Add avcall-x86_64-windows.c, avcall-x86_64-windows.s, + avcall-x86_64-windows-macro.S. + * vacall/vacall-internal.h (__x86_64_ms__, __x86_64_sysv__): New macros. + (__VA_FARG_NUM): Define also for __mipsn32__ || __mips64__. + (__va_alist): Add support for __x86_64_ms__. + (__va_reg_struct_return, __va_start_struct1, __va_start_struct2, + __va_arg_leftadjusted, __va_arg_rightadjusted, __va_arg_adjusted, + _va_arg_float, _va_arg_double, __va_arg_struct): Likewise. + * vacall/vacall-x86_64.c: Update comments. + * vacall/vacall-x86_64-windows.c: New file. + * vacall/Makefile.devel (vacall-x86_64-windows.s, + vacall-x86_64-windows-macro.S): New targets. + * vacall/Makefile.in (vacall-x86_64.s): On Windows, use + vacall-x86_64-windows-macro.S. + (SOURCE_FILES): Add vacall-x86_64-windows.c, vacall-x86_64-windows.s, + vacall-x86_64-windows-macro.S. + * callback/vacall_r/Makefile.devel (vacall-x86_64-windows.s, + vacall-x86_64-windows-macro.S): New targets. + * callback/vacall_r/Makefile.in (vacall-x86_64.s): On Windows, use + vacall-x86_64-windows-macro.S. + (SOURCE_FILES): Add vacall-x86_64-windows.s, + vacall-x86_64-windows-macro.S. + * PLATFORMS, */PLATFORMS: List the 64-bit Cygwin machine. + * NEWS: Mention the new port. + +2017-09-03 Bruno Haible + + Remove special build infrastructure for MSVC. The generic one works. + * avcall/Makefile.msvc: Remove file. + * avcall/Makefile.in (SOURCE_FILES): Remove it. + * vacall/Makefile.maint (config.h.msvc): Remove target. + (totally-clean): Don't remove config.h.msvc. + * vacall/Makefile.msvc: Remove file. + * vacall/Makefile.in (SOURCE_FILES): Remove it. + (GENERATED_FILES): Remove config.h.msvc. + * trampoline/Makefile.maint (config.h.msvc): Remove target. + (totally-clean): Don't remove config.h.msvc. + * trampoline/Makefile.msvc: Remove file. + * trampoline/Makefile.in (SOURCE_FILES): Remove it. + (GENERATED_FILES): Remove config.h.msvc. + * callback/vacall_r/Makefile.maint (config.h.msvc): Remove target. + (totally-clean): Don't remove config.h.msvc. + * callback/vacall_r/Makefile.msvc: Remove file. + * callback/vacall_r/Makefile.in (SOURCE_FILES): Remove it. + (GENERATED_FILES): Remove config.h.msvc. + * callback/trampoline_r/Makefile.maint (config.h.msvc): Remove target. + (totally-clean): Don't remove config.h.msvc. + * callback/trampoline_r/Makefile.msvc: Remove file. + * callback/trampoline_r/Makefile.in (SOURCE_FILES): Remove it. + (GENERATED_FILES): Remove config.h.msvc. + * callback/Makefile.maint (vacall_r/config.h.msvc, + trampoline_r/config.h.msvc): Remove targets. + * callback/Makefile.msvc: Remove file. + * callback/Makefile.in (SOURCE_FILES): Remove it. + * Makefile.msvc: Remove file. + * Makefile.in (SOURCE_FILES): Remove it. + +2017-09-03 Bruno Haible + + Make the generic build infrastructure work on MSVC. + * m4/as-underscore.m4: Rely on gl_ASM_SYMBOL_PREFIX from gnulib. Don't + define ASM_UNDERSCORE any more. + * configure.ac: Set IF_MSVC, IFNOT_MSVC. + * common/asm-i386.hh: Fix P2ALIGN parameter list. + * common/asm-i386.sh: Improve handling of indirect calls and jmps. + * avcall/Makefile.in: Use OBJEXT. + (avcall-i386.lo): Use a different rule for MSVC. + * vacall/Makefile.devel: Transform 'vacall_function' before the + asm-i386.sh script, not afterwards. + * vacall/Makefile.in: Use OBJEXT. + (vacall-i386.o): Use a different rule for MSVC. + * trampoline/trampoline.c: On native Windows, when CODE_EXECUTABLE is + not defined, use VirtualAlloc. + * trampoline/Makefile.in: Use OBJEXT. + * callback/vacall_r/get_receiver.c: New file. + * callback/vacall_r/Makefile.maint (vacall-i386-msvc.c): Use the C + source code of callback_get_receiver. + * callback/vacall_r/Makefile.in: Use OBJEXT. + (vacall-i386.lo): Use a different rule for MSVC. + (SOURCE_FILES): Add get_receiver.c. + * callback/trampoline_r/trampoline.c: On native Windows, when + CODE_EXECUTABLE is not defined, use VirtualAlloc. + * callback/trampoline_r/Makefile.in: Use OBJEXT. + * callback/Makefile.in: Use OBJEXT. + * README.win32: Remove file. + * README.windows: New file, from GNU gettext. + * Makefile.in (SOURCE_FILES): Remove README.win32. Add README.windows. + * PLATFORMS, */PLATFORMS: List the 32-bit mingw and MSVC machine. + * NEWS: Mention MSVC support. + +2017-09-03 Bruno Haible + + Don't use symbolic links for .h files. + MSVC 14 does not follow the symbolic links set by Cygwin's 'ln -s'. + * trampoline/Makefile.in (LN_S): Remove variable. + * callback/trampoline_r/Makefile.in (LN_S): Remove variable. + * callback/Makefile.in (INCLUDES): Add an -I option for vacall_r.h. + (LN_S): Remove variable. + (vacall_r.h, trampoline_r.h): Remove targets. + (callback-libapi.lo): Use explicit -I option for trampoline_r.h. Update + dependencies. + (test1.o, minitests.o, minitests.s, minitests-c++.o, tests.o, tests.s): + Update dependencies. + (MOSTLYCLEANFILES): Remove vacall_r.h, trampoline_r.h. + * configure.ac: Don't invoke CL_PROG_LN_S. + +2017-09-03 Bruno Haible + + Remove special build infrastructure for mingw. The generic one works. + * avcall/Makefile.maint (avcall-i386-mingw32.c): Remove target. + (totally-clean): Don't remove avcall-i386-mingw32.c. + * avcall/Makefile.mingw32: Remove file. + * avcall/Makefile.in (SOURCE_FILES): Remove it. + (GENERATED_FILES): Remove avcall-i386-mingw32.c. + * vacall/Makefile.maint (config.h.mingw32, vacall-i386-mingw32.c): + Remove targets. + (totally-clean): Don't remove config.h.mingw32, vacall-i386-mingw32.c. + * vacall/Makefile.mingw32: Remove file. + * vacall/Makefile.in (SOURCE_FILES): Remove it. + (GENERATED_FILES): Remove config.h.mingw32, vacall-i386-mingw32.c. + * trampoline/Makefile.maint (config.h.mingw32): Remove target. + (totally-clean): Don't remove config.h.mingw32. + * trampoline/Makefile.mingw32: Remove file. + * trampoline/Makefile.in (SOURCE_FILES): Remove it. + (GENERATED_FILES): Remove config.h.mingw32. + * callback/vacall_r/Makefile.maint (config.h.mingw32, + vacall-i386-mingw32.c): Remove targets. + (totally-clean): Don't remove config.h.mingw32, vacall-i386-mingw32.c. + * callback/vacall_r/Makefile.mingw32: Remove file. + * callback/vacall_r/Makefile.in (SOURCE_FILES): Remove it. + (GENERATED_FILES): Remove config.h.mingw32, vacall-i386-mingw32.c). + * callback/trampoline_r/Makefile.maint (config.h.mingw32): Remove + target. + (totally-clean): Don't remove config.h.mingw32. + * callback/trampoline_r/Makefile.mingw32: Remove file. + * callback/trampoline_r/Makefile.in (SOURCE_FILES): Remove it. + (GENERATED_FILES): Remove config.h.mingw32. + * callback/Makefile.maint (vacall_r/config.h.mingw32, + vacall_r/vacall-i386-mingw32.c, trampoline_r/config.h.mingw32): Remove + targets. + * callback/Makefile.mingw32: Remove file. + * callback/Makefile.in (SOURCE_FILES): Remove it. + * Makefile.mingw32: Remove file. + * Makefile.in (SOURCE_FILES): Remove it. + +2017-09-03 Bruno Haible + + Fix leftover files after "make distclean" (regression from 2017-08-27). + * avcall/Makefile.in (distclean): Also remove minitests-c++.output.*. + * vacall/Makefile.in (distclean): Likewise. + * callback/Makefile.in (DISTCLEANFILES): Add minitests-c++.output.*. + +2017-08-27 Bruno Haible + + Enable building shared libraries on Windows. + * avcall/Makefile.in (libavcall.la): Pass option '-no-undefined' to + $(LIBTOOL_LINK). + * trampoline/Makefile.in (libtrampoline.la): Likewise. + * callback/vacall_r/Makefile.in (libvacall.la): Likewise. + * callback/trampoline_r/Makefile.in (libtrampoline.la): Likewise. + * callback/Makefile.in (libcallback.la): Likewise. + +2017-08-27 Bruno Haible + + Do proper versioning of shared libraries. + * avcall/Makefile.in (LIBAVCALL_VERSION_INFO): New variable. + (libavcall.la): Use libtool option -version-info. + * trampoline/Makefile.in (LIBTRAMPOLINE_VERSION_INFO): New variable. + (libtrampoline.la): Use libtool option -version-info. + * callback/Makefile.in (LIBCALLBACK_VERSION_INFO): New variable. + (libcallback.la): Use libtool option -version-info. + * README: Remove statement of problem. Update figures about code size. + * NEWS: Mention the change. + +2017-08-27 Bruno Haible + + Fix warnings on 64-bit native Windows. + * testcases.c (vp_vpdpcpsp): Use %p to display the value of a pointer. + * vacall/tests.c (simulator): Likewise. + * callback/tests.c (vp_vpdpcpsp_simulator): Likewise, + +2017-08-27 Bruno Haible + + Remove code duplication of test cases. + * testcases.c: New file, extracted from avcall/tests.c. + * Makefile.in (SOURCE_FILES): Add it. + * avcall/tests.c: Remove testcases functions. Include testcases.c + instead. + * vacall/tests.c: Likewise. + * callback/tests.c: Likewise. + * porting-tools/abis/README: Update. + +2017-08-27 Bruno Haible + + avcall: Fix weakness in tests (added on 2017-01-29). + * avcall/tests.c (ll_l2ll, ll_l3ll, ll_l4ll, ll_l5ll, ll_l6ll, ll_l7ll): + Use a temporary variable of type 'long long'. + +2017-08-27 Bruno Haible + + vacall, callback: Remove workarounds for obsolete platforms. + * vacall/tests.c: Remove workarounds for SunOS 4 cc, gcc-2.5, gcc-2.7.x. + * callback/tests.c: Likewise. + +2017-08-27 Bruno Haible + + Add tests that verify the C++ support. + * Makefile.maint (GNULIB_MODULES): Add ansi-c++-opt. + * configure.ac: Invoke gl_PROG_ANSI_CXX. Set IF_CXX. + * avcall/minitests-c++.cc: New file. + * avcall/Makefile.in (CXX, CXXFLAGS): New variables. + (minitests-c++.o, minitests-c++): New targets. + (check): Optionally, test also minitests-c++. + (clean): Remove minitests-c++.o, minitests-c++, minitests-c++.out. + (SOURCE_FILES): Add minitests-c++.cc. + * vacall/minitests-c++.cc: New file. + * vacall/Makefile.in (CXX, CXXFLAGS): New variables. + (minitests-c++.o, minitests-c++): New targets. + (check): Optionally, test also minitests-c++. + (clean): Remove minitests-c++.o, minitests-c++, minitests-c++.out. + (SOURCE_FILES): Add minitests-c++.cc. + * trampoline/test2-c++.cc: New file. + * trampoline/test2.c (main): Don't test &main in C++ mode. + * trampoline/Makefile.in (CXX, CXXFLAGS): New variables. + (test2-c++.o, test2-c++): New targets. + (check): Optionally, test also test2-c++. + (clean): Remove test2-c++.o, test2-c++. + (SOURCE_FILES): test2-c++.cc. + * callback/minitests-c++.cc: New file. + * callback/Makefile.in (CXX, CXXFLAGS): New variables. + (minitests-c++.o, minitests-c++): New targets. + (check): Optionally, test also minitests-c++. + (MOSTLYCLEANFILES): Add minitests-c++.o, minitests-c++, + minitests-c++.out. + (SOURCE_FILES): Add minitests-c++.cc. + +2017-08-27 Bruno Haible + + Add support for SUNWspro C++ on Solaris. + * avcall/avcall.h: Treat SUNWspro C++ like SUNWspro C. + * vacall/vacall.h: Likewise. + * callback/vacall_r/vacall_r.h: Likewise. + +2017-08-27 Bruno Haible + + Make the include files C++-safe. + * avcall/avcall.h: Add C++ guards. + (__AV_alignof): Test __IBM__ALIGNOF__. Use template-based definition + for C++. + * vacall/vacall.h: Add C++ guards. + (__VA_alignof): Test __IBM__ALIGNOF__. Use template-based definition + for C++. + * callback/vacall_r/vacall_r.h: Add C++ guards. + (__VA_alignof): Test __IBM__ALIGNOF__. Use template-based definition + for C++. + +2017-08-27 Bruno Haible + + Make sure the tests use only the public include files. + * avcall/tests.c: Don't include config.h. + * vacall/tests.c: Don't include config.h. + * callback/tests.c: Likewise. + * callback/trampoline_r/test1.c: Likewise. Include ffcall-abi.h instead. + * avcall/Makefile.in (avcall-libapi.lo): Use $(INCLUDES). + * vacall/Makefile.in (INCLUDES): Remove -I options that reference + gnulib-lib. + (INCLUDES_WITH_GNULIB): New variable. + (vacall-libapi.o): Use INCLUDES_WITH_GNULIB instead of INCLUDES. + * trampoline/Makefile.in (INCLUDES): Remove -I options that reference + gnulib-lib. + (INCLUDES_WITH_GNULIB): New variable. + (trampoline.lo): Use INCLUDES_WITH_GNULIB instead of INCLUDES. + * callback/vacall_r/Makefile.in (INCLUDES): Remove -I options that + reference gnulib-lib. + (INCLUDES_WITH_GNULIB): New variable. + (vacall-libapi.lo): Use INCLUDES_WITH_GNULIB instead of INCLUDES. + * callback/trampoline_r/Makefile.in (INCLUDES): Remove -I options that + reference gnulib-lib. + (INCLUDES_WITH_GNULIB): New variable. + (trampoline.lo): Use INCLUDES_WITH_GNULIB instead of INCLUDES. + +2017-08-27 Bruno Haible + + Make recognition of Solaris more robust. + * avcall/avcall.h: Test for '__sun', not for 'sun'. + * vacall/vacall.h: Likewise. + * callback/vacall_r/vacall_r.h: Likewise. + * vacall/tests.c: Likewise. + * callback/tests.c: Likewise. + +2017-08-27 Bruno Haible + + avcall: Align field names. + * avcall/avcall-alist.h (__av_alist): Rename field 'farg' to 'fargs'. + * avcall/avcall-internal.h (_av_float): Update. + * avcall/avcall-mipsn32.c (avcall_call): Likewise. + * avcall/avcall-mips64.c (avcall_call): Likewise. + +2017-08-27 Bruno Haible + + Remove support for old NeXTstep. + * avcall/avcall.h (__AV_NEXTGCC_STRUCT_RETURN): Remove enum value. + * avcall/avcall-internal.h (__av_start_struct4) [__i386__]: Remove test + for __AV_NEXTGCC_STRUCT_RETURN. + * avcall/avcall-i386.c (avcall_call): Likewise. + * avcall/PLATFORMS: Update. + * vacall/vacall.h (__VA_NEXTGCC_STRUCT_RETURN): Remove enum value. + * callback/vacall_r/vacall_r.h: Likewise. + * vacall/vacall-internal.h (__va_start_struct2) [__i386__]: Remove test + for __VA_NEXTGCC_STRUCT_RETURN. + * vacall/vacall-i386.c (vacall_receiver): Likewise. + * trampoline/trampoline.c: Don't include . + * callback/trampoline_r/trampoline.c: Likewise. + +2017-08-27 Bruno Haible + + hppa: Remove support for old gcc-2.6.3. + * avcall/avcall.h (__AV_OLDGCC_STRUCT_RETURN): Remove enum value. + * avcall/avcall-internal.h (__av_reg_struct_return) [__hppa__]: Remove + test for __AV_OLDGCC_STRUCT_RETURN. + * avcall/avcall-hppa.c (avcall_call): Likewise. + * vacall/vacall.h (__VA_OLDGCC_STRUCT_RETURN): Remove enum value. + * callback/vacall_r/vacall_r.h (__VA_OLDGCC_STRUCT_RETURN): Likewise. + * vacall/vacall-internal.h (__va_reg_struct_return) [__hppa__]: Remove + test for __VA_OLDGCC_STRUCT_RETURN. + * vacall/vacall-hppa.c (vacall_receiver): Likewise. + +2017-08-27 Bruno Haible + + avcall: Evaluate __AV_ALIST_WORDS only during av_start_* macros. Part 2. + * avcall/avcall-alist.h (__av_alist) [__hppa__]: Add 'args_end' field. + * avcall/avcall-internal.h (__av_start1) [__hppa__]: Initialize it. + * avcall/avcall-hppa.c (avcall_call): Use it to reduce the use of + __AV_ALIST_WORDS. + +2017-08-27 Bruno Haible + + avcall: Fix overflow detection bug on hppa. + * avcall/avcall-internal.h (__av_struct) [__hppa__]: Use LIST.eptr + instead of &LIST.args[0]. + +2017-08-27 Bruno Haible + + Fix build failure with --enable-shared on Solaris/SPARC with cc. + * common/asm-sparc.h: Test __SVR4, not __svr4__. + * common/asm-sparc.sh: Fix comment about postprocessing. + * avcall/Makefile.in (avcall-sparc.s, avcall-sparc64.s): Remove space + after '#'. + * vacall/Makefile.in (vacall-sparc.s, vacall-sparc64.s): Likewise. + * trampoline/Makefile.in (cache-sparc.s, cache-sparc64.s): Likewise. + * callback/vacall_r/Makefile.in (vacall-sparc.s, vacall-sparc64.s): + Likewise. + * callback/trampoline_r/Makefile.in (cache-sparc.s, cache-sparc64.s): + Likewise. + +2017-08-27 Bruno Haible + + vacall: Fix build failure with gcc configured with --enable-default-pie. + Works around a GCC bug, reported at + . + * vacall/Makefile.devel (vacall-sparc-linux-pic.s): New target. + (vacall-sparc-macro.S): Combine vacall-sparc-linux.s and + vacall-sparc-linux-pic.s in one file. + (vacall-sparc64-linux-pic.s): New target. + (vacall-sparc64-macro.S): Combine vacall-sparc64-linux.s and + vacall-sparc64-linux-pic.s in one file. + * vacall/Makefile.in (SOURCE_FILES): Add vacall-sparc-linux-pic.s, + vacall-sparc64-linux-pic.s. + +2017-08-27 Bruno Haible + + mips: Avoid warning about undeclared function 'cacheflush' on Linux. + * trampoline/trampoline.c: On Linux, include , not + . + * callback/trampoline_r/trampoline.c: Likewise. + +2017-08-27 Bruno Haible + + vacall: Fix struct returns on mips (o32 ABI). + * vacall/vacall-mips.c (vacall_receiver): Return the struct return + address in register $2. + +2017-08-27 Bruno Haible + + ia64: Test __GNUC__ only in av/va_start_* (regression from 2017-07-30). + * avcall/avcall.h (__AV_OLDGCC_STRUCT_ARGS): New enum item. + (__AV_STRUCT_ARGS): Use it. + * avcall/avcall-internal.h (__av_struct) [__ia64__]: Test flag + __AV_OLDGCC_STRUCT_ARGS, not __GNUC__. + * vacall/vacall.h (__VA_OLDGCC_STRUCT_ARGS): New enum item. + (__VA_STRUCT_ARGS): Use it. + * callback/vacall_r/vacall_r.h: Likewise. + * vacall/vacall-internal.h (__va_arg_struct): Test flag + __VA_OLDGCC_STRUCT_ARGS, not __GNUC__. + +2017-08-27 Bruno Haible + + Fix "make check" failure on Linux/mips (regression from 2017-07-30). + * ffcall-abi.h: For mipsn32, test _MIPS_SIM, because defines + both _ABIO32 and _ABIN32. + +2017-07-31 Bruno Haible + + Fix preprocessor warning "does not give a valid preprocessing token". + Reported by Reini Urban at . + * common/asm-arm.sh: Don't put a colon inside the C() or L() argument. + * common/asm-i386.sh: Likewise. + * common/asm-m68k.sh: Likewise. + * common/asm-sparc.sh: Likewise. + * common/asm-x86_64.sh: Likewise. + * common/asm-arm.h (FUNBEGIN): Don't put a colon inside the C() + argument. + * common/asm-i386.hh (FUNBEGIN): Likewise. + * common/asm-m68k.h (FUNBEGIN): Likewise. + * common/asm-sparc.h (FUNBEGIN): Likewise. + * common/asm-x86_64.h (FUNBEGIN): Likewise. + +2017-07-31 Bruno Haible + + Fix preprocessor warning "Unknown preprocessing directive". + * common/asm-hppa.sh: Eliminate #APP, #NO_APP lines. + * common/asm-powerpc.sh: Likewise. + +2017-07-31 Bruno Haible + + trampoline_r: Rework API. + * callback/trampoline_r/trampoline_r.h (trampoline_r_address, + trampoline_r_data0, trampoline_r_data1): Change signatures. + * callback/trampoline_r/trampoline.c (trampoline_r_address, + trampoline_r_data0, trampoline_r_data1): Update accordingly. + * callback/trampoline_r/test2.c: Update. + * callback/callback-libapi.c (is_callback): Likewise. + +2017-07-31 Bruno Haible + + vacall: Fix build error on IRIX with cc (regression from 2017-07-30). + * vacall/vacall-internal.h (__va_arg_adjusted, __va_arg_struct): Cast + result of __va_arg_leftadjusted and __va_arg_rightadjusted to 'void*'. + +2017-07-31 Bruno Haible + + Fix "make check" failure on arm (regression from 2017-07-30). + * vacall/vacall-internal.h (__va_alist): Move the 'filler1' field right + before the 'tmp' field. + * callback/vacall_r/vacall_r.h (vacall_alist): Add 'filler1' field + between 'flags' and 'tmp' fields. + +2017-07-31 Bruno Haible + + Fix build error (regression from 2017-07-30). + * vacall/Makefile.in (INCLUDES): Add -I options for . + * callback/vacall_r/Makefile.in (INCLUDES): Likewise. + +2017-07-30 Bruno Haible + + vacall: Polish Makefile.in. + * vacall/Makefile.in (vacall-x86_64-x32.o): Remove spurious reference to + LIBTOOL_COMPILE. + +2017-07-30 Bruno Haible + + m68k: Fix callback test crash on Linux. + * avcall/Makefile.in (avcall-m68k.s): Use the .S file in Motorola + syntax (cross-compiled for m68k-linux), not the one in MIT syntax + (cross-compiled for m68k-sun). + * vacall/Makefile.in (vacall-m68k.s): Likewise. + * callback/vacall_r/Makefile.in (vacall-m68k.s): Likewise. + * avcall/PLATFORM, NEWS: Update. + +2017-07-30 Bruno Haible + + m68k: Fix build failure on Linux. + * common/asm-m68k.sh: In mit syntax, recognize 'pc' as a register name. + +2017-07-30 Bruno Haible + + Limit the exported symbols of the installed shared libraries. + * avcall/Makefile.in (LIBAVCALL_EXPORTED_SYMBOLS_REGEX): New variable. + (libavcall.la): Use libtool's -export-symbols-regex option. + * trampoline/Makefile.in (LIBTRAMPOLINE_EXPORTED_SYMBOLS_REGEX): New + variable. + (libtrampoline.la): Use libtool's -export-symbols-regex option. + * callback/Makefile.in (LIBCALLBACK_EXPORTED_SYMBOLS_REGEX): New + variable. + (libcallback.la): Use libtool's -export-symbols-regex option. + +2017-07-30 Bruno Haible + + Ensure source compatibility with existing versions of GNU clisp, part 3. + * vacall/vacall-internal.h (__va_alist): Move the 'flags' and 'tmp' + fields to the beginning. + * callback/vacall_r/vacall_r.h (vacall_alist): When used by GNU clisp, + declare 'flags' and 'tmp' members. + +2017-07-30 Bruno Haible + + Ensure source compatibility with existing versions of GNU clisp, part 2. + * avcall/avcall-alist.h (__av_alist): Move the 'flags' field to the + beginning. + * avcall/avcall.h (av_alist): When used by GNU clisp, declare a 'flags' + member. + +2017-07-30 Bruno Haible + + Ensure source compatibility with existing versions of GNU clisp, part 1. + * avcall/avcall-libapi.c (__builtin_avcall): New dummy function. + * callback/callback-libapi.c (trampoline_r_data0): New dummy function. + +2017-07-30 Bruno Haible + + Remove copied files from callback/vacall_r/. + * callback/vacall_r/Makefile.devel (vacall-*.s): Compile + ../../vacall/vacall-*.c directly. + * autogen.sh: Don't invoke target 'copied-files' in callback/vacall_r/. + * Makefile.devel (precompiled): Likewise. + * Makefile.in (COPIED_FILES): Remove callback/vacall_r/*. + * callback/vacall_r/Makefile.maint (COPIED_FILES): Remove variable. + (copied-files): Remove target. + * callback/vacall_r/Makefile.in (SOURCE_FILES): Remove vacall-*.c. + +2017-07-30 Bruno Haible + + callback: Allow for binary-compatible future changes of main API. + * callback/callback.h: Renamed from callback/callback.h.in. + Don't include trampoline_r.h. + (callback_t, __TR_function): New types. + (callback_function_t): Renamed from __VA_function. + (alloc_callback, free_callback, is_callback, callback_address, + callback_data): Declare as functions, not as macros. + * callback/callback-libapi.c: New file. + * configure.ac: Don't create callback/callback.h. + * callback/Makefile.in (LIBTOOL_COMPILE): New variable. + (callback.h): Remove target + (callback-libapi.lo): New target. + (libcallback.la): Include it. + (install-lib, install, installdirs, uninstall): Don't recurse into + 'trampoline_r' directory. + (test1.o, minitests.o, minitests.s, tests.o, tests.s): Update + dependency. + (MOSTLYCLEANFILES): Remove callback.h. + (SOURCE_FILES): Add callback.h, callback-libapi.c. Remove callback.h.in. + * callback/test1.c (function): Remove type. + (main): Remove a cast. + * callback/tests.c (main): Use the type 'callback_t'. + * Makefile.in (DISTCLEANFILES): Update stamp file list. + * NEWS: Mention the improvement. + +2017-07-30 Bruno Haible + + callback: Remove version number from trampoline_r.h. + Rationale: It is already present in callback.h. + * callback/trampoline_r/trampoline_r.h: Renamed from + callback/trampoline_r/trampoline_r.h.in. + (LIBFFCALL_VERSION): Remove macro. + * configure.ac: Don't create callback/trampoline_r/trampoline_r.h. + * callback/trampoline_r/Makefile.in (trampoline_r.h): Remove target. + (trampoline.lo, test1.o, test2.o): Update dependencies. + (install-lib, install): Update. + (distclean): Don't remove trampoline_r.h. + (SOURCE_FILES): Add trampoline_r.h. Remove trampoline_r.h.in. + * callback/Makefile.in (trampoline_r.h): Link to + $(srcdir)/trampoline_r/trampoline_r.h. + * Makefile.in (DISTCLEANFILES): Update stamp file list. + +2017-07-30 Bruno Haible + + vacall, callback: Allow compiler optimizations regarding noreturn. + * Makefile.maint (GNULIB_MODULES): Add 'stdnoreturn'. + * vacall/vacall-libapi.c: Include . + (__va_struct_buffer_t): Moved to here. + (vacall_struct_buffer): Declare static. + (vacall_error_type_mismatch, vacall_error_struct_too_large): Declare + static and noreturn. + * callback/vacall_r/vacall-libapi.c: Likewise. + * vacall/vacall-internal.h (__va_start_struct, __va_return): Update. + (vacall_error_type_mismatch, vacall_error_struct_too_large, + __va_struct_buffer_t, vacall_struct_buffer): Remove declarations. + +2017-07-30 Bruno Haible + + vacall, callback: Move copyright notice up. + * vacall/vacall.h: Put double-inclusion guard after copyright header. + * callback/vacall_r/vacall_r.h: Likewise. + +2017-07-30 Bruno Haible + + callback: Allow for binary-compatible future changes of __va_* macros. + * callback/vacall_r/vacall_r.h: New file, extracted from + callback/vacall_r/vacall_r.h.in. Include , ffcall-abi.h. + (vacall_*): Define to symbols that start with 'callback_'. + (va_alist): Define als pointer to 'struct vacall_alist'. + (vacall_start, vacall_start_struct, vacall_arg_char, vacall_arg_schar, + vacall_arg_uchar, vacall_arg_short, vacall_arg_ushort, vacall_arg_int, + vacall_arg_uint, vacall_arg_long, vacall_arg_ulong, vacall_arg_longlong, + vacall_arg_ulonglong, vacall_arg_float, vacall_arg_double, + vacall_arg_ptr, vacall_arg_struct, vacall_return_void, + vacall_return_char, vacall_return_schar, vacall_return_uchar, + vacall_return_short, vacall_return_ushort, vacall_return_int, + vacall_return_uint, vacall_return_long, vacall_return_ulong, + vacall_return_longlong, vacall_return_ulonglong, vacall_return_float, + vacall_return_double, vacall_return_ptr, vacall_return_struct): New + declarations. + (va_start_void, va_start_char, va_start_schar, va_start_uchar, + va_start_short, va_start_ushort, va_start_int, va_start_uint, + va_start_long, va_start_ulong, va_start_longlong, va_start_ulonglong, + va_start_float, va_start_double, va_start_ptr, _va_start_struct, + va_arg_char, va_arg_schar, va_arg_uchar, va_arg_short, va_arg_ushort, + va_arg_int, va_arg_uint, va_arg_long, va_arg_ulong, va_arg_longlong, + va_arg_ulonglong, va_arg_float, va_arg_double, va_arg_ptr, + va_arg_struct, _va_arg_struct, va_return_void, va_return_char, + va_return_schar, va_return_uchar, va_return_short, va_return_ushort, + va_return_int, va_return_uint, va_return_long, va_return_ulong, + va_return_longlong, va_return_ulonglong, va_return_float, + va_return_double, va_return_ptr, _va_return_struct): Define in terms of + these functions. + * callback/vacall_r/vacall-libapi.c: Include vacall-internal.h instead + of vacall_r.h.in. + (vacall_start, vacall_start_struct, vacall_arg_char, vacall_arg_schar, + vacall_arg_uchar, vacall_arg_short, vacall_arg_ushort, vacall_arg_int, + vacall_arg_uint, vacall_arg_long, vacall_arg_ulong, vacall_arg_longlong, + vacall_arg_ulonglong, vacall_arg_float, vacall_arg_double, + vacall_arg_ptr, vacall_arg_struct, vacall_return_void, + vacall_return_char, vacall_return_schar, vacall_return_uchar, + vacall_return_short, vacall_return_ushort, vacall_return_int, + vacall_return_uint, vacall_return_long, vacall_return_ulong, + vacall_return_longlong, vacall_return_ulonglong, vacall_return_float, + vacall_return_double, vacall_return_ptr, vacall_return_struct): New + functions. + * vacall/vacall-internal.h: If REENTRANT, include vacall_r.h. + * callback/vacall_r/vacall_r.h.in: Remove file. + * vacall/vacall-*.c: Include vacall-internal.h instead of vacall_r.h.in. + * vacall/vacall-libapi.c: Likewise. + * callback/vacall_r/Makefile.devel (GCCFLAGS): Add -I option for + ffcall-abi.h. + (vacall-*.s): Update dependencies. Pass -I options to gcc. + * configure.ac: Don't create callback/vacall_r/vacall_r.h. + * callback/vacall_r/Makefile.maint (vacall_r.h.msvc, + vacall_r.h.mingw32): Remove targets. + (totally-clean): Don't remove vacall_r.h.msvc, vacall_r.h.mingw32. + * callback/Makefile.maint (vacall_r/vacall_r.h.msvc, + vacall_r/vacall_r.h.mingw32): Remove targets. + * callback/vacall_r/Makefile.in (INCLUDES): Add -I options for + vacall-internal.h and ffcall-abi.h. + (all): Don't depend on vacall_r.h. + (vacall-libapi.lo): Update dependencies. Pass -DREENTRANT option. + (install-lib, install): Update. + (distclean): Don't remove vacall_r.h. + (SOURCE_FILES): Add vacall_r.h. Remove vacall_r.h.in. + (GENERATED_FILES): Remove vacall_r.h.mingw32, vacall_r.h.msvc. + * callback/Makefile.in (INCLUDES): Add -I option for ffcall-abi.h. + (vacall_r.h): Link to $(srcdir)/vacall_r/vacall_r.h. + * Makefile.in (DISTCLEANFILES): Update. + * porting-tools/abis/README: Update. + +2017-07-30 Bruno Haible + + vacall: Allow for binary-compatible future changes of the __va_* macros. + * vacall/vacall.h: New file, extracted from vacall/vacall.h.in. + Include , ffcall-abi.h. + (va_alist): Define als pointer to 'struct vacall_alist'. + (vacall_start, vacall_start_struct, vacall_arg_char, vacall_arg_schar, + vacall_arg_uchar, vacall_arg_short, vacall_arg_ushort, vacall_arg_int, + vacall_arg_uint, vacall_arg_long, vacall_arg_ulong, vacall_arg_longlong, + vacall_arg_ulonglong, vacall_arg_float, vacall_arg_double, + vacall_arg_ptr, vacall_arg_struct, vacall_return_void, + vacall_return_char, vacall_return_schar, vacall_return_uchar, + vacall_return_short, vacall_return_ushort, vacall_return_int, + vacall_return_uint, vacall_return_long, vacall_return_ulong, + vacall_return_longlong, vacall_return_ulonglong, vacall_return_float, + vacall_return_double, vacall_return_ptr, vacall_return_struct): New + declarations. + (va_start_void, va_start_char, va_start_schar, va_start_uchar, + va_start_short, va_start_ushort, va_start_int, va_start_uint, + va_start_long, va_start_ulong, va_start_longlong, va_start_ulonglong, + va_start_float, va_start_double, va_start_ptr, _va_start_struct, + va_arg_char, va_arg_schar, va_arg_uchar, va_arg_short, va_arg_ushort, + va_arg_int, va_arg_uint, va_arg_long, va_arg_ulong, va_arg_longlong, + va_arg_ulonglong, va_arg_float, va_arg_double, va_arg_ptr, + va_arg_struct, _va_arg_struct, va_return_void, va_return_char, + va_return_schar, va_return_uchar, va_return_short, va_return_ushort, + va_return_int, va_return_uint, va_return_long, va_return_ulong, + va_return_longlong, va_return_ulonglong, va_return_float, + va_return_double, va_return_ptr, _va_return_struct): Define in terms of + these functions. + * vacall/vacall-libapi.c: Include vacall-internal.h instead of + vacall.h.in. + (vacall_start, vacall_start_struct, vacall_arg_char, vacall_arg_schar, + vacall_arg_uchar, vacall_arg_short, vacall_arg_ushort, vacall_arg_int, + vacall_arg_uint, vacall_arg_long, vacall_arg_ulong, vacall_arg_longlong, + vacall_arg_ulonglong, vacall_arg_float, vacall_arg_double, + vacall_arg_ptr, vacall_arg_struct, vacall_return_void, + vacall_return_char, vacall_return_schar, vacall_return_uchar, + vacall_return_short, vacall_return_ushort, vacall_return_int, + vacall_return_uint, vacall_return_long, vacall_return_ulong, + vacall_return_longlong, vacall_return_ulonglong, vacall_return_float, + vacall_return_double, vacall_return_ptr, vacall_return_struct): New + functions. + * vacall/vacall-internal.h: New file, extracted from vacall/vacall.h.in. + (__VA_ALIST_WORDS): Fix comment. + (__va_alist): Declare as 'struct vacall_alist'. + (__va_start): Add FLAGS argument. + (__va_start_struct): Renamed from _va_start_struct. Add FLAGS argument. + (_va_arg_*): Renamed from va_arg_*. + (_va_arg_ptr): Renamed from va_arg_ptr. Remove TYPE argument. + (_va_return_*): Renamed from va_return_*. + (_va_return_ptr): Renamed from va_return_ptr. Remove TYPE argument. + (__va_return_struct): Renamed from _va_return_struct. + * vacall/vacall.h.in: Remove file. + * configure.ac: Don't create vacall.h by substitution. + * vacall/vacall-*.c: Include vacall-internal.h instead of vacall.h.in. + * vacall/Makefile.devel (GCCFLAGS): Add -I option for ffcall-abi.h. + (vacall-*.s): Update dependencies. + (tests-*.s): Likewise. No more need to symlink vacall.h. + * vacall/Makefile.maint (vacall.h.msvc, vacall.h.mingw32): Remove + targets. + (totally-clean): Don't remove them. + * vacall/Makefile.in (INCLUDES): Add -I option for ffcall-abi.h. + (vacall-libapi.o): Update dependencies. + (install): Update. + (minitests.o, minitests.s, tests.o, tests.s): Update dependency. + (distclean): Don't remove vacall.h. + (SOURCE_FILES): Add vacall.h, vacall-internal.h. Remove vacall.h.in. + (GENERATED_FILES): Remove vacall.h.mingw32, vacall.h.msvc. + * Makefile.in (DISTCLEANFILES): Update stamp file list. + * vacall/README: Update. + * porting-tools/abis/README: Update. + +2017-07-30 Bruno Haible + + vacall: Remove special optimization of va_return_struct macro. + * vacall/vacall.h.in (va_return_struct): Define through + _va_return_struct. + * callback/vacall_r/vacall_r.h.in: Likewise. + +2017-07-30 Bruno Haible + + vacall, callback: Prefix all exported symbols at linker level. + * vacall/vacall-*.c: Define vacall_receiver instead of __vacall, + callback_receiver instead of __vacall_r, + callback_get_receiver instead of get__vacall_r. + * vacall/vacall-libapi.c: Include config.h first. + (vacall_receiver): Renamed from __vacall. + (vacall_struct_buffer): Renamed from __va_struct_buffer. + (vacall_error_type_mismatch): Renamed from __va_error1. + (vacall_error_struct_too_large): Renamed from __va_error2. + * vacall/vacall.h.in (_va_start_struct, __va_return): Update. + (vacall_error_type_mismatch): Renamed from __va_error1. + (vacall_error_struct_too_large): Renamed from __va_error2. + (vacall_struct_buffer): Renamed from __va_struct_buffer. + * callback/vacall_r/vacall-libapi.c: Include config.h first. + (vacall_struct_buffer): Renamed from __va_struct_buffer. + (vacall_error_type_mismatch): Renamed from __va_error1. + (vacall_error_struct_too_large): Renamed from __va_error2. + * callback/vacall_r/vacall_r.h.in (vacall_error_type_mismatch, + vacall_error_struct_too_large, vacall_structcpy, vacall_struct_buffer): + Define to symbols that start with 'callback_'. + (_va_start_struct, __va_return): Update. + (callback_receiver): Renamed from __vacall_r. + (callback_get_receiver): Renamed from get__vacall_r. + (vacall_error_type_mismatch): Renamed from __va_error1. + (vacall_error_struct_too_large): Renamed from __va_error2. + (vacall_struct_buffer): Renamed from __va_struct_buffer. + * callback/callback.h.in: Update. + * callback/trampoline_r/trampoline_r.h.in (alloc_trampoline_r, + free_trampoline_r, is_trampoline_r, trampoline_r_address, + trampoline_r_data0, trampoline_r_data1): Define to symbols that start + with 'callback_trampoline_'. + * callback/elf-hack.txt: Update. + * porting-tools/abis/call-used-registers.txt: Update. + +2017-07-30 Bruno Haible + + callback: Use distinct object file names in static library. + * callback/vacall_r/vacall-libapi.c: Renamed from + callback/vacall_r/misc.c. + * callback/vacall_r/Makefile.in (OBJECTS, SOURCE_FILES): Update. + (vacall-libapi.lo): Renamed from misc.lo. + * callback/Makefile.in (libcallback.la): Update. + +2017-07-30 Bruno Haible + + vacall: Use distinct object file names in static library. + * vacall/vacall-libapi.c: Renamed from vacall/misc.c. + * vacall/Makefile.in (OBJECTS, SOURCE_FILES): Update. + (vacall-libapi.o): Renamed from misc.o. + * vacall/README: Update. + +2017-07-30 Bruno Haible + + avcall: Modernize. + * avcall/avcall.h: Change double-include guard. Modernize copyright + header. + +2017-07-30 Bruno Haible + + avcall: Allow for binary-compatible future changes of the __av_* macros. + * avcall/avcall.h: New file, extracted from avcall/avcall.h.in. + Include , ffcall-abi.h. + When included from avcall-internal.h, include avcall-alist.h and add + member '_av_m_alist' in av_alist type. + (avcall_overflown, avcall_start, avcall_start_struct, avcall_arg_long, + avcall_arg_ulong, avcall_arg_ptr, avcall_arg_longlong, + avcall_arg_ulonglong, avcall_arg_float, avcall_arg_double, + avcall_arg_struct): New declarations. + (av_overflown, av_start_void, av_start_char, av_start_schar, + av_start_uchar, av_start_short, av_start_ushort, av_start_int, + av_start_uint, av_start_long, av_start_ulong, av_start_longlong, + av_start_ulonglong, av_start_float, av_start_double, av_start_ptr, + _av_start_struct, av_char, av_schar, av_short, av_int, av_long, + av_uchar, av_ushort, av_uint, av_ulong, av_ptr, av_longlong, + av_ulonglong, av_float, av_double, av_struct, _av_struct, av_call): + Define in terms of these functions. + * avcall/avcall-libapi.c: New file. + * avcall/avcall-alist.h: New file, extracted from avcall/avcall.h.in. + * avcall/avcall-internal.h: New file, extracted from avcall/avcall.h.in. + (__av_start): Add LIST_ARGS_END and FLAGS arguments. + (__av_start1, __av_start_init_eptr): Add LIST_ARGS_END argument. + (__av_start_struct): Add LIST_ARGS, LIST_ARGS_END, FLAGS arguments. + (__av_long): Renamed from _av_long. + (__av_ulong): Renamed from _av_ulong. + (__av_ptr): Renamed from _av_ptr. Remove TYPE argument. + (__av_arg_longlong): Renamed from __av_longlong. + (__av_longlong): Renamed from _av_longlong. + (__av_ulonglong): Renamed from _av_ulonglong. + * avcall/avcall.h.in: Remove file. + * configure.ac: Don't create avcall.h by substitution. + * avcall/avcall-*.c: Include avcall-internal.h instead of avcall.h.in. + (avcall_call): Change argument type to 'av_alist*'. + * avcall/Makefile.devel (GCCFLAGS): Add -I option for ffcall-abi.h. + (avcall-*.s): Update dependencies. + (tests-*.s): Likewise. No more need to symlink avcall.h. + * avcall/Makefile.maint (avcall.h.msvc, avcall.h.mingw32): Remove + targets. + (totally-clean): Don't remove them. + * avcall/Makefile.in (INCLUDES): Add -I option for ffcall-abi.h. + (OBJECTS): Add avcall-libapi.lo. + (avcall-libapi.lo): New target. + (install-lib, install): Update. + (minitests.o, minitests.s, tests.o, tests.s): Update dependency. + (distclean): Don't remove avcall.h. + (SOURCE_FILES): Add avcall.h, avcall-internal.h, avcall-alist.h, + avcall-libapi.c. Remove avcall.h.in. + (GENERATED_FILES): Remove avcall.h.mingw32, avcall.h.msvc. + * Makefile.in (DISTCLEANFILES): Update stamp file list. + * avcall/README: Update. + * porting-tools/abis/README: Update. + +2017-07-30 Bruno Haible + + avcall: Allow for binary-compatible future changes of __av_alist. + * avcall/avcall.h.in (__AV_ALIST_SIZE_BOUND): New macro. + (__av_alist_verify): New verification. + (av_alist): Use it to allocate room. + +2017-07-30 Bruno Haible + + avcall: Separate the fixed-size part from the variable part of av_alist. + * avcall/avcall.h.in (__av_alist): Renamed from av_alist. Add 'args' + field as a pointer. + (av_alist): New type. + (_av_overflown): Renamed from av_overflown. + (av_overflown): New macro. + (__av_start): Add LIST_ARGS argument. + (av_start_*, _av_start_struct): Update accordingly. + (_av_long): Renamed from av_long. + (_av_ulong): Renamed from av_ulong. + (_av_ptr): Renamed from av_ptr. + (av_long, av_ulong, av_ptr): New macros. + (_av_longlong): Renamed from av_longlong. + (_av_ulonglong): Renamed from av_ulonglong. + (av_longlong, av_ulonglong): New macros. + (_av_float): Renamed from av_float. + (_av_double): Renamed from av_double. + (av_float, av_double): New macros. + (av_struct, _av_struct, av_call): Update. + (avcall_call): Take an '__av_alist*' parameter. + * avcall/avcall-*.c (avcall_call): Take an '__av_alist*' parameter. + +2017-07-30 Bruno Haible + + avcall: Remove unused macro argument TYPE. + * avcall/avcall.h.in (__av_struct_copy, __av_struct_leftadjusted, + __av_struct_rightadjusted, __av_struct): Remove TYPE argument. + +2017-07-30 Bruno Haible + + avcall: Remove special optimization of av_struct macro. + * avcall/avcall.h.in (av_struct): Take the address of VAL. + (__av_struct_assign): Remove macro. + (__av_struct, __av_struct_leftadjusted, __av_struct_rightadjusted): + Remove ASSIGN argument; use __av_struct_copy instead. + +2017-07-30 Bruno Haible + + avcall: Evaluate __AV_ALIST_WORDS only during av_start_* macros. Part 1. + * avcall/avcall.h.in (av_alist): Enable 'eptr' field on all platforms. + (__av_eptr): Remove macro. Use (LIST).eptr eveywhere instead. + (__av_start_init_eptr): New macro. + (__av_start): Invoke it. + (__av_start1): Don't initialize (LIST).eptr here. + +2017-07-30 Bruno Haible + + avcall: Prefix all exported symbols at linker level with 'avcall_'. + * avcall/avcall.h.in (avcall_call): Renamed from __builtin_avcall. + * avcall/avcall-*.c: Update accordingly. + * avcall/DOC: Likewise. + * avcall/avcall.3: Likewise. + * avcall/avcall.html: Likewise. + +2017-07-30 Bruno Haible + + trampoline: Rework API. + * trampoline/trampoline.h: Add C++ guards. Add comments. + (trampoline_function_t): Renamed from __TR_function. + (alloc_trampoline, trampoline_address, trampoline_variable, + trampoline_data): Change signatures. + * trampoline/trampoline.c: Update accordingly. + * trampoline/test1.c (function): Remove type. + (main): Update. + * trampoline/test2.c (function): Remove type. + (main): Update. + * NEWS: Mention the changes. + +2017-07-30 Bruno Haible + + trampoline: Restructure include file. + * trampoline/trampoline.h: Renamed from trampoline/trampoline.h.in. + * configure.ac: Don't create trampoline.h by substitution. + * trampoline/Makefile.in (trampoline.h): Remove target. + (trampoline.lo, test1.o, test2.o): Update dependency. + (install, SOURCE_FILES): Update. + (distclean): Don't remove trampoline.h. + * trampoline/README: Update. + * Makefile.in (DISTCLEANFILES): Update stamp file list. + +2017-07-30 Bruno Haible + + Move ABI indicator macro definitions to a separate include file. + Rationale: Prepare for getting rid of most .h.in -> .h substitutions. + * ffcall-abi.h: New file. + * Makefile.in (install, uninstall): Install/uninstall ffcall-abi.h. + (SOURCE_FILES): Add ffcall-abi.h. + * porting-tools/abis/predefines.c: New file. + * porting-tools/abis/README: Update. + +2017-07-30 Bruno Haible + + Move libffcall version number to a separate include file. + Rationale: Prepare for getting rid of most .h.in -> .h substitutions. + * ffcall-version.in.h: New file. + * configure.ac: Invoke AC_CONFIG_HEADERS for ffcall-version.h. + * avcall/avcall.h.in (LIBFFCALL_VERSION): Remove definition. Include + ffcall-version.h instead. + * vacall/vacall.h.in: Likewise. + * trampoline/trampoline.h.in: Likewise. + * callback/callback.h.in: Likewise. + * callback/vacall_r/vacall_r.h.in (LIBFFCALL_VERSION): Remove + definition. + * callback/trampoline_r/trampoline_r.h.in (LIBFFCALL_VERSION): Likewise. + * dummy/ffcall-version.h: New file. + * avcall/Makefile.devel (GCCFLAGS): Add -I option to find a dummy + ffcall-version.h. + * vacall/Makefile.devel (GCCFLAGS): Likewise. + * callback/vacall_r/Makefile.devel (GCCFLAGS): Likewise. + * vacall/Makefile.maint (VERSION): Remove macro. + (vacall.h.msvc, vacall.h.mingw32): Don't substitute LIBFFCALL_VERSION. + * callback/vacall_r/Makefile.maint (VERSION): Remove macro. + (vacall_r.h.msvc, vacall_r.h.mingw32): Don't substitute + LIBFFCALL_VERSION. + * Makefile.in (ffcall-version.h): New target. + (install, installdirs, uninstall): Install/uninstall ffcall-version.h. + (DISTCLEANFILES): Add ffcall-version.h. Update stamp file list. + (SOURCE_FILES): Add ffcall-version.in.h, dummy/ffcall-version.h. + +2017-07-30 Bruno Haible + + Remove configure test for 'long long'. Assume the compiler has it. + Rationale: All compilers nowadays have 'long long', for years. + * configure.ac: Don't invoke AC_TYPE_LONG_LONG_INT. + * avcall/avcall.h.in (HAVE_LONG_LONG_INT): Remove macro. + * vacall/vacall.h.in (HAVE_LONG_LONG_INT): Likewise. + * callback/vacall_r/vacall_r.h.in (HAVE_LONG_LONG_INT): Likewise. + * vacall/Makefile.devel (GCCFLAGS): Remove -DHAVE_LONG_LONG_INT. + * callback/vacall_r/Makefile.devel (GCCFLAGS): Likewise. + * avcall/tests.c: Remove test for HAVE_LONG_LONG_INT. + * vacall/tests.c: Likewise. + * callback/tests.c: Likewise. + * porting-tools/abis/README: Update. + +2017-07-30 Bruno Haible + + Remove unused configure test AC_C_CHAR_UNSIGNED. + * vacall/vacall.h.in (__CHAR_UNSIGNED__): Remove unuseed macro. + * callback/vacall_r/vacall_r.h.in (__CHAR_UNSIGNED__): Likewise. + * configure.ac: Don't invoke AC_C_CHAR_UNSIGNED. + +2017-07-30 Bruno Haible + + Don't depend on FFCALL_IREG_FLOAT_RETURN configure result. + Rationale: The installed .h files should be compiler independent. + * avcall/avcall.h.in (__IREG_FLOAT_RETURN__): Remove macro. Assume it is + not defined on m68k. + * vacall/vacall.h.in (__IREG_FLOAT_RETURN__): Likewise. + * callback/vacall_r/vacall_r.h.in (__IREG_FLOAT_RETURN__): Likewise. + +2017-07-30 Bruno Haible + + Don't depend on FFCALL_SMALL_STRUCT_RETURN configure result. + Rationale: The installed .h files should be compiler independent. + * avcall/avcall.h.in (__SMALL_STRUCT_RETURN__): Remove macro. Use + explicit ABI conditional instead. + * vacall/vacall.h.in (__SMALL_STRUCT_RETURN__): Likewise. + * callback/vacall_r/vacall_r.h.in (__SMALL_STRUCT_RETURN__): Likewise. + * avcall/Makefile.maint (avcall.h.msvc, avcall.h.mingw32): Don't + substitute __SMALL_STRUCT_RETURN__. + * vacall/Makefile.maint (vacall.h.msvc, vacall.h.mingw32): Likewise. + * callback/vacall_r/Makefile.maint (vacall_r.h.msvc, + vacall_r.h.mingw32): Likewise. + +2017-07-30 Bruno Haible + + Move a file. + * avcall/port-structs.c: Moved to porting-tools/abis/. + * porting-tools/abis/README: Mention it. + +2017-07-30 Bruno Haible + + Remove support for old PCC struct return convention. + It is not reentrant and therefore a fortiori not multithread-safe. + * m4/pccstruct.m4: Remove file. + * Makefile.in (SOURCE_FILES): Remove it. + * configure.ac: Remove FFCALL_PCC_STRUCT_RETURN invocation. + * avcall/avcall.h.in (__PCC_STRUCT_RETURN__): Remove macro. + (__AV_PCC_STRUCT_RETURN): Remove enum value. + (__av_start_struct1): Remove macro. + (_av_start_struct): Use __av_start_struct2 instead. + * avcall/avcall-*.c: Remove support for __AV_PCC_STRUCT_RETURN flag. + * vacall/vacall.h.in (__PCC_STRUCT_RETURN__): Remove macro. + (__VA_PCC_STRUCT_RETURN): Remove enum value. + (_va_start_struct): Update accordingly. + * callback/vacall_r/vacall_r.h.in: Likewise. + * vacall/vacall-*.c: Remove support for __VA_PCC_STRUCT_RETURN flag. + * vacall/misc.c (__va_error2): Update error message. + * callback/vacall_r/misc.c (__va_error2): Likewise. + +2017-07-22 Bruno Haible + + ia64: Make vacall code more robust. + * vacall/vacall-ia64.c: Use a split struct to allocate room for the + 8 leading words in the callee's stack. + * porting-tools/abis/stack-frame.txt: Mention the change. + +2017-07-22 Bruno Haible + + alpha: Make vacall code more robust. + * vacall/vacall-alpha.c: Use a split struct to allocate room for the + 6 leading words in the callee's stack. + * porting-tools/abis/stack-frame.txt: Mention the change. + +2017-07-22 Bruno Haible + + alpha: Make vacall code more maintainable. + * vacall/vacall.h.in (__va_alist, va_arg_double, va_arg_float) [alpha]: + Add fields 'farg_offset', 'farg'. + * callback/vacall_r/vacall_r.h.in: Likewise. + * vacall/vacall-alpha.c (__vacall): Don't allocate the fargs in the + 'locals' struct. Initialize 'farg_offset' field. + +2017-07-22 Bruno Haible + + mipsn32, mips64: Remove unused field. + * vacall/vacall.h.in (__va_alist) [__mipsn32__ || __mips64__]: Remove + field 'memargptr'. + * callback/vacall_r/vacall_r.h.in: Likewise. + * vacall/vacall-mipsn32.c (__vacall): Update accordingly. + * vacall/vacall-mips64.c (__vacall): Likewise. + +2017-07-22 Bruno Haible + + mipsn32, mips64: Make vacall code more robust. + * vacall/Makefile.devel (vacall-mipsn32eb-macro.S, + vacall-mipsn32el-macro.S, vacall-mips64eb-macro.S, + vacall-mips64el-macro.S): Remove post-processing hack. + * callback/vacall_r/Makefile.devel (vacall-mipsn32eb-macro.S, + vacall-mipsn32el-macro.S, vacall-mips64eb-macro.S, + vacall-mips64el-macro.S): Likewise. + * vacall/vacall-mipsn32.c: Use a split struct to allocate room for the + 8 leading words in the callee's stack. + * vacall/vacall-mips64.c: Likewise. + * porting-tools/abis/stack-frame.txt: Mention the change. + +2017-07-22 Bruno Haible + + mips: Don't store dynamic state in the flags. + * avcall/avcall.h.in (__AV_FLOAT_1, __AV_FLOAT_2, __AV_DOUBLE_1, + __AV_DOUBLE_2): Remove enum values. + (av_alist) [mips]: Store the number of floating-point register arguments + in fanum. Store bitmasks in farg_mask and darg_mask. Rename field + 'floatarg' to 'fargs'. Rename field 'doublearg' to 'dargs'. + (__av_start1, av_float, av_double): Update implementation accordingly. + * avcall/avcall-mips.c (__builtin_avcall): Access farg_mask and + darg_mask instead of the flags. + * vacall/vacall.h.in (__VA_FLOAT_1, __VA_FLOAT_2): Remove enum values. + (__VA_REGISTER_FLOATSTRUCT_RETURN, __VA_REGISTER_DOUBLESTRUCT_RETURN): + Change values. + (__va_alist, va_arg_float, va_arg_double) [mips]: Store the number of + floating-point register arguments in fanum. Use it instead of the + __VA_FLOAT_1 flag. + * callback/vacall_r/vacall_r.h.in: Likewise. + * vacall/vacall-mips.c (__vacall): Update accordingly. + +2017-07-22 Bruno Haible + + powerpc, powerpc64, ia64, x86_64: Undo premature optimization. + * vacall/vacall.h.in: Use 'fanum' field instead of 'memfargptr' field. + * callback/vacall_r/vacall_r.h.in: Likewise. + * vacall/vacall-ia64.c: Update accordingly. + * vacall/vacall-powerpc.c: Likewise. + * vacall/vacall-powerpc64.c: Likewise. + * vacall/vacall-x86_64.c: Likewise. + +2017-07-22 Bruno Haible + + x86_64: Undo premature optimization. + * vacall/vacall.h.in [__x86_64__]: Use 'ianum' field instead of + 'memiargptr' field. + * callback/vacall_r/vacall_r.h.in: Likewise. + * vacall/vacall-x86_64.c (__vacall): Update accordingly. + +2017-07-22 Bruno Haible + + x86_64: Undo premature optimization. + * avcall/avcall.h.in [__x86_64__]: Use 'ianum' field instead of 'iaptr' + field. + +2017-07-22 Bruno Haible + + ia64, x86_64: Use symbolic constants. + * avcall/avcall.h.in (__AV_FARG_NUM) [__ia64__ || __x86_64__]: + New macro. + (av_float, av_double): Use it. + (__av_struct): Use __AV_IARG_NUM. + * vacall/vacall.h.in (__VA_FARG_NUM) [__ia64__ || __x86_64__]: + New macro. + (va_arg_float, va_arg_double): Use it. + * callback/vacall_r/vacall_r.h.in: Likewise. + +2017-07-22 Bruno Haible + + armhf: Fix a bug in vacall (failing tests d_d13i, f_f17l3L, d_d17l3L). + * vacall/vacall.h.in (__va_alist, __va_start_struct2, + __va_arg_leftadjusted, __va_arg_rightadjusted, __va_arg_longlong) + [__armhf__]: Use 'iarg' and 'ianum' fields instead of 'saptr' field. + (va_arg_float, va_arg_double) [__armhf__]: Don't force all remaining + integer arguments to the stack. + * callback/vacall_r/vacall_r.h.in: Likewise. + * vacall/vacall-armhf.c (__vacall): Update accordingly. + +2017-07-22 Bruno Haible + + armhf: Fix a bug in avcall (failing tests f_f17l3L, d_d17l3L). + * avcall/avcall.h.in [__armhf__]: Store integer argument count in ianum. + (__av_start1, __av_start_struct4, __av_word, __av_longlong, av_float, + av_double, __av_struct): Update implementation accordingly. + * avcall/avcall-arm.c: Add comment. + * avcall/avcall-armhf.c: Likewise. + * porting-tools/abis/stack-frame.txt: Update information. + * NEWS: Mention the fix. + +2017-07-22 Bruno Haible + + powerpc: Make avcall code more robust. + * avcall/avcall-powerpc.c (__builtin_avcall) [_AIX]: Don't rely on a + particular stack frame layout produced by GCC. Use __builtin_alloca + instead. + * avcall/avcall-powerpc64.c (STACK_OFFSET): Remove unused macro. + +2017-07-22 Bruno Haible + + powerpc: Don't ever access out-of-range array elements. + * avcall/avcall-powerpc.c (__builtin_avcall): Access only 8 fargs when + only 8 exist. + +2017-07-22 Bruno Haible + + powerpc, powerpc64: Use symbolic constants. + * avcall/avcall.h.in (__AV_FARG_NUM) [__powerpc__ || __powerpc64__]: + New macro. + (av_float, av_double): Use it. + * vacall/vacall.h.in (__VA_FARG_NUM) [__powerpc__ || __powerpc64__]: + New macro. + (va_arg_float, va_arg_double): Use it. + * callback/vacall_r/vacall_r.h.in: Likewise. + +2017-07-22 Bruno Haible + + powerpc: Fix a bug (failing tests f_f12i, f_f13i, d_d12i, d_d13i). + * avcall/avcall.h.in [__powerpc_sysv4__]: Store integer register + arguments in iargs[] and their count in ianum. + (__av_start1, __av_start_struct4, av_long, av_ulong, av_ptr, + __av_longlong, __av_struct): Update implementation accordingly. + * avcall/avcall-powerpc.c (__builtin_avcall): Update accordingly. + Ignore farglen in the arg copy loop. + * vacall/vacall.h.in (__va_alist, __va_start_struct2, + __va_arg_leftadjusted, __va_arg_rightadjusted, __va_arg_longlong, + va_arg_float, va_arg_double) [__powerpc_sysv4__]: Use 'ianum' field + instead of 'saptr', 'onstack' fields. Don't bump 'ianum' in + va_arg_float, va_arg_double. + * callback/vacall_r/vacall_r.h.in: Likewise. + * vacall/vacall-powerpc.c (__vacall): Update accordingly + * porting-tools/abis/stack-frame.txt: Fix information. + * NEWS: Mention the fix. + +2017-07-22 Bruno Haible + + powerpc: Simplify #if expressions. + * avcall/avcall.h.in (__powerpc_aix__, __powerpc_sysv4__): New macros. + Use them in #if expressions. + * vacall/vacall.h.in: Likewise. + * callback/vacall_r/vacall_r.h.in: Likewise. + * avcall/avcall-powerpc.c: Add comments. + * vacall/vacall-powerpc.c: Likewise. + +2017-07-22 Bruno Haible + + s390, s390x: Merge common code. + * vacall/vacall.h.in (va_arg_float, va_arg_double) [s390,s390x]: Merge. + * callback/vacall_r/vacall_r.h.in: Likewise. + +2017-07-22 Bruno Haible + + s390: Fix a bug (failing tests f_f3i...f_f13i, d_d3i...d_d13i). + * vacall/vacall.h.in (va_arg_float, va_arg_double) [s390]: Don't bump + ianum, + * callback/vacall_r/vacall_r.h.in: Likewise. + * NEWS: Mention the fix. + +2017-07-22 Bruno Haible + + s390: Make vacall code more similar to s390x, arm64 cases. + * vacall/vacall.h.in (__va_alist, __va_start_struct2, + __va_arg_leftadjusted, __va_arg_rightadjusted, __va_arg_adjusted, + va_arg_float, va_arg_double, __va_arg_struct) [s390]: Use 'ianum' + field instead of 'saptr', 'onstack' fields. + * callback/vacall_r/vacall_r.h.in: Likewise. + * vacall/vacall-s390.c: Update accordingly. + +2017-07-22 Bruno Haible + + Add some mixed-number args boundary tests. + * avcall/tests.c (f_f17l3L, d_d17l3L): New tests. + * vacall/tests.c: Likewise. + * callback/tests.c: Likewise. + +2017-07-22 Bruno Haible + + Add more mixed-number tests. + * avcall/tests.c (f_fi, ..., f_f13i, d_di, ..., d_d13i): New tests. + * vacall/tests.c: Likewise. + * callback/tests.c: Likewise. + +2017-07-19 Bruno Haible + + s390: Make avcall code more robust. + * avcall/avcall-s390.c (STACK_OFFSET): Remove macro. + (__builtin_avcall): Don't rely on a particular stack frame layout + produced by GCC. Use __builtin_alloca instead. + +2017-07-19 Bruno Haible + + s390: Make avcall code more similar to s390x, arm64, x86_64 cases. + * avcall/avcall.h.in (av_alist, __av_start_struct4, __av_word, av_long, + av_ulong, av_ptr, __av_longlong, __av_struct) [s390]: Use iargs[] array + for the first 5 general-purpose argument words, like on s390x. + (__av_struct_rightadjusted) [s390]: Remove macro. + * avcall/avcall-s390.c (__builtin_avcall): Update accordingly. + +2017-07-19 Bruno Haible + + s390: Simplify avcall code. + * avcall/avcall.h.in (av_alist, __av_start1, __av_start_struct4, + __av_word, __av_longlong, av_float, av_double, + __av_struct_rightadjusted, __av_struct) [s390]: Use 'ianum' field + instead of 'fargwords' field. + * avcall/avcall-s390.c (__builtin_avcall): Update accordingly. + +2017-07-16 Bruno Haible + + Allow building statically linked binaries, through LDFLAGS="-static". + * Makefile.main (libtool-imported-files): Fetch and apply patch from + : + + 2017-07-15 Bruno Haible + + * build-aux/ltmain.sh (func_mode_help, func_mode_link): In the + link mode, accept option '-static-uninstalled-libs' in place of + '-static', and make '-static' an equivalent of '-all-static'. + +2017-07-07 Bruno Haible + + build: Avoid a hanging configure test on FreeBSD/arm64. + Seen with FreeBSD 11.1-RC1 on arm64 (under qemu 2.9.0). + * m4/codeexec.m4 (FFCALL_CODEEXEC): Avoid running the test on + FreeBSD/arm64. + +2017-06-27 Bruno Haible + + build: Fix warning in autoconf test. + * m4/shm.m4 (CL_SHM): Include , to declare exit(). + +2017-06-25 Bruno Haible + + Add doc about ABIs and calling conventions. + * porting-tools/abis: New directory. + * common/reg-struct-return.txt: Moved to porting-tools/abis/. + * callback/call-used-registers.txt: Likewise. + +2017-06-25 Bruno Haible + + Add doc about emulation of target platforms. + * porting-tools/emulation: New directory. + +2017-06-24 Bruno Haible + + s390: Simplify code. + * vacall/vacall.h.in (__va_alist) [s390]: Use a counter instead of + 2 pointers. + (va_arg_float, va_arg_double): Update accordingly; + * callback/vacall_r/vacall_r.h.in: Likewise. + * vacall/vacall-s390.c: Update accordingly. + +2017-06-24 Bruno Haible + + s390: Simplify code. + * avcall/avcall.h.in (av_alist) [s390]: Use a counter instead of + 4 pointers. Use 2 bitmasks instead of 2 int[] arrays. + (__av_start1, av_float, av_double): Update accordingly. + * avcall/avcall-s390.c (__builtin_avcall): Likewise. + +2017-06-24 Bruno Haible + + build: Improve guesses when cross-compiling. + * m4/codeexec.m4 (FFCALL_CODEEXEC, FFCALL_CODEEXEC_PAX): When + cross-compiling, use the known autoconf test results. + * m4/mmap.m4 (FFCALL_MMAP): Likewise. + * m4/mprotect.m4 (FFCALL_MPROTECT): Likewise. + * m4/pccstruct.m4 (FFCALL_PCC_STRUCT_RETURN): Likewise. + * m4/shm.m4 (CL_SHM): Likewise. + * m4/smallstruct.m4 (FFCALL_SMALL_STRUCT_RETURN): Likewise. + +2017-06-24 Bruno Haible + + Bump version number. + * VERSION: Set to 2.0. + * NEWS: Open new section for 2.0. + +2017-06-24 Bruno Haible + + build: Use decimal notation for the version number. + * VERSION: Set to 1.13. + * configure.ac: Simplify AC_CONFIG_HEADERS invocations. Define + LIBFFCALL_VERSION as C macro, based on PACKAGE_VERSION. + * avcall/avcall.h.in (LIBFFCALL_VERSION): Use a plain #define, for + substitution by config.status. + * vacall/vacall.h.in: Likewise. + * trampoline/trampoline.h.in: Likewise. + * callback/callback.h.in: Likewise. + * callback/vacall_r/vacall_r.h.in: Likewise. + * callback/trampoline_r/trampoline_r.h.in: Likewise. + +2017-06-24 Bruno Haible + + trampoline, callback: Make multithread-safe. + * Makefile.maint (AUTOMAKE): New variable. + (all): Depend on Makefile-ins. + (GNULIB_MODULES): Add 'lock'. + (gnulib-m4/gnulib-cache.m4): Don't remove generated gnulib-lib files. + (ALL_MAKEFILE_IN_FROM_AM): New variable. + (Makefile-ins, gnulib-lib/Makefile.in): New targets. + * configure.ac: Invoke AM_INIT_AUTOMAKE. Arrange to generate + gnulib-lib/Makefile. Invoke gl_EARLY earlier. Recurse into gnulib-lib + directory. + * Makefile.in (DISTCLEANFILES): Add the various stamp-h* files created + by config.status at the end of the 'configure' run. + (AUTOMAKE_IMPORTED_FILES): New variable. + (IMPORTED_FILES): Use it. + * trampoline/Makefile.in (INCLUDES): Reference the gnulib build dir and + source dir. + (LTLIBTHREAD): New variable. + (libtrampoline.la): Link against libgnu.la, with options $(LTLIBTHREAD). + (test1, test2): Link against libtrampoline.la. + * trampoline/trampoline.c: Include glthread/lock.h. + (zero_fd, file_fd, file_length): Move to file scope. + (for_mmap_init): New function, extracted from alloc_trampoline. + (for_mmap_once): New variable. + (freelist_lock): New variable. + (alloc_trampoline): Use once-only execution and locking. + * callback/trampoline_r/Makefile.in (INCLUDES): Reference the gnulib + build dir and source dir. + (LTLIBTHREAD): New variable. + (libtrampoline.la): Link against libgnu.la, with options $(LTLIBTHREAD). + (test1, test2): Link against libtrampoline.la. + * callback/trampoline_r/trampoline.c: Include glthread/lock.h. + (zero_fd, file_fd, file_length): Move to file scope. + (for_mmap_init): New function, extracted from alloc_trampoline. + (for_mmap_once): New variable. + (freelist_lock): New variable. + (alloc_trampoline_r): Use once-only execution and locking. + * callback/Makefile.in (LTLIBTHREAD): New variable. + (libcallback.la): Link against libgnu.la, with options $(LTLIBTHREAD). + +2017-06-24 Bruno Haible + + build: Rename glm4 to gnulib-m4. + * autogen.sh: Write gnulib-m4 instead of glm4. + * Makefile.maint: Likewise. + * Makefile.in (GNULIB_IMPORTED_FILES): Likewise. + +2017-06-24 Bruno Haible + + build: Assume a single configure.ac file. + * Makefile.maint (ALL_CONFIGURE_AC, aclocal.m4): Simplify. + +2017-06-24 Bruno Haible + + Merge all autoconf configurations into a single one. + * configure.ac: Include the body of all other configure.ac files. + Use a single config.h file. Inline FFCALL_COMMON_LIBTOOL and + FFCALL_COMMON_TRAMPOLINE. + * avcall/configure.ac: Remove file. + * vacall/configure.ac: Remove file. + * trampoline/configure.ac: Remove file. + * callback/configure.ac: Remove file. + * callback/vacall_r/configure.ac: Remove file. + * callback/trampoline_r/configure.ac: Remove file. + * m4/general.m4 (FFCALL_COMMON_LIBTOOL, FFCALL_COMMON_TRAMPOLINE): + Remove macros. + * build-aux/ac-help.sed: Remove file. + * Makefile.maint (CONFIGURED_SUBDIRS, SUBDIRS_CONFIGURE): Remove + variables. + (ALL_CONFIGURE): Keep only the top-level configure. + (%/configure): Remove rule. + (ALL_CONFIG_H_IN): Set to only the top-level config.h.in. + (config.h.in): Replace the %/config.h.in rule. + * vacall/Makefile.maint (config.h.msvc, config.h.mingw32): Use top-level + config.h.in. + * trampoline/Makefile.maint (config.h.msvc, config.h.mingw32): Use + top-level config.h.in. + * callback/Makefile.maint (vacall_r/config.h.msvc, + vacall_r/config.h.mingw32, trampoline_r/config.h.msvc, + trampoline_r/config.h.mingw32): Update dependencies. + * callback/vacall_r/Makefile.maint (config.h.msvc, config.h.mingw32): + Use top-level config.h.in. + * callback/trampoline_r/Makefile.maint (config.h.msvc, + config.h.mingw32): Use top-level config.h.in. + * Makefile.in (DISTCLEANFILES): Add config.h, libtool. + (SOURCE_FILES): Remove build-aux/ac-help.sed. + (GENERATED_FILES): Add config.h.in. Remove */config* and + callback/*/config*. + * avcall/Makefile.in (INCLUDES): Look also in '..'. + (top_builddir): Set to '..'. + (distclean): Don't remove config* and libtool. + (SOURCE_FILES): Remove configure.ac. + * vacall/Makefile.in (INCLUDES): Look also in '..'. + (misc.o): Update dependency. + (distclean): Don't remove config* and libtool. + (SOURCE_FILES): Remove configure.ac. + * trampoline/Makefile.in (INCLUDES): Look also in '..'. + (top_builddir): Set to '..'. + (distclean): Don't remove config* and libtool. + (SOURCE_FILES): Remove configure.ac. + * callback/Makefile.in (INCLUDES): Look also in '..'. + (top_builddir): Set to '..'. + (DISTCLEANFILES): Remove config* and libtool. + (SOURCE_FILES): Remove configure.ac. + * callback/vacall_r/Makefile.in (INCLUDES): Look also in '../..'. + (top_builddir): Set to '../..'. + (misc.lo): Update dependency. + (distclean): Don't remove config* and libtool. + (SOURCE_FILES): Remove configure.ac. + * callback/trampoline_r/Makefile.in (INCLUDES): Look also in '../..'. + (top_builddir): Set to '../..'. + (distclean): Don't remove config* and libtool. + (SOURCE_FILES): Remove configure.ac. + * README, */README: Update. + +2017-06-24 Bruno Haible + + trampoline: Build library using libtool. + * trampoline/configure.ac: Invoke FFCALL_COMMON_LIBTOOL. + (CPU_OBJECTS): Now contains .lo file names instead of .o file names. + * trampoline/Makefile.in (LIBTOOL*, top_builddir): New variables. + (*.lo): Targets renamed from *.o. + (libtrampoline.la): Replaces target libtrampoline.a. + Use LIBTOOL* variables as appropriate. + (clean): Remove also *.lo, libtrampoline.*, .libs, _libs. + (distclean): Remove also 'libtool'. + +2017-06-24 Bruno Haible + + trampoline: Generate position-independent code. + * trampoline/Makefile.devel (GCCFLAGS): Add -fPIC. + +2017-06-24 Bruno Haible + + vacall: Explain why not using libtool. + * vacall/README: Add comment about libtool. + +2017-06-24 Bruno Haible + + Fix result of an autoconf test on AIX. + * m4/codeexec.m4 (FFCALL_CODEEXEC): Don't actually run the test on + powerpc64 (AIX and Linux) and ia64 (Linux). + +2017-06-24 Bruno Haible + + build: Avoid testing an undefined variable. + * m4/codeexec.m4 (FFCALL_CODEEXEC_PAX): Before testing + cl_cv_func_mprotect_works, test ac_cv_func_mprotect. + +2017-06-24 Bruno Haible + + build: Add necessary AC_REQUIREs. + * m4/codeexec.m4 (FFCALL_CODEEXEC): Require AC_CANONICAL_HOST and + gl_HOST_CPU_C_ABI. + +2017-06-24 Bruno Haible + + Fix build error on Solaris 11 with Oracle Developer Studio 12.5. + * common/asm-x86_64.sh: Clarify the necessary postprocessing. + * common/asm-i386.sh: Document the necessary postprocessing. + * avcall/Makefile.in (avcall-i386.s): Do more postprocessing. + * vacall/Makefile.in (vacall-i386.s): Likewise. + * callback/vacall_r/Makefile.in (vacall-i386.s): Likewise. + +2017-06-24 Bruno Haible + + Fix compilation error on CentOS 5. + * trampoline/trampoline.c (open_noinherit): New function. + (alloc_trampoline): Use it. + * callback/trampoline_r/trampoline.c: Likewise. + +2017-06-24 Bruno Haible + + Prefer https over http URLs. + * autogen.sh: Access ftp.gnu.org through https. + +2017-06-24 Bruno Haible + + Remove obsolete mention of nonexistent file. + * avcall/README: Don't mention underscore.h. + * vacall/README: Likewise. + +2017-06-24 Bruno Haible + + Remove obsolete protexec.c file. + * trampoline/protexec.c: Remove file. + * trampoline/README: Update. + * callback/trampoline_r/Makefile.maint (COPIED_FILES): Remove + protexec.c. + +2017-06-21 Bruno Haible + + Fix list of distributed files. + * Makefile.in (SOURCE_FILES): Add m4/endianness.m4, common/asm-s390.sh. + +2017-06-19 Bruno Haible + + Fix a misnomer. + * vacall/vacall.h.in: Rename 'regarg' to 'iarg'. + * callback/vacall_r/vacall_r.h.in: Likewise. + * vacall/vacall-powerpc.c: Update accordingly. + * vacall/vacall-s390.c: Likewise. + +2017-06-18 Bruno Haible + + s390x: Add support for s390x CPU (64-bit S/390). + * cross-tools/cross.conf: Add configuration for s390x cross tools. + * common/reg-struct-return.txt: Add info about s390x. + * callback/call-used-registers.txt: Likewise. + * common/asm-s390.sh: New file. + * avcall/avcall.h.in: Optionally define __s390x__. Add code for + __s390x__, especially __av_start_struct4, av_float, av_double, + __av_struct. + * avcall/avcall-s390x.c: New file. + * avcall/Makefile.devel (avcall-s390-macro.S): Use asm-s390.sh. + (avcall-s390x-linux.s, avcall-s390x-macro.S): New targets. + * avcall/Makefile.in (avcall-s390x.lo, avcall-s390x.s): New targets. + (clean): Remove avcall-s390x.s. + (SOURCE_FILES): Add avcall-s390x.c, avcall-s390x-linux.s, + avcall-s390x-macro.S. + * vacall/vacall.h.in: Optionally define __s390x__. Add code for + __s390x__, especially __va_start_struct2, __va_arg_adjusted, + va_arg_float, va_arg_double, __va_arg_struct. + * vacall/vacall-s390x.c: New file. + * vacall/Makefile.devel (vacall-s390-macro.S): Use asm-s390.sh. + (vacall-s390x-linux.s, vacall-s390x-macro.S): New targets. + * vacall/Makefile.in (vacall-s390x.o, vacall-s390x.s): New targets. + (clean): Remove vacall-s390x.s. + (SOURCE_FILES): Add vacall-s390x.c, vacall-s390x-linux.s, + vacall-s390x-macro.S. + * callback/vacall_r/Makefile.maint (COPIED_FILES): Add vacall-s390x.c. + * Makefile.in (COPIED_FILES): Add callback/vacall_r/vacall-s390x.c. + * callback/vacall_r/vacall_r.h.in: Optionally define __s390x__. Add code + for __s390x__, especially __va_start_struct2, __va_arg_adjusted, + va_arg_float, va_arg_double, __va_arg_struct. + * callback/vacall_r/Makefile.devel (vacall-s390-macro.S): Use + asm-s390.sh. + (vacall-s390x-linux.s, vacall-s390x-macro.S): New targets. + * callback/vacall_r/Makefile.in (vacall-s390x.lo, vacall-s390x.s): New + targets. + (clean): Remove vacall-s390x.s. + (SOURCE_FILES): Add vacall-s390x.c, vacall-s390x-linux.s, + vacall-s390x-macro.S. + * trampoline/Makefile.devel (proto-s390x.s, tramp-s390x.o): New targets. + * trampoline/proto-s390x.s: New generated file. + * trampoline/tramp-s390x.s: New file. + * trampoline/tramp-s390x.o: New generated file. + * trampoline/trampoline.c: Implement for __s390x__. + * callback/trampoline_r/Makefile.devel (proto-s390x.s, tramp-s390x.o): + New targets. + * callback/trampoline_r/proto64.c: Add support for __s390x__. + * callback/trampoline_r/proto-s390x.s: New generated file. + * callback/trampoline_r/tramp-s390x.s: New file. + * callback/trampoline_r/tramp-s390x.o: New generated file. + * callback/trampoline_r/trampoline.c: Implement for __s390x__. + * callback/trampoline_r/test1.c: Add support for __s390x__. + * PLATFORMS, */PLATFORMS: List the s390x machine. + * NEWS: Mention the new port. + +2017-06-18 Bruno Haible + + Small code style improvements. + * avcall/avcall.h.in [__arm64__]: Define and use __AV_FARG_NUM. + [__s390__, __arm64__] (__av_struct): Avoid a boolean negation. + * vacall/vacall.h.in [__arm64__]: Define and use __VA_IARG_NUM, + __VA_FARG_NUM. + [__x86_64__]: Define and use __VA_IARG_NUM. + * callback/vacall_r/vacall_r.h.in: Likewise. + +2017-06-18 Bruno Haible + + s390: Reorder code. + * avcall/avcall.h.in: Move s390 specific code to the end (after ia64 and + x86_64 specific code). + * vacall/vacall.h.in: Likewise. + * callback/vacall_r/vacall_r.h.in: Likewise. + +2017-06-18 Bruno Haible + + s390: Improve trampolines. + * trampoline/Makefile.devel (proto-s390.s): New target. + (tramp-s390.o): Use cross tools. + * trampoline/proto-s390.s: Regenerated with gcc 3.1. + * trampoline/tramp-s390.s: Rewritten from scratch, to not use %r13. + * trampoline/tramp-s390.o: New generated file. + * trampoline/trampoline.c (alloc_trampoline) [__s390__]: Change the + trampoline to not use %r13. + * callback/trampoline_r/Makefile.devel (proto-s390.s): New target. + (tramp-s390.o): Use cross tools. + * callback/trampoline_r/proto-s390.s: Regenerated with gcc 3.1. + * callback/trampoline_r/tramp-s390.s: Rewritten from scratch. Use 'lm' + instruction. + * callback/trampoline_r/tramp-s390.o: Regenerated. + * callback/trampoline_r/trampoline.c (alloc_trampoline_r) [__s390__]: + Change the trampoline accordingly. + +2017-06-17 Bruno Haible + + arm64: Add support for arm64 CPU (a.k.a. aarch64). + * cross-tools/cross.conf: Add configuration for arm64 cross tools. + * common/reg-struct-return.txt: Add info about arm64. + * callback/call-used-registers.txt: Likewise. + * avcall/avcall.h.in: Add code for __arm64__, especially __av_start1, + av_long, av_ulong, av_ptr, av_float, av_double, __av_struct. + * avcall/avcall-arm64.c: New file. + * avcall/Makefile.devel (avcall-arm64-macro.S): New target. + * avcall/Makefile.in (avcall-arm64.lo, avcall-arm64.s): New targets. + (clean): Remove avcall-arm64.s. + (SOURCE_FILES): Add avcall-arm64.c, avcall-arm64-macro.S. + * vacall/vacall.h.in: Add code for __arm64__, especially + __va_arg_adjusted, va_arg_float, va_arg_double, __va_arg_struct. + * vacall/vacall-arm64.c: New file. + * vacall/Makefile.devel (vacall-arm64-macro.S): New target. + * vacall/Makefile.in (vacall-arm64.o, vacall-arm64.s): New targets. + (clean): Remove vacall-arm64.s. + (SOURCE_FILES): Add vacall-arm64.c, vacall-arm64-macro.S. + * callback/vacall_r/Makefile.maint (COPIED_FILES): Add vacall-arm64.c. + * Makefile.in (COPIED_FILES): Add callback/vacall_r/vacall-arm64.c. + * callback/vacall_r/vacall_r.h.in: Add code for __arm64__, especially + __va_arg_adjusted, va_arg_float, va_arg_double, __va_arg_struct. + * callback/vacall_r/Makefile.devel (vacall-arm64-macro.S): New target. + * callback/vacall_r/Makefile.in (vacall-arm64.lo, vacall-arm64.s): New + targets. + (clean): Remove vacall-arm64.s. + (SOURCE_FILES): Add vacall-arm64.c, vacall-arm64-macro.S. + * trampoline/Makefile.devel (proto-arm64.s, tramp-arm64.o): New targets. + * trampoline/proto-arm64.s: New generated file. + * trampoline/tramp-arm64.s: New file. + * trampoline/tramp-arm64.o: New generated file. + * trampoline/trampoline.c: Implement for __arm64__. + * callback/trampoline_r/Makefile.devel (proto-arm64.s, tramp-arm64.o): + New targets. + * callback/trampoline_r/proto64.c: Add support for __arm64__. + * callback/trampoline_r/proto-arm64.s: New generated file. + * callback/trampoline_r/tramp-arm64.s: New file. + * callback/trampoline_r/tramp-arm64.o: New generated file. + * callback/trampoline_r/trampoline.c: Implement for __arm64__. + * callback/trampoline_r/test1.c: Add support for __arm64__. + * PLATFORMS, */PLATFORMS: List the arm64 machine. + * NEWS: Mention the new port. + +2017-06-16 Bruno Haible + + Remove unused fields from __va_alist. + * vacall/vacall.h.in (__va_alist): Don't include _longlong and + _ulonglong on platforms where they are unused. + * callback/vacall_r/vacall_r.h.in: Likewise. + +2017-06-15 Bruno Haible + + Reduce the amount of cache invalidation to the necessary minimum. + * trampoline/trampoline.c (alloc_trampoline): New macro + TRAMP_CODE_LENGTH. Use it instead of TRAMP_LENGTH for cache + invalidation. + * callback/trampoline_r/trampoline.c (alloc_trampoline_r): Likewise. + +2017-06-10 Bruno Haible + + Make the top-level "./configure --help" output complete. + Reported by Karl Berry in + . + * build-aux/ac-help.sed: New file, from GNU gettext with modifications. + * Makefile.in (SOURCE_FILES): Add it. + * configure.ac: Collect the AC_ARG_* options from the subdirectories, + like in GNU gettext. + * callback/configure.ac: Likewise. + * Makefile.maint (aclocal.m4): Disable esyscmd invocations while running + aclocal. + +2017-06-10 Bruno Haible + + In comments, write 'libffcall' instead of 'ffcall'. + +2017-06-10 Bruno Haible + + Add cache invalidation for 64-bit powerpc. + * trampoline/cache-powerpc64.c: New file. + * trampoline/Makefile.devel (cache-powerpc64-elfv2-linux.s, + cache-powerpc64-elfv2-macro.S): New rules. + * trampoline/configure.ac (CPU_OBJECTS): Augment also for + powerpc64-elfv2 ABI. + * trampoline/Makefile.in (cache-powerpc64-elfv2.o, + cache-powerpc64-elfv2.s): New rules. + (clean): Remove also cache-powerpc64-elfv2.s. + (SOURCE_FILES): Add cache-powerpc64.c, cache-powerpc64-elfv2-linux.s, + cache-powerpc64-elfv2-macro.S. + * trampoline/trampoline.c (__TR_clear_cache): Declare also for + powerpc64-elfv2 ABI. + (alloc_trampoline): Invoke __TR_clear_cache also on powerpc64-elfv2 ABI. + * callback/trampoline_r/cache-powerpc64.c: New file. + * callback/trampoline_r/Makefile.devel (cache-powerpc64-elfv2-linux.s, + cache-powerpc64-elfv2-macro.S): New rules. + * trampoline/configure.ac (CPU_OBJECTS): Augment also for + powerpc64-elfv2 ABI. + * callback/trampoline_r/Makefile.in (cache-powerpc64-elfv2.lo, + cache-powerpc64-elfv2.s): New rules. + (clean): Remove also cache-powerpc64-elfv2.s. + (SOURCE_FILES): Add cache-powerpc64.c, cache-powerpc64-elfv2-linux.s, + cache-powerpc64-elfv2-macro.S. + * callback/trampoline_r/trampoline.c (__TR_clear_cache): Declare also + for powerpc64-elfv2 ABI. + (alloc_trampoline_r): Invoke __TR_clear_cache also on powerpc64-elfv2 + ABI. + +2017-06-10 Bruno Haible + + Fix cache invalidation for 32-bit powerpc. + * trampoline/cache-powerpc.c: Add comment. + * callback/trampoline_r/cache-powerpc.c: New file, based on + trampoline/cache-powerpc.c. + * callback/trampoline_r/Makefile.maint (COPIED_FILES): Remove + cache-powerpc.c. + * Makefile.in (COPIED_FILES): Remove + callback/trampoline_r/cache-powerpc.c. + +2017-06-10 Bruno Haible + + Don't declare the need for an executable stack on Linux and FreeBSD. + * porting-tools: New directory. + * common/asm-alpha.sh: New file. + * common/asm-powerpc.sh: New file. + * common/asm-arm.sh: Remove the GNU-stack note line. + * common/asm-sparc.sh: Likewise. + * common/asm-x86_64.sh: Likewise. + * common/noexecstack.h: New file. + * common/noexecstack-arm.h: New file. + * avcall/Makefile.devel (precompiled): Add avcall-alpha-macro.S, + avcall-powerpc-linux-macro.S, avcall-powerpc-sysv4-macro.S, + avcall-powerpc64-linux.S, avcall-powerpc64-elfv2-linux.S, + avcall-ia64-macro.S, avcall-s390-macro.S. Remove avcall-alpha.s, + avcall-powerpc-linux.s, avcall-powerpc-sysv4.s, + avcall-powerpc64-linux.s, avcall-powerpc64-elfv2-linux.s, avcall-ia64.s, + avcall-s390.s. + (avcall-i386-macro.S, avcall-m68k.mit.S, avcall-m68k.motorola.S, + avcall-sparc-macro.S, avcall-sparc64-macro.S, avcall-hppa-macro.S, + avcall-x86_64-macro.S): Include noexecstack.h. + (avcall-alpha-linux.s): Renamed from avcall-alpha.s. + (avcall-alpha-macro.S): New rule. + (avcall-arm-macro.S, avcall-armhf-macro.S): Include noexecstack-arm.h. + (avcall-powerpc-linux-macro.S): New rule. + (avcall-powerpc-sysv4-macro.S): Replaces rule for + avcall-powerpc-sysv4.s. + (avcall-powerpc64-linux.S): Replaces rule for avcall-powerpc64-linux.s. + (avcall-powerpc64-elfv2-linux.S): Replaces rule for + avcall-powerpc64-elfv2-linux.s. + (avcall-ia64-linux.s): Renamed from avcall-ia64.s. + (avcall-ia64-macro.S): New rule. + (avcall-s390-linux.s): Renamed from avcall-s390.s. + (avcall-s390-macro.S): New rule. + * avcall/Makefile.in (avcall-alpha.s): New rule. + (avcall-alpha.lo): Update. + (avcall-powerpc.s): Use avcall-powerpc-linux-macro.S, + avcall-powerpc-sysv4-macro.S instead of avcall-powerpc-linux.s, + avcall-powerpc-sysv4.s. + (avcall-powerpc64.s): Use avcall-powerpc64-linux.S instead of + avcall-powerpc64-linux.s. + (avcall-powerpc64-elfv2.s): Use avcall-powerpc64-elfv2-linux.S instead + of avcall-powerpc64-elfv2-linux.s. + (avcall-ia64.s): New rule. + (avcall-ia64.lo): Update. + (avcall-s390.s): New rule. + (avcall-s390.lo): Update. + (clean): Remove also avcall-alpha.s, avcall-ia64.s, avcall-s390.s. + (SOURCE_FILES): Update. + * vacall/Makefile.devel (precompiled): Add vacall-alpha-macro.S, + vacall-powerpc-linux-macro.S, vacall-powerpc-sysv4-macro.S, + vacall-powerpc64-linux.S, vacall-powerpc64-elfv2-linux.S, + vacall-ia64-macro.S, vacall-s390-macro.S. Remove vacall-alpha.s, + vacall-powerpc-linux.s, vacall-powerpc-sysv4.s, + vacall-powerpc64-linux.s, vacall-powerpc64-elfv2-linux.s, vacall-ia64.s, + vacall-s390.s. + (vacall-i386-macro.S, vacall-m68k.mit.S, vacall-m68k.motorola.S, + vacall-sparc-macro.S, vacall-sparc64-macro.S, vacall-hppa-macro.S, + vacall-x86_64-macro.S): Include noexecstack.h. + (vacall-alpha-linux.s): Renamed from vacall-alpha.s. + (vacall-alpha-macro.S): New rule. + (vacall-arm-macro.S, vacall-armhf-macro.S): Include noexecstack-arm.h. + (vacall-powerpc-linux-macro.S): New rule. + (vacall-powerpc-sysv4-macro.S): Replaces rule for + vacall-powerpc-sysv4.s. + (vacall-powerpc64-linux.S): Replaces rule for vacall-powerpc64-linux.s. + (vacall-powerpc64-elfv2-linux.S): Replaces rule for + vacall-powerpc64-elfv2-linux.s. + (vacall-ia64-linux.s): Renamed from vacall-ia64.s. + (vacall-ia64-macro.S): New rule. + (vacall-s390-linux.s): Renamed from vacall-s390.s. + (vacall-s390-macro.S): New rule. + * vacall/Makefile.in (vacall-alpha.s): New rule. + (vacall-alpha.o): Update. + (vacall-powerpc.s): Use vacall-powerpc-linux-macro.S, + vacall-powerpc-sysv4-macro.S instead of vacall-powerpc-linux.s, + vacall-powerpc-sysv4.s. + (vacall-powerpc64.s): Use vacall-powerpc64-linux.S instead of + vacall-powerpc64-linux.s. + (vacall-powerpc64-elfv2.s): Use vacall-powerpc64-elfv2-linux.S instead + of vacall-powerpc64-elfv2-linux.s. + (vacall-ia64.s): New rule. + (vacall-ia64.o): Update. + (vacall-s390.s): New rule. + (vacall-s390.o): Update. + (clean): Remove also vacall-alpha.s, vacall-ia64.s, vacall-s390.s. + (SOURCE_FILES): Update. + * callback/vacall_r/Makefile.devel (precompiled): Add + vacall-powerpc64-linux.S, vacall-powerpc64-elfv2-linux.S, + vacall-ia64-macro.S. Remove vacall-powerpc64-linux.s, + vacall-powerpc64-elfv2-linux.s, vacall-ia64.s. + (vacall-i386-macro.S, vacall-m68k.mit.S, vacall-m68k.motorola.S, + vacall-sparc-macro.S, vacall-sparc64-macro.S, vacall-alpha-macro.S, + vacall-hppa-macro.S, vacall-powerpc-linux-macro.S, + vacall-powerpc-sysv4-macro.S, vacall-x86_64-macro.S, + vacall-s390-macro.S): Include noexecstack.h. + (vacall-arm-macro.S, vacall-armhf-macro.S): Include noexecstack-arm.h. + (vacall-powerpc64-linux.S): Replaces rule for vacall-powerpc64-linux.s. + (vacall-powerpc64-elfv2-linux.S): Replaces rule for + vacall-powerpc64-elfv2-linux.s. + (vacall-ia64-linux.s): Renamed from vacall-ia64.s. + (vacall-ia64-macro.S): New rule. + * callback/vacall_r/Makefile.in (vacall-powerpc64.s): Use + vacall-powerpc64-linux.S instead of vacall-powerpc64-linux.s. + (vacall-powerpc64-elfv2.s): Use vacall-powerpc64-elfv2-linux.S instead + of vacall-powerpc64-elfv2-linux.s. + (vacall-ia64.s): New rule. + (vacall-ia64.lo): Update. + (vacall-s390.s): New rule. + (vacall-s390.lo): Update. + (clean): Remove also vacall-ia64.s. + (SOURCE_FILES): Update. + * trampoline/cache-alpha.s: Remove file. + * trampoline/cache-hppa.s: Remove file. + * trampoline/cache-powerpc-macos.s, trampoline/cache-powerpc-sysv4.s: + Remove files. + * trampoline/cache-sparc-macro.S: Remove file. + * trampoline/tramp-hppa-macro.S: Renamed from trampoline/tramp-hppa.s. + Include "noexecstack.h". + * trampoline/tramp-ia64-macro.S: Renamed from trampoline/tramp-ia64.s. + Include "noexecstack.h". + * trampoline/tramp-powerpc64-aix.S: Include "noexecstack.h". + * trampoline/Makefile.devel: Rename GCCFLAGS to OLDGCCFLAGS in old + rules. + (cache-*): Remove old rules. + (precompiled): New target. + (cache-sparc-linux.s, cache-sparc-macro.S, cache-sparc64-linux.s, + cache-sparc64-macro.S, cache-alpha-linux.s, cache-alpha-macro.S, + cache-hppa-linux.s, cache-hppa-macro.S, cache-powerpc-linux.s, + cache-powerpc-linux-macro.S, cache-powerpc-macos.s): New rules. + * trampoline/Makefile.in (tramp-hppa.s): New rule. + (tramp-hppa.o): Update. + (tramp-powerpc64.s: Depend on noexecstack.h. + (tramp-ia64.s): New rule. + (tramp-ia64.o): Update. + (cache-sparc64.s): Update. + (cache-alpha.s): New rule. + (cache-alpha.o): Update. + (cache-hppa.s): New rule. + (cache-hppa.o): Update. + (cache-powerpc.s): New rule. + (cache-powerpc.o): Update. + (clean): Remove also tramp-hppa.s, tramp-ia64.s, cache-alpha.s, + cache-hppa.s, cache-powerpc.s. + (SOURCE_FILES): Update. + * callback/trampoline_r/cache-sparc-macro.S: Remove file. + * callback/trampoline_r/tramp-hppa-macro.S: Renamed from + callback/trampoline_r/tramp-hppa.s. Include "noexecstack.h". + * callback/trampoline_r/tramp-ia64-macro.S: Renamed from + callback/trampoline_r/tramp-ia64.s. Include "noexecstack.h". + * callback/trampoline_r/tramp-powerpc64-aix.S: Include "noexecstack.h". + * callback/trampoline_r/Makefile.maint (COPIED_FILES): Remove + cache-alpha.s, cache-hppa.s, cache-powerpc-macos.s, + cache-powerpc-sysv4.s. + * callback/trampoline_r/Makefile.devel: Rename GCCFLAGS to OLDGCCFLAGS + in old rules. + (cache-*): Remove old rules. + (precompiled): New target. + (cache-sparc-linux.s, cache-sparc-macro.S, cache-sparc64-linux.s, + cache-sparc64-macro.S, cache-alpha-linux.s, cache-alpha-macro.S, + cache-hppa-linux.s, cache-hppa-macro.S, cache-powerpc-linux.s, + cache-powerpc-linux-macro.S, cache-powerpc-macos.s): New rules. + * callback/trampoline_r/Makefile.in (tramp-hppa.s): New rule. + (tramp-hppa.lo): Update. + (tramp-powerpc64.s: Depend on noexecstack.h. + (tramp-ia64.s): New rule. + (tramp-ia64.lo): Update. + (cache-sparc64.s): Update. + (cache-alpha.s): New rule. + (cache-alpha.lo): Update. + (cache-hppa.s): New rule. + (cache-hppa.lo): Update. + (cache-powerpc.s): New rule. + (cache-powerpc.lo): Update. + (clean): Remove also tramp-hppa.s, tramp-ia64.s, cache-alpha.s, + cache-hppa.s, cache-powerpc.s. + (SOURCE_FILES): Update. + * Makefile.devel (precompiled): Recurse also into trampoline and + callback/trampoline_r directories. + * Makefile.in (SOURCE_FILES): Update. + (COPIED_FILES): Remove callback/trampoline_r/cache-alpha.s, + callback/trampoline_r/cache-hppa.s, + callback/trampoline_r/cache-powerpc-macos.s, + callback/trampoline_r/cache-powerpc-sysv4.s. + * NEWS: Mention the change. + +2017-06-10 Bruno Haible + + Simplify Makefile.devel. + * avcall/Makefile.devel (HOST, CPU): Remove unused variables. + * vacall/Makefile.devel (HOST, CPU): Likewise. + * trampoline/Makefile.devel (HOST, CPU): Likewise. + * callback/vacall_r/Makefile.devel (HOST, CPU): Likewise. + * callback/trampoline_r/Makefile.devel (HOST, CPU): Likewise. + +2017-06-10 Bruno Haible + + Make the EXECUTABLE_VIA_MMAP_FILE_SHARED support work on i386. + * trampoline/trampoline.c (alloc_trampoline): New local variable + 'function_x'. Use it instead of 'function' for the computation of the + relative address in the i386 trampoline. + * callback/trampoline_r/trampoline.c (alloc_trampoline_r): Likewise. + +2017-06-04 Bruno Haible + + build: Get rid of autom4te.cache directories. + * Makefile.maint (configure, $(SUBDIRS_CONFIGURE), $(ALL_CONFIG_H_IN)): + Remove autom4te.cache subdirectory. + +2017-06-04 Bruno Haible + + Change the license from GPLv2 to GPLv2+. + * **/configure.ac, **/*.3, **/*.html, **/minitests.c, + callback/MIGRATION, common/asm-*: Add copyright notice. + * m4/*.m4: Use GPLv2+ with exception notice. + * Everywhere else: Change GPLv2 copyright notice to GPLv2+ copyright + notice. Update copyright years. + +2017-06-03 Bruno Haible + + Make the cross-build.sh script work with argument 'all'. + * cross-tools/cross-build.sh: Fix typo. + +2017-06-03 Bruno Haible + + Improve support for SELinux. + * m4/codeexec.m4 (FFCALL_CODEEXEC_PAX): On SELinux systems, define + HAVE_MPROTECT_AFTER_MALLOC_CAN_EXEC to -1. + * trampoline/trampoline.c: When HAVE_MPROTECT_AFTER_MALLOC_CAN_EXEC is + -1, assume the worst and don't set EXECUTABLE_VIA_MALLOC_THEN_MPROTECT. + * callback/trampoline_r/trampoline.c: Likewise. + +2017-06-03 Bruno Haible + + Improve support for SELinux. + * m4/codeexec.m4 (FFCALL_CODEEXEC_PAX): On SELinux systems, define + HAVE_MPROTECT_AFTER_MMAP_CAN_EXEC to -1. + * trampoline/trampoline.c: When HAVE_MPROTECT_AFTER_MMAP_CAN_EXEC is -1, + assume the worst and don't set EXECUTABLE_VIA_MMAP_THEN_MPROTECT. + * callback/trampoline_r/trampoline.c: Likewise. + +2017-06-03 Bruno Haible + + Indent the *.m4 files. + * m4/as-underscore.m4: Use reasonable indentation. + * m4/cc-gcc.m4: Likewise. + * m4/codeexec.m4: Likewise. + * m4/endianness.m4: Likewise. + * m4/general.m4: Likewise. + * m4/getpagesize.m4: Likewise. + * m4/ireg.m4: Likewise. + * m4/ln.m4: Likewise. + * m4/mach-vm.m4: Likewise. + * m4/mmap.m4: Likewise. + * m4/mprotect.m4: Likewise. + * m4/pccstruct.m4: Likewise. + * m4/shm.m4: Likewise. + * m4/smallstruct.m4: Likewise. + * m4/proto.m4: Likewise. + (CL_PROTO_TRY, CL_PROTO_CONST, CL_PROTO_MISSING, CONST_VARIANTS, + SIZE_VARIANTS): Remove macros. + +2017-02-26 Bruno Haible + + Document more clearly the maintainer prerequisites. + * Makefile.in (ACLOCAL, AUTOCONF, AUTOHEADER): Add comments. + * README-hacking: Likewise. + Reported by Don Cohen in + + and Sam Steingold . + +2017-02-26 Bruno Haible + + Document the support for GNU Hurd. + * PLATFORMS, */PLATFORMS: List i686-unknown-gnu0.9 (gcc). + +2017-02-19 Bruno Haible + + configuration: Avoid running an unneeded test. + * m4/codeexec.m4 (FFCALL_CODEEXEC_PAX): Require FFCALL_CODEEXEC. Do + nothing if its result is that malloc()ed memory is already executable. + +2017-02-19 Bruno Haible + + Remove useless double-inclusion guard on .c files. + * avcall/tests.c: Remove double-inclusion guard. + * avcall/avcall-*.c: Likewise. Fix comment. + +2017-02-19 Bruno Haible + + powerpc: Fix build failure on MacOS X (regression from 2017-01-29). + 1. + * cross-tools/cross.conf: For powerpc-darwin, go back to gcc 3.3.6. + * cross-tools/patches/gcc-3.3.6.patch: New file. + * avcall/Makefile.devel (avcall-powerpc-macos.s): Use gcc 3.3.6. + * vacall/Makefile.devel (vacall-powerpc-macos.s): Use gcc 3.3.6. + * callback/vacall_r/Makefile.devel (vacall-powerpc-macos.s): Use gcc + 3.3.6. + 2. + * avcall/Makefile.in (avcall-powerpc.s): For MacOS, remove the .machine + pseudo-op. + * vacall/Makefile.in (vacall-powerpc.s): Likewise. + * callback/vacall_r/Makefile.in (vacall-powerpc.s): Likewise. + 3. + * PLATFORMS, */PLATFORMS: List powerpc-apple-darwin9.8.0 (gcc). + * NEWS: Mention the status of MacOS X / powerpc. + +2017-02-12 Bruno Haible + + Make the cross-build.sh script work on an x86_64-linux host. + * cross-tools/cross-build.sh: Remove the binutils-*/gprof directory. + * cross-tools/patches/binutils-*.patch: Backport a buffer overrun bug + fix from binutils-2.17. + +2017-02-12 Bruno Haible + + Make the cross-build.sh script more usable. + * README-hacking: Add more text. + * cross-tools/cross-build.sh: Don't assume the script is run from the + current directory. Accept a relative HOST_CROSS_DIR. + Reported by Don Cohen . + +2017-02-11 Bruno Haible + + Update documentation. + * NEWS: List the progress since version 1.12. + +2017-02-11 Bruno Haible + + powerpc: Add support for OpenBSD. + * avcall/Makefile.in (avcall-powerpc.s): Treat OpenBSD like NetBSD. + * vacall/Makefile.in (vacall-powerpc.s): Likewise. + * callback/vacall_r/Makefile.in (vacall-powerpc.s): Likewise. + +2017-02-11 Bruno Haible + + mips64: Add support for OpenBSD. + On OpenBSD, cacheflush() is declared in , see + openbsd-src/blob/master/lib/libarch/mips64/cacheflush.3 . + * trampoline/trampoline.c [__OpenBSD__]: Include . + * callback/trampoline_r/trampoline.c: Likewise. + +2017-02-11 Bruno Haible + + Support the LDFLAGS configure variable. + * avcall/Makefile.in (LDFLAGS): New variable. + Use it in all linking commands. + * vacall/Makefile.in (LDFLAGS): New variable. + Use it in all linking commands. + * trampoline/Makefile.in (LDFLAGS): New variable. + Use it in all linking commands. + * callback/Makefile.in (LDFLAGS): New variable. + Use it in all linking commands. + * callback/vacall_r/Makefile.in (LDFLAGS): New variable. + Use it in all linking commands. + * callback/trampoline_r/Makefile.in (LDFLAGS): New variable. + Use it in all linking commands. + +2017-02-11 Bruno Haible + + Fix build failure on Mac OS X 10.5 / x86_64. Regression from today. + * common/asm-x86_64.sh: Recognize symbol in symbol(%rip) syntax. + * vacall/Makefile.devel (vacall-x86_64-macro.S): Remove extra + postprocessing, now done by common/asm-x86_64.sh. + +2017-02-11 Bruno Haible + + Fix build failure on Mac OS X 10.5 / i386. Regression from today. + * common/asm-i386.sh: Simplify the function referencing code, originally + for PIC on ELF platforms, so that it works also on non-ELF platforms. + +2017-02-11 Bruno Haible + + x86_64: Add support for the x32 ABI on Linux. + * avcall/avcall.h.in: Optionally define __x86_64_x32__. + (__avword, __av_longlong): Define differently for __x86_64_x32__. + * avcall/Makefile.devel (avcall-x86_64-x32-linux.s): New target. + * avcall/Makefile.in (avcall-x86_64-x32.lo, avcall-x86_64-x32.s): New + targets. + (clean): Remove also avcall-x86_64-x32.s. + (SOURCE_FILES): Add avcall-x86_64-x32-linux.s. + * vacall/vacall-x86_64.c: Don't declare a register variable in %rbp for + GCC >= 4.9. + For __x86_64_x32__, treat return of 'long long' and 'unsigned long long' + differently. + * vacall/vacall.h.in: Optionally define __x86_64_x32__. + (__vaword, va_arg_longlong, va_return_longlong): Define differently for + __x86_64_x32__. + * callback/vacall_r/vacall_r.h.in: Likewise. + * vacall/Makefile.devel (vacall-x86_64-x32-linux.s): New target. + * vacall/Makefile.in (vacall-x86_64-x32.o, vacall-x86_64-x32.s): New + targets. + (clean): Remove also vacall-x86_64-x32.s. + (SOURCE_FILES): Add vacall-x86_64-x32-linux.s. + * trampoline/Makefile.devel (proto-x86_64-x32.s, tramp-x86_64-x32.o): + New targets. + * trampoline/proto-x86_64-x32.s: New generated file. + * trampoline/tramp-x86_64-x32.s: New file. + * trampoline/tramp-x86_64-x32.o: New generated file. + * trampoline/trampoline.c: Add code for __x86_64_x32__. + * callback/vacall_r/Makefile.devel (vacall-x86_64-x32-linux.s): New + target. + * callback/vacall_r/Makefile.in (vacall-x86_64-x32.lo, + vacall-x86_64-x32.s): New targets. + (clean): Remove also vacall-x86_64-x32.s. + (SOURCE_FILES): Add vacall-x86_64-x32-linux.s. + * callback/trampoline_r/Makefile.devel (proto-x86_64-x32.s, + tramp-x86_64-x32.o): New targets. + * callback/trampoline_r/proto.c: Specify env register for + __x86_64_x32__. + * callback/trampoline_r/proto-x86_64-x32.s: New generated file. + * callback/trampoline_r/tramp-x86_64-x32.s: New file. + * callback/trampoline_r/tramp-x86_64-x32.o: New generated file. + * callback/trampoline_r/trampoline.c: Add code for __x86_64_x32__. + * PLATFORMS, */PLATFORMS: List x86_64-unknown-linux (gcc -mx32). + +2017-02-11 Bruno Haible + + Simplify platform defines. Reverts commit from 2010-07-20. + * trampoline/trampoline.h.in: Remove CPU symbol definitions. + * callback/trampoline_r/trampoline_r.h.in: Likewise. + +2017-02-11 Bruno Haible + + powerpc64: Add support for the ELFv2 ABI on Linux. + * avcall/avcall-powerpc64.c: Handle small struct return in registers + when __AV_REGISTER_STRUCT_RETURN is set. + * avcall/avcall.h.in: Optionally define __powerpc64_elfv2__. + (__AV_REGISTER_STRUCT_RETURN): Define also for __powerpc64__. + (__av_reg_struct_return, __av_start_struct3): Define differently for + __powerpc64_elfv2__. + (av_float) [__powerpc64__]: Define in a simplified way if + __AV_AIXCC_FLOAT_ARGS cannot be set. + (__av_struct): Define differently for little-endian __powerpc64__. + * avcall/Makefile.devel (avcall-powerpc64-elfv2-linux.s): New target. + * avcall/Makefile.in (avcall-powerpc64-elfv2.lo, + avcall-powerpc64-elfv2.s): New targets. + (clean): Remove also avcall-powerpc64-elfv2.s. + (SOURCE_FILES): Add avcall-powerpc64-elfv2-linux.s. + * vacall/vacall-powerpc64.c: Handle small struct return in registers + when __VA_REGISTER_STRUCT_RETURN is set. + * vacall/vacall.h.in: Optionally define __powerpc64_elfv2__. + (__VA_REGISTER_STRUCT_RETURN): Define also for __powerpc64__. + (__va_reg_struct_return, __va_start_struct1): Define differently for + __powerpc64_elfv2__. + (__va_arg_adjusted): Define differently for little-endian __powerpc64__. + (va_arg_float) [__powerpc64__]: Define in a simplified way if + __VA_AIXCC_FLOAT_ARGS cannot be set. + * callback/vacall_r/vacall_r.h.in: Likewise. + * vacall/Makefile.devel (vacall-powerpc64-elfv2-linux.s): New target. + * vacall/Makefile.in (vacall-powerpc64-elfv2.o, + vacall-powerpc64-elfv2.s): New targets. + (clean): Remove also vacall-powerpc64-elfv2.s. + (SOURCE_FILES): Add vacall-powerpc64-elfv2-linux.s. + * trampoline/Makefile.devel (proto-powerpc64-elfv2.s, + tramp-powerpc64-elfv2.o): New targets. + * trampoline/proto-powerpc64elfv2.s: New generated file. + * trampoline/tramp-powerpc64elfv2.s: New file. + * trampoline/tramp-powerpc64elfv2.o: New generated file. + * trampoline/trampoline.c: Add code for __powerpc64_elfv2__. + * callback/vacall_r/Makefile.devel (vacall-powerpc64-elfv2-linux.s): + New target. + * callback/vacall_r/Makefile.in (vacall-powerpc64-elfv2.lo, + vacall-powerpc64-elfv2.s): New targets. + (clean): Remove also vacall-powerpc64-elfv2.s. + (SOURCE_FILES): Add vacall-powerpc64-elfv2-linux.s. + * callback/trampoline_r/Makefile.devel (proto-powerpc64-elfv2.s, + tramp-powerpc64-elfv2.o): New targets. + * callback/trampoline_r/proto-powerpc64elfv2.s: New generated file. + * callback/trampoline_r/tramp-powerpc64elfv2.s: New file. + * callback/trampoline_r/tramp-powerpc64elfv2.o: New generated file. + * callback/trampoline_r/trampoline.c: Add code for __powerpc64_elfv2__. + * PLATFORMS, */PLATFORMS: List powerpc64le-unknown-linux (gcc). + +2017-02-11 Bruno Haible + + powerpc64: Add support for AIX in a 64-bit build, with xlc. + * avcall/avcall.h.in (__AV_AIXCC_FLOAT_ARGS, __AV_FLOAT_ARGS): New enum + values. + (__AV_START_FLAGS): Include __AV_FLOAT_ARGS. + (av_float) [__powerpc64__]: Pick word according to whether + __AV_AIXCC_FLOAT_ARGS is set. + * vacall/vacall.h.in (__VA_AIXCC_FLOAT_ARGS, __VA_FLOAT_ARGS): New enum + values. + (__VA_START_FLAGS): Include __VA_FLOAT_ARGS. + (va_arg_float) [__powerpc64__]: Pick word according to whether + __VA_AIXCC_FLOAT_ARGS is set. + * callback/vacall_r/vacall_r.h.in: Likewise. + * PLATFORMS, */PLATFORMS: List powerpc-ibm-aix7.1.3.0 (xlc -q64). + +2017-02-11 Bruno Haible + + powerpc64: Add support for AIX in a 64-bit build, with gcc. + * avcall/avcall.h.in (__AV_AIXCC_STRUCT_ARGS): Define also on + __powerpc64__. + (__AV_STRUCT_ARGS): Set to __AV_AIXCC_STRUCT_ARGS on __powerpc64__ with + AIX. + (__av_struct): Define for __powerpc64__ like for __powerpc__. + * vacall/vacall.h.in (__VA_AIXCC_STRUCT_ARGS): Define also on + __powerpc64__. + (__VA_STRUCT_ARGS): Set to __VA_AIXCC_STRUCT_ARGS on __powerpc64__ with + AIX. + (__va_arg_struct): Define for __powerpc64__ with AIX like for + __powerpc__ with AIX. + * callback/vacall_r/vacall_r.h.in: Likewise. + * PLATFORMS, */PLATFORMS: List powerpc-ibm-aix7.1.3.0 (gcc -maix64). + +2017-02-11 Bruno Haible + + powerpc64: Add support for AIX in a 64-bit build, part 1. + * avcall/Makefile.devel (avcall-powerpc64-aix.s, + avcall-powerpc64-linux.s): New targets. + (avcall-powerpc64.s): Remove target. + * avcall/Makefile.in (avcall-powerpc64.s): New target. + (avcall-powerpc64.lo): Update. + (clean): Remove also avcall-powerpc64.s. + (SOURCE_FILES): Add avcall-powerpc64-aix.s, avcall-powerpc64-linux.s. + Remove avcall-powerpc64.s. + * vacall/Makefile.devel (vacall-powerpc64-aix.s, + vacall-powerpc64-linux.s): New targets. + (vacall-powerpc64.s): Remove target. + * vacall/Makefile.in (vacall-powerpc64.s): New target. + (vacall-powerpc64.o): Update. + (clean): Remove also vacall-powerpc64.s. + (SOURCE_FILES): Add vacall-powerpc64-aix.s, vacall-powerpc64-linux.s. + Remove vacall-powerpc64.s. + * callback/vacall_r/Makefile.devel (vacall-powerpc64-aix.s, + vacall-powerpc64-linux.s): New targets. + (vacall-powerpc64.s): Remove target. + * callback/vacall_r/Makefile.in (vacall-powerpc64.s): New target. + (vacall-powerpc64.lo): Update. + (clean): Remove also vacall-powerpc64.s. + (SOURCE_FILES): Add vacall-powerpc64-aix.s, vacall-powerpc64-linux.s. + Remove vacall-powerpc64.s. + +2017-02-11 Bruno Haible + + powerpc64: Update Makefile.devel rules. + * trampoline/Makefile.devel (CROSS_TOOL): New variable. + (proto-powerpc64-aix.s): Update rule. + * callback/trampoline_r/Makefile.devel (proto-powerpc64-aix.s): Update + rule. + +2017-02-11 Bruno Haible + + hppa: Fix bug with structure return for sizes 5, 6, 7. + * avcall/avcall-hppa.c: For structure return for sizes > 4, get 4 bytes + from iret2. + * vacall/vacall-hppa.c: For structure return for sizes > 4, put 4 bytes + into iret2. + +2017-02-11 Bruno Haible + + x86_64: Fix bug with structure return for sizes < 16, != 1, 2, 4, 8. + * avcall/avcall-x86_64.c: Treat structure returns for all sizes <= 16 + like those with sizes 1, 2, 4, 8, 16. + +2017-02-11 Bruno Haible + + Add some dedicated small structure return tests. + * avcall/tests.c (Size1, Size2, Size3, Size4, Size7, Size8, Size12, + Size15, Size16): New types. + (S1_v, S2_v, S3_v, S4_v, S7_v, S8_v, S12_v, S15_v, S15_v): New tests. + * vacall/tests.c: Likewise. + * callback/tests.c: Likewise. + +2017-02-11 Bruno Haible + + Remove outdated no-op definition. + * vacall/vacall.h.in (__VA_ANSI_FLOAT_ARGS): Remove enum value. + +2017-02-11 Bruno Haible + + powerpc: Don't special-case NetBSD. + * vacall/vacall-powerpc.c: Remove special case of NetBSD. + * callback/vacall_r/Makefile.devel (vacall-powerpc-netbsd-macro.S): + Remove target. + * callback/vacall_r/vacall-powerpc-netbsd.s: Remove file. + * callback/vacall_r/vacall-powerpc-netbsd-macro.S: Remove file. + * callback/vacall_r/Makefile.in (vacall-powerpc.s): Use + vacall-powerpc-linux-macro.S instead of vacall-powerpc-netbsd-macro.S. + (SOURCE_FILES): Remove vacall-powerpc-netbsd.s, + vacall-powerpc-netbsd-macro.S. + * callback/trampoline_r/proto.c: Remove special case of powerpc/NetBSD. + * callback/trampoline_r/trampoline.c: Remove special case of + powerpc/NetBSD. + * callback/trampoline_r/test1.c: Likewise. + +2017-02-11 Bruno Haible + + m68k: Don't special-case NetBSD. + * callback/call-used-registers.txt: Add comment about NetBSD. + * vacall/vacall-m68k.c: Remove special case of NetBSD. + * callback/vacall_r/Makefile.devel (vacall-m68k-netbsd-macro.S): Remove + target. + * callback/vacall_r/Makefile.in (vacall-m68k.s): Always use + vacall-m68k.mit.S. + (SOURCE_FILES): Remove vacall-m68k-netbsd-macro.S. + * callback/trampoline_r/proto.c: Remove special case of m68k/NetBSD. + * callback/trampoline_r/proto-m68k-netbsd.s: Remove file. + * callback/trampoline_r/tramp-m68k-netbsd.s: Remove file. + * callback/trampoline_r/tramp-m68k-netbsd.o: Remove file. + * callback/trampoline_r/Makefile.devel (proto-m68k-netbsd.s, + tramp-m68k-netbsd.o): Remove targets. + * callback/trampoline_r/trampoline.c: Remove special case of + m68k/NetBSD. + * callback/trampoline_r/test1.c: Likewise. + +2017-02-11 Bruno Haible + + Revert BINFMT_ELF hack. + * callback/elf-hack.txt: Explain the new workaround. + * callback/vacall_r/Makefile.devel (vacall-i386-macro.S, + vacall-m68k.mit.S, vacall-m68k.motorola.S, vacall-m68k-netbsd-macro.S, + vacall-mipseb-macro.S, vacall-mipsel-macro.S, vacall-mipsn32eb-macro.S, + vacall-mipsn32el-macro.S, vacall-mips64eb-macro.S, + vacall-mips64el-macro.S, vacall-alpha-macro.S, + vacall-powerpc-linux-macro.S, vacall-powerpc-netbsd-macro.S, + vacall-powerpc-sysv4-macro.S, vacall-x86_64-macro.S, + vacall-s390-macro.S): Don't postprocess through elfhack-*.sed. + * callback/vacall_r/elfhack-alpha.S: Remove file. + * callback/vacall_r/elfhack-alpha.sed: Remove file. + * callback/vacall_r/elfhack-i386.S: Remove file. + * callback/vacall_r/elfhack-i386.sed: Remove file. + * callback/vacall_r/elfhack-m68k.S: Remove file. + * callback/vacall_r/elfhack-m68k.sed: Remove file. + * callback/vacall_r/elfhack-mips.S: Remove file. + * callback/vacall_r/elfhack-mips.sed: Remove file. + * callback/vacall_r/elfhack-mips64.S: Remove file. + * callback/vacall_r/elfhack-mips64.sed: Remove file. + * callback/vacall_r/elfhack-powerpc.S: Remove file. + * callback/vacall_r/elfhack-powerpc.sed: Remove file. + * callback/vacall_r/elfhack-s390.S: Remove file. + * callback/vacall_r/elfhack-s390.sed: Remove file. + * callback/vacall_r/elfhack-x86_64.S: Remove file. + * callback/vacall_r/elfhack-x86_64.sed: Remove file. + * callback/vacall_r/Makefile.in (ASPFLAGS): Don't set BINFMT_ELF. + (SOURCE_FILES): Remove elhack-*.S and elfhack-*.sed. + * callback/vacall_r/configure.ac: Don't invoke FFCALL_BINFMT_ELF. + * callback/trampoline_r/trampoline.c: Remove code for BINFMT_ELF. + * callback/trampoline_r/tramp-alpha.s: Remove trampelf. + * callback/trampoline_r/tramp-alpha.o: Regenerated. + * callback/trampoline_r/tramp-i386.s: Remove trampelf. + * callback/trampoline_r/tramp-i386.o: Regenerated. + * callback/trampoline_r/tramp-m68k-netbsd.s: Remove trampelf. + * callback/trampoline_r/tramp-m68k-netbsd.o: Regenerated. + * callback/trampoline_r/tramp-m68k.s: Remove trampelf. + * callback/trampoline_r/tramp-m68k.o: Regenerated. + * callback/trampoline_r/tramp-mips.s: Remove trampelf. + * callback/trampoline_r/tramp-mips.o: Regenerated. + * callback/trampoline_r/tramp-mips64.s: Remove trampelf. + * callback/trampoline_r/tramp-mips64.o: Regenerated. + * callback/trampoline_r/tramp-powerpc-sysv4.s: Remove trampelf. + * callback/trampoline_r/tramp-powerpc-sysv4.o: Regenerated. + * callback/trampoline_r/tramp-s390.s: Remove trampelf. + * callback/trampoline_r/tramp-s390.o: Regenerated. + * callback/trampoline_r/tramp-x86_64.s: Remove trampelf. + * callback/trampoline_r/tramp-x86_64.o: Regenerated. + * callback/trampoline_r/test1.c: Reenable on ELF platforms. + * callback/trampoline_r/configure.ac: Don't invoke FFCALL_BINFMT_ELF. + * callback/configure.ac: Don't invoke FFCALL_BINFMT_ELF_OPTION. + * configure.ac: Don't invoke FFCALL_BINFMT_ELF_OPTION. + * m4/binfmt-elf.m4: Remove file. + * Makefile.in (SOURCE_FILES): Remove it. + * README: Update regarding the ELF problem. + +2017-02-11 Bruno Haible + + Access __vacall_r through an indirection, except on SPARC. + * callback/vacall_r/vacall_r.h.in (__vacall_r_t): New type. + (get__vacall_r): New declaration. + (__vacall_r): Remove declaration. + * vacall/vacall-alpha.c [REENTRANT]: Make __vacall_r static. + (get__vacall_r): New function. + * vacall/vacall-arm.c: Likewise. + * vacall/vacall-armhf.c: Likewise. + * vacall/vacall-hppa.c: Likewise. + * vacall/vacall-i386.c: Likewise. + * vacall/vacall-ia64.c: Likewise. + * vacall/vacall-m68k.c: Likewise. + * vacall/vacall-mips.c: Likewise. + * vacall/vacall-mipsn32.c: Likewise. + * vacall/vacall-mips64.c: Likewise. + * vacall/vacall-powerpc.c: Likewise. + * vacall/vacall-powerpc64.c: Likewise. + * vacall/vacall-s390.c: Likewise. + * vacall/vacall-x86_64.c: Likewise. + * callback/vacall_r/vacall-powerpc-netbsd-macro.S: Update accordingly. + * callback/vacall_r/Makefile.devel (vacall-mipseb-linux.s, + vacall-mipsel-linux.s): Use option -mno-explicit-relocs. Needed for + IRIX. + * callback/vacall_r/Makefile.in (vacall-i386.s): Remove space after '@'. + Needed on Solaris/x86. + * callback/callback.h.in (alloc_callback, is_callback): Use + get__vacall_r(). + +2017-01-29 Bruno Haible + + s390: Regenerate .s and .S files with known compilers. + * avcall/avcall-s390.c: Fix include statement. + * avcall/Makefile.devel (avcall-s390.s): New target. + * vacall/Makefile.devel (vacall-s390.s): New target. + * callback/vacall_r/Makefile.devel (vacall-s390-linux.s): New target. + * avcall/Makefile.in: Move avcall-s390.lo target. + * vacall/Makefile.in: Move vacall-s390.o target. + * avcall/avcall-s390.s: Remove from version control. + * vacall/vacall-s390.s: Likewise. + * callback/vacall_r/vacall-s390-linux.s: Likewise. + * callback/vacall_r/vacall-s390-macro.S: Likewise. + +2017-01-29 Bruno Haible + + x86_64: Regenerate .s and .S files with known compilers. + * common/asm-x86_64.h (P2ALIGN): New macro. + (ALIGN): Remove macro. + * common/asm-x86_64.sh: Rewritten to consume ELF input. Produce L, + P2ALIGN macros. + * avcall/avcall-x86_64.c: Use __builtin_alloca instead of hacking on the + 'sp' register. + * avcall/Makefile.devel (avcall-x86_64-linux.s): Rewritten. + * vacall/Makefile.devel (vacall-x86_64-linux.s): Rewritten. + * callback/vacall_r/Makefile.devel (vacall-x86_64-linux.s): Rewritten. + * avcall/avcall-x86_64-linux.s: Remove from version control. + * avcall/avcall-x86_64-macro.S: Likewise. + * vacall/vacall-x86_64-linux.s: Likewise. + * vacall/vacall-x86_64-macro.S: Likewise. + * callback/vacall_r/vacall-x86_64-linux.s: Likewise. + * callback/vacall_r/vacall-x86_64-macro.S: Likewise. + +2017-01-29 Bruno Haible + + ia64: Regenerate .s and .S files with known compilers. + * avcall/Makefile.devel (avcall-ia64.s): Rewritten. + * vacall/Makefile.devel (vacall-ia64.s): Rewritten. + * callback/vacall_r/Makefile.devel (vacall-ia64.s): Rewritten. + * vacall/vacall-ia64.c: Put all local variables in a struct. + * avcall/avcall-ia64.s: Remove from version control. + * vacall/vacall-ia64.s: Likewise. + * callback/vacall_r/vacall-ia64.s: Likewise. + +2017-01-29 Bruno Haible + + powerpc, powerpc64: Regenerate .s and .S files with known compilers. + * avcall/avcall-powerpc64.c: Use __builtin_alloca. Use an 'if' cascade + instead of gotos. + * avcall/Makefile.devel (avcall-powerpc-linux.s): New target. + (avcall-powerpc-aix.s, avcall-powerpc-sysv4.s, avcall-powerpc-macos.s, + avcall-powerpc64.s): Rewritten. + * vacall/Makefile.devel (vacall-powerpc-linux.s): New target. + (vacall-powerpc-aix.s, vacall-powerpc-sysv4.s, vacall-powerpc-macos.s, + vacall-powerpc64.s): Rewritten. + * callback/vacall_r/Makefile.devel (vacall-powerpc-linux.s): New target. + (vacall-powerpc-aix.s, vacall-powerpc-sysv4-macro.S, + vacall-powerpc-macos.s, vacall-powerpc64.s): Rewritten. + * avcall/avcall-powerpc-aix.s: Remove from version control. + * avcall/avcall-powerpc-linux.s: Likewise. + * avcall/avcall-powerpc-sysv4.s: Likewise. + * avcall/avcall-powerpc-macos.s: Likewise. + * avcall/avcall-powerpc64.s: Likewise. + * vacall/vacall-powerpc-aix.s: Likewise. + * vacall/vacall-powerpc-linux.s: Likewise. + * vacall/vacall-powerpc-sysv4.s: Likewise. + * vacall/vacall-powerpc-macos.s: Likewise. + * vacall/vacall-powerpc64.s: Likewise. + * callback/vacall_r/vacall-powerpc-aix.s: Likewise. + * callback/vacall_r/vacall-powerpc-linux.s: Likewise. + * callback/vacall_r/vacall-powerpc-linux-macro.S: Likewise. + * callback/vacall_r/vacall-powerpc-sysv4-macro.S: Likewise. + * callback/vacall_r/vacall-powerpc-macos.s: Likewise. + * callback/vacall_r/vacall-powerpc64.s: Likewise. + +2017-02-11 Bruno Haible + + armhf: Add support for arm with -mfloat-abi=hard. + * avcall/avcall.h.in: Add code for __armhf__, especially __av_start1, + __av_start_struct4, av_long, av_ulong, av_ptr, __av_longlong, av_float, + av_double, __av_struct. + * avcall/avcall-armhf.c: New file. + * avcall/Makefile.devel (avcall-armhf-macro.S): New target. + * avcall/Makefile.in (avcall-armhf.lo, avcall-armhf.s): New targets. + (clean): Remove avcall-armhf.s. + (SOURCE_FILES): Add avcall-armhf.c, avcall-armhf-macro.S. + * vacall/vacall.h.in: Add code for __armhf__, especially va_arg_float, + va_arg_double. + * vacall/vacall-armhf.c: New file. + * vacall/Makefile.devel (vacall-armhf-macro.S): New target. + * vacall/Makefile.in (vacall-armhf.o, vacall-armhf.s): New targets. + (clean): Remove vacall-armhf.s. + (SOURCE_FILES): Add vacall-armhf.c, vacall-armhf-macro.S. + * callback/vacall_r/Makefile.maint (COPIED_FILES): Add vacall-armhf.c. + * Makefile.in (COPIED_FILES): Add callback/vacall_r/vacall-armhf.c. + * callback/vacall_r/vacall_r.h.in: Add code for __armhf__, especially + va_arg_float, va_arg_double. + * callback/vacall_r/Makefile.devel (vacall-armhf-macro.S): New target. + * callback/vacall_r/Makefile.in (vacall-armhf.lo, vacall-armhf.s): New + targets. + (clean): Remove vacall-armhf.s. + (SOURCE_FILES): Add vacall-armhf.c, vacall-armhf-macro.S. + * trampoline/trampoline.h.in: Optionally define __armhf__. + * trampoline/trampoline.c: Treat __armhf__ like __arm__. + * callback/trampoline_r/trampoline_r.h.in: Optionally define __armhf__. + * callback/trampoline_r/trampoline.c: Treat __armhf__ like __arm__. + * PLATFORMS, */PLATFORMS: List the armv7 machine with 'hard' floats. + +2017-02-11 Bruno Haible + + arm: Make callback work, for -mfloat-abi=soft. + * callback/trampoline_r/Makefile.devel (CROSS_TOOL): New variable. + (proto-arm.s): Use known cross-compiler and -fno-omit-frame-pointer. + (tramp-arm.o): Use known cross-assembler. + * callback/trampoline_r/proto-arm.s: Regenerated. + * callback/trampoline_r/tramp-arm.s: Try three different trampolines. + The third one, trampcallwithframe, works. + * callback/trampoline_r/tramp-arm.o: Regenerated. + * callback/call-used-registers.txt: Add comments about arm. + * callback/trampoline_r/trampoline.c: For arm, use a trampoline with + standard prologue with struct args and standard epilogue. + * callback/trampoline_r/test1.c: On arm platforms, don't check the + passing of env. + * vacall/vacall-arm.c [REENTRANT]: Expect to find env on the stack, not + in r12. + * callback/vacall_r/Makefile.devel (vacall-arm-macro.S): Don't + postprocess through elfhack-arm.sed. + * callback/vacall_r/elfhack-arm.S: Remove file. + * callback/vacall_r/elfhack-arm.sed: Remove file. + * callback/vacall_r/Makefile.in (SOURCE_FILES): Remove elfhack-arm.S, + elfhack-arm.sed. + * PLATFORMS: List the arm5 machine with 'soft' floats. + * callback/PLATFORMS: Likewise. + +2017-01-31 Bruno Haible + + arm: Make vacall work, for -mfloat-abi=soft. + * vacall/vacall.h.in [__arm__] (__va_alist): Enable the filler word. + * callback/vacall_r/vacall_r.h.in: Likewise. + * vacall/vacall-arm.c: Use a split struct to convince GCC to allocate + room on the stack for the first 4 general-purpose argument words. + * vacall/PLATFORMS: List the arm5 machine with 'soft' floats. + * avcall/PLATFORMS: Likewise. + +2017-01-29 Bruno Haible + + arm: Fulfil the constraint that the sp register must be 8-bytes-aligned. + * avcall/avcall-arm.c: Enforce 8-bytes-alignment of the stack pointer. + * vacall/vacall-arm.c: Likewise. + + arm: Remove support for old arm platforms without the ARM EABI. + * avcall/avcall.h.in: Revisit all __arm__ and __ARMEL__ conditionals. + * vacall/vacall.h.in: Likewise. + * callback/vacall_r/vacall_r.h.in: Likewise. + * avcall/avcall-arm.c: Renamed from avcall/avcall-armel.c. + * avcall/Makefile.devel (avcall-arm-macro.S): Make sure it's usable for + both endiannesses. + (avcall-armel.s): Remove target. + * avcall/Makefile.in (avcall-armel.lo): Remove target. + (SOURCE_FILES): Remove avcall-armel.[cs]. + * vacall/vacall-arm.c: Renamed from vacall/vacall-armel.c. + * vacall/Makefile.devel (vacall-arm-macro.S): Make sure it's usable for + both endiannesses. + (vacall-armel.s): Remove target. + * vacall/Makefile.in (vacall-armel.o): Remove target. + (SOURCE_FILES): Remove vacall-armel.[cs]. + * Makefile.in (COPIED_FILES): Remove callback/vacall_r/vacall-armel.c. + * callback/vacall_r/Makefile.devel (vacall-arm-macro.S): Make sure it's + usable for both endiannesses. + (vacall-armel-macro.S): Remove target. + * callback/vacall_r/Makefile.maint (COPIED_FILES): Remove + vacall-armel.c. + * callback/vacall_r/Makefile.in (vacall-armel.lo, vacall-armel.s): + Remove targets. + (clean): Don't remove vacall-armel.s. + (SOURCE_FILES): Remove vacall-armel.c, vacall-armel-macro.S. + + arm: Regenerate .s and .S files with known compilers. + * common/asm-arm.h (L, FUNBEGIN, FUNEND): New macros. + * common/asm-arm.sh: Rewritten to consume ELF input. Produce L, + FUNBEGIN, FUNEND macros. + * avcall/Makefile.devel (avcall-arm-macro.S, avcall-armel.s): Rewritten. + * vacall/Makefile.devel (vacall-arm-macro.S, vacall-armel.s): Rewritten. + * callback/vacall_r/Makefile.devel (vacall-arm-macro.S, + vacall-armel-macro.S): Rewritten. + * avcall/avcall-arm-macro.S: Remove from version control. + * avcall/avcall-armel.s: Likewise. + * vacall/vacall-arm-macro.S: Likewise. + * vacall/vacall-armel.s: Likewise. + * callback/vacall_r/vacall-arm-macro.S: Likewise. + * callback/vacall_r/vacall-armel-macro.S: Likewise. + +2017-01-29 Bruno Haible + + hppa: Regenerate .s and .S files with known compilers. + * common/asm-hppa.sh: New file. + * common/asm-hppa.h: New file. + * Makefile.in (SOURCE_FILES): Add them. + * avcall/Makefile.devel (avcall-hppa-linux.s, avcall-hppa-macro.S): New + targets. + (avcall-hppa.s): Remove target. + * avcall/Makefile.in (avcall-hppa.s): New target. + (avcall-hppa.lo): Update. + (clean): Remove also avcall-hppa.s. + (SOURCE_FILES): Add avcall-hppa-linux.s, avcall-hppa-macro.S. Remove + avcall-hppa.s. + * vacall/vacall-hppa.c: Use explicit assignments to move the arguments + to their stack locations. + * vacall/Makefile.devel (vacall-hppa-linux.s, vacall-hppa-macro.S): New + targets. + (vacall-hppa.s): Remove target. + * vacall/Makefile.in (vacall-hppa.s): New target. + (vacall-hppa.o): Update. + (clean): Remove also vacall-hppa.s. + (SOURCE_FILES): Add vacall-hppa-linux.s, vacall-hppa-macro.S. Remove + vacall-hppa.s. + * callback/vacall_r/Makefile.devel (vacall-hppa-linux.s, + vacall-hppa-macro.S): New targets. + (vacall-hppa.s): Remove target. + * callback/vacall_r/Makefile.in (vacall-hppa.s): New target. + (vacall-hppa.lo): Update. + (clean): Remove also vacall-hppa.s. + (SOURCE_FILES): Add vacall-hppa-linux.s, vacall-hppa-macro.S. Remove + vacall-hppa.s. + * avcall/avcall-hppa.s: Remove from version control. + * vacall/vacall-hppa.s: Likewise. + * callback/vacall_r/vacall-hppa.s: Likewise. + * PLATFORMS, */PLATFORMS: List hppa2.0w-hp-hpux11.31 (cc). + +2017-01-29 Bruno Haible + + alpha: Regenerate .s and .S files with known compilers. + * avcall/avcall-alpha.c: Use __builtin_alloca. + * avcall/Makefile.devel (precompiled): Depend on avcall-alpha.s. + (avcall-alpha.s): Rewritten. + * vacall/vacall-alpha.c: Put all local variables in a struct. + * vacall/Makefile.devel (precompiled): Depend on vacall-alpha.s. + (vacall-alpha.s): Rewritten. + * callback/vacall_r/Makefile.devel (precompiled): Depend on + vacall-alpha-macro.S. + (vacall-alpha-linux.s): New target. + (vacall-alpha-macro.S): Rewritten. + * callback/vacall_r/Makefile.in (SOURCE_FILES): Add + vacall-alpha-linux.s. + * avcall/avcall-alpha.s: Remove from version control. + * vacall/vacall-alpha.s: Likewise. + * callback/vacall_r/vacall-alpha-macro.S: Likewise. + +2017-01-29 Bruno Haible + + sparc64: Fix for Solaris. + * vacall/Makefile.devel (vacall-sparc64-linux.s): Produce code that does + not make assumptions about the address space. + * PLATFORMS, */PLATFORMS: List sparc64-sun-solaris2.10 (gcc -m64, + cc -xarch=generic64). + +2017-01-29 Bruno Haible + + sparc, sparc64: Regenerate .s and .S files with known compilers. + * common/asm-sparc.h (L, FUNBEGIN, FUNEND): New macros. + * common/asm-sparc.sh: Rewritten to consume ELF input. Produce L, + FUNBEGIN, FUNEND macros. + * common/asm-sparc64.sh: Remove file. + * Makefile.in (SOURCE_FILES): Remove common/asm-sparc64.sh. + * avcall/Makefile.devel (precompiled): Depend on avcall-sparc-macro.S + and avcall-sparc64-macro.S. + (avcall-sparc-linux.s, avcall-sparc64-linux.s): New target. + (avcall-sparc-macro.S, avcall-sparc64-macro.S): Rewritten. + * avcall/Makefile.in (SOURCE_FILES): Add avcall-sparc-linux.s, + avcall-sparc64-linux.s. + * vacall/Makefile.devel (precompiled): Depend on vacall-sparc-macro.S + and vacall-sparc64-macro.S. + (vacall-sparc-linux.s, vacall-sparc64-linux.s): New target. + (vacall-sparc-macro.S, vacall-sparc64-macro.S): Rewritten. + * vacall/Makefile.in (SOURCE_FILES): Add vacall-sparc-linux.s, + vacall-sparc64-linux.s. + * callback/vacall_r/Makefile.devel (precompiled): Depend on + vacall-sparc-macro.S and vacall-sparc64-macro.S. + (vacall-sparc-linux.s, vacall-sparc64-linux.s): New target. + (vacall-sparc-macro.S, vacall-sparc64-macro.S): Rewritten. + * callback/vacall_r/Makefile.in (SOURCE_FILES): Add + vacall-sparc-linux.s, vacall-sparc64-linux.s. + * avcall/avcall-sparc-macro.S: Remove from version control. + * avcall/avcall-sparc64-macro.S: Likewise. + * vacall/vacall-sparc-macro.S: Likewise. + * vacall/vacall-sparc64-macro.S: Likewise. + * callback/vacall_r/vacall-sparc-macro.S: Likewise. + * callback/vacall_r/vacall-sparc64-macro.S: Likewise. + +2017-01-29 Bruno Haible + + mips64: Make it work on Linux (mips64, mips64el) with "gcc -mabi=64". + * avcall/avcall-mips64.c: Add code for struct returns on _MIPSEL. + * avcall/Makefile.devel (avcall-mips64eb-linux.s, + avcall-mips64eb-macro.S, avcall-mips64el-linux.s, + avcall-mips64el-macro.S): New targets. + (avcall-mips64-linux.s, avcall-mips64-macro.S): Remove targets. + * avcall/Makefile.in (avcall-mips64.s): Take into account the + ENDIANNESS. + (SOURCE_FILES): Add avcall-mips64eb-linux.s, avcall-mips64el-linux.s, + avcall-mips64eb-macro.S, avcall-mips64el-macro.S. + Remove avcall-mips64-linux.s, avcall-mips64-macro.S. + * vacall/vacall-mips64.c: Add code for struct returns on _MIPSEL. + * vacall/Makefile.devel (vacall-mips64eb-linux.s, + vacall-mips64eb-macro.S, vacall-mips64el-linux.s, + vacall-mips64el-macro.S): New targets. + (vacall-mips64-linux.s, vacall-mips64-macro.S): Remove targets. + * vacall/Makefile.in (vacall-mips64.s): Take into account the + ENDIANNESS. + (SOURCE_FILES): Add vacall-mips64eb-linux.s, vacall-mips64el-linux.s, + vacall-mips64eb-macro.S, vacall-mips64el-macro.S. + Remove vacall-mips64-linux.s, vacall-mips64-macro.S. + * callback/vacall_r/Makefile.devel (vacall-mips64eb-linux.s, + vacall-mips64eb-macro.S, vacall-mips64el-linux.s, + vacall-mips64el-macro.S): New targets. + (vacall-mips64-linux.s, vacall-mips64-macro.S): Remove targets. + * callback/vacall_r/Makefile.in (vacall-mips64.s): Take into account the + ENDIANNESS. + (SOURCE_FILES): Add vacall-mips64eb-linux.s, vacall-mips64el-linux.s, + vacall-mips64eb-macro.S, vacall-mips64el-macro.S. + Remove vacall-mips64-linux.s, vacall-mips64-macro.S. + * PLATFORMS, */PLATFORMS: List mips64-unknown-linux (gcc -mabi=64). + +2017-01-29 Bruno Haible + + mipsn32: Make it work on Linux (mips64, mips64el) with "gcc -mabi=n32". + * avcall/avcall-mipsn32.c: Add code for struct returns on _MIPSEL. + * avcall/Makefile.devel (avcall-mipsn32eb-linux.s, + avcall-mipsn32eb-macro.S, avcall-mipsn32el-linux.s, + avcall-mipsn32el-macro.S): New targets. + (avcall-mipsn32-linux.s, avcall-mipsn32-macro.S): Remove targets. + * avcall/Makefile.in (avcall-mipsn32.s): Take into account the + ENDIANNESS. + (SOURCE_FILES): Add avcall-mipsn32eb-linux.s, + avcall-mipsn32el-linux.s, avcall-mipsn32eb-macro.S, + avcall-mipsn32el-macro.S. + Remove avcall-mipsn32-linux.s, avcall-mipsn32-macro.S. + * vacall/vacall-mipsn32.c: Add code for struct returns on _MIPSEL. + * vacall/Makefile.devel (vacall-mipsn32eb-linux.s, + vacall-mipsn32eb-macro.S, vacall-mipsn32el-linux.s, + vacall-mipsn32el-macro.S): New targets. + (vacall-mipsn32-linux.s, vacall-mipsn32-macro.S): Remove targets. + * vacall/Makefile.in (vacall-mipsn32.s): Take into account the + ENDIANNESS. + (SOURCE_FILES): Add vacall-mipsn32eb-linux.s, vacall-mipsn32el-linux.s, + vacall-mipsn32eb-macro.S, vacall-mipsn32el-macro.S. + Remove vacall-mipsn32-linux.s, vacall-mipsn32-macro.S. + * callback/vacall_r/Makefile.devel (vacall-mipsn32eb-linux.s, + vacall-mipsn32eb-macro.S, vacall-mipsn32el-linux.s, + vacall-mipsn32el-macro.S): New targets. + (vacall-mipsn32-linux.s, vacall-mipsn32-macro.S): Remove targets. + * callback/vacall_r/Makefile.in (vacall-mipsn32.s): Take into account + the ENDIANNESS. + (SOURCE_FILES): Add vacall-mipsn32eb-linux.s, vacall-mipsn32el-linux.s, + vacall-mipsn32eb-macro.S, vacall-mipsn32el-macro.S. + Remove vacall-mipsn32-linux.s, vacall-mipsn32-macro.S. + * PLATFORMS, */PLATFORMS: List mips64-unknown-linux (gcc -mabi=n32). + +2017-01-29 Bruno Haible + + mips: Make it work on Linux (mips, mipsel) with "gcc -mabi=32". + * m4/endianness.m4: New file. + * avcall/Makefile.devel (avcall-mipseb-linux.s, avcall-mipseb-macro.S, + avcall-mipsel-linux.s, avcall-mipsel-macro.S): New targets. + (avcall-mips-linux.s, avcall-mips-macro.S): Remove targets. + * avcall/configure.ac: Invoke FFCALL_ENDIANNESS. + * avcall/Makefile.in (avcall-mips.s): Take into account the ENDIANNESS. + (SOURCE_FILES): Add avcall-mipseb-linux.s, avcall-mipsel-linux.s, + avcall-mipseb-macro.S, avcall-mipsel-macro.S. + Remove avcall-mips-linux.s, avcall-mips-macro.S. + * vacall/Makefile.devel (vacall-mipseb-linux.s, vacall-mipseb-macro.S, + vacall-mipsel-linux.s, vacall-mipsel-macro.S): New targets. + (vacall-mips-linux.s, vacall-mips-macro.S): Remove targets. + * vacall/configure.ac: Invoke FFCALL_ENDIANNESS. + * vacall/Makefile.in (vacall-mips.s): Take into account the ENDIANNESS. + (SOURCE_FILES): Add vacall-mipseb-linux.s, vacall-mipsel-linux.s, + vacall-mipseb-macro.S, vacall-mipsel-macro.S. + Remove vacall-mips-linux.s, vacall-mips-macro.S. + * callback/vacall_r/Makefile.devel (vacall-mipseb-linux.s, + vacall-mipseb-macro.S, vacall-mipsel-linux.s, vacall-mipsel-macro.S): + New targets. + * callback/vacall_r/configure.ac: Invoke FFCALL_ENDIANNESS. + * callback/vacall_r/Makefile.in (vacall-mips.s): Take into account the + ENDIANNESS. + (SOURCE_FILES): Add vacall-mipseb-linux.s, vacall-mipsel-linux.s, + vacall-mipseb-macro.S, vacall-mipsel-macro.S. + Remove vacall-mips-linux.s, vacall-mips-macro.S. + * PLATFORMS, */PLATFORMS: List mips-unknown-linux (gcc -mabi=32). + +2017-01-29 Bruno Haible + + mips, mipsn32, mips64: Regenerate .s and .S files with known compilers. + This restores support for IRIX with cc -32 (regression from 2008-09-26). + * common/asm-mips.sh: Rewritten to consume ELF input. + * avcall/avcall-mips.c: Rely on the compiler to set $25 at each + function call. Add comment about broken GCC 3.3.x and 3.4.x. Avoid + 'switch' statements, to make the generated code position-independent. + Declare iret2 as single __avword. + * avcall/avcall-mipsn32.c: Use __builtin_alloca. Rely on the compiler + to set $25 at each function call. + * avcall/avcall-mips64.c: Likewise. + * avcall/Makefile.devel (precompiled): Depend on avcall-mips-macro.S, + avcall-mipsn32-macro.S, avcall-mips64-macro.S. + (avcall-mips-linux.s, avcall-mipsn32-linux.s, avcall-mips64-linux.s): + New targets. + (avcall-mips-macro.S, avcall-mipsn32-macro.S, avcall-mips64-macro.S): + Rewritten. + * avcall/Makefile.in (SOURCE_FILES): Add avcall-mips-linux.s, + avcall-mipsn32-linux.s, avcall-mips64-linux.s. + * vacall/vacall-mips.c: Rely on the compiler to set $25 at each + function call. + * vacall/vacall-mipsn32.c: Likewise. + * vacall/vacall-mips64.c: Likewise. Add offset to references of + arguments in the stack. + * vacall/Makefile.devel (precompiled): Depend on vacall-mips-macro.S, + vacall-mipsn32-macro.S, vacall-mips64-macro.S. + (vacall-mips-linux.s, vacall-mipsn32-linux.s, vacall-mips64-linux.s): + New targets. + (vacall-mips-macro.S): Rewritten. + (vacall-mipsn32-macro.S): Rewritten. Update the postprocessing hack. + (vacall-mips64-macro.S): Rewritten. Add a postprocessing hack. + * vacall/Makefile.in (SOURCE_FILES): Add vacall-mips-linux.s, + vacall-mipsn32-linux.s, vacall-mips64-linux.s. + * callback/vacall_r/Makefile.devel (precompiled): Depend on + vacall-mips-macro.S, vacall-mipsn32-macro.S, vacall-mips64-macro.S. + (vacall-mips-linux.s, vacall-mipsn32-linux.s, vacall-mips64-linux.s): + New targets. + (vacall-mips-macro.S): Rewritten. + (vacall-mipsn32-macro.S): Rewritten. Update the postprocessing hack. + (vacall-mips64-macro.S): Rewritten. Add a postprocessing hack. + * callback/vacall_r/Makefile.in (SOURCE_FILES): Add vacall-mips-linux.s, + vacall-mipsn32-linux.s, vacall-mips64-linux.s. + * avcall/avcall-mips-macro.S: Remove from version control. + * avcall/avcall-mipsn32-macro.S: Likewise. + * avcall/avcall-mips64-macro.S: Likewise. + * vacall/vacall-mips-macro.S: Likewise. + * vacall/vacall-mipsn32-macro.S: Likewise. + * vacall/vacall-mips64-macro.S: Likewise. + * callback/vacall_r/vacall-mips-macro.S: Likewise. + * callback/vacall_r/vacall-mipsn32-macro.S: Likewise. + * callback/vacall_r/vacall-mips64-macro.S: Likewise. + * PLATFORMS, */PLATFORMS: List mips-sgi-irix6.5 (cc -32). + +2017-01-29 Bruno Haible + + m68k: Regenerate .s and .S files with known compilers. + * common/asm-m68k.h (L, FUNBEGIN, FUNEND): New macros. + * common/asm-m68k.sh: Expect a syntax argument. Produce L, FUNBEGIN, + FUNEND macros. + * avcall/avcall-m68k.c: Use __builtin_alloca instead of hacking on the + 'sp' register. + * avcall/Makefile.devel (precompiled): Depend on avcall-m68k.mit.S and + avcall-m68k.motorola.S. + (avcall-m68k-linux.s, avcall-m68k-sun.s): New targets. + (avcall-m68k.mit.S, avcall-m68k.motorola.S): Rewritten. + * avcall/Makefile.in (avcall-m68k.s): Depend on avcall-m68k.motorola.S + instead of avcall-m68k.mot.s. + (SOURCE_FILES): Add avcall-m68k-linux.s, avcall-m68k-sun.s. + Replace avcall-m68k.mot.s with avcall-m68k.motorola.S. + * vacall/Makefile.devel (precompiled): Depend on vacall-m68k.mit.S and + vacall-m68k.motorola.S. + (vacall-m68k-linux.s, vacall-m68k-sun.s): New targets. + (vacall-m68k.mit.S, vacall-m68k.motorola.S): Rewritten. + * vacall/Makefile.in (vacall-m68k.s): Depend on vacall-m68k.motorola.S + instead of vacall-m68k.mot.s. + (SOURCE_FILES): Add vacall-m68k-linux.s, + vacall-m68k-sun.s, vacall-mips-linux.s, vacall-mipsn32-linux.s, + Replace vacall-m68k.mot.s with vacall-m68k.motorola.S. + * callback/vacall_r/Makefile.devel (precompiled): Depend on + vacall-m68k.mit.S, vacall-m68k.motorola.S, vacall-m68k-netbsd-macro.S. + (vacall-m68k-linux.s, vacall-m68k-sun.s): New targets. + (vacall-m68k.mit.S, vacall-m68k.motorola.S, vacall-m68k-netbsd-macro.S): + Rewritten. + * callback/vacall_r/Makefile.in (vacall-m68k.s): Depend on + vacall-m68k.motorola.S instead of vacall-m68k.mot.s. + (SOURCE_FILES): Add vacall-m68k-linux.s, vacall-m68k-sun.s. + Replace vacall-m68k.mot.s with vacall-m68k.motorola.S. + * avcall/avcall-m68k.mit.S: Remove from version control. + * avcall/avcall-m68k.mot.s: Likewise. + * callback/vacall_r/vacall-m68k-netbsd-macro.S: Likewise. + * callback/vacall_r/vacall-m68k.mit.S: Likewise. + * callback/vacall_r/vacall-m68k.mot.s: Likewise. + * vacall/vacall-m68k.mit.S: Likewise. + * vacall/vacall-m68k.mot.s: Likewise. + +2017-01-29 Bruno Haible + + i386: Regenerate .s and .S files with known compilers. + * common/asm-i386.hh (P2ALIGN): New macro. + (FUNEND): Take two arguments. + * common/asm-i386.sh: Rewritten to consume ELF input. Produce P2ALIGN + macro. Handle indirect call statements. + * avcall/avcall-i386.c: Use __builtin_alloca instead of hacking on the + 'sp' register. + * avcall/Makefile.devel (precompiled): Depend on avcall-i386-macro.S. + (avcall-i386-linux.s): New target. + (avcall-i386-macro.S): Rewritten. + * avcall/Makefile.in (SOURCE_FILES): Add avcall-i386-linux.s. + * vacall/vacall-i386.c: Insert the appropriate stack cleanup before + 'ret $4'. + * vacall/Makefile.devel (precompiled): Depend on vacall-i386-macro.S. + (vacall-i386-linux.s): New target. + (vacall-i386-macro.S): Rewritten. + * vacall/Makefile.in (SOURCE_FILES): Add vacall-i386-linux.s. + * callback/vacall_r/Makefile.devel (precompiled): Depend on + vacall-i386-macro.S. + (vacall-i386-linux.s): New target. + (vacall-i386-macro.S): Rewritten. + * callback/vacall_r/Makefile.in (SOURCE_FILES): Add vacall-i386-linux.s. + * avcall/avcall-i386-macro.S: Remove from version control. + * vacall/vacall-i386-macro.S: Likewise. + * callback/vacall_r/vacall-i386-macro.S: Likewise. + +2017-02-11 Bruno Haible + + Prepare for regenerating .s and .S files with known compilers. + This serves three purposes: + 1. Being able to regenerate everything if avcall.h.in or vacall.h.in + changes. + 2. Allow safe stack unwinding across avcall and vacall invocations. + 3. Allow distributing libavcall and libcallback as shared libraries. + * README-hacking: Document the cross compilers. + * cross-tools/cross.conf: New file. + * cross-tools/cross-build.sh: New file. + * cross-tools/cross.in: New file. + * cross-tools/patches/*.patch: New files. + * avcall/Makefile.devel (GCCFLAGS): Add -fno-omit-frame-pointer, -fPIC. + (CROSS_TOOL): New variable. + * vacall/Makefile.devel (GCCFLAGS): Add -fno-omit-frame-pointer. + (CROSS_TOOL): New variable. + * callback/vacall_r/Makefile.devel (GCCFLAGS): Add + -fno-omit-frame-pointer, -fPIC. + (CROSS_TOOL): New variable. + +2017-01-29 Bruno Haible + + s390: Fix long long args. + * avcall/avcall.h.in (__av_longlong): Align only on a 4-bytes boundary, + not on an 8-bytes boundary. Fix condition for switching from register + args to stack args. + * vacall/vacall.h.in (__va_arg_leftadjusted, __va_arg_rightadjusted): + Fix condition for switching from register args to stack args. + (__va_arg_longlong): Use __va_arg. + * callback/vacall_r/vacall_r.h.in (__va_arg_leftadjusted, + __va_arg_rightadjusted): Fix condition for switching from register args + to stack args. + (__va_arg_longlong): Use __va_arg. + * PLATFORMS, */PLATFORMS: List s390x-ibm-linux with "gcc -m31". + +2017-01-29 Bruno Haible + + s390: Fix trampoline. + * trampoline/trampoline.c [__s390__]: Fix is_tramp macro. + +2017-01-29 Bruno Haible + + ia64: Fix struct args. + * avcall/avcall.h.in (__av_struct): Tweak #if. + * avcall/avcall-ia64.c: Fix comment. + * vacall/vacall.h.in (__va_arg_struct): Change #if to match + callback/vacall_r/vacall_r.h.in. + * callback/call-used-registers.txt: Fix info about ia64. + * callback/vacall_r/vacall_r.h.in (__va_arg_struct): Tweak #if. + * callback/trampoline_r/trampoline.c [__ia64__]: Fix is_tramp macro. + +2017-01-29 Bruno Haible + + powerpc64: Make trampoline work on AIX in a 64-bit build. + * trampoline/tramp-powerpc64-aix.S: Add assembler pseudo-ops for AIX. + * callback/trampoline_r/tramp-powerpc64-aix.S: Likewise. + +2017-01-29 Bruno Haible + + arm: Comments. + * avcall/avcall-arm.c: Add comments. + * avcall/avcall.h.in: Fix comment. + +2017-01-29 Bruno Haible + + arm: Make trampoline work on real ARM harware. + The cache flushing code in cache-arm.c and cache-armel.c are for old + Linux versions. Nowadays the best way is through the GCC builtin + function __clear_cache (which makes the appropriate Linux system call). + * trampoline/trampoline.c (alloc_trampoline) [__arm__]: Invoke GCC + builtin function __clear_cache. Remove call to __TR_clear_cache. + * callback/trampoline_r/trampoline.c (alloc_trampoline_r) [__arm__]: + Likewise. + * trampoline/cache-arm.[cs]: Remove files. + * trampoline/cache-armel.[cs]: Remove files. + * callback/trampoline_r/Makefile.maint (COPIED_FILES): Remove + cache-arm*. + * Makefile.in (COPIED_FILES): Remove callback/trampoline_r/cache-arm*. + * trampoline/Makefile.devel (cache-armel.s): Remove target. + * trampoline/configure.ac (CPU_OBJECTS): Leave empty for arm and armel. + * trampoline/Makefile.in (cache-arm.o, cache-armel.o): Remove targets. + (SOURCE_FILES): Remove cache-arm.[cs], cache-armel.[cs]. + * callback/trampoline_r/Makefile.devel (cache-armel.s): Remove target. + * callback/trampoline_r/configure.ac (CPU_OBJECTS): Leave empty for arm + and armel. + * callback/trampoline_r/Makefile.in (cache-arm.lo, cache-armel.lo): + Remove targets. + (SOURCE_FILES): Remove cache-arm.[cs], cache-armel.[cs]. + * trampoline/PLATFORMS: Add two ARM platforms. + +2017-01-29 Bruno Haible + + hppa: Fix struct returns. + * avcall/avcall.h.in [__hppa__]: Don't set __AV_PCC_STRUCT_RETURN by + default. + * avcall/avcall-hppa.c: Fix comment. + * vacall/vacall.h.in [__hppa__]: Don't set __VA_PCC_STRUCT_RETURN by + default. + * callback/vacall_r/vacall_r.h.in [__hppa__]: Don't set + __VA_PCC_STRUCT_RETURN by default. + +2017-01-29 Bruno Haible + + sparc64: Fix the passing of 'float' arguments. + * vacall/vacall.h.in (va_arg_float): Expect the float in the upper half + of the 8-bytes word. + * callback/vacall_r/vacall_r.h.in (va_arg_float): Likewise. + * PLATFORMS, */PLATFORMS: List sparc64-unknown-linux (gcc). + +2017-01-29 Bruno Haible + + sparc64: Fix a compiler warning. + * vacall/vacall.h.in (__va_arg_struct): Add a cast to pointer. + * callback/vacall_r/vacall_r.h.in: Likewise. + +2017-01-29 Bruno Haible + + mips64: Fix trampoline_r. + * callback/trampoline_r/trampoline.c: Fix conditionals that involve + __mips64__. + * callback/trampoline_r/test1.c: Fix duplicate declaration of 'env' on + mips64. + +2017-01-29 Bruno Haible + + mipsn32, mips64: Fix for little-endian platforms. + * vacall/vacall.h.in (__va_arg_adjusted): Use same conditional on + _MIPSEB and _MIPSEL as in callback/vacall_r/vacall_r.h.in. + * callback/vacall_r/vacall_r.h.in: Reorder parts of a #if condition. + +2017-01-29 Bruno Haible + + mips: Fix for Linux with "gcc -mabi=32". + * trampoline/tramp-mips.old.o: Renamed from trampoline/tramp-mips.o. + * trampoline/tramp-mips.old.s: Renamed from trampoline/tramp-mips.s. + * trampoline/tramp-mips.s: New file, based on + trampoline/tramp-mipsn32.s. + * trampoline/tramp-mips.o: New generated file. + * trampoline/trampoline.c: For __mips__, use the same trampoline as for + __mipsn32__. + +2017-01-29 Bruno Haible + + mips: Fix for Linux with "gcc -mabi=32". + * vacall/vacall.h.in (__va_arg_adjusted): Use same conditional on + _MIPSEB as in callback/vacall_r/vacall_r.h.in. + +2017-01-29 Bruno Haible + + mipsn32, mips64: Fix struct args and struct returns with newer GCC. + * avcall/avcall.h.in: For mipsn32 and mips64 in gcc >= 3.4: + 1. Don't set __AV_GCC_STRUCT_RETURN. + 2. Use __AV_SGICC_STRUCT_ARGS. + * vacall/vacall.h.in: For mipsn32 and mips64 in gcc >= 3.4: + 1. Don't set __VA_GCC_STRUCT_RETURN. + 2. Use __VA_SGICC_STRUCT_ARGS. + * callback/vacall_r/vacall_r.h.in: Likewise. + * PLATFORMS, */PLATFORMS: List mips-sgi-irix6.5 (gcc -mabi=n32). + +2017-01-29 Bruno Haible + + x86_64: Fix bug with structure arguments larger than 16 bytes. + * avcall/avcall.h.in (__av_struct): Pass structures > 16 bytes on the + stack. + * vacall/vacall.h.in (__va_arg_adjusted): Expect types > 16 bytes passed + on the stack. + * callback/vacall_r/vacall_r.h.in (__va_arg_adjusted): Likewise. + +2017-01-29 Bruno Haible + + i386, x86_64, sparc, sparc64: Fix for the Sun Studio 11 compiler. + When preprocessing a .S file, "cc -E" activates some other preprocessor + than the usual C preprocessor. + * avcall/Makefile.in (avcall-i386.s, avcall-sparc.s, avcall-sparc64.s, + avcall-x86_64.s): Feed the input to the preprocessor through standard + input. Postprocess to remove space after '.' and '@'. + * vacall/Makefile.in (vacall-i386.s, vacall-sparc.s, vacall-sparc64.s, + vacall-x86_64.s): Likewise. + * trampoline/Makefile.in (cache-sparc.s, cache-sparc64.s): Likewise. + * callback/vacall_r/Makefile.in (vacall-i386.s, vacall-sparc.s, + vacall-sparc64.s, vacall-x86_64.s): Likewise. + * callback/trampoline_r/Makefile.in (cache-sparc.s, cache-sparc64.s): + Likewise. + +2017-01-29 Bruno Haible + + List platforms on which libffcall is known to work. + * PLATFORMS, */PLATFORMS: List i386-pc-solaris2.10 (gcc), + mips-sgi-irix6.5 (cc -n32), sparc-unknown-linux (gcc), + alphaev67-unknown-linux (gcc), powerpc-ibm-aix7.1.3.0 (xlc, gcc). + +2017-01-29 Bruno Haible + + Don't violate ISO C rules. + * avcall/avcall.h.in (__av_struct): Don't store an unaligned pointer + in (LIST).aptr. + +2017-01-29 Bruno Haible + + Don't make side-effects before overflow checking. + * avcall/avcall.h.in: In most macro definitions, modify (LIST).aptr + after checking that it will remain within range, not before. But + continue to modify (LIST).aptr before storing the argument, as this + makes it easier w.r.t. to the alignment. This produces some more + duplicate expressions that the compiler will eliminate. But the code + is clearer this way. + +2017-01-29 Bruno Haible + + Add more floating-point, mixed-number, general-purpose args tests. + * avcall/tests.c (f_f24, d_iiidi, d_fdi, ll_iiilli, D_Dfd, + l_l0K, ..., l_l6K, ll_l2ll, ..., ll_l7ll, d_l2d, ... d_l7d): New tests. + * vacall/tests.c: Likewise. + * callback/tests.c: Likewise. + +2017-01-29 Bruno Haible + + Enable the 'long long' tests in callback. + * callback/configure.ac: Invoke AC_TYPE_LONG_LONG_INT. + * callback/tests.c: Test HAVE_LONG_LONG_INT, not HAVE_LONG_LONG. + * avcall/avcall.h.in: Fix comment. + * vacall/vacall.h.in: Likewise. + +2017-01-29 Bruno Haible + + devel: Make it easy to keep the autogenerated files up-to-date. + * avcall/Makefile.devel: Make all *.[sS] files depend on this file. + (precompiled): Comment out all dependencies. + * vacall/Makefile.devel: Likewise. + * callback/vacall_r/Makefile.devel: Likewise. + * callback/vacall_r/Makefile.maint (copied-files): New target. + * callback/trampoline_r/Makefile.maint (copied-files): New target. + * autogen.sh: To copy the files, just invoke these targets. + * Makefile.devel (precompiled): New target. + +2017-01-29 Bruno Haible + + configuration: Support the AR configure variable. + Needed for a 64-bit build on AIX. + * vacall/configure.ac: Invoke gl_PROG_AR_RANLIB instead of + AC_PROG_RANLIB. + * trampoline/configure.ac: Likewise. + * vacall/Makefile.in (AR): Use value determined by gl_PROG_AR_RANLIB. + * trampoline/Makefile.in (AR): Likewise. + * avcall/Makefile.in (AR): Use value determined by libtool. + * callback/Makefile.in (AR): Likewise. + * callback/vacall_r/Makefile.in (AR): Likewise. + * callback/trampoline_r/Makefile.in (AR): Likewise. + * avcall/configure.ac: Reorder (a no-op). + * callback/configure.ac: Likewise. + * callback/vacall_r/configure.ac: Likewise. + * callback/trampoline_r/configure.ac: Likewise. + +2017-01-29 Bruno Haible + + configuration: Simplification. + * m4/general.m4 (CL_CONFIG_SUBDIRS): Remove macro. + * configure.ac: Use AC_CONFIG_SUBDIRS instead of CL_CONFIG_SUBDIRS. + * callback/configure.ac: Likewise. + +2017-01-29 Bruno Haible + + Revert the addition of a powerpc64le port by Masanori Mitsugi + (commit from 2015-08-23). + +2017-01-29 Bruno Haible + + Add support for some Linux+PaX or SELinux kernels and for HardenedBSD. + Reported + - by Gerard Milmeister in https://sourceforge.net/p/clisp/bugs/356/, + - by Pradeep Kumar in https://sourceforge.net/p/clisp/bugs/415/, + - by Don Cohen in + https://lists.gnu.org/archive/html/libffcall/2016-12/msg00002.html, + - by Nelson Beebe. + * m4/codeexec.m4 (FFCALL_CODEEXEC_PAX): New macro. + * m4/general.m4 (FFCALL_COMMON_TRAMPOLINE): Require it. + * trampoline/trampoline.c (EXECUTABLE_VIA_MALLOC_THEN_MPROTECT, + EXECUTABLE_VIA_MMAP_THEN_MPROTECT, EXECUTABLE_VIA_MMAP_FILE_SHARED): + New macros. + (EXECUTABLE_VIA_MPROTECT, EXECUTABLE_VIA_MMAP_ANONYMOUS, + EXECUTABLE_VIA_MMAP_DEVZERO): Remove macros. + (MAP_FILE, MAP_VARIABLE): Define fallbacks. + (pagesize): Define outside of functions. + (alloc_trampoline): If EXECUTABLE_VIA_MMAP_FILE_SHARED is defined, + create separate mappings of a file, for writing and for executing. + If EXECUTABLE_VIA_MMAP_THEN_MPROTECT is defined, use mmap of an + anonymous page, then mprotect. + (free_trampoline): Convert back from executable address to writable + address. + * callback/trampoline_r/trampoline.c + (EXECUTABLE_VIA_MALLOC_THEN_MPROTECT, EXECUTABLE_VIA_MMAP_THEN_MPROTECT, + EXECUTABLE_VIA_MMAP_FILE_SHARED): New macros. + (EXECUTABLE_VIA_MPROTECT, EXECUTABLE_VIA_MMAP_ANONYMOUS, + EXECUTABLE_VIA_MMAP_DEVZERO): Remove macros. + (MAP_FILE, MAP_VARIABLE): Define fallbacks. + (pagesize): Define outside of functions. + (alloc_trampoline_r): If EXECUTABLE_VIA_MMAP_FILE_SHARED is defined, + create separate mappings of a file, for writing and for executing. + If EXECUTABLE_VIA_MMAP_THEN_MPROTECT is defined, use mmap of an + anonymous page, then mprotect. + (free_trampoline_r, is_trampoline_r): Convert back from executable + address to writable address. + +2017-01-29 Bruno Haible + + Fix "Generic workaround against the ELF symbol resolving routine". + * callback/vacall_r/elfhack-alpha.S: Put env in register $1, not $2. + * callback/vacall_r/elfhack-alpha.sed: Make it find the correct line. + * callback/trampoline_r/trampoline.c [__ia64__]: Fix code for + BINFMT_ELF. + [__mips64__]: Fix a typo in the trampoline for BINFMT_ELF. + [__s390__]: Fix typo in is_tramp macro for BINFMT_ELF. + +2017-01-10 Bruno Haible + + Update documentation. + * README: Refer to the git repository, not to the last release. + * DEPENDENCIES: New file. + * Makefile.in (SOURCE_FILES): Add it. + * README-hacking: New file. + +2017-01-09 Bruno Haible + + Remove support for m68k/HP-UX, m68k/NeXT, apollo, mips/Ultrix. + * trampoline/trampoline.c: Remove hpux, NeXT, apollo, ultrix + conditionals. + * trampoline/cache.c: Likewise. + * callback/trampoline_r/trampoline.c: Likewise. + +2017-01-09 Bruno Haible + + Remove support for m68k/AmigaOS. + * avcall/Makefile.devel (avcall-m68k-amiga.s): Remove target. + * avcall/avcall-m68k-amiga.c: Remove file. + * avcall/avcall-m68k-amiga.s: Remove file. + * avcall/Makefile.in (SOURCE_FILES): Remove them. + * avcall/avcall.h.in: Remove AMIGA conditionals. + * avcall/tests.c: Likewise. + * trampoline/trampoline.c: Likewise. + * callback/trampoline_r/trampoline.c: Likewise. + +2017-01-09 Bruno Haible + + Remove support for the AIX 3 operating system. + * avcall/Makefile.devel (avcall-powerpc-aix.s): Renamed from + avcall-powerpc-aix.new.s. + (avcall-powerpc-aix.old.s): Remove target. + * avcall/avcall-powerpc-aix.s: Renamed from + avcall/avcall-powerpc-aix.new.s. + * avcall/avcall-powerpc-aix.old.s: Remove file. + * avcall/Makefile.in (avcall-powerpc.s): No longer use + avcall-powerpc-aix.old.s. + (SOURCE_FILES): Add avcall-powerpc-aix.s. Remove + avcall-powerpc-aix.new.s, avcall-powerpc-aix.old.s. + * vacall/Makefile.devel (vacall-powerpc-aix.s): Renamed from + vacall-powerpc-aix.new.s. + (vacall-powerpc-aix.old.s): Remove target. + * vacall/vacall-powerpc-aix.s: Renamed from + vacall/vacall-powerpc-aix.new.s. + * vacall/vacall-powerpc-aix.old.s: Remove file. + * vacall/Makefile.in (vacall-powerpc.s): No longer use + vacall-powerpc-aix.old.s. + (SOURCE_FILES): Add vacall-powerpc-aix.s. Remove + vacall-powerpc-aix.new.s, vacall-powerpc-aix.old.s. + * callback/vacall_r/Makefile.devel (vacall-powerpc-aix.s): Renamed from + vacall-powerpc-aix.new.s. + (vacall-powerpc-aix.old.s): Remove target. + * callback/vacall_r/vacall-powerpc-aix.s: Renamed from + callback/vacall_r/vacall-powerpc-aix.new.s. + * callback/vacall_r/vacall-powerpc-aix.old.s: Remove file. + * callback/vacall_r/Makefile.in (vacall-powerpc.s): No longer use + vacall-powerpc-aix.old.s. + (SOURCE_FILES): Add vacall-powerpc-aix.s. Remove + vacall-powerpc-aix.new.s, vacall-powerpc-aix.old.s. + * trampoline/Makefile.devel (proto-powerpc-aix.s): Renamed from + proto-powerpc-aix.new.s. + (proto-powerpc-aix.old.s): Remove target. + * trampoline/proto-powerpc-aix.s: Renamed from + trampoline/proto-powerpc-aix.new.s. + * trampoline/proto-powerpc-aix.old.s: Remove file. + * trampoline/tramp-powerpc-aix.S: Renamed from + trampoline/tramp-powerpc.new.S. + * trampoline/tramp-powerpc.old.S: Remove file. + * trampoline/tramp-powerpc64-aix.S: Renamed from + trampoline/tramp-powerpc64.new.S. + * trampoline/Makefile.in (tramp-powerpc.s): No longer use + tramp-powerpc.old.S. + (tramp-powerpc64.s): Update. + (SOURCE_FILES): Add tramp-powerpc-aix.S, tramp-powerpc64-aix.S. Remove + tramp-powerpc.old.S, tramp-powerpc.new.S tramp-powerpc64.new.S. + * callback/trampoline_r/Makefile.devel (proto-powerpc-aix.s): Renamed + from proto-powerpc-aix.new.s. + (proto-powerpc-aix.old.s): Remove target. + * callback/trampoline_r/proto-powerpc-aix.s: Renamed from + callback/trampoline_r/proto-powerpc-aix.new.s. + * callback/trampoline_r/proto-powerpc-aix.old.s: Remove file. + * callback/trampoline_r/tramp-powerpc-aix.S: Renamed from + callback/trampoline_r/tramp-powerpc.new.S. + * callback/trampoline_r/tramp-powerpc.old.S: Remove file. + * callback/trampoline_r/tramp-powerpc64-aix.S: Renamed from + callback/trampoline_r/tramp-powerpc64.new.S. + * callback/trampoline_r/Makefile.in (tramp-powerpc.s): No longer use + tramp-powerpc.old.S. + (tramp-powerpc64.s): Update. + (SOURCE_FILES): Add tramp-powerpc-aix.S, tramp-powerpc64-aix.S. Remove + tramp-powerpc.old.S, tramp-powerpc.new.S tramp-powerpc64.new.S. + * PLATFORMS, **/PLATFORMS: Update. + +2017-01-08 Bruno Haible + + Remove support for the m88k CPU. + The only place where this CPU is still used is in the OpenBSD 5.8 + luna88k port. The luna88k is museum hardware. They use the ELF binary + format, through an inofficial port of the 10-years old binutils-2.17. + * avcall/Makefile.devel (avcall-m88k.s, tests-m88k.s): Remove targets. + * avcall/avcall-m88k.[cs]: Remove files. + * avcall/Makefile.in (avcall-m88k.lo): Remove target. + (SOURCE_FILES): Remove avcall-m88k.[cs]. + * avcall/avcall.h.in: Remove defined(__m88k__) conditionals. + * vacall/Makefile.devel (vacall-m88k.s, tests-m88k.s): Remove targets. + * vacall/vacall-m88k.[cs]: Remove files. + * vacall/Makefile.in (vacall-m88k.o): Remove target. + (SOURCE_FILES): Remove vacall-m88k.[cs]. + * vacall/vacall.h.in: Remove defined(__m88k__) conditionals. + * trampoline/Makefile.devel (proto-m88k.s, tramp-m88k.s): Remove targets. + * trampoline/proto-m88k.s: Remove file. + * trampoline/tramp-m88k.s: Remove file. + * trampoline/protexec.c: Remove __DOLPHIN__ conditionals. + * trampoline/trampoline.c: Remove defined(__m88k__), HAVE_SYS_M88KBCS_H conditionals. + * trampoline/trampoline.h.in: Don't test for m88k host. + * trampoline/configure.ac: Don't test for m88k host. + * callback/vacall_r/Makefile.devel (vacall-m88k.s): Remove target. + * callback/vacall_r/vacall-m88k.s: Remove file. + * callback/vacall_r/Makefile.in (vacall-m88k.lo): Remove target. + (SOURCE_FILES): Remove vacall-m88k.[cs]. + * callback/vacall_r/vacall_r.h.in: Remove defined(__m88k__) conditionals. + * callback/trampoline_r/Makefile.devel (proto-m88k.s, tramp-m88k.s): Remove targets. + * callback/trampoline_r/proto-m88k.s: Remove file. + * callback/trampoline_r/tramp-m88k.s: Remove file. + * callback/trampoline_r/proto.c: Remove defined(__m88k__) conditional. + * callback/trampoline_r/trampoline.c: Remove defined(__m88k__), HAVE_SYS_M88KBCS_H conditionals. + * callback/trampoline_r/trampoline_r.h.in: Don't test for m88k host. + * callback/trampoline_r/test1.c: Remove defined(__m88k__) conditionals. + * callback/trampoline_r/configure.ac: Don't test for m88k host. + * callback/call-used-registers.txt: Update. + * callback/elf-hack.txt: Update. + * common/reg-struct-return.txt: Update. + * PLATFORMS, **/PLATFORMS: Update. + * README: Update. + * autogen.sh: Don't copy vacall-m88k.c. + * Makefile.in (COPIED_FILES): Remove callback/vacall_r/vacall-m88k.c. + +2017-01-08 Bruno Haible + + Fix last commit. + * common/asm-x86_64.sh: Escape '&' characters in replacement string. + +2017-01-03 Bruno Haible + + Add support for the Mac OS X 10.5 / x86_64 platform. + * common/asm-x86_64.sh: Disable the frame info for exception handlers + on Mac OS X. + * avcall/avcall-x86_64-macro.S: Regenerated. + * vacall/vacall-x86_64-macro.S: Likewise. + * callback/vacall_r/vacall-x86_64-macro.S: Likewise. + * m4/mmap.m4 (FFCALL_MMAP): Renamed from CL_MMAP. Remove AC_BEFORE + invocations. Test mmap without MAP_FIXED only. Don't define + HAVE_MMAP_DEVZERO_SUN4_29. + * m4/mprotect.m4 (FFCALL_MPROTECT): Renamed from CL_MPROTECT. Update + dependency. + * m4/getpagesize.m4 (CL_GETPAGESIZE): Remove AC_BEFORE invocations. + * m4/general.m4 (FFCALL_COMMON_TRAMPOLINE): Update dependencies. + +2017-01-02 Bruno Haible + + Ensure the alignment of trampolines when we use the free-list approach. + * trampoline/trampoline.c (alloc_trampoline): Consider TRAMP_ALIGN + when allocating a page of trampolines. + * callback/trampoline_r/trampoline.c (alloc_trampoline_r): Likewise. + +2017-01-02 Bruno Haible + + Fix a build failure on Solaris/SPARC with newer gcc. + * trampoline/trampoline.c: Remove 'extern inline' declarations. + * callback/trampoline_r/trampoline.c: Likewise. For SPARC, declare + __TR_clear_cache_2, not __TR_clear_cache_4. + * PLATFORMS: Update. + * avcall/PLATFORMS: Likewise. + * vacall/PLATFORMS: Likewise. + * trampoline/PLATFORMS: Likewise. + * callback/PLATFORMS: Likewise. + +2017-01-02 Bruno Haible + + Add support for the Solaris/x86 platform with cc. + * common/asm-i386.sh: Remove the whitespace in the second argument of + INSN2MOVX. + * vacall/vacall-i386-macro.S: Regenerated. + * callback/vacall_r/vacall-i386-macro.S: Likewise. + * avcall/Makefile.in (avcall-i386.s): Eliminate ##. + * vacall/Makefile.in (vacall-i386.s): Likewise. + * callback/vacall_r/Makefile.in (vacall-i386.s): Likewise. + * PLATFORMS: Update. + * avcall/PLATFORMS: Likewise. + * vacall/PLATFORMS: Likewise. + * trampoline/PLATFORMS: Likewise. + * callback/PLATFORMS: Likewise. + +2017-01-02 Bruno Haible + + Add support for the Solaris/x86_64 platform. + * common/asm-x86_64.sh: Introduce ALIGN macro. Disable the frame info + for exception handlers on Solaris. + * common/asm-x86_64.h (ALIGN): New macro. + (FUNEND, EH_FRAME_SECTION): Define differently for Solaris. + * vacall/Makefile.devel (vacall-x86_64-macro.S): Don't use a #define + that assumes an ANSI C preprocessor. + * avcall/avcall-x86_64-macro.S: Regenerated. + * vacall/vacall-x86_64-macro.S: Likewise. + * callback/vacall_r/vacall-x86_64-macro.S: Likewise. + * avcall/Makefile.in (avcall-x86_64.s): Eliminate ##. + * vacall/Makefile.in (vacall-x86_64.s): Likewise. + * callback/vacall_r/Makefile.in (vacall-x86_64.s): Likewise. + * PLATFORMS: Update. + * avcall/PLATFORMS: Likewise. + * vacall/PLATFORMS: Likewise. + * trampoline/PLATFORMS: Likewise. + * callback/PLATFORMS: Likewise. + +2017-01-01 Bruno Haible + + Assume ANSI C in the documentation. + * vacall/vacall.{3,html}: Use ANSI C declaration syntax. Stop + mentioning . Reference stdarg(3). + * trampoline/trampoline.{3,html}: Reference stdarg(3). + * callback/callback.{3,html}: Use ANSI C declaration syntax. Stop + mentioning . + * callback/trampoline_r/trampoline_r.{3,html}: Reference stdarg(3). + +2017-01-01 Bruno Haible + + Support the CPPFLAGS configure variable. + * avcall/Makefile.in (CPPFLAGS): New variable. + Use it in all .c file compilations. + * vacall/Makefile.in (CPPFLAGS): New variable. + Use it in all .c file compilations. + * trampoline/Makefile.in (CPPFLAGS): New variable. + Use it in all .c file compilations. + * callback/Makefile.in (CPPFLAGS): New variable. + Use it in all .c file compilations. + * callback/vacall_r/Makefile.in (CPPFLAGS): New variable. + Use it in all .c file compilations. + * callback/trampoline_r/Makefile.in (CPPFLAGS): New variable. + Use it in all .c file compilations. + +2017-01-01 Bruno Haible + + Add option --disable-elf-hack to disable the ELF workaround. + * m4/binfmt-elf.m4 (FFCALL_BINFMT_ELF_OPTION): New macro. + (FFCALL_BINFMT_ELF): Require it. Set BINFMT_ELF to false and define + BINFMT_ELF to 0 if --disable-elf-hack was specified. + * configure.ac: Invoke FFCALL_BINFMT_ELF_OPTION. + * callback/configure.ac: Likewise. + * callback/elf-hack.txt: Explain how to use --disable-elf-hack for + testing. + +2017-01-01 Bruno Haible + + Generic workaround against the ELF symbol resolving routine. + Reported for x86_64 by Andrey Kutejko + at https://savannah.gnu.org/bugs/?32466 . + * m4/binfmt-elf.m4: New file. + * Makefile.in (SOURCE_FILES): Add it. + * callback/elf-hack.txt: New file. + * callback/test1.c: New file. + * callback/Makefile.in (SOURCE_FILES): Add both. + (test1.o, test1): New targets. + (check): Also run test1. + (MOSTLYCLEANFILES): Add test1.o, test1. + * callback/trampoline_r/configure.ac: Invoke FFCALL_BINFMT_ELF. + * callback/trampoline_r/Makefile.devel: Update the paths to the cross + assemblers. + * callback/trampoline_r/tramp-*.s: Add a 'trampelf' function. + * callback/trampoline_r/tramp-*.S: Likewise. + * callback/trampoline_r/tramp-*.o: Regenerated. + * callback/trampoline_r/trampoline.c: Implement alternate trampolines on + platforms with BINFMT_ELF. + * callback/trampoline_r/test1.c: Skip the test if BINFMT_ELF. + * callback/vacall_r/configure.ac: Invoke FFCALL_BINFMT_ELF. + * callback/vacall_r/elfhack-alpha.S: New file. + * callback/vacall_r/elfhack-alpha.sed: New file. + * callback/vacall_r/elfhack-arm.S: New file. + * callback/vacall_r/elfhack-arm.sed: New file. + * callback/vacall_r/elfhack-i386.S: New file. + * callback/vacall_r/elfhack-i386.sed: New file. + * callback/vacall_r/elfhack-m68k.S: New file. + * callback/vacall_r/elfhack-m68k.sed: New file. + * callback/vacall_r/elfhack-mips.S: New file. + * callback/vacall_r/elfhack-mips.sed: New file. + * callback/vacall_r/elfhack-mips64.S: New file. + * callback/vacall_r/elfhack-mips64.sed: New file. + * callback/vacall_r/elfhack-powerpc.S: New file. + * callback/vacall_r/elfhack-powerpc.sed: New file. + * callback/vacall_r/elfhack-powerpc64le.S: New file. + * callback/vacall_r/elfhack-powerpc64le.sed: New file. + * callback/vacall_r/elfhack-s390.S: New file. + * callback/vacall_r/elfhack-s390.sed: New file. + * callback/vacall_r/elfhack-x86_64.S: New file. + * callback/vacall_r/elfhack-x86_64.sed: New file. + * callback/vacall_r/Makefile.devel (vacall-i386-macro.S): Insert an + include of elfhack-i386.S. + (vacall-m68k.mit.S, vacall-m68k-netbsd-macro.S): Insert an include of + elfhack-m68k.S. + (vacall-mips-macro.S, vacall-mipsn32-macro.S): Insert an include of + elfhack-mips.S. + (vacall-mips64-macro.S): Insert an include of elfhack-mips64.S. + (vacall-alpha-macro.S): Renamed from vacall-alpha.s. Insert an include + of elfhack-alpha.S. + (vacall-arm-macro.S): Insert an include of elfhack-arm.S. + (vacall-armel-macro.S): Renamed from vacall-armel.s. Insert an include + of asm-arm.h and elfhack-arm.S. + (vacall-powerpc-linux-macro.S, vacall-powerpc-netbsd-macro.S): New + targets. + (vacall-powerpc-sysv4-macro.S): Renamed from vacall-powerpc-sysv4.s. + Insert an include of elfhack-powerpc.S. + (vacall-powerpc64le-macro.S): Renamed from vacall-powerpc64le.s. Insert + an include of elfhack-powerpc64.S. + (vacall-x86_64-macro.S): Insert an include of elfhack-x86_64.S. + (vacall-s390-macro.S): New target. + * callback/vacall_r/vacall-alpha-macro.S: Renamed from + callback/vacall_r/vacall-alpha.s. Include elfhack-alpha.S. + * callback/vacall_r/vacall-arm-macro.S: Include elfhack-arm.S. + * callback/vacall_r/vacall-armel-macro.S: Renamed from + callback/vacall_r/vacall-armel.s. Include asm-arm.h and elfhack-arm.S. + * callback/vacall_r/vacall-i386-macro.S: Include elfhack-i386.S. + * callback/vacall_r/vacall-m68k.mit.S: Include elfhack-m68k.S. + * callback/vacall_r/vacall-m68k-netbsd-macro.S: Likewise. + * callback/vacall_r/vacall-mips-macro.S: Include elfhack-mips.S. + * callback/vacall_r/vacall-mipsn32-macro.S: Likewise. + * callback/vacall_r/vacall-mips64-macro.S: Include elfhack-mips64.S. + * callback/vacall_r/vacall-powerpc-linux-macro.S: Generated, to include + elfhack-powerpc.S. + * callback/vacall_r/vacall-powerpc-netbsd-macro.S: Generated, to include + elfhack-powerpc.S. + * callback/vacall_r/vacall-powerpc-sysv4-macro.S: Renamed from + callback/vacall_r/vacall-powerpc-sysv4.s. Include elfhack-powerpc.S. + * callback/vacall_r/vacall-powerpc64le-macro.S: Renamed from + callback/vacall_r/vacall-powerpc64le.s. Include elfhack-powerpc64le.S. + * callback/vacall_r/vacall-s390-linux.s: Renamed from + callback/vacall_r/vacall-s390.s. + * callback/vacall_r/vacall-s390-macro.S: Generated, to include + elfhack-s390.S. + * callback/vacall_r/vacall-x86_64-macro.S: Include elfhack-x86_64.S. + * callback/vacall_r/Makefile.in (ASPFLAGS): Conditionally define + BINFMT_ELF. + (vacall-i386.s, vacall-m68k.s, vacall-mips.s, vacall-mipsn32.s, + vacall-mips64.s): Add a -I option for elfhack-*.S. + (vacall-alpha.s): New target. + (vacall-alpha.lo): Depend on it. + (vacall-arm.s): Add a -I option for elfhack-*.S. + (vacall-armel.s): New target. + (vacall-armel.lo): Depend on it. + (vacall-powerpc.s): For the linux, netbsd, sysv4 syntaxes, use the + corresponding *.S file. + (vacall-powerpc64le.s): New target. + (vacall-powerpc64le.lo): Depend on it. + (vacall-x86_64.s): Add a -I option for elfhack-*.S. + (vacall-s390.s): New target. + (vacall-s390.lo): Depend on it. + (clean): Remove also vacall-alpha.s, vacall-armel.s, + vacall-powerpc64le.s, vacall-s390.s. + (SOURCE_FILES): Update for the renamed files. Add + vacall-powerpc-linux-macro.S, vacall-powerpc-netbsd-macro.S, + vacall-s390-macro.S, elfhack-*.S, elfhack-*.sed. + * README: Clarify on which platforms the problem with the ELF symbol + resolving routine still exists. + +2016-12-31 Bruno Haible + + Update doc about available registers. + * callback/call-used-registers.txt: Clarify call-used registers versus + registers available for use in trampolines. + * trampoline/tramp-powerpc-old.s: Mark as obsolete. + * callback/trampoline_r/tramp-powerpc-old.s: Likewise. + * trampoline/tramp-x86_64.s: Fix comment about available registers. + * callback/trampoline_r/tramp-x86_64.s: Likewise. + * trampoline/tramp-powerpc-sysv4.s: Likewise. + * callback/trampoline_r/tramp-powerpc-sysv4.s: Likewise. + * trampoline/tramp-*.s: Update comment about available registers. + * trampoline/tramp-*.S: Likewise. + * callback/trampoline_r/tramp-*.s: Likewise. + * callback/trampoline_r/tramp-*.S: Likewise. + +2016-12-31 Bruno Haible + + Simplify powerpc compilation rules. + * avcall/Makefile.in (avcall-powerpc.s): New rule. + (avcall-powerpc.lo): Depend on it. Remove libtool specific workaround. + (clean): Remove also avcall-powerpc.s. + * vacall/Makefile.in (vacall-powerpc.s): New rule. + (vacall-powerpc.o): Depend on it. + (clean): Remove also vacall-powerpc.s. + * callback/vacall_r/Makefile.in (vacall-powerpc.s): New rule. + (vacall-powerpc.lo): Depend on it. Remove libtool specific workaround. + (clean): Remove also vacall-powerpc.s. + +2016-12-29 Bruno Haible + + Revert "Pass the environment argument through the stack, not in a + register." commit from 1999-06-01. + * vacall/vacall-i386.c: Revert: Allow use of registers %esi, %edi, %ebp. + Expect env in %ecx, not as first stack argument. + * vacall/vacall-i386-macro.S: Revert. + * callback/vacall_r/vacall-i386-macro.S: Revert. + * callback/trampoline_r/proto.c (tramp2): Remove function. + * callback/trampoline_r/proto-i386.s: Revert accordingly. + * callback/trampoline_r/tramp-i386.s: Put the data in %ecx, not as + first stack argument. + * callback/trampoline_r/trampoline.c [i386]: Revert to simple + trampoline. + * callback/trampoline_r/test1.c (f) [i386]: Expect env in %ecx, not as + first stack argument. + +2016-12-29 Bruno Haible + + Revert "Never build shared libraries: --enable-shared has no effect." + commit from 2012-04-24. + * README: Revert, but still recommend --disable-shared. + * avcall/Makefile.in (libavcall.la): Don't pass -static to libtool. + * callback/Makefile.in (libcallback.la): Likewise. + * callback/vacall_r/Makefile.in (libvacall.la): Likewise. + * callback/trampoline_r/Makefile.in (libtrampoline.la): Likewise. + +2016-12-30 Bruno Haible + + Rename text files. + * common/reg-struct-return.txt: Renamed from common/reg-struct-return. + * callback/call-used-registers.txt: Renamed from + callback/call-used-registers. + * trampoline/PORTING: Update. + * callback/README: Likewise. + +2016-12-29 Bruno Haible + + Update documentation about register usage. + * callback/call-used-registers: Update regarding powerpc/NetBSD. + +2016-12-29 Bruno Haible + + Remove support for the 'convex' CPU. + * avcall/Makefile.devel (avcall-convex.s, tests-convex.s): Remove + targets. + * avcall/avcall-convex.[cs]: Remove files. + * avcall/Makefile.in (avcall-convex.lo): Remove target. + (SOURCE_FILES): Remove avcall-convex.[cs]. + * avcall/avcall.h.in: Remove defined(__convex__) conditionals. + * vacall/Makefile.devel (vacall-convex.s, tests-convex.s): Remove + targets. + * vacall/vacall-convex.[cs]: Remove files. + * vacall/Makefile.in (vacall-convex.o): Remove target. + (SOURCE_FILES): Remove vacall-convex.[cs]. + * vacall/vacall.h.in: Remove defined(__convex__) conditionals. + * trampoline/Makefile.devel (proto-convex.s, cache-convex.s, + tramp-convex.s): Remove targets. + * trampoline/proto-convex.s: Remove file. + * trampoline/cache-convex.[cs]: Remove files. + * trampoline/tramp-convex.s: Remove file. + * trampoline/Makefile.in (cache-convex.o): Remove target. + (SOURCE_FILES): Remove cache-convex.[cs]. + * trampoline/cache.c: Remove defined(__convex__) conditionals. + * trampoline/protexec.c: Remove defined(__convex__) conditionals. + * trampoline/trampoline.c: Remove defined(__convex__) conditionals. + * trampoline/trampoline.h.in: Don't test for convex host. + * trampoline/configure.ac: Don't test for convex host. + * callback/vacall_r/Makefile.devel (vacall-convex.s): Remove target. + * callback/vacall_r/vacall-convex.s: Remove file. + * callback/vacall_r/Makefile.in (vacall-convex.lo): Remove target. + (SOURCE_FILES): Remove vacall-convex.[cs]. + * callback/vacall_r/vacall_r.h.in: Remove defined(__convex__) + conditionals. + * callback/trampoline_r/Makefile.devel (proto-convex.s, cache-convex.s, + tramp-convex.s): Remove targets. + * callback/trampoline_r/proto-convex.s: Remove file. + * callback/trampoline_r/tramp-convex.s: Remove file. + * callback/trampoline_r/Makefile.in (cache-convex.lo): Remove target. + (SOURCE_FILES): Remove cache-convex.[cs]. + * callback/trampoline_r/proto.c: Remove defined(__convex__) + conditionals. + * callback/trampoline_r/trampoline.c: Remove defined(__convex__) + conditionals. + * callback/trampoline_r/trampoline_r.h.in: Don't test for convex host. + * callback/trampoline_r/test1.c: Remove defined(__convex__) + conditionals. + * callback/trampoline_r/configure.ac: Don't test for convex host. + * callback/call-used-registers: Update. + * common/reg-struct-return: Update. + * PLATFORMS, **/PLATFORMS: Update. + * autogen.sh: Don't copy vacall-convex.c, cache-convex.[cs]. + * Makefile.in (COPIED_FILES): Remove callback/vacall_r/vacall-convex.c, + callback/trampoline_r/cache-convex.[cs]. + +2016-12-29 Bruno Haible + + Fix collision between different copies of __structcpy. + Reported in https://savannah.gnu.org/bugs/?23474 . + * avcall/avcall-structcpy.c: New file. + * avcall/Makefile.in (avcall-structcpy.lo): Renamed from structcpy.lo. + (SOURCE_FILES): Add avcall-structcpy.c. + * avcall/Makefile.mingw32 (avcall-structcpy.o): Renamed from + structcpy.o. + * avcall/Makefile.msvc (avcall-structcpy.obj): Renamed from + structcpy.obj. + * avcall/avcall.h.in: Declare and use avcall_structcpy instead of + __structcpy. + * avcall/README: Update. + * vacall/vacall-structcpy.c: New file. + * vacall/Makefile.in (vacall-structcpy.o): Renamed from structcpy.o. + (SOURCE_FILES): Add vacall-structcpy.c. + * vacall/Makefile.mingw32 (vacall-structcpy.o): Renamed from + structcpy.o. + * vacall/Makefile.msvc (vacall-structcpy.obj): Renamed from + structcpy.obj. + * vacall/vacall.h.in: Declare and use vacall_structcpy instead of + __structcpy. + * callback/vacall_r/vacall-structcpy.c: New file. + * callback/vacall_r/Makefile.in (vacall-structcpy.lo): Renamed from + structcpy.lo. + (SOURCE_FILES): Add vacall-structcpy.c. + * callback/vacall_r/Makefile.mingw32 (vacall-structcpy.o): Renamed from + structcpy.o. + * callback/vacall_r/Makefile.msvc (vacall-structcpy.obj): Renamed from + structcpy.obj. + * callback/vacall_r/vacall_r.h.in: Declare and use callback_structcpy + instead of __structcpy. + * callback/Makefile.in (libcallback.la): Use vacall-structcpy.lo, not + structcpy.lo. + * callback/Makefile.mingw32 (OBJECTS): Use vacall-structcpy.o, not + structcpy.o. + * callback/Makefile.msvc (OBJECTS): Use vacall-structcpy.obj, not + structcpy.obj. + (vacall_r/vacall-structcpy.obj): Renamed from vacall_r/structcpy.obj. + (clean): Update accordingly. + +2016-12-29 Bruno Haible + + Put duplicated files under version control only once, part 2. + * vacall/vacall-powerpc.c: Update with the 'REENTRANT' code from + callback/vacall_r/. + * vacall/vacall-s390.c: Likewise. + * callback/vacall_r/vacall-alpha.c: Remove file. + * callback/vacall_r/vacall-arm.c: Remove file. + * callback/vacall_r/vacall-armel.c: Remove file. + * callback/vacall_r/vacall-convex.c: Remove file. + * callback/vacall_r/vacall-hppa.c: Remove file. + * callback/vacall_r/vacall-i386.c: Remove file. + * callback/vacall_r/vacall-ia64.c: Remove file. + * callback/vacall_r/vacall-m68k.c: Remove file. + * callback/vacall_r/vacall-m88k.c: Remove file. + * callback/vacall_r/vacall-mips.c: Remove file. + * callback/vacall_r/vacall-mipsn32.c: Remove file. + * callback/vacall_r/vacall-mips64.c: Remove file. + * callback/vacall_r/vacall-powerpc.c: Remove file. + * callback/vacall_r/vacall-powerpc64.c: Remove file. + * callback/vacall_r/vacall-powerpc64le.c: Remove file. + * callback/vacall_r/vacall-s390.c: Remove file. + * callback/vacall_r/vacall-sparc.c: Remove file. + * callback/vacall_r/vacall-sparc64.c: Remove file. + * callback/vacall_r/vacall-x86_64.c: Remove file. + * autogen.sh: Copy these files from vacall/. + * Makefile.in (COPIED_FILES): Add these files. + +2016-12-28 Bruno Haible + + More robust quoting in Autoconf macros. + * configure.ac: Add brackets around Autoconf macro arguments. + * avcall/configure.ac: Likewise. + * vacall/configure.ac: Likewise. + * trampoline/configure.ac: Likewise. + * callback/configure.ac: Likewise. + * callback/vacall_r/configure.ac: Likewise. + * callback/trampoline_r/configure.ac: Likewise. + * m4/as-underscore.m4: Likewise. + * m4/cc-gcc.m4: Likewise. + * m4/codeexec.m4: Likewise. + * m4/general.m4: Likewise. + * m4/getpagesize.m4: Likewise. + * m4/ireg.m4: Likewise. + * m4/ln.m4: Likewise. + * m4/mach-vm.m4: Likewise. + * m4/mmap.m4: Likewise. + * m4/mprotect.m4: Likewise. + * m4/pccstruct.m4: Likewise. + * m4/proto.m4: Likewise. + * m4/shm.m4: Likewise. + * m4/smallstruct.m4: Likewise. + +2016-12-28 Bruno Haible + + Update list of contributors. + * README: List all contributors. + +2016-12-28 Bruno Haible + + Add support for 64-bit mode (x86_64) on Mac OS X. + * common/asm-x86_64.sh: New file. + * common/asm-x86_64.h: New file. + * Makefile.in (SOURCE_FILES): Add them. + * avcall/avcall-x86_64-linux.s: Renamed from avcall/avcall-x86_64.s. + * avcall/Makefile.devel (avcall-x86_64-linux.s): Renamed from avcall-x86_64.s. + (avcall-x86_64-macro.S): New target. + * avcall/avcall-x86_64-macro.S: New file, generated through avcall/Makefile.devel. + * avcall/Makefile.in (avcall-x86_64.s): New target. + (avcall-x86_64.lo): Use it, in the build dir. + (clean): Remove it. + (SOURCE_FILES): Add avcall-x86_64-linux.s, avcall-x86_64-macro.S. Remove avcall-x86_64.s. + * vacall/vacall-x86_64-linux.s: Renamed from vacall/vacall-x86_64.s. + * vacall/Makefile.devel (vacall-x86_64-linux.s): Renamed from vacall-x86_64.s. + (vacall-x86_64-macro.S): New target. + * vacall/vacall-x86_64-macro.S: New file, generated through vacall/Makefile.devel. + * vacall/Makefile.in (vacall-x86_64.s): New target. + (vacall-x86_64.o): Use it, in the build dir. + (clean): Remove it. + (SOURCE_FILES): Add vacall-x86_64-linux.s, vacall-x86_64-macro.S. Remove vacall-x86_64.s. + * callback/vacall_r/vacall-x86_64-linux.s: Renamed from callback/vacall_r/vacall-x86_64.s. + * callback/vacall_r/Makefile.devel (vacall-x86_64-linux.s): Renamed from vacall-x86_64.s. + (vacall-x86_64-macro.S): New target. + * callback/vacall_r/vacall-x86_64-macro.S: New file, generated through callback/vacall_r/Makefile.devel. + * callback/vacall_r/Makefile.in (vacall-x86_64.s): New target. + (vacall-x86_64.lo): Use it, in the build dir. + (clean): Remove it. + (SOURCE_FILES): Add vacall-x86_64-linux.s, vacall-x86_64-macro.S. Remove vacall-x86_64.s. + * callback/trampoline_r/test1.c (CHECK_ENV_REGISTER): New macro. + (f, main): Use it instead of __GNUC__. + * NEWS: Mention the change. + +2016-12-28 Bruno Haible + + Rename the asm* files. + * common/asm-arm.h: Renamed from common/asmarm.h. + * common/asm-arm.sh: Renamed from common/asmarm.sh. + * common/asm-i386.hh: Renamed from common/asmi386.hh. + * common/asm-i386.sh: Renamed from common/asmi386.sh. + * common/asm-m68k.h: Renamed from common/asmm68k.h. + * common/asm-m68k.sh: Renamed from common/asmm68k.sh. + * common/asm-mips.h: Renamed from common/asmmips.h. + * common/asm-mips.sh: Renamed from common/asmmips.sh. + * common/asm-sparc.h: Renamed from common/asmsparc.h. + * common/asm-sparc.sh: Renamed from common/asmsparc.sh. + * common/asm-sparc64.sh: Renamed from common/asmsparc64.sh. + * **/Makefile.devel, **/*.S: Update. + * Makefile.maint (common/asm-i386.h): Renamed from common/asmi386.h. + * Makefile.in (SOURCE_FILES, GENERATED_FILES): Update. + +2016-12-27 Bruno Haible + + Add the real source of asmi386.h. + * common/asmi386.hh: New file, from GNU clisp. + * common/asmi386.h: Remove file. + * Makefile.maint (common/asmi386.h): New target. Rule copied from + GNU clisp's Makefile.devel. + (all): Depend on it. + * Makefile.in (SOURCE_FILES): Add common/asmi386.hh. Remove + common/asmi386.h. + (GENERATED_FILES): Add common/asmi386.h. + +2016-12-27 Bruno Haible + + Modernize Cygwin detection. + * common/asmi386.h: Test __CYGWIN__, not __CYGWIN32__. + From Ken Brown on 2015-03-05. + +2016-12-27 Bruno Haible + + Create tarballs through an Automake-like "make dist" command. + * Makefile.in (SOURCE_FILES, LIBTOOL_IMPORTED_FILES, + GNULIB_IMPORTED_FILES, IMPORTED_FILES, COPIED_FILES, GENERATED_FILES, + DISTFILES): New macros. + (distdir): New target. + (PACKAGE, VERSION, TAR, GZIP): New macros. + (dist): New target. + * avcall/Makefile.in (SOURCE_FILES, GENERATED_FILES, DISTFILES): New + macros. + (distdir): New target. + * vacall/Makefile.in (SOURCE_FILES, GENERATED_FILES, DISTFILES): New + macros. + (distdir): New target. + * trampoline/Makefile.in (SOURCE_FILES, GENERATED_FILES, DISTFILES): + New macros. + (distdir): New target. + * callback/Makefile.in (SOURCE_FILES, GENERATED_FILES, DISTFILES): New + macros. + (distdir): New target. + * callback/vacall_r/Makefile.in (SOURCE_FILES, GENERATED_FILES, + DISTFILES): New macros. + (distdir): New target. + * callback/trampoline_r/Makefile.in (SOURCE_FILES, GENERATED_FILES, + DISTFILES): New macros. + (distdir): New target. + * configure.ac (extrasub): Replace all occurrences of @subdir@. + * callback/configure.ac (extrasub): Likewise. + +2016-12-27 Bruno Haible + + Bump version number. + * VERSION: Set to 0x010D (= 1.13). + +2016-12-27 Bruno Haible + + Rename each configure.in to configure.ac. + * configure.ac: Renamed from configure.in. + * avcall/configure.ac: Renamed from avcall/configure.in. + * vacall/configure.ac: Renamed from vacall/configure.in. + * trampoline/configure.ac: Renamed from trampoline/configure.in. + * callback/configure.ac: Renamed from callback/configure.in. + * callback/vacall_r/configure.ac: Renamed from + callback/vacall_r/configure.in. + * callback/trampoline_r/configure.ac: Renamed from + callback/trampoline_r/configure.in. + * Makefile.maint (ALL_CONFIGURE_AC): Renamed from ALL_CONFIGURE_IN. + (aclocal.m4, configure, %/configure, %/config.h.in): Update. + * README, */README: Update. + +2016-12-27 Bruno Haible + + Modernize quoting. + * NEWS: Quote ‘like this’, not `like this'. + * README.os2: Likewise. + * common/uniq-u.c: Likewise. + * avcall/DOC: Likewise. + * avcall/avcall-i386.c: Likewise. + * avcall/avcall-sparc.c: Likewise. + * avcall/avcall-sparc64.c: Likewise. + * avcall/avcall.h.in: Likewise. + * avcall/avcall.html: Likewise. + * vacall/vacall.h.in: Likewise. + * callback/trampoline_r/trampoline.c: Likewise. + * callback/trampoline_r/trampoline_r.h.in: Likewise. + * trampoline/PORTING: Likewise. + * trampoline/trampoline.c: Likewise. + * trampoline/trampoline.h.in: Likewise. + * callback/vacall_r/vacall_r.h.in: Likewise. + * configurations/README: Likewise. + * avcall/Makefile.maint (ROFF_MAN): Produce UTF-8 output instead of + ASCII output. + * vacall/Makefile.maint (ROFF_MAN): Likewise. + * trampoline/Makefile.maint (ROFF_MAN): Likewise. + * callback/Makefile.maint (ROFF_MAN): Likewise. + * callback/trampoline_r/Makefile.maint (ROFF_MAN): Likewise. + +2016-12-27 Bruno Haible + + Avoid unnecessary recursion in "make maintainer-clean". + * Makefile.in (DISTCLEANFILES): New variable. + (distclean, maintainer-clean): Use it. + * callback/Makefile.in (DISTCLEANFILES): New variable. + (distclean): Use it. Don't depend on 'clean'. Instead, use + MOSTLYCLEANDIRS, MOSTLYCLEANFILES. + (maintainer-clean): Don't depend on 'distclean'. Instead, use + MOSTLYCLEANDIRS, MOSTLYCLEANFILES, DISTCLEANFILES. + (distclean-subdirs, maintainerclean-subdirs): Inline and remove targets. + +2016-12-27 Bruno Haible + + Make "make mostlyclean" act like "make clean". + * callback/Makefile.in (MOSTLYCLEANDIRS, MOSTLYCLEANFILES): New + variables. + (mostlyclean, clean): Use them. + (clean-subdirs): Inline and remove target. + +2016-12-27 Bruno Haible + + Fix Makefile rules for powerpc64, from 2006-04-27. + * trampoline/Makefile.in (clean): Also remove tramp-powerpc64.s. + * callback/trampoline_r/Makefile.in (clean): Likewise. + +2016-12-26 Bruno Haible + + Reorder Makefile targets. + * trampoline/Makefile.in: Reorder. + * callback/trampoline_r/Makefile.in: Reorder. + +2016-12-26 Bruno Haible + + Fix Makefile rules for powerpc64le, from 2015-08-23. + * trampoline/Makefile.devel (CPP): New variable. + (tramp-powerpc64le.o, tramp-powerpc64le.s): New targets. + * trampoline/Makefile.in (tramp-powerpc64le.o, tramp-powerpc64le.s): + Remove targets. + * callback/trampoline_r/Makefile.devel (CPP): New variable. + (tramp-powerpc64le.o, tramp-powerpc64le.s): New targets. + * callback/trampoline_r/Makefile.in (tramp-powerpc64le.lo, + tramp-powerpc64le.s): Remove targets. + +2016-12-26 Bruno Haible + + Fix Makefile rules for s390, from 2002-03-24. + * trampoline/Makefile.devel (tramp-s390.o): New target. + * trampoline/Makefile.in (tramp-s390.o): Remove target. + * callback/trampoline_r/Makefile.devel (tramp-s390.o): New target. + * callback/trampoline_r/Makefile.in (tramp-s390.lo): Remove target. + +2016-12-26 Bruno Haible + + Fix "make distclean". + * avcall/Makefile.in (distclean): Also remove config.h. + * callback/Makefile.in (distclean): Likewise. + +2016-12-26 Bruno Haible + + Make it possible to build in $(srcdir) on case-insensitive file systems. + * avcall/avcall-${cpu}-macro.S: Renamed from avcall/avcall-${cpu}.S. + * avcall/Makefile.devel: Update accordingly. + * avcall/Makefile.in: Likewise. + * vacall/vacall-${cpu}-macro.S: Renamed from vacall/vacall-${cpu}.S. + * vacall/Makefile.devel: Update accordingly. + * vacall/Makefile.in: Likewise. + * trampoline/cache-sparc-macro.S: Renamed from trampoline/cache-sparc.S. + * trampoline/Makefile.devel: Update accordingly. + * trampoline/Makefile.in: Update accordingly. + * callback/vacall_r/vacall-${cpu}-macro.S: Renamed from + callback/vacall_r/vacall-${cpu}.S. + * callback/vacall_r/Makefile.devel: Update accordingly. + * callback/vacall_r/Makefile.in: Likewise. + * callback/trampoline_r/cache-sparc-macro.S: Renamed from + callback/trampoline_r/cache-sparc.S. + * callback/trampoline_r/Makefile.devel: Update accordingly. + * callback/trampoline_r/Makefile.in: Update accordingly. + +2016-12-26 Bruno Haible + + Simplify armel build rule. + * avcall/Makefile.devel (avcall-armel.s): Renamed from avcall-armel.S. + Simplify. + * avcall/Makefile.in (avcall-armel.lo): Use $(srcdir)/avcall-armel.s. + (avcall-armel.s): Remove target. + +2016-12-26 Bruno Haible + + Put duplicated files under version control only once. + * autogen.sh: Copy some files from trampoline/ to callback/trampoline_r. + * common/asm*.sh: Moved here from avcall/, vacall/, callback/vacall_r. + * common/asm*.h: Likewise. + * common/reg-struct-return: Likewise. + * common/structcpy.c: Likewise. + * common/uniq-u.c: Moved here from avcall/, vacall/, callback/. + * avcall/Makefile.devel: Update paths of asm*.sh. + * avcall/Makefile.in: Add -I options for asm*.h. Update path of structcpy.c. + * avcall/Makefile.mingw32: Likewise. + * avcall/Makefile.msvc: Likewise. Update path of uniq-u.c. + * vacall/Makefile.devel: Update paths of asm*.sh. + * vacall/Makefile.in: Add -I options for asm*.h. Update path of structcpy.c. + * vacall/Makefile.mingw32: Likewise. + * vacall/Makefile.msvc: Likewise. Update path of uniq-u.c. + * trampoline/Makefile.devel: Update paths of asm*.sh. + * trampoline/Makefile.in: Add -I options for asm*.h. + * callback/Makefile.msvc: Update path of uniq-u.c. + * callback/vacall_r/Makefile.devel: Update paths of asm*.sh. + * callback/vacall_r/Makefile.in: Add -I options for asm*.h. Update path of structcpy.c. + * callback/vacall_r/Makefile.mingw32: Likewise. + * callback/vacall_r/Makefile.msvc: Likewise. + * callback/trampoline_r/Makefile.devel: Update paths of asm*.sh. + * callback/trampoline_r/Makefile.in: Add -I options for asm*.h. + +2016-12-26 Bruno Haible + + Fix dependencies. + * avcall/Makefile.devel (avcall-sparc64.S): Depend on asmsparc64.sh, + not asmsparc.sh. + * vacall/Makefile.devel (vacall-sparc64.S): Likewise. + * callback/vacall_r/Makefile.devel (vacall-sparc64.S): Likewise. + * callback/Makefile.maint (vacall_r/vacall-i386-*.c): Don't depend on + vacall_r/asmi386.sh. + +2016-12-26 Bruno Haible + + Add missing dependency. + * callback/vacall_r/Makefile.devel (vacall-m68k-netbsd.S): Depend on + asmm68k.sh. + +2016-12-26 Bruno Haible + + Switch to libtool-2.4.6. + * autogen.sh (LIBTOOL_VERSION): Set to 2.4.6. + * Makefile.maint (libtool-imported-files): Import also m4/ltoptions.m4, + m4/ltsugar.m4, m4/ltversion.m4, m4/lt~obsolete.m4. + * m4/general.m4 (FFCALL_COMMON_LIBTOOL): Invoke LT_INIT. + +2016-12-26 Bruno Haible + + Switch to autoconf 2.69 and automake 1.15. + * Makefile.maint (ACLOCAL, AUTOCONF, AUTOHEADER): Bump version numbers. + +2016-12-26 Bruno Haible + + Remove files that can easily be autogenerated from version control. + * autogen.sh: New file. + * Makefile.maint: New file, partially inspired by Makefile.devel. + * Makefile.devel (all): Remove target and its subtargets. + * avcall/Makefile.maint: New file, extracted from avcall/Makefile.devel. + * avcall/Makefile.devel (precompiled): Renamed from 'all'. + Remove all targets that are moved to avcall/Makefile.maint. + * vacall/Makefile.maint: New file, extracted from vacall/Makefile.devel. + * vacall/Makefile.devel (precompiled): Renamed from 'all'. + Remove all targets that are moved to vacall/Makefile.maint. + * trampoline/Makefile.maint: New file, extracted from + trampoline/Makefile.devel. + * trampoline/Makefile.devel (precompiled): Renamed from 'all'. + Remove all targets that are moved to trampoline/Makefile.maint. + * callback/Makefile.maint: Renamed from callback/Makefile.devel. + (trampoline_r/trampoline_r.man): New target. + (totally-clean, force): New targets. + * callback/vacall_r/Makefile.maint: New file, extracted from + callback/vacall_r/Makefile.devel. + * callback/vacall_r/Makefile.devel (precompiled): Renamed from 'all'. + Remove all targets that are moved to callback/vacall_r/Makefile.maint. + (vacall_r.man): Remove target. + * callback/trampoline_r/Makefile.maint: New file, extracted from + callback/trampoline_r/Makefile.devel. + * callback/trampoline_r/Makefile.devel (precompiled): Renamed from + 'all'. + Remove all targets that are moved to + callback/trampoline_r/Makefile.maint. + +2016-12-26 Bruno Haible + + Remove test result files from version control. + * callback/trampoline_r/tests.passed.i386-pc-win32-gcc: Remove file. + +2015-08-23 Hernán Erasmo + + Added compatibility with ppc64le architecture. Credit goes + to Masanori Mitsugi + +2012-04-24 Sam Steingold + + Never build shared libraries: --enable-shared has no effect. + * avcall/Makefile.in (libavcall.la): pass -static to LIBTOOL_LINK + * callback/Makefile.in (libcallback.la): ditto + * callback/trampoline_r/Makefile.in (libtrampoline.la): ditto + * callback/vacall_r/Makefile.in (libvacall.la): ditto + +2010-09-03 Sam Steingold + + * configure.in: call AC_CONFIG_AUX_DIR(build-aux) + +2010-09-03 Sam Steingold + + * Makefile.devel (gnulib-imported): also import host-cpu-c-abi + * avcall/configure.in, callback/configure.in: + * callback/trampoline_r/configure.in, callback/vacall_r/configure.in: + * trampoline/configure.in, vacall/configure.in: + use gl_HOST_CPU_C_ABI instead of FFCALL_CANONICAL_HOST_CPU + * m4/general.m4: remove FFCALL_CANONICAL_HOST_CPU, + FFCALL_CACHE_EGREP_CPP, FFCALL_SET_CPU_ABI + * glm4/host-cpu-c-abi.m4: add + * avcall/Makefile.in, callback/Makefile.in: + * callback/trampoline_r/Makefile.in, callback/vacall_r/Makefile.in: + * trampoline/Makefile.in, vacall/Makefile.in, + use @HOST_CPU_C_ABI@ instead of @host_cpu_abi@ + * callback/trampoline_r/configure.in, trampoline/configure.in: + * m4/codeexec.m4: use $HOST_CPU_C_ABI instead of $host_cpu_abi + +2010-07-20 Sam Steingold + + * callback/trampoline_r/trampoline_r.h.in, trampoline/trampoline.h.in: + add autoconf CPU detection block; this fixes trampoline on sparc64/linux + Suggested by Valeriy E. Ushakov + +2010-07-20 Valeriy E. Ushakov + + https://savannah.gnu.org/bugs/?22081 + support sparc64 for solaris & *bsd + * avcall/avcall-sparc64.c, avcall/avcall.h.in: + Kill callee (%g2). Sparc64 doesn't need that code. + Delete space[] - gcc optimizes it away anyway, and it doesn't + guarantee correct operation even if it's not removed - if compiler + allocs it below other local vars on the stack, then calling + function with enough arguments will clobber local vars. + Instead i've changed the code to use alloca, see the comment in + the code for details on why this works. It also doesn't waste 2K + of stack on each call, we only grab the space we actually need. + I nuked farg_mask. It's not necessary for float args, marking + them in darg_mask does the right thing (new av_float). And they + just hurt structure passing, where, again, marking up darg_mask + does the right thing. + * avcall/avcall-saprc64.S: Regenerated with NetBSD gcc4 + * vacall/vacall-sparc64.S, callback/vacall_r/vacall-sparc64.S: + New binutils on sparc64 insist on having global registers properly + declared with .register. I've just added the declarations manually + w/out actually regenerating the files to demonstrate that's the + only change needed there. IF the files are regenerated with a + newer compiler you will get them automatically. + +2009-11-10 Sam Steingold + + * vacall/Makefile.in (vacall-armel.o): vacall-armel.s is in $(srcdir) + * callback/vacall_r/Makefile.in (vacall-armel.lo): ditto + +2009-10-16 Sam Steingold + + the final fix for LIBFFCALL_VERSION + * Makefile.devel (vacall/vacall.h.msvc, vacall/vacall.h.mingw32) + (callback/vacall_r/vacall_r.h.msvc) + (callback/vacall_r/vacall_r.h.mingw32): depend on VERSION + * avcall/avcall.h.in, callback/callback.h.in, + * callback/trampoline_r/trampoline_r.h.in, vacall/vacall.h.in, + * callback/vacall_r/vacall_r.h.in, trampoline/trampoline.h.in: + use @LIBFFCALL_VERSION@ instead of @PACKAGE_VERSION@ + * avcall/configure.in: additional processing for avcall.h to + substitute @LIBFFCALL_VERSION@ + * callback/configure.in: ditto for callback.h + * callback/trampoline_r/configure.in: ditto for trampoline_r.h + * callback/vacall_r/configure.in: ditto for vacall_r.h + * trampoline/configure.in: ditto for trampoline.h + * vacall/configure.in: ditto for vacall.h + * callback/vacall_r/Makefile.devel (vacall_r.h.msvc) + (vacall_r.h.mingw32): depend on ../../VERSION; + substitute @LIBFFCALL_VERSION@ + * vacall/Makefile.devel (vacall.h.msvc, vacall.h.mingw32): depend + on ../VERSION; substitute @LIBFFCALL_VERSION@ + +2009-10-16 Sam Steingold + + * glm4/longlong.m4, glm4/nocrash.m4: update from gnulib + +2009-10-16 Sam Steingold + + * Makefile.devel (update-gnulib): use git when available + +2009-10-16 Sam Steingold + + * avcall/configure.in, callback/configure.in, + * callback/trampoline_r/configure.in, callback/vacall_r/configure.in, + * trampoline/configure.in, vacall/configure.in: list the main generated + header (avcall.h et al) in AC_CONFIG_HEADERS, not in AC_CONFIG_FILES + fixes the bug#27706 (introduced on 2009-04-24) + +2009-04-28 Sam Steingold + + * m4/general.m4 (FFCALL_CACHE_EGREP_CPP, FFCALL_SET_CPU_ABI): + abstracted out of FFCALL_CANONICAL_HOST_CPU + (FFCALL_CANONICAL_HOST_CPU): use them + +2009-04-27 Max Lapan + Sam Steingold + + * avcall/Makefile.devel, avcall/Makefile.in, avcall/avcall.h.in, + * callback/trampoline_r/Makefile.devel, + * callback/trampoline_r/Makefile.in, + * callback/trampoline_r/configure.in, + * callback/vacall_r/Makefile.devel, callback/vacall_r/Makefile.in, + * callback/vacall_r/vacall_r.h.in, trampoline/Makefile.devel, + * trampoline/Makefile.in, trampoline/configure.in, + * vacall/Makefile.devel, vacall/Makefile.in, vacall/vacall.h.in: + Add ARMel support + * m4/general.m4 (FFCALL_CANONICAL_HOST_CPU): use AC_EGREP_CPP to + distinguish between arm and armel + * avcall/avcall-armel.S, avcall/avcall-armel.c, + * callback/trampoline_r/cache-armel.c, + * callback/trampoline_r/cache-armel.s, + * callback/vacall_r/vacall-armel.c, callback/vacall_r/vacall-armel.s, + * trampoline/cache-armel.c, trampoline/cache-armel.s, + * vacall/vacall-armel.c, vacall/vacall-armel.s: + new files + +2009-04-27 Max Lapan + + * avcall/tests.c, callback/tests.c, vacall/tests.c: + #include "config.h" for HAVE_LONG_LONG_INT + +2009-04-27 Max Lapan + + * callback/trampoline_r/trampoline.c (is_tramp) [__arm__]: + fix bug in the last patch + +2009-04-24 Sam Steingold + + * avcall/configure.in, callback/configure.in, + * callback/trampoline_r/configure.in, callback/vacall_r/configure.in, + * trampoline/configure.in, vacall/configure.in: + use AC_CONFIG_FILES instead of AC_OUTPUT with argument + * Makefile.devel (aclocal.m4): adjust the grep regexp + +2009-04-24 Sam Steingold + + * Makefile.in, avcall/Makefile.in, callback/Makefile.in, + * callback/trampoline_r/Makefile.in, callback/vacall_r/Makefile.in, + * trampoline/Makefile.in, vacall/Makefile.in (datarootdir): + set to @datarootdir@ to avoid a configure warning + +2009-04-24 Sam Steingold + + * Makefile.devel (SUBDIRS_CONFIG_H): add avcall and callback + +2009-04-24 Sam Steingold + + * VERSION: new file + * configure.in: use AC_INIT with the version argument + * avcall/Makefile.mingw32: use sed to set LIBFFCALL_VERSION in avcall.h + * callback/vacall_r/Makefile.mingw32: + use sed to set LIBFFCALL_VERSION in vacall_r.h + * vacall/Makefile.mingw32: use sed to set LIBFFCALL_VERSION in vacall.h + * avcall/avcall.h.in, callback/callback.h.in, + * callback/trampoline_r/trampoline_r.h.in, + * callback/vacall_r/vacall_r.h.in, + * trampoline/trampoline.h.in, vacall/vacall.h.in: + (LIBFFCALL_VERSION): define to @PACKAGE_VERSION@ + * avcall/configure.in, callback/configure.in, + * callback/trampoline_r/configure.in, callback/vacall_r/configure.in, + * trampoline/configure.in, vacall/configure.in: + use AC_INIT with the version argument, + pass [config.h] to AC_CONFIG_HEADERS + +2009-04-23 Sam Steingold + + * m4/codeexec.m4, m4/ireg.m4, m4/pccstruct.m4, m4/smallstruct.m4: + all 3 arguments of AC_DEFINE are now required + +2009-04-21 Sam Steingold + + * m4/as-underscore.m4, m4/codeexec.m4, m4/general.m4: + * m4/getpagesize.m4, m4/ireg.m4, m4/mach-vm.m4, m4/mmap.m4: + * m4/mprotect.m4, m4/pccstruct.m4, m4/shm.m4, m4/smallstruct.m4: + quote AC_DEFINE arguments + +2008-09-28 Sam Steingold + + * Makefile.devel (aclocal.m4): include glm4 (this defined gl_EARLY + and gl_INIT and fixes make check on x86_64) + +2008-09-26 Sam Steingold + + * avcall/avcall-ia64.s, avcall/avcall.h.in: + * callback/vacall_r/vacall_r.h.in: + support IA64 on Linux (kernel 2.6.16+ and gcc 4.1.0+) + https://savannah.gnu.org/bugs/index.php?22130 + https://sourceforge.net/tracker/index.php?func=detail&aid=1528895&group_id=1355&atid=301355 + +2008-09-26 Sam Steingold + + * callback/trampoline_r/Makefile.in, callback/trampoline_r/cache-arm.c: + * callback/trampoline_r/cache-arm.s, callback/trampoline_r/configure.in: + * callback/trampoline_r/tramp-arm.s, callback/trampoline_r/tramp-mips.s: + * callback/trampoline_r/trampoline.c, trampoline/cache-arm.c: + * trampoline/cache-arm.s, trampoline/configure.in: + * trampoline/tramp-arm.s, trampoline/trampoline.c: + add arm support from Jonathan Olson (debian 1.10-2) + https://savannah.gnu.org/bugs/?func=detailitem&item_id=9468 + +2008-09-26 Sam Steingold + + * avcall/avcall-mips.S, avcall/avcall-mips.c, avcall/avcall.h.in: + * callback/trampoline_r/trampoline.c, callback/vacall_r/vacall_r.h.in: + * m4/general.m4, trampoline/trampoline.c, vacall/vacall.h.in: + add mipsel support from Thiemo Seufer (debian 1.10-2) + +2008-09-26 Sam Steingold + + * Makefile.devel, Makefile.in, callback/Makefile.devel, + * callback/Makefile.in: use "&&" instead of ";" for all targets + +2008-07-13 Sam Steingold + + * glm4/gnulib-cache.m4, glm4/gnulib-common.m4, glm4/gnulib-comp.m4: + * glm4/gnulib-tool.m4, glm4/onceonly.m4: add from gnulib + * glm4/nocrash.m4: update from gnulib + * Makefile.devel (gnulib-imported): remove gllib + * configure.ac: call gl_EARLY and gl_INIT + +2008-07-08 Sam Steingold + + * Makefile.devel (SUBDIRS_CONFIGURE): use $(CURDIR) instead of . + (%/configure): use "&&" instead of ";" + +2008-07-03 Sam Steingold + + * Makefile.devel (all): split into a few manageable targets + (config-h-in, woe32-h, woe32-c): new targets + (configure): use patterns + +2008-07-03 Sam Steingold + + * m4/smallstruct.m4 (FFCALL_SMALL_STRUCT_RETURN): rename from + CL_SMALL_STRUCT_RETURN; use ffcall_cv_* instead of cl_cv_*; + use return instead of exit() + * m4/pccstruct.m4 (FFCALL_PCC_STRUCT_RETURN): rename from + CL_PCC_STRUCT_RETURN; use ffcall_cv_* instead of cl_cv_*; + use return instead of exit() + * m4/ireg.m4 (FFCALL_IREG_FLOAT_RETURN): remame from + CL_IREG_FLOAT_RETURN; use ffcall_cv_* instead of cl_cv_*; + use return instead of exit() + * m4/codeexec.m4 (FFCALL_CODEEXEC): rename from CL_CODEEXEC + use ffcall_cv_* instead of cl_cv_*; use return instead of exit() + * m4/general.m4: remove non-FFCALL code + (FFCALL_COMMON_LIBTOOL): rename from CL_FFCALL_COMMON_LIBTOOL + (FFCALL_COMMON_TRAMPOLINE): rename from CL_FFCALL_COMMON_TRAMPOLINE + (FFCALL_CANONICAL_HOST_CPU): <- CL_CANONICAL_HOST_CPU_FOR_FFCALL + +2008-07-03 Sam Steingold + + * Makefile.devel (build-aux-update): new target + +2008-07-02 Sam Steingold + + * Makefile.devel (gnulib-imported, update-gnulib): new targets + * glm4: new directory + * longlong.m4, nocrash.m4: move from m4 to glm4 + +2008-07-02 Sam Steingold + + * m4/ln.m4: update from clisp + * m4/cp.m4: remove + * m4/getpagesize.m4: update from clisp + * m4/general.m4: update from clisp + * m4/mmap.m4: update from clisp + * m4/mprotect.m4: update from clisp + * m4/proto.m4: update from clisp + * m4/openflags.m4: remove + * m4/cc-void.m4: remove + +2008-07-02 Sam Steingold + + * Makefile.devel, aclocal.m4: move autoconf/aclocal.m4 to aclocal.m4 + * aclocal/autoconf.m4: remove + * Makefile.devel (CLISP_DIR): remove + +2008-07-02 Sam Steingold + + * m4/ffcall-pccstruct.m4, m4/ffcall-smallstruct.m4, m4/ffcall-ireg.m4: + * m4/ffcall-codeexec.m4: remove "ffcall-" prefix + * Makefile.devel: update + +See clisp ChangeLog for earlier changes. diff --git a/DEPENDENCIES b/DEPENDENCIES new file mode 100644 index 0000000..fcbd036 --- /dev/null +++ b/DEPENDENCIES @@ -0,0 +1,69 @@ +The following packages should be installed before GNU libffcall is installed +(runtime dependencies that are also build dependencies): + +None. + + +The following packages should be installed when GNU libffcall is installed +(runtime dependencies, but not build dependencies): + +None. + + +The following should be installed when GNU libffcall is built, but are not +needed later, once it is installed (build dependencies, but not runtime +dependencies): + +* A C runtime, compiler, linker, etc. + + Mandatory. Either the platform's native 'cc', or GCC 2.95 or newer. + + GCC Homepage: + https://gcc.gnu.org/ + + Download: + https://ftp.gnu.org/gnu/gcc/ + +* A 'make' utility. + + Mandatory. Either the platform's native 'make' (for in-tree builds only), + or GNU Make 3.79.1 or newer. + + GNU Make Homepage: + https://www.gnu.org/software/make/ + + Download: + https://ftp.gnu.org/gnu/make/ + +* A shell + + Mandatory. Either the platform's native 'sh', or Bash. + + Homepage: + https://www.gnu.org/software/bash/ + + Download: + https://ftp.gnu.org/gnu/bash/ + +* Core POSIX utilities, including: + [ basename cat chgrp chmod chown cp dd echo expand expr + false hostname install kill ln ls md5sum mkdir mkfifo + mknod mv printenv pwd rm rmdir sleep sort tee test touch + true uname + + Mandatory. Either the platform's native utilities, or GNU coreutils. + + Homepage: + https://www.gnu.org/software/coreutils/ + + Download: + https://ftp.gnu.org/gnu/coreutils/ + +* The comparison utilities 'cmp' and 'diff'. + + Mandatory. Either the platform's native utilities, or GNU diffutils. + + Homepage: + https://www.gnu.org/software/diffutils/ + + Download: + https://ftp.gnu.org/gnu/diffutils/ + +* Grep. + + Mandatory. Either the platform's native grep, or GNU grep. + + Homepage: + https://www.gnu.org/software/grep/ + + Download: + https://ftp.gnu.org/gnu/grep/ + +* Awk. + + Mandatory. Either the platform's native awk, or GNU awk. + + Homepages: + https://www.gnu.org/software/gawk/ + + Download: + https://ftp.gnu.org/gnu/gawk/ diff --git a/INSTALL.os2 b/INSTALL.os2 new file mode 100644 index 0000000..0c804fe --- /dev/null +++ b/INSTALL.os2 @@ -0,0 +1,10 @@ +Installation on OS/2: + +- Requires emx+gcc and a working shell (Bourne shell, Korn shell or GNU bash). + +- Set the environment variables CC=gcc CFLAGS="-Zexe" before calling + ‘configure’. + +- Must build in a separate directory and pass the --srcdir option to + ‘configure’, otherwise avcall-i386.s will overwrite avcall-i386.S. + diff --git a/INSTALL.windows b/INSTALL.windows new file mode 100644 index 0000000..6892f36 --- /dev/null +++ b/INSTALL.windows @@ -0,0 +1,263 @@ +Installation on Microsoft Windows: + +There are three ways to create binaries of this package for Microsoft Windows: +1) Native binaries, built using the mingw tool chain. +2) Native binaries, built using the MS Visual C/C++ tool chain. +3) Binaries for the Cygwin environment. + +=============================================================================== +1) Native binaries, built using the mingw tool chain. + + I recommend to use the Cygwin environment as the development environment + and mingw only as the target (runtime, deployment) environment. + For this, you need to install + * Cygwin (from https://cygwin.com/), + * some packages available from the Cygwin package installer: + make + * the mingw cross-compilation tools and runtime package, available from + the Cygwin package installer (setup-x86_64.exe): + - for creating 32-bit binaries: packages + mingw64-i686-gcc-core, + mingw64-i686-gcc-g++, + mingw64-i686-headers, + mingw64-i686-runtime + - for creating 64-bit binaries: packages + mingw64-x86_64-gcc-core, + mingw64-x86_64-gcc-g++, + mingw64-x86_64-headers, + mingw64-x86_64-runtime + + Building 32-bit binaries for mingw is achieved through the following + preparation, configure, and build commands: + + PATH=/usr/local/mingw32/bin:/usr/i686-w64-mingw32/sys-root/mingw/bin:$PATH + export PATH + ./configure --host=i686-w64-mingw32 --prefix=/usr/local/mingw32 \ + CC=i686-w64-mingw32-gcc \ + CXX=i686-w64-mingw32-g++ \ + CPPFLAGS="-I/usr/local/mingw32/include -Wall" \ + LDFLAGS="-L/usr/local/mingw32/lib" + make + make check + + Building 64-bit binaries for mingw is achieved through the following + preparation, configure, and build commands: + + PATH=/usr/local/mingw64/bin:/usr/x86_64-w64-mingw32/sys-root/mingw/bin:$PATH + export PATH + ./configure --host=x86_64-w64-mingw32 --prefix=/usr/local/mingw64 \ + CC=x86_64-w64-mingw32-gcc \ + CXX=x86_64-w64-mingw32-g++ \ + CPPFLAGS="-I/usr/local/mingw64/include -Wall" \ + LDFLAGS="-L/usr/local/mingw64/lib" + make + make check + + Installation: + + make install + +=============================================================================== +2) Native binaries, built using the MS Visual C/C++ tool chain. + + Note that binaries created with MSVC have a distribution constraint: They + depend on a closed-source library ('msvcr90.dll' for MSVC 9.0, + 'vcruntime140.dll' for MSVC 14.0, and so on) which is not normally part of + a Windows installation. + You cannot distribute 'vcruntime*.dll' with the binaries - this would be a + violation of the GPL and of the Microsoft EULA. + You can distribute the binaries without including 'vcruntime*.dll'. Users + who don't have this library on their system will require to pull some files + (api-ms-win*.dll) through the Windows Update mechanism, see + https://support.microsoft.com/en-us/kb/2999226 . + + This recipe requires MS Visual C/C++ 9.0 or newer. + You don't need the Visual Studio IDE, just the C/C++ tool chain. + As of 2016, you can install the MS Visual C/C++ 14.0 tool chain from + http://landinghub.visualstudio.com/visual-cpp-build-tools (it's the file + visualcppbuildtools_full.exe). + + This recipe requires also a Cygwin environment (with 'bash', the common POSIX + commands, and 'make') as a build environment. Building with 'nmake' is not + supported. + For this, you need to install + * Cygwin (from https://cygwin.com/), + * some packages available from the Cygwin package installer: + make + + You also need the scripts 'ar-lib' and 'compile' from + https://git.savannah.gnu.org/gitweb/?p=automake.git;a=blob_plain;f=lib/ar-lib;hb=HEAD + https://git.savannah.gnu.org/gitweb/?p=automake.git;a=blob_plain;f=lib/compile;hb=HEAD + respectively. + They may also be included in this package, in directory 'build-aux/'. + Save them; the instructions below assume that you stored them in $HOME/msvc/. + Make them executable: + chmod a+x ar-lib compile + + Start a bash (from Cygwin). + + Make sure that the MSVC tools ("cl" etc.) are found in PATH and the + environment variables INCLUDE and LIB are set appropriately. + In a typical MSVC 9.0 installation, it can be achieved by running + C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat + In a typical MSVC 14.0 installation on Windows 10, it can be achieved + - for creating 32-bit binaries: through the following bash commands: + + # Set environment variables for using MSVC 14, + # for creating native 32-bit Windows executables. + + # Windows C library headers and libraries. + WindowsCrtIncludeDir='C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt' + WindowsCrtLibDir='C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\' + INCLUDE="${WindowsCrtIncludeDir};$INCLUDE" + LIB="${WindowsCrtLibDir}x86;$LIB" + + # Windows API headers and libraries. + WindowsSdkIncludeDir='C:\Program Files (x86)\Windows Kits\8.1\Include\' + WindowsSdkLibDir='C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\' + INCLUDE="${WindowsSdkIncludeDir}um;${WindowsSdkIncludeDir}shared;$INCLUDE" + LIB="${WindowsSdkLibDir}x86;$LIB" + + # Visual C++ tools, headers and libraries. + VSINSTALLDIR='C:\Program Files (x86)\Microsoft Visual Studio 14.0' + VCINSTALLDIR="${VSINSTALLDIR}"'\VC' + PATH=`cygpath -u "${VCINSTALLDIR}"`/bin:"$PATH" + INCLUDE="${VCINSTALLDIR}"'\include;'"${INCLUDE}" + LIB="${VCINSTALLDIR}"'\lib;'"${LIB}" + + export INCLUDE LIB + + - for creating 64-bit binaries: through the following bash commands: + + # Set environment variables for using MSVC 14, + # for creating native 64-bit Windows executables. + + # Windows C library headers and libraries. + WindowsCrtIncludeDir='C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt' + WindowsCrtLibDir='C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\' + INCLUDE="${WindowsCrtIncludeDir};$INCLUDE" + LIB="${WindowsCrtLibDir}x64;$LIB" + + # Windows API headers and libraries. + WindowsSdkIncludeDir='C:\Program Files (x86)\Windows Kits\8.1\Include\' + WindowsSdkLibDir='C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\' + INCLUDE="${WindowsSdkIncludeDir}um;${WindowsSdkIncludeDir}shared;$INCLUDE" + LIB="${WindowsSdkLibDir}x64;$LIB" + + # Visual C++ tools, headers and libraries. + VSINSTALLDIR='C:\Program Files (x86)\Microsoft Visual Studio 14.0' + VCINSTALLDIR="${VSINSTALLDIR}"'\VC' + PATH=`cygpath -u "${VCINSTALLDIR}"`/bin/amd64:"$PATH" + INCLUDE="${VCINSTALLDIR}"'\include;'"${INCLUDE}" + LIB="${VCINSTALLDIR}"'\lib\amd64;'"${LIB}" + + export INCLUDE LIB + + Building 32-bit binaries with MSVC is achieved through the following + preparation, configure, and build commands: + + PATH=/usr/local/msvc32/bin:$PATH + export PATH + + win32_target=_WIN32_WINNT_WINXP # for MSVC 9.0 + win32_target=_WIN32_WINNT_VISTA # possibly for MSVC >= 10.0 + win32_target=_WIN32_WINNT_WIN7 # possibly for MSVC >= 10.0 + win32_target=_WIN32_WINNT_WIN8 # possibly for MSVC >= 10.0 + + ./configure --host=i686-w64-mingw32 --prefix=/usr/local/msvc32 \ + CC="$HOME/msvc/compile cl -nologo" \ + CFLAGS="-MD" \ + CXX="$HOME/msvc/compile cl -nologo" \ + CXXFLAGS="-MD" \ + CPPFLAGS="-D_WIN32_WINNT=$win32_target -I/usr/local/msvc32/include" \ + LDFLAGS="-L/usr/local/msvc32/lib" \ + LD="link" \ + NM="dumpbin -symbols" \ + STRIP=":" \ + AR="$HOME/msvc/ar-lib lib" \ + RANLIB=":" + make + make check + + Building 64-bit binaries with MSVC is achieved through the following + preparation, configure, and build commands: + + PATH=/usr/local/msvc64/bin:$PATH + export PATH + + win32_target=_WIN32_WINNT_WINXP # for MSVC 9.0 + win32_target=_WIN32_WINNT_VISTA # possibly for MSVC >= 10.0 + win32_target=_WIN32_WINNT_WIN7 # possibly for MSVC >= 10.0 + win32_target=_WIN32_WINNT_WIN8 # possibly for MSVC >= 10.0 + + ./configure --host=x86_64-w64-mingw32 --prefix=/usr/local/msvc64 \ + CC="$HOME/msvc/compile cl -nologo" \ + CFLAGS="-MD" \ + CXX="$HOME/msvc/compile cl -nologo" \ + CXXFLAGS="-MD" \ + CPPFLAGS="-D_WIN32_WINNT=$win32_target -I/usr/local/msvc64/include" \ + LDFLAGS="-L/usr/local/msvc64/lib" \ + LD="link" \ + NM="dumpbin -symbols" \ + STRIP=":" \ + AR="$HOME/msvc/ar-lib lib" \ + RANLIB=":" + make + make check + + Installation: + + make install + +=============================================================================== +3) Binaries for the Cygwin environment. + + The generic instructions in the INSTALL file apply. But here are more + specific ones. + + You need to install + * Cygwin (from https://cygwin.com/), + * some packages available from the Cygwin package installer: + make + * the Cygwin [cross-]compilation tools package, available from + the Cygwin package installer (setup-x86_64.exe): + - for creating 32-bit binaries: packages + cygwin32-gcc-core, + cygwin32-gcc-g++, + cygwin32 + - for creating 64-bit binaries: packages + gcc-core, + gcc-g++ + + Building 32-bit binaries for Cygwin must be done in a directory *outside* + the Cygwin /home and /usr hierarchies. It is achieved through the following + preparation, configure, and build commands: + + PATH=/usr/local/cygwin32/bin:/usr/i686-pc-cygwin/sys-root/usr/bin:$PATH + export PATH + ./configure --host=i686-pc-cygwin --prefix=/usr/local/cygwin32 \ + CC=i686-pc-cygwin-gcc \ + CXX=i686-pc-cygwin-g++ \ + CPPFLAGS="-I/usr/local/cygwin32/include -Wall" \ + LDFLAGS="-L/usr/local/cygwin32/lib" + make + make check + + Building 64-bit binaries for Cygwin is achieved through the following + preparation, configure, and build commands: + + PATH=/usr/local/cygwin64/bin:$PATH + export PATH + ./configure --host=x86_64-pc-cygwin --prefix=/usr/local/cygwin64 \ + CC=x86_64-pc-cygwin-gcc \ + CXX=x86_64-pc-cygwin-g++ \ + CPPFLAGS="-I/usr/local/cygwin64/include -Wall" \ + LDFLAGS="-L/usr/local/cygwin64/lib" + make + make check + + Installation: + + make install + +=============================================================================== diff --git a/Makefile.devel b/Makefile.devel new file mode 100644 index 0000000..ae8d87f --- /dev/null +++ b/Makefile.devel @@ -0,0 +1,29 @@ +# This is the developer's -*-Makefile-*-, not the user's makefile. +# Do not use it unless you know exactly what you do! + +# ============ Rules that require cross-compilation tools ============ + +precompiled : force + cd avcall && $(MAKE) -f Makefile.devel precompiled + cd vacall && $(MAKE) -f Makefile.devel precompiled + cd trampoline && $(MAKE) -f Makefile.devel precompiled + cd callback/vacall_r \ + && $(MAKE) -f Makefile.devel precompiled + cd callback/trampoline_r \ + && $(MAKE) -f Makefile.maint copied-files \ + && $(MAKE) -f Makefile.devel precompiled + +# ==================== Targets for testing ==================== + +COMPILERS="cc -O" "gcc -freg-struct-return" "gcc -fpcc-struct-return" + +multibuild : force + for compiler in $(COMPILERS) ; do \ + dir=build-`echo $$compiler | sed -e 's, ,,g' -e 's,/,_,g'`; \ + mkdir $$dir; cd $$dir; \ + CC="$$compiler" ../configure --srcdir=.. && make && make check; \ + cd ..; \ + done + + +force : diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..d234bdf --- /dev/null +++ b/Makefile.in @@ -0,0 +1,239 @@ +# Makefile for libffcall + +#### Start of system configuration section. #### + +# Directories used by "make": +srcdir = @srcdir@ + +# Directories used by "make install": +prefix = @prefix@ +local_prefix = /usr/local +exec_prefix = @exec_prefix@ +libdir = @libdir@ +includedir = @includedir@ +mandir = @mandir@ +datadir = @datadir@ +datarootdir = @datarootdir@ + +# Programs used by "make": +# C compiler +CC = @CC@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +# Both C and C++ compiler +CPPFLAGS = @CPPFLAGS@ +INCLUDES = -I. -I$(srcdir) -I.. -I$(srcdir)/.. -I$(srcdir)/vacall_r +LDFLAGS = @LDFLAGS@ +LIBTOOL = @LIBTOOL@ +LIBTOOL_COMPILE = $(LIBTOOL) --mode=compile +LIBTOOL_LINK = $(LIBTOOL) --mode=link +LIBTOOL_INSTALL = $(LIBTOOL) --mode=install +LIBTOOL_UNINSTALL = $(LIBTOOL) --mode=uninstall +AR = @AR@ +AR_FLAGS = rc +RANLIB = @RANLIB@ +RM = rm -f +@SET_MAKE@ + +# Programs used by "make install": +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ + +#### End of system configuration section. #### + +SHELL = /bin/sh + +# This package does not support parallel make. +# So, turn off parallel execution (at least in GNU make >= 4.0). +GNUMAKEFLAGS = -j1 + +# Needed by $(LIBTOOL). +top_builddir = . + +# Limit the set of exported symbols, on those platforms where libtool supports it. +# Currently this excludes the symbols from gnulib modules. +LIBFFCALL_EXPORTED_SYMBOLS_REGEX = '^ffcall_|^avcall_|^callback_|_callback$$' + +# Before making a release, change this according to the libtool documentation, +# section "Library interface versions". +LIBFFCALL_VERSION_INFO = 0:2:0 + +all : all-subdirs libffcall.la + +all-subdirs : ffcall-version.h force + cd @subdir@ && $(MAKE) all + +ffcall-version.h : $(srcdir)/ffcall-version.in.h + cd .. && ./config.status --header=ffcall-version.h:ffcall-version.in.h + +ffcall-version.lo : $(srcdir)/ffcall-version.c ffcall-version.h config.h + $(LIBTOOL_COMPILE) $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/ffcall-version.c + +libffcall.la : ffcall-version.lo avcall/avcall.lo avcall/avcall-libapi.lo avcall/avcall-structcpy.lo callback/vacall_r/libvacall.la callback/trampoline_r/libtrampoline.la callback/callback-libapi.lo + $(LIBTOOL_LINK) $(CC) -o libffcall.la -rpath $(libdir) -no-undefined -export-symbols-regex $(LIBFFCALL_EXPORTED_SYMBOLS_REGEX) -version-info $(LIBFFCALL_VERSION_INFO) ffcall-version.lo avcall/avcall.lo avcall/avcall-libapi.lo avcall/avcall-structcpy.lo callback/vacall_r/vacall.lo callback/vacall_r/vacall-libapi.lo callback/vacall_r/vacall-structcpy.lo callback/trampoline_r/*.lo callback/callback-libapi.lo gnulib-lib/libgnu.la $(LDFLAGS) $(LTLIBTHREAD) + +install : force + mkdir -p $(DESTDIR)$(prefix) + mkdir -p $(DESTDIR)$(libdir) + $(LIBTOOL_INSTALL) $(INSTALL_DATA) libffcall.la $(DESTDIR)$(libdir)/libffcall.la + mkdir -p $(DESTDIR)$(includedir) + $(INSTALL_DATA) ffcall-version.h $(DESTDIR)$(includedir)/ffcall-version.h + $(INSTALL_DATA) $(srcdir)/ffcall-abi.h $(DESTDIR)$(includedir)/ffcall-abi.h + cd @subdir@ && $(MAKE) install + +installdirs : force + mkdir -p $(DESTDIR)$(prefix) + mkdir -p $(DESTDIR)$(libdir) + mkdir -p $(DESTDIR)$(includedir) + cd @subdir@ && $(MAKE) installdirs + +uninstall : force + cd @subdir@ && $(MAKE) uninstall + $(LIBTOOL_UNINSTALL) $(RM) $(DESTDIR)$(libdir)/libffcall.la + $(RM) $(DESTDIR)$(includedir)/ffcall-abi.h + $(RM) $(DESTDIR)$(includedir)/ffcall-version.h + +check : force + cd @subdir@ && $(MAKE) check + +extracheck : force + cd @subdir@ && $(MAKE) extracheck + +MOSTLYCLEANDIRS = .libs _libs +MOSTLYCLEANFILES = \ + *.@OBJEXT@ *.lo core \ + libffcall.* + +mostlyclean : force + cd @subdir@ && $(MAKE) mostlyclean + $(RM) -r $(MOSTLYCLEANDIRS) + $(RM) $(MOSTLYCLEANFILES) + +clean : force + cd @subdir@ && $(MAKE) clean + $(RM) -r $(MOSTLYCLEANDIRS) + $(RM) $(MOSTLYCLEANFILES) + +DISTCLEANFILES = \ + config.status config.log config.cache Makefile config.h ffcall-version.h libtool \ + stamp-h1 stamp-h2 + +distclean : force + cd @subdir@; if test -f Makefile; then $(MAKE) distclean; fi + $(RM) -r $(MOSTLYCLEANDIRS) + $(RM) $(MOSTLYCLEANFILES) + $(RM) $(DISTCLEANFILES) + +maintainer-clean : force + cd @subdir@; if test -f Makefile; then $(MAKE) maintainer-clean; fi + $(RM) -r $(MOSTLYCLEANDIRS) + $(RM) $(MOSTLYCLEANFILES) + $(RM) $(DISTCLEANFILES) + + +# List of source files (committed in version control). +SOURCE_FILES = \ + COPYING DEPENDENCIES INSTALL.os2 INSTALL.windows NEWS PLATFORMS README \ + ChangeLog \ + VERSION \ + Makefile.devel \ + Makefile.maint \ + Makefile.in \ + configure.ac \ + m4/as-underscore.m4 \ + m4/cc-gcc.m4 \ + m4/codeexec.m4 \ + m4/endianness.m4 \ + m4/general.m4 \ + m4/getpagesize.m4 \ + m4/ireg.m4 \ + m4/ln.m4 \ + m4/mach-vm.m4 \ + m4/mmap.m4 \ + m4/mprotect.m4 \ + m4/proto.m4 \ + m4/shm.m4 \ + m4/smallstruct.m4 \ + common/asm-alpha.sh \ + common/asm-arm.sh common/asm-arm.h \ + common/asm-hppa.sh common/asm-hppa.h \ + common/asm-hppa64.sh common/asm-hppa64.h \ + common/asm-i386.sh common/asm-i386.h \ + common/asm-m68k.sh common/asm-m68k.h \ + common/asm-mips.sh common/asm-mips.h \ + common/asm-powerpc.sh \ + common/asm-riscv.sh \ + common/asm-s390.sh \ + common/asm-sparc.sh common/asm-sparc.h \ + common/asm-x86_64.sh common/asm-x86_64.h \ + common/noexecstack.h common/noexecstack-arm.h \ + common/structcpy.c \ + common/uniq-u.c \ + ffcall-version.in.h dummy/ffcall-version.h \ + ffcall-abi.h \ + ffcall-stdint.h \ + ffcall-version.c \ + testcases.c +# List of distributed files imported from other packages or directories. +LIBTOOL_IMPORTED_FILES = \ + build-aux/ltmain.sh \ + m4/libtool.m4 \ + m4/lt~obsolete.m4 \ + m4/ltoptions.m4 \ + m4/ltsugar.m4 \ + m4/ltversion.m4 +GNULIB_IMPORTED_FILES = \ + build-aux/ar-lib \ + build-aux/compile \ + build-aux/config.guess \ + build-aux/config.sub \ + build-aux/install-sh \ + gnulib-m4/*.m4 +AUTOMAKE_IMPORTED_FILES = \ + build-aux/missing +IMPORTED_FILES = \ + $(LIBTOOL_IMPORTED_FILES) $(GNULIB_IMPORTED_FILES) $(AUTOMAKE_IMPORTED_FILES) +# List of files copied by autogen.sh. +COPIED_FILES = \ + callback/trampoline_r/PORTING \ + callback/trampoline_r/cache.c \ + callback/trampoline_r/cache-alpha.c \ + callback/trampoline_r/cache-hppa.c +# List of distributed files generated by Makefile.maint. +GENERATED_FILES = \ + aclocal.m4 \ + configure \ + config.h.in +# List of distributed files. +DISTFILES = $(SOURCE_FILES) $(IMPORTED_FILES) $(COPIED_FILES) $(GENERATED_FILES) + +distdir : $(DISTFILES) + for file in $(DISTFILES); do \ + if test -f $$file; then dir='.'; else dir='$(srcdir)'; fi; \ + destdir=`echo '$(distdir)'/$$file | sed -e 's|//*[^/]*$$||'`; \ + test -d "$$destdir" || mkdir -p "$$destdir"; \ + cp -p "$$dir/$$file" '$(distdir)'/$$file || exit 1; \ + done + test -d '$(distdir)'/@subdir@ || mkdir '$(distdir)'/@subdir@; cd @subdir@ && $(MAKE) distdir distdir='$(distdir)'/@subdir@ + + +# Creating a distribution tarball. +# Example: make dist VERSION=1.13-pre-20161227 +PACKAGE = @PACKAGE_TARNAME@ +VERSION = @VERSION@ +TAR = tar +GZIP = gzip + +dist : force + tmpdistdir=$(PACKAGE)-$(VERSION); \ + abstmpdistdir=`pwd`/$$tmpdistdir; \ + rm -rf $$tmpdistdir $$tmpdistdir.tar $$tmpdistdir.tar.gz \ + && mkdir $$tmpdistdir \ + && $(MAKE) distdir distdir="$$abstmpdistdir" \ + && $(TAR) chof $$tmpdistdir.tar --owner=root --group=root $$tmpdistdir \ + && $(GZIP) -9 $$tmpdistdir.tar \ + && rm -rf $$tmpdistdir + + +force : + diff --git a/Makefile.maint b/Makefile.maint new file mode 100644 index 0000000..d344ae7 --- /dev/null +++ b/Makefile.maint @@ -0,0 +1,176 @@ +# maintainer -*-Makefile-*- + +SHELL = /bin/sh +MAKE = make + +# You need to use this precise version of GNU Automake. +# If you want to use a different version of GNU Automake, you are on your own! +ACLOCAL = aclocal-1.15 +AUTOMAKE = automake-1.15 + +# You need to use this precise version of GNU Autoconf and create +# symbolic links +# $ ln -s `which autoconf` autoconf-`autoconf --version | sed -e '2,$d' -e 's/^[^0-9]*//'` +# $ ln -s `which autoheader` autoheader-`autoheader --version | sed -e '2,$d' -e 's/^[^0-9]*//'` +# If you want to use a different version of GNU Autoconf, you are on your own! +AUTOCONF = autoconf-2.69 +AUTOHEADER = autoheader-2.69 + +CP = cp +RM = rm -f + +# ==================== Easily regeneratable files ==================== + +.PHONY : all +all : aclocal.m4 configures check-configures config-h-in Makefile-ins force + cd avcall && $(MAKE) -f Makefile.maint all + cd vacall && $(MAKE) -f Makefile.maint all + cd trampoline && $(MAKE) -f Makefile.maint all + cd callback && $(MAKE) -f Makefile.maint all + + +# Files originating from GNU libtool. + +# It is important to get ltmain.sh and libtool.m4 from the same version of +# libtool. Don't rely on what's installed in /usr/share or similar. + +.PHONY : libtool-imported-files +libtool-imported-files : force + test -n "$(LIBTOOL_RELEASE)" || { echo "Variable LIBTOOL_RELEASE not set." 1>&2; exit 1; } + test -f "$(LIBTOOL_RELEASE)" || { echo "File $(LIBTOOL_RELEASE) does not exist." 1>&2; exit 1; } + rm -rf libtool.tmp + mkdir libtool.tmp + gzip -d -c < "$(LIBTOOL_RELEASE)" | (cd libtool.tmp && tar -xf -) + test -d build-aux || mkdir build-aux + for destfile in m4/libtool.m4 m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 m4/lt~obsolete.m4 build-aux/ltmain.sh; do \ + name=`echo $$destfile | sed -e 's|^.*/||'`; \ + srcfile=`find libtool.tmp -name $$name -print | sed 1q`; \ + if test -n "$$srcfile"; then \ + if test -f $$destfile && cmp "$$srcfile" $$destfile > /dev/null; then \ + : ; \ + else \ + mv "$$srcfile" $$destfile; \ + fi; \ + else \ + echo "File $(LIBTOOL_RELEASE) does not contain the expected files of a libtool release." 1>&2; \ + exit 1; \ + fi; \ + done + rm -rf libtool.tmp + : "Allow building statically linked binaries, through LDFLAGS=-static ." + wget --execute netrc=off --no-verbose --retry-connrefused --timeout=60 -O libtool-allow-static.diff https://lists.gnu.org/archive/html/bug-libtool/2017-07/txt7Q9LRXv6HS.txt + chmod u+w build-aux/ltmain.sh + patch build-aux/ltmain.sh < libtool-allow-static.diff + rm -f libtool-allow-static.diff + : "Fix -export-symbols and -export-symbols-regex support on Solaris 11.3" + wget --execute netrc=off --no-verbose --retry-connrefused --timeout=60 -O libtool-solaris11-fix.diff 'https://savannah.gnu.org/patch/download.php?file_id=42205' + chmod u+w m4/libtool.m4 + patch -p1 < libtool-solaris11-fix.diff + rm -f libtool-solaris11-fix.diff + +.PHONY : libtool-clean +libtool-clean : force + $(RM) m4/libtool.m4 build-aux/ltmain.sh + + +# Files brought in by gnulib-tool. + +GNULIB_MODULES = \ + ansi-c++-opt \ + host-cpu-c-abi \ + lock \ + longlong \ + nocrash \ + stdint \ + stdnoreturn + +gnulib-m4/gnulib-cache.m4 : + if test -n "$$GNULIB_TOOL"; then \ + $$GNULIB_TOOL --source-base=gnulib-lib --m4-base=gnulib-m4 --aux-dir=build-aux --libtool --no-changelog \ + --import $(GNULIB_MODULES); \ + fi + +.PHONY : gnulib-imported-files +gnulib-imported-files : force +# Get up-to-date versions of files imported from https://git.savannah.gnu.org/gitweb/?p=automake.git;a=tree;f=lib via gnulib. + if test -n "$$GNULIB_TOOL"; then \ + for file in ar-lib compile install-sh; do \ + $$GNULIB_TOOL --copy-file build-aux/$$file || exit $$?; \ + chmod a+x build-aux/$$file || exit $$?; \ + done; \ + fi +# Get up-to-date versions of files imported from https://git.savannah.gnu.org/gitweb/?p=config.git;a=tree via gnulib. + if test -n "$$GNULIB_TOOL"; then \ + for file in config.guess config.sub; do \ + $$GNULIB_TOOL --copy-file build-aux/$$file || exit $$?; \ + chmod a+x build-aux/$$file || exit $$?; \ + done; \ + fi + +.PHONY : gnulib-clean +gnulib-clean : force +# Move gnulib-m4/gnulib-cache.m4 away, so that the target 'gnulib-m4/gnulib-cache.m4' will actually do something. + if test -f gnulib-m4/gnulib-cache.m4; then \ + mv gnulib-m4/gnulib-cache.m4 gnulib-m4/gnulib-cache.m4~; \ + fi +# No need to remove the stale files. gnulib-tool does this itself, thanks to gnulib-m4/gnulib-comp.m4. +# rm -rf gnulib-m4 + + +# Files generated by GNU Autoconf and GNU Automake. + +AUTOCONF_CACHE = autom4te.cache + +ALL_CONFIGURE = configure +ALL_CONFIGURE_AC = configure.ac + +aclocal.m4 : $(ALL_CONFIGURE_AC) $(wildcard m4/*.m4) $(wildcard gnulib-m4/*.m4) + $(ACLOCAL) --output=aclocal.m4 -I m4 -I gnulib-m4 + +.PHONY : configures +configures : $(ALL_CONFIGURE) + +AUTOCONF_FILES = aclocal.m4 $(wildcard m4/*.m4) $(wildcard gnulib-m4/*.m4) + +configure : configure.ac $(AUTOCONF_FILES) + $(AUTOCONF) && rm -rf autom4te.cache + +.PHONY : check-configures +check-configures : $(ALL_CONFIGURE) + set -e; for f in $(ALL_CONFIGURE); do bash -x -n $$f; done + + +ALL_CONFIG_H_IN = config.h.in + +.PHONY : config-h-in +config-h-in : $(ALL_CONFIG_H_IN) + +config.h.in : configure.ac $(AUTOCONF_FILES) + srcdir=`pwd`; $(AUTOHEADER) --include="$$srcdir" && rm -rf autom4te.cache + + +ALL_MAKEFILE_IN_FROM_AM = gnulib-lib/Makefile.in + +.PHONY: Makefile-ins +Makefile-ins : $(ALL_MAKEFILE_IN_FROM_AM) + +gnulib-lib/Makefile.in : gnulib-lib/Makefile.am configure.ac $(AUTOCONF_FILES) + : "Make sure we get new versions of files brought in by automake." + (cd build-aux && rm -f depcomp missing) + $(AUTOMAKE) --add-missing --copy && rm -rf autom4te.cache + + +# ==================== Cleanup ==================== + +.PHONY : totally-clean +totally-clean : force + cd avcall && $(MAKE) -f Makefile.maint totally-clean + cd vacall && $(MAKE) -f Makefile.maint totally-clean + cd trampoline && $(MAKE) -f Makefile.maint totally-clean + cd callback && $(MAKE) -f Makefile.maint totally-clean + rm -f $(ALL_CONFIGURE) $(ALL_CONFIG_H_IN) + rm -f aclocal.m4 + rm -rf `find . -name $(AUTOCONF_CACHE) -print` + + +force : diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..d724008 --- /dev/null +++ b/NEWS @@ -0,0 +1,222 @@ +New in 2.2: + +* Added support for the following platforms: + (Previously, a build on these platforms failed.) + - armv6 (Raspberry Pi): Linux. + - hppa: Linux 32-bit. + - riscv32: Linux with ilp32d ABI. + - riscv64: Linux with lp64d ABI. + +* The build for the mips 32-bit ABI is now compatible with toolchains for + the 'fpxx' ABI variant. The downside is that the mips1 architecture is + no longer supported. + +* Fixed a bug regarding passing of more than 8 arguments on the following + platforms: + - arm64: Linux 64-bit. + +* Fixed a stack corruption bug on the following platforms: + - hppa: HP-UX 32-bit. + +New in 2.1: + +* Added support for the following platforms: + (Previously, a build on these platforms failed.) + - arm: Linux with PIE-enabled gcc. + - x86_64: Solaris 11.3. + - OpenBSD 6.1. + - HardenedBSD 10 and 11. + +* Fixed a bug regarding passing of pointers on the following platforms: + - x86_64: Linux with x32 ABI: CC="gcc -mx32". + +* Fixed a crash in trampoline on the following platforms: + - mips: Linux with CC="gcc -mabi=64", little endian. + +New in 2.0: + +* The package now installs a library libffcall.{a,so}. It contains the + 'avcall' and 'callback' packages. The libraries libavcall.{a,so} and + libcallback.{a,so} are still installed as well, but are deprecated. + +* The installed libraries are now installed as shared libraries by default + (except for libvacall, which is still a static library only). + +* The installed shared libraries are now properly versioned. This means that + when installing with --enable-shared, upgrading to a newer version of + libffcall will not break existing binaries. + +* The installed include files are now platform independent. This means that + you can now install libffcall for different ABIs on the same system, using + the same --prefix option but different --exec-prefix options for each ABI. + +* API changes in : + - The second argument of alloc_trampoline() is now a 'void**', rather + than a 'void*'. + - The return value of trampoline_variable() is now a 'void**', rather + than a 'void*'. + - The argument of trampoline_address(), trampoline_variable(), + trampoline_data() is now a function pointer instead of a 'void*'. + +* API changes in : + - The argument of callback_address(), callback_data() is now a function + pointer instead of a 'void*'. + +* Fixed a bug regarding floating-point arguments followed by + non-floating-point arguments on the following platforms: + - arm: Linux 32-bit, with hardware floats. + - powerpc: Linux 32-bit. + - s390: Linux. + +* Fixed a bug regarding structure returns on the following platforms: + - i386: FreeBSD. + - i386: MinGW. + - mips: old 32-bit ABI (Linux, IRIX). + +* Added support for the following platforms: + (Previously, a build on these platforms failed.) + - i386: MSVC 14. + - x86_64: Cygwin. + - x86_64: MinGW. + - x86_64: MSVC 14. + - hppa64: HP-UX 11. + - m68k: Linux. + +* Verified support for the following platforms: + (A build on these platforms worked and still works.) + - i386: FreeBSD, NetBSD, OpenBSD, DragonFly BSD. + - i386: Hurd. + - x86_64: FreeBSD, NetBSD, OpenBSD. + +New in 1.13: + +* The license has been changed from GPLv2 to GPLv2+. + +* Added support for the following platforms: + (Previously, a build on these platforms failed.) + - x86_64: Mac OS X 64-bit. + - x86_64: Solaris 64-bit. + - x86_64: Linux with x32 ABI: CC="gcc -mx32". + - arm: Linux 32-bit, without hardware floats. + - arm64: Linux 64-bit. + - s390x: Linux 64-bit. + - powerpc: AIX 64-bit. + - mips: IRIX 6.5 with CC="cc -32". + - sparc: Solaris 64-bit. + +* Fixed support for the following platforms: + (Previously, a build on these platforms appeared to succeed but was buggy.) + - x86_64: Linux. + - arm: Linux 32-bit, with hardware floats. + - powerpc: Linux 64-bit. + - mips: Linux with CC="gcc -mabi=32". + - mips: Linux with CC="gcc -mabi=n32". + - mips: Linux with CC="gcc -mabi=64". + - mips: IRIX 6.5 with CC="gcc -mabi=n32". + - s390: Linux. + - sparc: Linux 64-bit. + - ia64: Linux. + - hppa: HP-UX 32-bit. + +* Verified support for the following platforms: + (A build on these platforms worked and still works.) + - i386: Linux, Solaris, Mac OS X. + - powerpc: Linux 32-bit. + - powerpc: AIX 32-bit. + - powerpc: MacOS X. + - mips: IRIX 6.5 with CC="cc -n32". + - sparc: Solaris 32-bit. + - sparc: Linux 32-bit: CC="gcc -m32". + - alpha: Linux. + +* Support for a security feature: On Linux and FreeBSD platforms, linking with + the libffcall libraries no longer causes the stack to become executable. + +New in 1.12: + +* Added ppc64le to the list of supported architectures. + +New in 1.11: + +* Header now define LIBFFCALL_VERSION (to 0x010B). +* Better support for IA64 on Linux (kernel 2.6.16+ and gcc 4.1.0+). +* Added ARM support from Jonathan Olson (debian 1.10-2). +* Added MIPSel support from Thiemo Seufer (debian 1.10-2). +* Added ARMel support from Max Lapan. + +New in 1.10: + +* Added support for PowerPC NetBSD. + +New in 1.9: + +* Added support for x86_64 (AMD64) Linux. +* Added support for PowerPC MacOS X. + +New in 1.8: + +* Added support for IA64 Linux. + +New in 1.7: + +* Struct types containing elements other than int, long, long long, pointer + are not supported any more. Passing them as arguments and results is too + hairy. +* Added support for PowerPC Linux. + +New in 1.6: + +* The avcall and callback packages are compiled as position-independent code, + if CC="gcc -fPIC". +* The avcall and callback packages are built as shared libraries, if + the option "--enable-shared" is passed to configure. +* The package can now be built with CC="gcc -x c++". +* Improved RS6000/PowerPC support. +* Improved support for gcc on Irix6 (-n32 ABI). +* Added preliminary support for 64-bit SPARC. + +New in 1.5: + +* Added support for m68k Linux. + +New in 1.4: + +* Added support for the two new ABIs on Irix6 (-n32, -64). +* A fix for DEC Alpha. + +New in 1.3.1: + +* Added support for Mingw32 on Win32. +* Fixed a compilation problem in trampoline on m68k NetBSD. +* Fixed an installation problem with clisp: When configured outside the source + directory, callback.h would not be copied into the build directory. + +New in 1.3: + +* Added the callback package, a reentrant combination of vacall and trampoline. +* The avcall and callback packages are multithread-safe. +* Fixed bugs in trampoline on hppa and rs6000. +* On hppa, added support for gcc-2.7.2, although its calling convention is + different from gcc-2.6.3. + +New in 1.2.1: + +* Added support for MSVC5 on Win32. + +New in 1.2: + +* Support passing/returning values of type ‘long long’ and ‘unsigned long long’ + on platforms which have these types. +* Support for "stdcall" calling convention on i386. +* Added support for Cygwin32 and MSVC4 on Win32. +* Added support for EMX on OS/2. +* Added support for m68k AmigaOS (Jörg Höhle). +* Added support for m68k SunOS 4.0.3. +* More reliable cache-flushing in trampoline. + +New in 1.1: + +* Added support for SUNWspro cc on Sparc Solaris. +* Added support for AIX 4. +* Added preliminary support for 64-bit MIPS. + diff --git a/PLATFORMS b/PLATFORMS new file mode 100644 index 0000000..729a200 --- /dev/null +++ b/PLATFORMS @@ -0,0 +1,52 @@ +Supported CPUs: (Put the GNU config.guess values here.) + i386 i486-unknown-linux (gcc), i686-unknown-gnu0.9 (gcc), + i386-unknown-sysv4.0 (gcc, /usr/bin/cc, /usr/ucb/cc), + i386-pc-solaris2.6 (gcc), i386-pc-solaris2.10 (gcc, cc), + i486-unknown-sco3.2v4.2 (gcc, cc -Of), + i486-unknown-os2emx (gcc), i386-pc-cygwin32 (gcc), + i386-w64-mingw32 (gcc, MSVC 14), + i586-unknown-freebsd11.0 (cc), i386-unknown-dragonfly3.8 (gcc), + i386-unknown-netbsdelf7.0 (gcc), i386-unknown-openbsd6.0 (gcc), + i586-pc-haiku (gcc-x86), i386-pc-minix (clang) + m68k m68k-next-nextstep3 (cc), m68k-sun-sunos4.0 (cc), + m68k-unknown-linux (gcc) + mips mips-sgi-irix4.0.5 (gcc, cc -ansi, cc -D__STDC__, cc -cckr), + mips-sgi-irix5.2 (gcc, cc -ansi, cc -D__STDC__, cc -cckr), + mips-sgi-irix5.3 (gcc, cc -ansi, cc -D__STDC__, cc -cckr), + mips-sgi-irix6.2 (cc -32), + mips-sgi-irix6.4 (cc -32, cc -n32, cc -64), + mips-sgi-irix6.5 (cc -32, cc -n32, gcc -mabi=n32), + mips-unknown-linux (gcc -mabi=32), + mips64-unknown-linux (gcc -mabi=n32, gcc -mabi=64) + sparc sparc-sun-sunos4.1.1 (gcc, cc), sparc-sun-solaris2.3 (gcc) + sparc-sun-solaris2.4 (gcc, cc), sparc-sun-solaris2.10 (gcc, cc), + sparc64-sun-solaris2.10 (gcc -m64, cc -xarch=generic64), + sparc-unknown-linux (gcc), sparc64-unknown-linux (gcc), + sparc-unknown-netbsdelf7.1 (gcc), + sparc64-unknown-netbsd8.0 (gcc) + alpha alpha-dec-osf3.0 (gcc, cc), alpha-dec-osf4.0 (gcc, cc), + alphaev67-unknown-linux (gcc) + hppa hppa1.0-hp-hpux8.00 (gcc, cc), hppa1.1-hp-hpux9.05 (cc), + hppa1.1-hp-hpux10.01 (cc), hppa2.0-hp-hpux10.20 (cc +DA1.1), + hppa2.0w-hp-hpux11.31 (cc), hppa-unknown-linux (gcc) + hppa64 hppa64-hp-hpux11.31 (cc +DD64) + arm armv5tejl-unknown-linux (gcc), armv6l-unknown-linux (gcc), + armv7l-unknown-linux (gcc) + arm64 aarch64-unknown-linux (gcc) + powerpc powerpc-ibm-aix4.1.4.0 (cc), powerpc-ibm-aix7.1.3.0 (xlc, gcc), + powerpc-unknown-linux (gcc), powerpc-apple-darwin6.8 (gcc), + powerpc-apple-darwin9.8.0 (gcc) + powerpc64 powerpc-ibm-aix7.1.3.0 (gcc -maix64, xlc -q64; AR="ar -X 64"), + powerpc64-unknown-linux (gcc -m64), + powerpc64le-unknown-linux (gcc) + ia64 ia64-unknown-linux (gcc) + x86_64 x86_64-suse-linux (gcc), x86_64-unknown-linux (gcc -mx32), + x86_64-pc-solaris2.10 (gcc -m64, cc -xarch=generic64), + x86_64-pc-cygwin (gcc), x86_64-w64-mingw32 (gcc, MSVC 14), + x86_64-unknown-freebsd11.0 (cc), x86_64-unknown-netbsd7.0 (gcc), + x86_64-unknown-openbsd6.0 (gcc) + s390 s390x-ibm-linux (gcc -m31) + s390x s390x-ibm-linux (gcc) + riscv32 riscv32-unknown-linux (gcc -mabi=ilp32d) + riscv64 riscv64-unknown-linux (gcc -mabi=lp64d) + diff --git a/README b/README new file mode 100644 index 0000000..c78f9d8 --- /dev/null +++ b/README @@ -0,0 +1,112 @@ +libffcall - foreign function call libraries + +This is a library which can be used to build foreign function call interfaces +in embedded interpreters. + + +Installed libraries and header files: + + It installs a library libffcall.{a,so}; to link with it, use the compiler + option '-lffcall'. + + It consists of two parts: + * avcall - calling C functions with variable arguments. + Its include file is . + * callback - closures with variable arguments as first-class C functions. + Its include file is . + + Additionally, you can determine the libffcall version by including + . + + For backward compatibility with versions 1.x, libraries libavcall.{a,so} + and libcallback.{a,so} are installed as well. But they are deprecated; + use libffcall.{a,so} instead. + + +Installation instructions: + + mkdir builddir + cd builddir + ../configure --cache-file=config.cache + make + make check + make install + + +Files in this package: + + Documentation: + + README this text + COPYING free software license + PLATFORMS list of supported platforms + + Source: + + avcall/* the avcall package + (compiled into libffcall) + + vacall/* the vacall package + Implements C functions accepting variable argument + prototypes. + This is a non-reentrant variant of part of 'callback'. + *Not* compiled into libffcall. + + trampoline/* the trampoline package + Implements closures as first-class C functions. + This is a non-reentrant variant of part of 'callback'. + *Not* compiled into libffcall. + + callback/* the callback package + (compiled into libffcall) + + Building: + + configure configuration script + configure.ac autoconf source for the configuration script + m4/* auxiliary configuration scripts + Makefile.in Makefile master + + +Copyright notice: + +Copyright 1993-1995 Bill Triggs (original avcall) +Copyright 1995-2017 Bruno Haible (everything) +Copyright 1997 Jörg Höhle (m68k AmigaOS support) +Copyright 2000 Adam Fedor (PowerPC MacOS support) +Copyright 2001-2012 Sam Steingold (build infrastructure) +Copyright 2001-2002 Gerhard Tonn (s390 support) +Copyright 2004 Paul Guyot (PowerPC MacOS support) +Copyright 2005 Thiemo Seufer (MIPS EL support) +Copyright 2009 Max Lapan (ARM EL support) +Copyright 2010 Valery Ushakov (SPARC64 improvements) + +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, see . + + +Distribution: + +git: +$ git clone git://git.savannah.gnu.org/libffcall.git +See https://savannah.gnu.org/git/?group=libffcall for more info. + +Bug reports: + +Report bugs + - in the bug tracker at + - or by email to . + +Homepage: + + https://www.gnu.org/software/libffcall/ diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..8bbe6cf --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +2.2 diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 0000000..3380e50 --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,1194 @@ +# generated automatically by aclocal 1.15.1 -*- Autoconf -*- + +# Copyright (C) 1996-2017 Free Software Foundation, Inc. + +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, +[m4_warning([this file was generated for autoconf 2.69. +You have another version of autoconf. It may work, but is not guaranteed to. +If you have problems, you may need to regenerate the build system entirely. +To do so, use the procedure documented by the package, typically 'autoreconf'.])]) + +# Copyright (C) 2002-2017 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_AUTOMAKE_VERSION(VERSION) +# ---------------------------- +# Automake X.Y traces this macro to ensure aclocal.m4 has been +# generated from the m4 files accompanying Automake X.Y. +# (This private macro should not be called outside this file.) +AC_DEFUN([AM_AUTOMAKE_VERSION], +[am__api_version='1.15' +dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to +dnl require some minimum version. Point them to the right macro. +m4_if([$1], [1.15.1], [], + [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl +]) + +# _AM_AUTOCONF_VERSION(VERSION) +# ----------------------------- +# aclocal traces this macro to find the Autoconf version. +# This is a private macro too. Using m4_define simplifies +# the logic in aclocal, which can simply ignore this definition. +m4_define([_AM_AUTOCONF_VERSION], []) + +# AM_SET_CURRENT_AUTOMAKE_VERSION +# ------------------------------- +# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. +# This function is AC_REQUIREd by AM_INIT_AUTOMAKE. +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], +[AM_AUTOMAKE_VERSION([1.15.1])dnl +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) + +# AM_AUX_DIR_EXPAND -*- Autoconf -*- + +# Copyright (C) 2001-2017 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets +# $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to +# '$srcdir', '$srcdir/..', or '$srcdir/../..'. +# +# Of course, Automake must honor this variable whenever it calls a +# tool from the auxiliary directory. The problem is that $srcdir (and +# therefore $ac_aux_dir as well) can be either absolute or relative, +# depending on how configure is run. This is pretty annoying, since +# it makes $ac_aux_dir quite unusable in subdirectories: in the top +# source directory, any form will work fine, but in subdirectories a +# relative path needs to be adjusted first. +# +# $ac_aux_dir/missing +# fails when called from a subdirectory if $ac_aux_dir is relative +# $top_srcdir/$ac_aux_dir/missing +# fails if $ac_aux_dir is absolute, +# fails when called from a subdirectory in a VPATH build with +# a relative $ac_aux_dir +# +# The reason of the latter failure is that $top_srcdir and $ac_aux_dir +# are both prefixed by $srcdir. In an in-source build this is usually +# harmless because $srcdir is '.', but things will broke when you +# start a VPATH build or use an absolute $srcdir. +# +# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, +# iff we strip the leading $srcdir from $ac_aux_dir. That would be: +# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` +# and then we would define $MISSING as +# MISSING="\${SHELL} $am_aux_dir/missing" +# This will work as long as MISSING is not called from configure, because +# unfortunately $(top_srcdir) has no meaning in configure. +# However there are other variables, like CC, which are often used in +# configure, and could therefore not use this "fixed" $ac_aux_dir. +# +# Another solution, used here, is to always expand $ac_aux_dir to an +# absolute PATH. The drawback is that using absolute paths prevent a +# configured tree to be moved without reconfiguration. + +AC_DEFUN([AM_AUX_DIR_EXPAND], +[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl +# Expand $ac_aux_dir to an absolute path. +am_aux_dir=`cd "$ac_aux_dir" && pwd` +]) + +# AM_CONDITIONAL -*- Autoconf -*- + +# Copyright (C) 1997-2017 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +AC_DEFUN([AM_CONDITIONAL], +[AC_PREREQ([2.52])dnl + m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +AC_SUBST([$1_TRUE])dnl +AC_SUBST([$1_FALSE])dnl +_AM_SUBST_NOTMAKE([$1_TRUE])dnl +_AM_SUBST_NOTMAKE([$1_FALSE])dnl +m4_define([_AM_COND_VALUE_$1], [$2])dnl +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi +AC_CONFIG_COMMANDS_PRE( +[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then + AC_MSG_ERROR([[conditional "$1" was never defined. +Usually this means the macro was only invoked conditionally.]]) +fi])]) + +# Copyright (C) 1999-2017 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + + +# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be +# written in clear, in which case automake, when reading aclocal.m4, +# will think it sees a *use*, and therefore will trigger all it's +# C support machinery. Also note that it means that autoscan, seeing +# CC etc. in the Makefile, will ask for an AC_PROG_CC use... + + +# _AM_DEPENDENCIES(NAME) +# ---------------------- +# See how the compiler implements dependency checking. +# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". +# We try a few techniques and use that to set a single cache variable. +# +# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was +# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular +# dependency, and given that the user is not expected to run this macro, +# just rely on AC_PROG_CC. +AC_DEFUN([_AM_DEPENDENCIES], +[AC_REQUIRE([AM_SET_DEPDIR])dnl +AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl +AC_REQUIRE([AM_MAKE_INCLUDE])dnl +AC_REQUIRE([AM_DEP_TRACK])dnl + +m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], + [$1], [CXX], [depcc="$CXX" am_compiler_list=], + [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], + [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], + [$1], [UPC], [depcc="$UPC" am_compiler_list=], + [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], + [depcc="$$1" am_compiler_list=]) + +AC_CACHE_CHECK([dependency style of $depcc], + [am_cv_$1_dependencies_compiler_type], +[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named 'D' -- because '-MD' means "put the output + # in D". + rm -rf conftest.dir + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_$1_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` + fi + am__universal=false + m4_case([$1], [CC], + [case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac], + [CXX], + [case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac]) + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with + # Solaris 10 /bin/sh. + echo '/* dummy */' > sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with '-c' and '-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle '-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs. + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # After this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested. + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvc7 | msvc7msys | msvisualcpp | msvcmsys) + # This compiler won't grok '-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_$1_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_$1_dependencies_compiler_type=none +fi +]) +AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) +AM_CONDITIONAL([am__fastdep$1], [ + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) +]) + + +# AM_SET_DEPDIR +# ------------- +# Choose a directory name for dependency files. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES. +AC_DEFUN([AM_SET_DEPDIR], +[AC_REQUIRE([AM_SET_LEADING_DOT])dnl +AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl +]) + + +# AM_DEP_TRACK +# ------------ +AC_DEFUN([AM_DEP_TRACK], +[AC_ARG_ENABLE([dependency-tracking], [dnl +AS_HELP_STRING( + [--enable-dependency-tracking], + [do not reject slow dependency extractors]) +AS_HELP_STRING( + [--disable-dependency-tracking], + [speeds up one-time build])]) +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' + am__nodep='_no' +fi +AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) +AC_SUBST([AMDEPBACKSLASH])dnl +_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl +AC_SUBST([am__nodep])dnl +_AM_SUBST_NOTMAKE([am__nodep])dnl +]) + +# Generate code to set up dependency tracking. -*- Autoconf -*- + +# Copyright (C) 1999-2017 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + + +# _AM_OUTPUT_DEPENDENCY_COMMANDS +# ------------------------------ +AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], +[{ + # Older Autoconf quotes --file arguments for eval, but not when files + # are listed without --file. Let's play safe and only enable the eval + # if we detect the quoting. + case $CONFIG_FILES in + *\'*) eval set x "$CONFIG_FILES" ;; + *) set x $CONFIG_FILES ;; + esac + shift + for mf + do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named 'Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # Grep'ing the whole file is not good either: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then + dirpart=`AS_DIRNAME("$mf")` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running 'make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "$am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`AS_DIRNAME(["$file"])` + AS_MKDIR_P([$dirpart/$fdir]) + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done + done +} +])# _AM_OUTPUT_DEPENDENCY_COMMANDS + + +# AM_OUTPUT_DEPENDENCY_COMMANDS +# ----------------------------- +# This macro should only be invoked once -- use via AC_REQUIRE. +# +# This code is only required when automatic dependency tracking +# is enabled. FIXME. This creates each '.P' file that we will +# need in order to bootstrap the dependency handling code. +AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], +[AC_CONFIG_COMMANDS([depfiles], + [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], + [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) +]) + +# Do all the work for Automake. -*- Autoconf -*- + +# Copyright (C) 1996-2017 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This macro actually does too much. Some checks are only needed if +# your package does certain things. But this isn't really a big deal. + +dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. +m4_define([AC_PROG_CC], +m4_defn([AC_PROG_CC]) +[_AM_PROG_CC_C_O +]) + +# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) +# AM_INIT_AUTOMAKE([OPTIONS]) +# ----------------------------------------------- +# The call with PACKAGE and VERSION arguments is the old style +# call (pre autoconf-2.50), which is being phased out. PACKAGE +# and VERSION should now be passed to AC_INIT and removed from +# the call to AM_INIT_AUTOMAKE. +# We support both call styles for the transition. After +# the next Automake release, Autoconf can make the AC_INIT +# arguments mandatory, and then we can depend on a new Autoconf +# release and drop the old call support. +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_PREREQ([2.65])dnl +dnl Autoconf wants to disallow AM_ names. We explicitly allow +dnl the ones we care about. +m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl +AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl +AC_REQUIRE([AC_PROG_INSTALL])dnl +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) + fi +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi +AC_SUBST([CYGPATH_W]) + +# Define the identity of the package. +dnl Distinguish between old-style and new-style calls. +m4_ifval([$2], +[AC_DIAGNOSE([obsolete], + [$0: two- and three-arguments forms are deprecated.]) +m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl + AC_SUBST([PACKAGE], [$1])dnl + AC_SUBST([VERSION], [$2])], +[_AM_SET_OPTIONS([$1])dnl +dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. +m4_if( + m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), + [ok:ok],, + [m4_fatal([AC_INIT should be called with package and version arguments])])dnl + AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl + AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl + +_AM_IF_OPTION([no-define],, +[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) + AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl + +# Some tools Automake needs. +AC_REQUIRE([AM_SANITY_CHECK])dnl +AC_REQUIRE([AC_ARG_PROGRAM])dnl +AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) +AM_MISSING_PROG([AUTOCONF], [autoconf]) +AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) +AM_MISSING_PROG([AUTOHEADER], [autoheader]) +AM_MISSING_PROG([MAKEINFO], [makeinfo]) +AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl +AC_REQUIRE([AC_PROG_MKDIR_P])dnl +# For better backward compatibility. To be removed once Automake 1.9.x +# dies out for good. For more background, see: +# +# +AC_SUBST([mkdir_p], ['$(MKDIR_P)']) +# We need awk for the "check" target (and possibly the TAP driver). The +# system "awk" is bad on some platforms. +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([AC_PROG_MAKE_SET])dnl +AC_REQUIRE([AM_SET_LEADING_DOT])dnl +_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], + [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], + [_AM_PROG_TAR([v7])])]) +_AM_IF_OPTION([no-dependencies],, +[AC_PROVIDE_IFELSE([AC_PROG_CC], + [_AM_DEPENDENCIES([CC])], + [m4_define([AC_PROG_CC], + m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl +AC_PROVIDE_IFELSE([AC_PROG_CXX], + [_AM_DEPENDENCIES([CXX])], + [m4_define([AC_PROG_CXX], + m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl +AC_PROVIDE_IFELSE([AC_PROG_OBJC], + [_AM_DEPENDENCIES([OBJC])], + [m4_define([AC_PROG_OBJC], + m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl +AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], + [_AM_DEPENDENCIES([OBJCXX])], + [m4_define([AC_PROG_OBJCXX], + m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl +]) +AC_REQUIRE([AM_SILENT_RULES])dnl +dnl The testsuite driver may need to know about EXEEXT, so add the +dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This +dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. +AC_CONFIG_COMMANDS_PRE(dnl +[m4_provide_if([_AM_COMPILER_EXEEXT], + [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl + +# POSIX will say in a future version that running "rm -f" with no argument +# is OK; and we want to be able to make that assumption in our Makefile +# recipes. So use an aggressive probe to check that the usage we want is +# actually supported "in the wild" to an acceptable degree. +# See automake bug#10828. +# To make any issue more visible, cause the running configure to be aborted +# by default if the 'rm' program in use doesn't match our expectations; the +# user can still override this though. +if rm -f && rm -fr && rm -rf; then : OK; else + cat >&2 <<'END' +Oops! + +Your 'rm' program seems unable to run without file operands specified +on the command line, even when the '-f' option is present. This is contrary +to the behaviour of most rm programs out there, and not conforming with +the upcoming POSIX standard: + +Please tell bug-automake@gnu.org about your system, including the value +of your $PATH and any error possibly output before this message. This +can help us improve future automake versions. + +END + if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then + echo 'Configuration will proceed anyway, since you have set the' >&2 + echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 + echo >&2 + else + cat >&2 <<'END' +Aborting the configuration process, to ensure you take notice of the issue. + +You can download and install GNU coreutils to get an 'rm' implementation +that behaves properly: . + +If you want to complete the configuration process using your problematic +'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM +to "yes", and re-run configure. + +END + AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) + fi +fi +dnl The trailing newline in this macro's definition is deliberate, for +dnl backward compatibility and to allow trailing 'dnl'-style comments +dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. +]) + +dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not +dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further +dnl mangled by Autoconf and run in a shell conditional statement. +m4_define([_AC_COMPILER_EXEEXT], +m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) + +# When config.status generates a header, we must update the stamp-h file. +# This file resides in the same directory as the config header +# that is generated. The stamp files are numbered to have different names. + +# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the +# loop where config.status creates the headers, so we can generate +# our stamp files there. +AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], +[# Compute $1's index in $config_headers. +_am_arg=$1 +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $_am_arg | $_am_arg:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) + +# Copyright (C) 2001-2017 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_SH +# ------------------ +# Define $install_sh. +AC_DEFUN([AM_PROG_INSTALL_SH], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +if test x"${install_sh+set}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; + *) + install_sh="\${SHELL} $am_aux_dir/install-sh" + esac +fi +AC_SUBST([install_sh])]) + +# Copyright (C) 2003-2017 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# Check whether the underlying file-system supports filenames +# with a leading dot. For instance MS-DOS doesn't. +AC_DEFUN([AM_SET_LEADING_DOT], +[rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null +AC_SUBST([am__leading_dot])]) + +# Check to see how 'make' treats includes. -*- Autoconf -*- + +# Copyright (C) 2001-2017 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_MAKE_INCLUDE() +# ----------------- +# Check to see how make treats includes. +AC_DEFUN([AM_MAKE_INCLUDE], +[am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo this is the am__doit target +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +AC_MSG_CHECKING([for style of include used by $am_make]) +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# Ignore all kinds of additional output from 'make'. +case `$am_make -s -f confmf 2> /dev/null` in #( +*the\ am__doit\ target*) + am__include=include + am__quote= + _am_result=GNU + ;; +esac +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + case `$am_make -s -f confmf 2> /dev/null` in #( + *the\ am__doit\ target*) + am__include=.include + am__quote="\"" + _am_result=BSD + ;; + esac +fi +AC_SUBST([am__include]) +AC_SUBST([am__quote]) +AC_MSG_RESULT([$_am_result]) +rm -f confinc confmf +]) + +# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- + +# Copyright (C) 1997-2017 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_MISSING_PROG(NAME, PROGRAM) +# ------------------------------ +AC_DEFUN([AM_MISSING_PROG], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +$1=${$1-"${am_missing_run}$2"} +AC_SUBST($1)]) + +# AM_MISSING_HAS_RUN +# ------------------ +# Define MISSING if not defined so far and test if it is modern enough. +# If it is, set am_missing_run to use it, otherwise, to nothing. +AC_DEFUN([AM_MISSING_HAS_RUN], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +AC_REQUIRE_AUX_FILE([missing])dnl +if test x"${MISSING+set}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; + *) + MISSING="\${SHELL} $am_aux_dir/missing" ;; + esac +fi +# Use eval to expand $SHELL +if eval "$MISSING --is-lightweight"; then + am_missing_run="$MISSING " +else + am_missing_run= + AC_MSG_WARN(['missing' script is too old or missing]) +fi +]) + +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright (C) 2001-2017 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# _AM_MANGLE_OPTION(NAME) +# ----------------------- +AC_DEFUN([_AM_MANGLE_OPTION], +[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) + +# _AM_SET_OPTION(NAME) +# -------------------- +# Set option NAME. Presently that only means defining a flag for this option. +AC_DEFUN([_AM_SET_OPTION], +[m4_define(_AM_MANGLE_OPTION([$1]), [1])]) + +# _AM_SET_OPTIONS(OPTIONS) +# ------------------------ +# OPTIONS is a space-separated list of Automake options. +AC_DEFUN([_AM_SET_OPTIONS], +[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) + +# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) +# ------------------------------------------- +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +AC_DEFUN([_AM_IF_OPTION], +[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) + +# Copyright (C) 1999-2017 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# _AM_PROG_CC_C_O +# --------------- +# Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC +# to automatically call this. +AC_DEFUN([_AM_PROG_CC_C_O], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +AC_REQUIRE_AUX_FILE([compile])dnl +AC_LANG_PUSH([C])dnl +AC_CACHE_CHECK( + [whether $CC understands -c and -o together], + [am_cv_prog_cc_c_o], + [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) + # Make sure it works both with $CC and with simple cc. + # Following AC_PROG_CC_C_O, we do the test twice because some + # compilers refuse to overwrite an existing .o file with -o, + # though they will create one. + am_cv_prog_cc_c_o=yes + for am_i in 1 2; do + if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ + && test -f conftest2.$ac_objext; then + : OK + else + am_cv_prog_cc_c_o=no + break + fi + done + rm -f core conftest* + unset am_i]) +if test "$am_cv_prog_cc_c_o" != yes; then + # Losing compiler, so override with the script. + # FIXME: It is wrong to rewrite CC. + # But if we don't then we get into trouble of one sort or another. + # A longer-term fix would be to have automake use am__CC in this case, + # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" + CC="$am_aux_dir/compile $CC" +fi +AC_LANG_POP([C])]) + +# For backward compatibility. +AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) + +# Copyright (C) 2001-2017 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_RUN_LOG(COMMAND) +# ------------------- +# Run COMMAND, save the exit status in ac_status, and log it. +# (This has been adapted from Autoconf's _AC_RUN_LOG macro.) +AC_DEFUN([AM_RUN_LOG], +[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD + ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + (exit $ac_status); }]) + +# Check to make sure that the build environment is sane. -*- Autoconf -*- + +# Copyright (C) 1996-2017 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_SANITY_CHECK +# --------------- +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Reject unsafe characters in $srcdir or the absolute working directory +# name. Accept space and tab only in the latter. +am_lf=' +' +case `pwd` in + *[[\\\"\#\$\&\'\`$am_lf]]*) + AC_MSG_ERROR([unsafe absolute working directory name]);; +esac +case $srcdir in + *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) + AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; +esac + +# Do 'set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + am_has_slept=no + for am_try in 1 2; do + echo "timestamp, slept: $am_has_slept" > conftest.file + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken + alias in your environment]) + fi + if test "$[2]" = conftest.file || test $am_try -eq 2; then + break + fi + # Just in case. + sleep 1 + am_has_slept=yes + done + test "$[2]" = conftest.file + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +AC_MSG_RESULT([yes]) +# If we didn't sleep, we still need to ensure time stamps of config.status and +# generated files are strictly newer. +am_sleep_pid= +if grep 'slept: no' conftest.file >/dev/null 2>&1; then + ( sleep 1 ) & + am_sleep_pid=$! +fi +AC_CONFIG_COMMANDS_PRE( + [AC_MSG_CHECKING([that generated files are newer than configure]) + if test -n "$am_sleep_pid"; then + # Hide warnings about reused PIDs. + wait $am_sleep_pid 2>/dev/null + fi + AC_MSG_RESULT([done])]) +rm -f conftest.file +]) + +# Copyright (C) 2009-2017 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_SILENT_RULES([DEFAULT]) +# -------------------------- +# Enable less verbose build rules; with the default set to DEFAULT +# ("yes" being less verbose, "no" or empty being verbose). +AC_DEFUN([AM_SILENT_RULES], +[AC_ARG_ENABLE([silent-rules], [dnl +AS_HELP_STRING( + [--enable-silent-rules], + [less verbose build output (undo: "make V=1")]) +AS_HELP_STRING( + [--disable-silent-rules], + [verbose build output (undo: "make V=0")])dnl +]) +case $enable_silent_rules in @%:@ ((( + yes) AM_DEFAULT_VERBOSITY=0;; + no) AM_DEFAULT_VERBOSITY=1;; + *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; +esac +dnl +dnl A few 'make' implementations (e.g., NonStop OS and NextStep) +dnl do not support nested variable expansions. +dnl See automake bug#9928 and bug#10237. +am_make=${MAKE-make} +AC_CACHE_CHECK([whether $am_make supports nested variables], + [am_cv_make_support_nested_variables], + [if AS_ECHO([['TRUE=$(BAR$(V)) +BAR0=false +BAR1=true +V=1 +am__doit: + @$(TRUE) +.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then + am_cv_make_support_nested_variables=yes +else + am_cv_make_support_nested_variables=no +fi]) +if test $am_cv_make_support_nested_variables = yes; then + dnl Using '$V' instead of '$(V)' breaks IRIX make. + AM_V='$(V)' + AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' +else + AM_V=$AM_DEFAULT_VERBOSITY + AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY +fi +AC_SUBST([AM_V])dnl +AM_SUBST_NOTMAKE([AM_V])dnl +AC_SUBST([AM_DEFAULT_V])dnl +AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl +AC_SUBST([AM_DEFAULT_VERBOSITY])dnl +AM_BACKSLASH='\' +AC_SUBST([AM_BACKSLASH])dnl +_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl +]) + +# Copyright (C) 2001-2017 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_STRIP +# --------------------- +# One issue with vendor 'install' (even GNU) is that you can't +# specify the program used to strip binaries. This is especially +# annoying in cross-compiling environments, where the build's strip +# is unlikely to handle the host's binaries. +# Fortunately install-sh will honor a STRIPPROG variable, so we +# always use install-sh in "make install-strip", and initialize +# STRIPPROG with the value of the STRIP variable (set by the user). +AC_DEFUN([AM_PROG_INSTALL_STRIP], +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +# Installed binaries are usually stripped using 'strip' when the user +# run "make install-strip". However 'strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the 'STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. +if test "$cross_compiling" != no; then + AC_CHECK_TOOL([STRIP], [strip], :) +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) + +# Copyright (C) 2006-2017 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# _AM_SUBST_NOTMAKE(VARIABLE) +# --------------------------- +# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. +# This macro is traced by Automake. +AC_DEFUN([_AM_SUBST_NOTMAKE]) + +# AM_SUBST_NOTMAKE(VARIABLE) +# -------------------------- +# Public sister of _AM_SUBST_NOTMAKE. +AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) + +# Check how to create a tarball. -*- Autoconf -*- + +# Copyright (C) 2004-2017 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# _AM_PROG_TAR(FORMAT) +# -------------------- +# Check how to create a tarball in format FORMAT. +# FORMAT should be one of 'v7', 'ustar', or 'pax'. +# +# Substitute a variable $(am__tar) that is a command +# writing to stdout a FORMAT-tarball containing the directory +# $tardir. +# tardir=directory && $(am__tar) > result.tar +# +# Substitute a variable $(am__untar) that extract such +# a tarball read from stdin. +# $(am__untar) < result.tar +# +AC_DEFUN([_AM_PROG_TAR], +[# Always define AMTAR for backward compatibility. Yes, it's still used +# in the wild :-( We should find a proper way to deprecate it ... +AC_SUBST([AMTAR], ['$${TAR-tar}']) + +# We'll loop over all known methods to create a tar archive until one works. +_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' + +m4_if([$1], [v7], + [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], + + [m4_case([$1], + [ustar], + [# The POSIX 1988 'ustar' format is defined with fixed-size fields. + # There is notably a 21 bits limit for the UID and the GID. In fact, + # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 + # and bug#13588). + am_max_uid=2097151 # 2^21 - 1 + am_max_gid=$am_max_uid + # The $UID and $GID variables are not portable, so we need to resort + # to the POSIX-mandated id(1) utility. Errors in the 'id' calls + # below are definitely unexpected, so allow the users to see them + # (that is, avoid stderr redirection). + am_uid=`id -u || echo unknown` + am_gid=`id -g || echo unknown` + AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) + if test $am_uid -le $am_max_uid; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + _am_tools=none + fi + AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) + if test $am_gid -le $am_max_gid; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + _am_tools=none + fi], + + [pax], + [], + + [m4_fatal([Unknown tar format])]) + + AC_MSG_CHECKING([how to create a $1 tar archive]) + + # Go ahead even if we have the value already cached. We do so because we + # need to set the values for the 'am__tar' and 'am__untar' variables. + _am_tools=${am_cv_prog_tar_$1-$_am_tools} + + for _am_tool in $_am_tools; do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac + + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break + + # tar/untar a dummy directory, and stop if the command works. + rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + rm -rf conftest.dir + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar /dev/null 2>&1 && break + fi + done + rm -rf conftest.dir + + AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) + AC_MSG_RESULT([$am_cv_prog_tar_$1])]) + +AC_SUBST([am__tar]) +AC_SUBST([am__untar]) +]) # _AM_PROG_TAR + +m4_include([gnulib-m4/00gnulib.m4]) +m4_include([gnulib-m4/absolute-header.m4]) +m4_include([gnulib-m4/ansi-c++.m4]) +m4_include([gnulib-m4/asm-underscore.m4]) +m4_include([gnulib-m4/extensions.m4]) +m4_include([gnulib-m4/gnulib-common.m4]) +m4_include([gnulib-m4/gnulib-comp.m4]) +m4_include([gnulib-m4/host-cpu-c-abi.m4]) +m4_include([gnulib-m4/include_next.m4]) +m4_include([gnulib-m4/limits-h.m4]) +m4_include([gnulib-m4/lock.m4]) +m4_include([gnulib-m4/longlong.m4]) +m4_include([gnulib-m4/multiarch.m4]) +m4_include([gnulib-m4/nocrash.m4]) +m4_include([gnulib-m4/off_t.m4]) +m4_include([gnulib-m4/onceonly.m4]) +m4_include([gnulib-m4/pthread_rwlock_rdlock.m4]) +m4_include([gnulib-m4/ssize_t.m4]) +m4_include([gnulib-m4/stdint.m4]) +m4_include([gnulib-m4/stdnoreturn.m4]) +m4_include([gnulib-m4/sys_types_h.m4]) +m4_include([gnulib-m4/threadlib.m4]) +m4_include([gnulib-m4/wint_t.m4]) +m4_include([m4/as-underscore.m4]) +m4_include([m4/cc-gcc.m4]) +m4_include([m4/codeexec.m4]) +m4_include([m4/endianness.m4]) +m4_include([m4/general.m4]) +m4_include([m4/getpagesize.m4]) +m4_include([m4/ireg.m4]) +m4_include([m4/libtool.m4]) +m4_include([m4/ln.m4]) +m4_include([m4/ltoptions.m4]) +m4_include([m4/ltsugar.m4]) +m4_include([m4/ltversion.m4]) +m4_include([m4/lt~obsolete.m4]) +m4_include([m4/mach-vm.m4]) +m4_include([m4/mmap.m4]) +m4_include([m4/mprotect.m4]) +m4_include([m4/proto.m4]) +m4_include([m4/shm.m4]) +m4_include([m4/smallstruct.m4]) diff --git a/avcall/COPYING b/avcall/COPYING new file mode 100644 index 0000000..a3d1815 --- /dev/null +++ b/avcall/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, 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) + + 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/avcall/DOC b/avcall/DOC new file mode 100644 index 0000000..255618e --- /dev/null +++ b/avcall/DOC @@ -0,0 +1,133 @@ +---------------------------------------------------------------------- + AVCALL --- a foreign function interface to ANSI-C +---------------------------------------------------------------------- + +This library allows arbitrary C functions to be called from embedded +interpreters, debuggers, RPC calls, etc, by building up a C argument +list incrementally from explicitly typed arguments. This considerably +reduces the amount of boilerplate glue code required for such +applications. + +The interface is like stdargs/varargs in reverse and is intended to be as +portable as possible, however the details of function calling are highly +machine-dependent so your mileage may vary. At the very least there are +typically built-in limits on the size of the argument-list. The +argument-pushing macros all return 0 for success, < 0 for error (eg, +arg-list overflow). + +Installation instructions are in the Makefile. + +---------------------------------------------------------------------- +DECLARE ALIST -> OPEN ALIST -> SET FLAGS -> PUSH ARGS -> CALL FUNCTION +---------------------------------------------------------------------- + +1) Declare the argument list structure: + + #include "avcall.h" + { + av_alist alist; + +2) Set any special flags. This is architecture and compiler dependent. +Sometimes, compiler options must be flagged by #defines before the +#include . Usually, however, the ‘configure’ script should +have determined which #defines are needed and put them at the head of +avcall.h. + +3) Initialise the alist with the function address and return type. +There is a separate macro for each built-in C type (char, int, float, etc). +Eg, + av_start_int(alist,&func,&return_addr); +or + av_start_double(alist,&func,&return_addr); +etc. +Functions returning a structure or pointer take an extra type argument: +Eg, + av_start_struct(alist,&func,STRUCT_OR_UNION_TYPE,SPLITTABLE,&return_addr); +or + av_start_ptr(alist,&func,POINTER_TYPE,&return_addr); + + +4) Push the arguments one by one in order. There is a macro for each +built-in C type, eg: + av_int(alist,value); +or + av_double(alist,value); + +Structure and pointer arguments require an extra type argument: + + av_struct(alist,STRUCT_TYPE,value); +or + av_ptr(alist,POINTER_TYPE,value); + +5) Call the function, set the return value, and tidy up: + + av_call(alist); + +---------------------------------------------------------------------- + NOTES + +1) Functions declared in K&R style (ie, without a typed arglist) must +use default K&R expression promotions (char,short-->int; float-->double) +whether they are compiled by a K&R or an ANSI compiler, because the +true arg types may not be known at the call point. Such functions +back-convert their arguments to the declared types on function entry. +The only way to pass a true char, short or float (eg, from K&R C to an +ANSI or varargs function) is by an explicit cast: foo((char)c,(float)f). + + !! Hence, for args of functions declared in K&R style you should use + !! av_int() and av_double() instead of av_{char,short}() and av_float(). + +If you use a K&R compiler, the avcall header files may detect this and +define av_float, etc, appropriately, but with an ANSI compiler there's +no way avcall can know how a function was declared, so you have to +correct the argument types yourself. Similarly, some K&R compilers (such +as Sun cc on the sparc) actually return a float as a double. + +2) There are too many possible structure and pointer types to have a +separate macro for each, so the pointer and structure macros take an +explicit type argument which may be used (eg) to calculate the size of +the structure. On most architectures this provides enough information +for the compiler to make the proper call, but there will always be +machines with odd alignment requirements or argument passing +conventions, unusual reprentations for function, char, or void pointers, +etc, for which this scheme will not suffice. These machines may define +additional av_start_TYPE and av_TYPE macros. + +3) The current implementations are pretty flakey in places. I'm happy to +accept new ports and (properly tested) fixes and enhancements. In +particular, many of the routines waste a lot of stack space and generally +do hairy things with stack frames - a bit more assembly code would probably +help things along quite a bit, but I don't speak assembler at all well. + +4) The macros required for all this are pretty grungy, but it does seem +to be possible to port avcall to many machines. Some of the grunge is +usually handled by a C or assembly level glue routine that actually +pushes the arguments, calls the function and unpacks any return value. +This is called avcall_call(). A precompiled assembler version for +people without gcc is also made available. The routine should ideally +have flags for the passing conventions of other compilers. +---------------------------------------------------------------------- + ACKNOWLEDGEMENTS + +I was aware of two similar but rather more restricted foreign function +interfaces when the initial version of this library was written, although +(I believe) all of the present code is my own: the C interface in the zelk +extensions to Oliver Laumann's Elk scheme interpreter +by J.P.Lewis, NEC C&C Research, (for Sun4 and SGI); +and Roy Featherstone's personal C interface +library for Sun3,4 and SGI. I also looked at the comments and some of the +code in the machine-dependent parts of the GCC and GDB distributions, and +put the GCC __asm__ extensions to good use. Thanks guys! + +This work was partly supported by EC-ESPRIT Basic Research Action SECOND. +---------------------------------------------------------------------- + +================================================================================ +Copyright 1993 Bill Triggs +Copyright 1995-2017 Bruno Haible + +This manual is covered by the GNU GPL. You can redistribute it and/or +modify it under the terms of the GNU General Public License (GPL), either +version 2 of the License, or (at your option) any later version published +by the Free Software Foundation (FSF). +A copy of the license is at . diff --git a/avcall/Makefile.devel b/avcall/Makefile.devel new file mode 100644 index 0000000..080898b --- /dev/null +++ b/avcall/Makefile.devel @@ -0,0 +1,266 @@ +# This is the developer's -*-Makefile-*-, not the user's makefile. +# Do not use it unless you know exactly what you do! + +THISFILE = Makefile.devel +LN = ln -s +RM = rm -f + +# ============ Rules that require cross-compilation tools ============ + +GCC = gcc +GCCFLAGS = -I.. -I../dummy -O2 -fno-omit-frame-pointer -fPIC +SED = sed +CROSS_TOOL = cross + +precompiled : \ + avcall-i386-macro.S \ + avcall-m68k.mit.S avcall-m68k.motorola.S \ + avcall-mipseb-macro.S avcall-mipsel-macro.S avcall-mipsn32eb-macro.S avcall-mipsn32el-macro.S avcall-mips64eb-macro.S avcall-mips64el-macro.S \ + avcall-sparc-macro.S avcall-sparc64-macro.S \ + avcall-alpha-macro.S \ + avcall-hppa-macro.S avcall-hppa64-macro.S \ + avcall-arm-macro.S avcall-armhf-macro.S \ + avcall-arm64-macro.S \ + avcall-powerpc-aix.s avcall-powerpc-linux-macro.S avcall-powerpc-sysv4-macro.S avcall-powerpc-macos.s avcall-powerpc64-aix.s avcall-powerpc64-linux.S avcall-powerpc64-elfv2-linux.S \ + avcall-ia64-macro.S \ + avcall-x86_64-macro.S avcall-x86_64-x32-linux.s avcall-x86_64-windows-macro.S \ + avcall-s390-macro.S avcall-s390x-macro.S \ + avcall-riscv32-ilp32d-macro.S avcall-riscv64-lp64d-macro.S + + +avcall-i386-linux.s : avcall-i386.c avcall-internal.h avcall.h avcall-alist.h $(THISFILE) + $(CROSS_TOOL) i386-linux gcc -V 3.1 $(GCCFLAGS) -D__i386__ -fno-omit-frame-pointer -S avcall-i386.c -o avcall-i386-linux.s + +avcall-i386-macro.S : avcall-i386-linux.s ../common/asm-i386.sh ../common/noexecstack.h $(THISFILE) + (echo '#include "asm-i386.h"' ; sed -e '/\.align.*,0x90$$/d' < avcall-i386-linux.s | ../common/asm-i386.sh ; cat ../common/noexecstack.h) > avcall-i386-macro.S + + +avcall-m68k-linux.s : avcall-m68k.c avcall-internal.h avcall.h avcall-alist.h $(THISFILE) + $(CROSS_TOOL) m68k-linux gcc -V 3.1 $(GCCFLAGS) -D__m68k__ -S avcall-m68k.c -o avcall-m68k-linux.s + +avcall-m68k-sun.s : avcall-m68k.c avcall-internal.h avcall.h avcall-alist.h $(THISFILE) + $(CROSS_TOOL) m68k-sun gcc -V 3.1 $(GCCFLAGS) -D__m68k__ -S avcall-m68k.c -o avcall-m68k-sun.s + +avcall-m68k.mit.S : avcall-m68k-sun.s ../common/asm-m68k.sh ../common/noexecstack.h $(THISFILE) + (echo '#include "asm-m68k.h"' ; ../common/asm-m68k.sh mit < avcall-m68k-sun.s ; cat ../common/noexecstack.h) > avcall-m68k.mit.S + +avcall-m68k.motorola.S : avcall-m68k-linux.s ../common/asm-m68k.sh ../common/noexecstack.h $(THISFILE) + (echo '#include "asm-m68k.h"' ; ../common/asm-m68k.sh motorola < avcall-m68k-linux.s ; cat ../common/noexecstack.h) > avcall-m68k.motorola.S + + +avcall-mipseb-linux.s : avcall-mips.c avcall-internal.h avcall.h avcall-alist.h $(THISFILE) + $(CROSS_TOOL) mips64-linux gcc-5.4.0 -mabi=32 -mfpxx -march=mips2 -meb $(GCCFLAGS) -D__mips__ -fno-tree-dce -S avcall-mips.c -o avcall-mipseb-linux.s + +avcall-mipseb-macro.S : avcall-mipseb-linux.s ../common/asm-mips.sh $(THISFILE) + (echo '#include "asm-mips.h"' ; ../common/asm-mips.sh < avcall-mipseb-linux.s) > avcall-mipseb-macro.S + +avcall-mipsel-linux.s : avcall-mips.c avcall-internal.h avcall.h avcall-alist.h $(THISFILE) + $(CROSS_TOOL) mips64-linux gcc-5.4.0 -mabi=32 -mfpxx -march=mips2 -mel $(GCCFLAGS) -D__mips__ -fno-tree-dce -S avcall-mips.c -o avcall-mipsel-linux.s + +avcall-mipsel-macro.S : avcall-mipsel-linux.s ../common/asm-mips.sh $(THISFILE) + (echo '#include "asm-mips.h"' ; ../common/asm-mips.sh < avcall-mipsel-linux.s) > avcall-mipsel-macro.S + +avcall-mipsn32eb-linux.s : avcall-mipsn32.c avcall-internal.h avcall.h avcall-alist.h $(THISFILE) + $(CROSS_TOOL) mips64-linux gcc-5.4.0 -mabi=n32 -meb $(GCCFLAGS) -D__mipsn32__ -S avcall-mipsn32.c -o avcall-mipsn32eb-linux.s + +avcall-mipsn32eb-macro.S : avcall-mipsn32eb-linux.s ../common/asm-mips.sh $(THISFILE) + (echo '#include "asm-mips.h"' ; ../common/asm-mips.sh < avcall-mipsn32eb-linux.s) > avcall-mipsn32eb-macro.S + +avcall-mipsn32el-linux.s : avcall-mipsn32.c avcall-internal.h avcall.h avcall-alist.h $(THISFILE) + $(CROSS_TOOL) mips64-linux gcc-5.4.0 -mabi=n32 -mel $(GCCFLAGS) -D__mipsn32__ -S avcall-mipsn32.c -o avcall-mipsn32el-linux.s + +avcall-mipsn32el-macro.S : avcall-mipsn32el-linux.s ../common/asm-mips.sh $(THISFILE) + (echo '#include "asm-mips.h"' ; ../common/asm-mips.sh < avcall-mipsn32el-linux.s) > avcall-mipsn32el-macro.S + +avcall-mips64eb-linux.s : avcall-mips64.c avcall-internal.h avcall.h avcall-alist.h $(THISFILE) + $(CROSS_TOOL) mips64-linux gcc-5.4.0 -mabi=64 -meb $(GCCFLAGS) -D__mips64__ -S avcall-mips64.c -o avcall-mips64eb-linux.s + +avcall-mips64eb-macro.S : avcall-mips64eb-linux.s ../common/asm-mips.sh $(THISFILE) + (echo '#include "asm-mips.h"' ; ../common/asm-mips.sh < avcall-mips64eb-linux.s) > avcall-mips64eb-macro.S + +avcall-mips64el-linux.s : avcall-mips64.c avcall-internal.h avcall.h avcall-alist.h $(THISFILE) + $(CROSS_TOOL) mips64-linux gcc-5.4.0 -mabi=64 -mel $(GCCFLAGS) -D__mips64__ -S avcall-mips64.c -o avcall-mips64el-linux.s + +avcall-mips64el-macro.S : avcall-mips64el-linux.s ../common/asm-mips.sh $(THISFILE) + (echo '#include "asm-mips.h"' ; ../common/asm-mips.sh < avcall-mips64el-linux.s) > avcall-mips64el-macro.S + + +avcall-sparc-linux.s : avcall-sparc.c avcall-internal.h avcall.h avcall-alist.h $(THISFILE) + $(CROSS_TOOL) sparc-linux gcc -V 3.1 $(GCCFLAGS) -D__sparc__ -S avcall-sparc.c -o avcall-sparc-linux.s + +avcall-sparc-macro.S : avcall-sparc-linux.s ../common/asm-sparc.sh ../common/noexecstack.h $(THISFILE) + (echo '#include "asm-sparc.h"' ; ../common/asm-sparc.sh < avcall-sparc-linux.s ; cat ../common/noexecstack.h) > avcall-sparc-macro.S + +avcall-sparc64-linux.s : avcall-sparc64.c avcall-internal.h avcall.h avcall-alist.h $(THISFILE) +# This compiler produces useless instructions with -fPIC. The result is PIC even without -fPIC. + $(CROSS_TOOL) sparc64-linux gcc -V 4.0.2 $(GCCFLAGS) -fno-PIC -D__sparc64__ -S avcall-sparc64.c -o avcall-sparc64-linux.s + +avcall-sparc64-macro.S : avcall-sparc64-linux.s ../common/asm-sparc.sh ../common/noexecstack.h $(THISFILE) + (echo '#include "asm-sparc.h"' ; ../common/asm-sparc.sh < avcall-sparc64-linux.s ; cat ../common/noexecstack.h) > avcall-sparc64-macro.S + + +avcall-alpha-linux.s : avcall-alpha.c avcall-internal.h avcall.h avcall-alist.h $(THISFILE) + $(CROSS_TOOL) alpha-linux gcc -V 4.0.2 $(GCCFLAGS) -D__alpha__ -S avcall-alpha.c -o avcall-alpha-linux.s + +avcall-alpha-macro.S : avcall-alpha-linux.s ../common/asm-alpha.sh ../common/noexecstack.h $(THISFILE) + (../common/asm-alpha.sh < avcall-alpha-linux.s ; cat ../common/noexecstack.h) > avcall-alpha-macro.S + + +avcall-hppa-linux.s : avcall-hppa.c avcall-internal.h avcall.h avcall-alist.h $(THISFILE) + $(CROSS_TOOL) hppa-linux gcc -V 3.1 $(GCCFLAGS) -D__hppa__ -S avcall-hppa.c -o avcall-hppa-linux.s + +avcall-hppa-macro.S : avcall-hppa-linux.s ../common/asm-hppa.sh ../common/noexecstack.h $(THISFILE) + (echo '#include "asm-hppa.h"' ; ../common/asm-hppa.sh < avcall-hppa-linux.s ; cat ../common/noexecstack.h) > avcall-hppa-macro.S + +avcall-hppa64-linux.s : avcall-hppa64.c avcall-internal.h avcall.h avcall-alist.h $(THISFILE) + $(CROSS_TOOL) hppa64-linux gcc -V 3.1 $(GCCFLAGS) -D__hppa64__ -S avcall-hppa64.c -o avcall-hppa64-linux.s + +avcall-hppa64-macro.S : avcall-hppa64-linux.s ../common/asm-hppa64.sh ../common/noexecstack.h $(THISFILE) +# Need to remove the gcc-generated instructions that clobber %r29 right before each of the calls. + (echo '#include "asm-hppa64.h"' ; grep -v 'ldo -16(%r30),%r29' < avcall-hppa64-linux.s | ../common/asm-hppa64.sh ; cat ../common/noexecstack.h) > avcall-hppa64-macro.S + + +avcall-arm-macro.S : avcall-arm.c avcall-internal.h avcall.h avcall-alist.h ../common/asm-arm.sh ../common/noexecstack-arm.h $(THISFILE) + $(CROSS_TOOL) arm-linux gcc -V 3.1 -mlittle-endian $(GCCFLAGS) -D__arm__ -S avcall-arm.c -o avcall-armel.s + $(CROSS_TOOL) arm-linux gcc -V 3.1 -mbig-endian $(GCCFLAGS) -D__arm__ -S avcall-arm.c -o avcall-armeb.s + cmp avcall-armel.s avcall-armeb.s > /dev/null + (echo '#include "asm-arm.h"' ; ../common/asm-arm.sh < avcall-armel.s ; cat ../common/noexecstack-arm.h) > avcall-arm-macro.S + $(RM) avcall-armel.s avcall-armeb.s + +avcall-armhf-macro.S : avcall-armhf.c avcall-internal.h avcall.h avcall-alist.h ../common/asm-arm.sh ../common/noexecstack-arm.h $(THISFILE) +# The option -mabi=aapcs ensures an 8-bytes-aligned stack pointer. + $(CROSS_TOOL) armv7l-linux-gnueabihf gcc-6.3.0 -march=armv6 -mabi=aapcs -mfloat-abi=hard -mlittle-endian $(GCCFLAGS) -D__armhf__ -S avcall-armhf.c -o avcall-armhfel.s + $(CROSS_TOOL) armv7l-linux-gnueabihf gcc-6.3.0 -march=armv6 -mabi=aapcs -mfloat-abi=hard -mbig-endian $(GCCFLAGS) -D__armhf__ -S avcall-armhf.c -o avcall-armhfeb.s + cmp avcall-armhfel.s avcall-armhfeb.s > /dev/null + (echo '#include "asm-arm.h"' ; ../common/asm-arm.sh < avcall-armhfel.s ; cat ../common/noexecstack-arm.h) > avcall-armhf-macro.S + $(RM) avcall-armhfel.s avcall-armhfeb.s + + +avcall-arm64-macro.S : avcall-arm64.c avcall-internal.h avcall.h avcall-alist.h ../common/asm-arm.sh ../common/noexecstack-arm.h $(THISFILE) + $(CROSS_TOOL) aarch64-linux gcc-5.4.0 -mlittle-endian $(GCCFLAGS) -D__arm64__ -S avcall-arm64.c -o avcall-arm64el.s + $(CROSS_TOOL) aarch64-linux gcc-5.4.0 -mbig-endian $(GCCFLAGS) -D__arm64__ -S avcall-arm64.c -o avcall-arm64eb.s + cmp avcall-arm64el.s avcall-arm64eb.s > /dev/null + (echo '#include "asm-arm.h"' ; ../common/asm-arm.sh < avcall-arm64el.s ; cat ../common/noexecstack-arm.h) > avcall-arm64-macro.S + $(RM) avcall-arm64el.s avcall-arm64eb.s + + +avcall-powerpc-aix.s : avcall-powerpc.c avcall-internal.h avcall.h avcall-alist.h $(THISFILE) + $(CROSS_TOOL) rs6000-aix gcc -V 3.3.6 -mno-power -mno-power2 -mno-powerpc -mnew-mnemonics $(GCCFLAGS) -D__powerpc__ -S avcall-powerpc.c -o avcall-powerpc-aix.s + +avcall-powerpc-linux.s : avcall-powerpc.c avcall-internal.h avcall.h avcall-alist.h $(THISFILE) + $(CROSS_TOOL) powerpc-linux gcc -V 3.3.6 -mno-power -mno-power2 -mno-powerpc $(GCCFLAGS) -D__powerpc__ -S avcall-powerpc.c -o avcall-powerpc-linux.s + +avcall-powerpc-linux-macro.S : avcall-powerpc-linux.s ../common/asm-powerpc.sh ../common/noexecstack.h $(THISFILE) + (../common/asm-powerpc.sh < avcall-powerpc-linux.s ; cat ../common/noexecstack.h) > avcall-powerpc-linux-macro.S + +avcall-powerpc-sysv4-macro.S : avcall-powerpc.c avcall-internal.h avcall.h avcall-alist.h ../common/asm-powerpc.sh ../common/noexecstack.h $(THISFILE) + $(CROSS_TOOL) powerpc-linux gcc -V 3.3.6 -mno-power -mno-power2 -mno-powerpc $(GCCFLAGS) -D__powerpc__ -S avcall-powerpc.c -o avcall-powerpc-sysv4.s + (../common/asm-powerpc.sh < avcall-powerpc-sysv4.s ; cat ../common/noexecstack.h) > avcall-powerpc-sysv4-macro.S + $(RM) avcall-powerpc-sysv4.s + +avcall-powerpc-macos.s : avcall-powerpc.c avcall-internal.h avcall.h avcall-alist.h $(THISFILE) + $(CROSS_TOOL) powerpc-darwin gcc -V 3.3.6 $(GCCFLAGS) -D__powerpc__ -S avcall-powerpc.c -o avcall-powerpc-macos.s + +avcall-powerpc64-aix.s : avcall-powerpc64.c avcall-internal.h avcall.h avcall-alist.h $(THISFILE) + $(CROSS_TOOL) rs6000-aix6.1 gcc-5.4.0 -maix64 $(GCCFLAGS) -D__powerpc64__ -S avcall-powerpc64.c -o avcall-powerpc64-aix.s + +avcall-powerpc64-linux.S : avcall-powerpc64.c avcall-internal.h avcall.h avcall-alist.h ../common/asm-powerpc.sh ../common/noexecstack.h $(THISFILE) + $(CROSS_TOOL) powerpc64le-linux gcc-5.4.0 -mabi=elfv1 -mcpu=power4 -mlittle-endian $(GCCFLAGS) -D__powerpc64__ -S avcall-powerpc64.c -o avcall-powerpc64-linux-le.s + $(CROSS_TOOL) powerpc64le-linux gcc-5.4.0 -mabi=elfv1 -mcpu=power4 -mbig-endian $(GCCFLAGS) -D__powerpc64__ -S avcall-powerpc64.c -o avcall-powerpc64-linux-be.s + cmp avcall-powerpc64-linux-le.s avcall-powerpc64-linux-be.s > /dev/null + (../common/asm-powerpc.sh < avcall-powerpc64-linux-be.s ; cat ../common/noexecstack.h) > avcall-powerpc64-linux.S + $(RM) avcall-powerpc64-linux-le.s avcall-powerpc64-linux-be.s + +avcall-powerpc64-elfv2-linux.S : avcall-powerpc64.c avcall-internal.h avcall.h avcall-alist.h ../common/asm-powerpc.sh ../common/noexecstack.h $(THISFILE) + $(CROSS_TOOL) powerpc64le-linux gcc-5.4.0 -mabi=elfv2 -mcpu=power4 -mlittle-endian $(GCCFLAGS) -D__powerpc64__ -D__powerpc64_elfv2__ -S avcall-powerpc64.c -o avcall-powerpc64-elfv2-linux-le.s + $(CROSS_TOOL) powerpc64le-linux gcc-5.4.0 -mabi=elfv2 -mcpu=power4 -mbig-endian $(GCCFLAGS) -D__powerpc64__ -D__powerpc64_elfv2__ -S avcall-powerpc64.c -o avcall-powerpc64-elfv2-linux-be.s + cmp avcall-powerpc64-elfv2-linux-le.s avcall-powerpc64-elfv2-linux-be.s > /dev/null + (../common/asm-powerpc.sh < avcall-powerpc64-elfv2-linux-be.s ; cat ../common/noexecstack.h) > avcall-powerpc64-elfv2-linux.S + $(RM) avcall-powerpc64-elfv2-linux-le.s avcall-powerpc64-elfv2-linux-be.s + + +avcall-ia64-linux.s : avcall-ia64.c avcall-internal.h avcall.h avcall-alist.h $(THISFILE) + $(CROSS_TOOL) ia64-linux gcc -V 4.0.1 $(GCCFLAGS) -D__ia64__ -S avcall-ia64.c -o avcall-ia64-linux.s + +avcall-ia64-macro.S : avcall-ia64-linux.s ../common/noexecstack.h $(THISFILE) + cat avcall-ia64-linux.s ../common/noexecstack.h > avcall-ia64-macro.S + + +avcall-x86_64-linux.s : avcall-x86_64.c avcall-internal.h avcall.h avcall-alist.h $(THISFILE) + $(CROSS_TOOL) x86_64-linux gcc-4.0.2 $(GCCFLAGS) -D__x86_64__ -S avcall-x86_64.c -o avcall-x86_64-linux.s + +avcall-x86_64-macro.S : avcall-x86_64-linux.s ../common/asm-x86_64.sh ../common/noexecstack.h $(THISFILE) + (echo '#include "asm-x86_64.h"' ; ../common/asm-x86_64.sh < avcall-x86_64-linux.s ; cat ../common/noexecstack.h) > avcall-x86_64-macro.S + +avcall-x86_64-x32-linux.s : avcall-x86_64.c avcall-internal.h avcall.h avcall-alist.h $(THISFILE) + $(CROSS_TOOL) x86_64-linux gcc-5.4.0 -mx32 $(GCCFLAGS) -D__x86_64__ -D__x86_64_x32__ -S avcall-x86_64.c -o avcall-x86_64-x32-linux.s + +avcall-x86_64-windows.s : avcall-x86_64-windows.c avcall-internal.h avcall.h avcall-alist.h $(THISFILE) + $(CROSS_TOOL) x86_64-linux gcc-5.4.0 -mabi=ms $(GCCFLAGS) -fno-reorder-blocks-and-partition -D__x86_64__ -D_WIN32 -S avcall-x86_64-windows.c -o avcall-x86_64-windows.s + +avcall-x86_64-windows-macro.S : avcall-x86_64-windows.s ../common/asm-x86_64.sh ../common/noexecstack.h $(THISFILE) + (echo '#include "asm-x86_64.h"' ; ../common/asm-x86_64.sh < avcall-x86_64-windows.s ; cat ../common/noexecstack.h) > avcall-x86_64-windows-macro.S + + +avcall-s390-linux.s : avcall-s390.c avcall-internal.h avcall.h avcall-alist.h $(THISFILE) + $(CROSS_TOOL) s390-linux gcc -V 3.1 $(GCCFLAGS) -D__s390__ -S avcall-s390.c -o avcall-s390-linux.s + +avcall-s390-macro.S : avcall-s390-linux.s ../common/asm-s390.sh ../common/noexecstack.h $(THISFILE) + (../common/asm-s390.sh < avcall-s390-linux.s ; cat ../common/noexecstack.h) > avcall-s390-macro.S + + +avcall-s390x-linux.s : avcall-s390x.c avcall-internal.h avcall.h avcall-alist.h $(THISFILE) + $(CROSS_TOOL) s390x-linux gcc-5.4.0 $(GCCFLAGS) -D__s390x__ -S avcall-s390x.c -o avcall-s390x-linux.s + +avcall-s390x-macro.S : avcall-s390x-linux.s ../common/asm-s390.sh ../common/noexecstack.h $(THISFILE) + (../common/asm-s390.sh < avcall-s390x-linux.s ; cat ../common/noexecstack.h) > avcall-s390x-macro.S + + +avcall-riscv32-ilp32d-linux.s : avcall-riscv32.c avcall-internal.h avcall.h avcall-alist.h $(THISFILE) + $(CROSS_TOOL) riscv32-linux gcc-7.3.0 $(GCCFLAGS) -D__riscv32__ -S avcall-riscv32.c -o avcall-riscv32-ilp32d-linux.s + +avcall-riscv32-ilp32d-macro.S : avcall-riscv32-ilp32d-linux.s ../common/asm-riscv.sh ../common/noexecstack.h $(THISFILE) + (../common/asm-riscv.sh < avcall-riscv32-ilp32d-linux.s ; cat ../common/noexecstack.h) > avcall-riscv32-ilp32d-macro.S + + +avcall-riscv64-lp64d-linux.s : avcall-riscv64.c avcall-internal.h avcall.h avcall-alist.h $(THISFILE) + $(CROSS_TOOL) riscv64-linux gcc-7.3.0 $(GCCFLAGS) -D__riscv64__ -S avcall-riscv64.c -o avcall-riscv64-lp64d-linux.s + +avcall-riscv64-lp64d-macro.S : avcall-riscv64-lp64d-linux.s ../common/asm-riscv.sh ../common/noexecstack.h $(THISFILE) + (../common/asm-riscv.sh < avcall-riscv64-lp64d-linux.s ; cat ../common/noexecstack.h) > avcall-riscv64-lp64d-macro.S + + +# --------------- Rules for debugging test failures --------------- + +tests : tests-i386.s tests-m68k.s tests-mips.s tests-sparc.s tests-alpha.s tests-hppa.s tests-arm.s tests-powerpc.s tests-ia64.s tests-x86_64.s + true + +tests-i386.s : tests.c avcall.h + $(GCC) -V 2.7.2 -b i486-linuxaout $(GCCFLAGS) -I/usr/include -D__i386__ -S tests.c -o tests-i386.s + +tests-m68k.s : tests.c avcall.h + $(GCC) -V 2.95.2 -b m68k-sun $(GCCFLAGS) -I/usr/include -D__m68k__ -S tests.c -o tests-m68k.s + +tests-mips.s : tests.c avcall.h + $(GCC) -V 2.95.2 -b mips-sgi $(GCCFLAGS) -I/usr/include -D__mips__ -S tests.c -o tests-mips.s + +tests-sparc.s : tests.c avcall.h + $(GCC) -V 2.95.2 -b sparc-sun $(GCCFLAGS) -I/usr/include -D__sparc__ -S tests.c -o tests-sparc.s + +tests-alpha.s : tests.c avcall.h + $(GCC) -V 2.7.2 -b alpha-dec-osf $(GCCFLAGS) -I/usr/include -D__alpha__ -S tests.c -o tests-alpha.s + +tests-hppa.s : tests.c avcall.h + $(GCC) -V 2.6.3 -b hppa1.0-hpux $(GCCFLAGS) -I/usr/include -D__hppa__ -S tests.c -o tests-hppa.s + +tests-arm.s : tests.c avcall.h + $(GCC) -V 2.6.3 -b arm-acorn-riscix $(GCCFLAGS) -I/usr/include -D__arm__ -S tests.c -o tests-arm.s + +tests-powerpc.s : tests.c avcall.h + $(GCC) -V 2.95.2 -b rs6000 $(GCCFLAGS) -I/usr/include -D__powerpc__ -S tests.c -o tests-powerpc.s + +tests-ia64.s : tests.c avcall.h + $(GCC) -V 2.9-ia64-000216 -b ia64-hp-linux $(GCCFLAGS) -I/usr/include -D__ia64__ -S tests.c -o tests-ia64.s + +tests-x86_64.s : tests.c avcall.h + $(GCC) -V 3.2.2 -b x86_64-suse-linux $(GCCFLAGS) -I/usr/include -D__x86_64__ -S tests.c -o tests-x86_64.s diff --git a/avcall/Makefile.in b/avcall/Makefile.in new file mode 100644 index 0000000..6c3a334 --- /dev/null +++ b/avcall/Makefile.in @@ -0,0 +1,410 @@ +# Makefile for avcall + +#### Start of system configuration section. #### + +HOST = @host@ +CPU = @HOST_CPU_C_ABI@ +OS = @host_os@ + +# Directories used by "make": +srcdir = @srcdir@ + +# Directories used by "make install": +prefix = @prefix@ +local_prefix = /usr/local +exec_prefix = @exec_prefix@ +libdir = @libdir@ +includedir = @includedir@ +mandir = @mandir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +htmldir = $(datadir)/html + +# Programs used by "make": +# C compiler +CC = @CC@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +# C++ compiler +CXX = @CXX@ +CXXFLAGS = @CXXFLAGS@ +# Both C and C++ compiler +CPPFLAGS = @CPPFLAGS@ +INCLUDES = -I. -I$(srcdir) -I.. -I$(srcdir)/.. +ASPFLAGS = `if test @AS_UNDERSCORE@ = true; then echo '-DASM_UNDERSCORE'; fi` +LDFLAGS = @LDFLAGS@ +LIBTOOL = @LIBTOOL@ +LIBTOOL_COMPILE = $(LIBTOOL) --mode=compile +LIBTOOL_LINK = $(LIBTOOL) --mode=link +LIBTOOL_INSTALL = $(LIBTOOL) --mode=install +LIBTOOL_UNINSTALL = $(LIBTOOL) --mode=uninstall +AR = @AR@ +AR_FLAGS = rc +RANLIB = @RANLIB@ +MV = mv +LN = @LN@ +RM = rm -f +@SET_MAKE@ + +# Programs used by "make install": +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ + +#### End of system configuration section. #### + +SHELL = /bin/sh + +# Needed by $(LIBTOOL). +top_builddir = .. + +OBJECTS = avcall.lo avcall-libapi.lo avcall-structcpy.lo avcall-compat.lo + +# Limit the set of exported symbols, on those platforms where libtool supports it. +# Currently this does not exclude any symbol; maybe sometime in the future... +LIBAVCALL_EXPORTED_SYMBOLS_REGEX = '^avcall_|^__builtin_avcall$$' + +# Before making a release, change this according to the libtool documentation, +# section "Library interface versions". +LIBAVCALL_VERSION_INFO = 1:2:0 + +all : $(OBJECTS) libavcall.la $(srcdir)/avcall.3 $(srcdir)/avcall.html + +avcall.lo : avcall-$(CPU).lo + $(RM) avcall.lo avcall.@OBJEXT@ + $(LN) avcall-$(CPU).lo avcall.lo + if test -f avcall-$(CPU).@OBJEXT@; then $(LN) avcall-$(CPU).@OBJEXT@ avcall.@OBJEXT@; fi + +@IFNOT_MSVC@avcall-i386.lo : avcall-i386.s +@IFNOT_MSVC@ $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c avcall-i386.s + +@IFNOT_MSVC@avcall-i386.s : $(srcdir)/avcall-i386-macro.S +@IFNOT_MSVC@ $(CPP) $(ASPFLAGS) -I$(srcdir)/../common - < $(srcdir)/avcall-i386-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,\. ,.,g' -e 's,@ ,@,g' -e 's,//.*$$,,' -e 's/##//g' > avcall-i386.s + +@IF_MSVC@avcall-i386.lo : $(srcdir)/avcall-i386-msvc.c +@IF_MSVC@ $(LIBTOOL_COMPILE) $(CC) -I$(srcdir)/../common $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/avcall-i386-msvc.c -o avcall-i386.lo + +avcall-sparc.lo : avcall-sparc.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c avcall-sparc.s + +avcall-sparc.s : $(srcdir)/avcall-sparc-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../common - < $(srcdir)/avcall-sparc-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,\. ,.,g' -e 's,//.*$$,,' -e 's,\$$,#,g' -e 's,# ,#,g' > avcall-sparc.s + +avcall-sparc64.lo : avcall-sparc64.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c avcall-sparc64.s + +avcall-sparc64.s : $(srcdir)/avcall-sparc64-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../common - < $(srcdir)/avcall-sparc64-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,\. ,.,g' -e 's,//.*$$,,' -e 's,\$$,#,g' -e 's,# ,#,g' > avcall-sparc64.s + +avcall-m68k.lo : avcall-m68k.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c avcall-m68k.s + +avcall-m68k.s : $(srcdir)/avcall-m68k.mit.S $(srcdir)/avcall-m68k.motorola.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../common $(srcdir)/avcall-m68k.motorola.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' | if test @AS_UNDERSCORE@ = true; then sed -e 's/\$$//g'; else sed -e 's/\$$/%/g'; fi > avcall-m68k.s + +avcall-mips.lo : avcall-mips.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c avcall-mips.s + +avcall-mips.s : $(srcdir)/avcall-mips@ENDIANNESS@-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../common $(srcdir)/avcall-mips@ENDIANNESS@-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > avcall-mips.s + +avcall-mipsn32.lo : avcall-mipsn32.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c avcall-mipsn32.s + +avcall-mipsn32.s : $(srcdir)/avcall-mipsn32@ENDIANNESS@-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../common $(srcdir)/avcall-mipsn32@ENDIANNESS@-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > avcall-mipsn32.s + +avcall-mips64.lo : avcall-mips64.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c avcall-mips64.s + +avcall-mips64.s : $(srcdir)/avcall-mips64@ENDIANNESS@-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../common $(srcdir)/avcall-mips64@ENDIANNESS@-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > avcall-mips64.s + +avcall-alpha.lo : avcall-alpha.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c avcall-alpha.s + +avcall-alpha.s : $(srcdir)/avcall-alpha-macro.S + $(CPP) $(ASPFLAGS) $(srcdir)/avcall-alpha-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > avcall-alpha.s + +avcall-hppa.lo : avcall-hppa.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c avcall-hppa.s + +avcall-hppa.s : $(srcdir)/avcall-hppa-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../common $(srcdir)/avcall-hppa-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e "s,!,',g" > avcall-hppa.s + +avcall-hppa64.lo : avcall-hppa64.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c avcall-hppa64.s + +avcall-hppa64.s : $(srcdir)/avcall-hppa64-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../common $(srcdir)/avcall-hppa64-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e "s,!,',g" > avcall-hppa64.s + +avcall-arm.lo : avcall-arm.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c avcall-arm.s + +avcall-arm.s : $(srcdir)/avcall-arm-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../common $(srcdir)/avcall-arm-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//,@,g' -e 's,\$$,#,g' > avcall-arm.s + +avcall-armhf.lo : avcall-armhf.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c avcall-armhf.s + +avcall-armhf.s : $(srcdir)/avcall-armhf-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../common $(srcdir)/avcall-armhf-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//,@,g' -e 's,\$$,#,g' > avcall-armhf.s + +avcall-arm64.lo : avcall-arm64.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c avcall-arm64.s + +avcall-arm64.s : $(srcdir)/avcall-arm64-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../common $(srcdir)/avcall-arm64-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//,@,g' -e 's,\$$,#,g' > avcall-arm64.s + +avcall-powerpc.lo : avcall-powerpc.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c avcall-powerpc.s + +avcall-powerpc.s : $(srcdir)/avcall-powerpc-aix.s $(srcdir)/avcall-powerpc-linux-macro.S $(srcdir)/avcall-powerpc-macos.s $(srcdir)/avcall-powerpc-sysv4-macro.S + case "$(OS)" in \ + aix*) syntax=aix;; \ + linux* | netbsd* | openbsd*) syntax=linux;; \ + macos* | darwin*) syntax=macos;; \ + *) syntax=sysv4;; \ + esac; \ + case $${syntax} in \ + macos) \ + grep -v '\.machine' $(srcdir)/avcall-powerpc-$${syntax}.s > avcall-powerpc.s || exit 1 ;; \ + linux | sysv4) \ + $(CPP) $(ASPFLAGS) $(srcdir)/avcall-powerpc-$${syntax}-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > avcall-powerpc.s || exit 1 ;; \ + *) \ + cp $(srcdir)/avcall-powerpc-$${syntax}.s avcall-powerpc.s || exit 1 ;; \ + esac + +avcall-powerpc64.lo : avcall-powerpc64.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c avcall-powerpc64.s + +avcall-powerpc64.s : $(srcdir)/avcall-powerpc64-aix.s $(srcdir)/avcall-powerpc64-linux.S + case "$(OS)" in \ + aix*) syntax=aix;; \ + *) syntax=linux;; \ + esac; \ + case $${syntax} in \ + linux) \ + $(CPP) $(ASPFLAGS) $(srcdir)/avcall-powerpc64-$${syntax}.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > avcall-powerpc64.s || exit 1 ;; \ + *) \ + cp $(srcdir)/avcall-powerpc64-$${syntax}.s avcall-powerpc64.s || exit 1 ;; \ + esac + +avcall-powerpc64-elfv2.lo : avcall-powerpc64-elfv2.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c avcall-powerpc64-elfv2.s + +avcall-powerpc64-elfv2.s : $(srcdir)/avcall-powerpc64-elfv2-linux.S + $(CPP) $(ASPFLAGS) $(srcdir)/avcall-powerpc64-elfv2-linux.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > avcall-powerpc64-elfv2.s + +avcall-ia64.lo : avcall-ia64.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c avcall-ia64.s + +avcall-ia64.s : $(srcdir)/avcall-ia64-macro.S + $(CPP) $(ASPFLAGS) $(srcdir)/avcall-ia64-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > avcall-ia64.s + +@IFNOT_MSVC@avcall-x86_64.lo : avcall-x86_64.s +@IFNOT_MSVC@ $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c avcall-x86_64.s + +@IFNOT_MSVC@avcall-x86_64.s : $(srcdir)/avcall-x86_64-macro.S $(srcdir)/avcall-x86_64-windows-macro.S +@IFNOT_MSVC@ case "$(OS)" in \ +@IFNOT_MSVC@ cygwin* | mingw*) variant='-windows';; \ +@IFNOT_MSVC@ *) variant='';; \ +@IFNOT_MSVC@ esac; \ +@IFNOT_MSVC@ $(CPP) $(ASPFLAGS) -I$(srcdir)/../common - < $(srcdir)/avcall-x86_64$${variant}-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,\. ,.,g' -e 's,@ ,@,g' -e 's,//.*$$,,' -e 's/##//g' > avcall-x86_64.s + +@IF_MSVC@avcall-x86_64.lo : avcall-x86_64.asm +@IF_MSVC@ $(LIBTOOL_COMPILE) ml64 -c -nologo avcall-x86_64.asm +@IF_MSVC@ mkdir -p .libs; cp avcall-x86_64.@OBJEXT@ .libs/avcall-x86_64.@OBJEXT@ + +@IF_MSVC@avcall-x86_64.asm : $(srcdir)/avcall-x86_64-windows-macro.S +@IF_MSVC@ { $(CPP) $(ASPFLAGS) -I$(srcdir)/../common $(srcdir)/avcall-x86_64-windows-macro.S | grep -v '^#'; echo 'END'; } > avcall-x86_64.asm + +avcall-x86_64-x32.lo : avcall-x86_64-x32.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c avcall-x86_64-x32.s + +avcall-x86_64-x32.s : $(srcdir)/avcall-x86_64-x32-linux.s + cp $(srcdir)/avcall-x86_64-x32-linux.s avcall-x86_64-x32.s + +avcall-s390.lo : avcall-s390.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c avcall-s390.s + +avcall-s390.s : $(srcdir)/avcall-s390-macro.S + $(CPP) $(ASPFLAGS) $(srcdir)/avcall-s390-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > avcall-s390.s + +avcall-s390x.lo : avcall-s390x.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c avcall-s390x.s + +avcall-s390x.s : $(srcdir)/avcall-s390x-macro.S + $(CPP) $(ASPFLAGS) $(srcdir)/avcall-s390x-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > avcall-s390x.s + +avcall-riscv32-ilp32d.lo : avcall-riscv32-ilp32d.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c avcall-riscv32-ilp32d.s + +avcall-riscv32-ilp32d.s : $(srcdir)/avcall-riscv32-ilp32d-macro.S + $(CPP) $(ASPFLAGS) $(srcdir)/avcall-riscv32-ilp32d-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > avcall-riscv32-ilp32d.s + +avcall-riscv64-lp64d.lo : avcall-riscv64-lp64d.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c avcall-riscv64-lp64d.s + +avcall-riscv64-lp64d.s : $(srcdir)/avcall-riscv64-lp64d-macro.S + $(CPP) $(ASPFLAGS) $(srcdir)/avcall-riscv64-lp64d-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > avcall-riscv64-lp64d.s + +avcall-libapi.lo : $(srcdir)/avcall-libapi.c ../config.h $(srcdir)/avcall-internal.h $(srcdir)/avcall.h $(srcdir)/avcall-alist.h + $(LIBTOOL_COMPILE) $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @DISABLE_TYPE_BASED_ALIASING@ -c $(srcdir)/avcall-libapi.c + +avcall-structcpy.lo : $(srcdir)/avcall-structcpy.c $(srcdir)/../common/structcpy.c + $(LIBTOOL_COMPILE) $(CC) -I$(srcdir)/../common $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/avcall-structcpy.c + +avcall-compat.lo : $(srcdir)/avcall-compat.c ../config.h + $(LIBTOOL_COMPILE) $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/avcall-compat.c + +libavcall.la : $(OBJECTS) + $(LIBTOOL_LINK) $(CC) -o libavcall.la -rpath $(libdir) -no-undefined -export-symbols-regex $(LIBAVCALL_EXPORTED_SYMBOLS_REGEX) -version-info $(LIBAVCALL_VERSION_INFO) $(OBJECTS) $(LDFLAGS) + +# Installs the library and include files only. Typically called with only +# $(libdir) and $(includedir) - don't use $(prefix) and $(exec_prefix) here. +install-lib : all force + mkdir -p $(libdir) + $(LIBTOOL_INSTALL) $(INSTALL_DATA) libavcall.la $(libdir)/libavcall.la + mkdir -p $(includedir) + $(INSTALL_DATA) $(srcdir)/avcall.h $(includedir)/avcall.h + +install : all force + mkdir -p $(DESTDIR)$(prefix) + mkdir -p $(DESTDIR)$(exec_prefix) + mkdir -p $(DESTDIR)$(libdir) + $(LIBTOOL_INSTALL) $(INSTALL_DATA) libavcall.la $(DESTDIR)$(libdir)/libavcall.la + mkdir -p $(DESTDIR)$(includedir) + $(INSTALL_DATA) $(srcdir)/avcall.h $(DESTDIR)$(includedir)/avcall.h + mkdir -p $(DESTDIR)$(mandir) + mkdir -p $(DESTDIR)$(mandir)/man3 + $(INSTALL_DATA) $(srcdir)/avcall.3 $(DESTDIR)$(mandir)/man3/avcall.3 + mkdir -p $(DESTDIR)$(datadir) + mkdir -p $(DESTDIR)$(htmldir) + $(INSTALL_DATA) $(srcdir)/avcall.html $(DESTDIR)$(htmldir)/avcall.html + +installdirs : force + mkdir -p $(DESTDIR)$(prefix) + mkdir -p $(DESTDIR)$(exec_prefix) + mkdir -p $(DESTDIR)$(libdir) + mkdir -p $(DESTDIR)$(includedir) + mkdir -p $(DESTDIR)$(mandir) + mkdir -p $(DESTDIR)$(mandir)/man3 + mkdir -p $(DESTDIR)$(datadir) + mkdir -p $(DESTDIR)$(htmldir) + +uninstall : force + $(LIBTOOL_UNINSTALL) $(RM) $(DESTDIR)$(libdir)/libavcall.la + $(RM) $(DESTDIR)$(includedir)/avcall.h + $(RM) $(DESTDIR)$(mandir)/man3/avcall.3 + $(RM) $(DESTDIR)$(htmldir)/avcall.html + +minitests.@OBJEXT@ : $(srcdir)/minitests.c $(srcdir)/tests.c $(srcdir)/avcall.h + $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/minitests.c + +minitests.s : $(srcdir)/minitests.c $(srcdir)/tests.c $(srcdir)/avcall.h + $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -S $(srcdir)/minitests.c + +minitests : minitests.@OBJEXT@ libavcall.la + $(LIBTOOL_LINK) $(CC) $(CFLAGS) @GCC_X_NONE@ minitests.@OBJEXT@ libavcall.la $(LDFLAGS) -o minitests + +minitests-c++.@OBJEXT@ : $(srcdir)/minitests-c++.cc $(srcdir)/minitests.c $(srcdir)/tests.c $(srcdir)/avcall.h + $(CXX) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS) -c $(srcdir)/minitests-c++.cc + +minitests-c++ : minitests-c++.@OBJEXT@ libavcall.la + $(LIBTOOL_LINK) $(CXX) $(CXXFLAGS) @GCC_X_NONE@ minitests-c++.@OBJEXT@ libavcall.la $(LDFLAGS) -o minitests-c++ + +check : all minitests + ./minitests > minitests.out + LC_ALL=C uniq -u < minitests.out > minitests.output.$(HOST) + test '!' -s minitests.output.$(HOST) +@IF_CXX@# minitests-c++ crashes on HP-UX HPPA 32-bit with aCC, even without "-O". +@IF_CXX@ test $(CPU) = 'hppa' || { \ +@IF_CXX@ ./minitests-c++ > minitests-c++.out \ +@IF_CXX@ && LC_ALL=C uniq -u < minitests-c++.out > minitests-c++.output.$(HOST) \ +@IF_CXX@ && test '!' -s minitests-c++.output.$(HOST); \ +@IF_CXX@ } +@IF_CXX@check : minitests-c++ + +tests.@OBJEXT@ : $(srcdir)/tests.c $(srcdir)/avcall.h + $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/tests.c + +tests.s : $(srcdir)/tests.c $(srcdir)/avcall.h + $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -S $(srcdir)/tests.c + +tests : tests.@OBJEXT@ libavcall.la + $(LIBTOOL_LINK) $(CC) $(CFLAGS) @GCC_X_NONE@ tests.@OBJEXT@ libavcall.la $(LDFLAGS) -o tests + +extracheck : all tests + ./tests > tests.out + LC_ALL=C uniq -u < tests.out > tests.output.$(HOST) + test '!' -s tests.output.$(HOST) + +mostlyclean : clean + +clean : force + $(RM) *.@OBJEXT@ *.lo *.a libavcall.* core + $(RM) avcall-i386.s avcall-sparc.s avcall-sparc64.s avcall-m68k.s avcall-mips.s avcall-mipsn32.s avcall-mips64.s avcall-alpha.s avcall-hppa.s avcall-hppa64.s avcall-arm.s avcall-armhf.s avcall-arm64.s avcall-powerpc.s avcall-powerpc64.s avcall-powerpc64-elfv2.s avcall-ia64.s avcall-x86_64.s avcall-x86_64.asm avcall-x86_64-x32.s avcall-s390.s avcall-s390x.s avcall-riscv32-ilp32d.s avcall-riscv64-lp64d.s + $(RM) -r .libs _libs + $(RM) minitests.@OBJEXT@ minitests.s minitests minitests.out + $(RM) minitests-c++.@OBJEXT@ minitests-c++ minitests-c++.out + $(RM) tests.@OBJEXT@ tests.s tests tests.out + +distclean : clean + $(RM) Makefile minitests.output.* minitests-c++.output.* tests.output.* + +maintainer-clean : distclean + + +# List of source files (committed in version control or generated by Makefile.devel). +SOURCE_FILES = \ + COPYING \ + DOC PLATFORMS README avcall.3 avcall.html \ + Makefile.devel \ + Makefile.maint \ + Makefile.in \ + avcall.h avcall-internal.h avcall-alist.h \ + avcall-alpha.c avcall-alpha-linux.s avcall-alpha-macro.S \ + avcall-arm.c avcall-arm-macro.S \ + avcall-armhf.c avcall-armhf-macro.S \ + avcall-arm64.c avcall-arm64-macro.S \ + avcall-hppa.c avcall-hppa-linux.s avcall-hppa-macro.S \ + avcall-hppa64.c avcall-hppa64-linux.s avcall-hppa64-macro.S \ + avcall-i386.c avcall-i386-linux.s avcall-i386-macro.S \ + avcall-ia64.c avcall-ia64-linux.s avcall-ia64-macro.S \ + avcall-m68k.c avcall-m68k-linux.s avcall-m68k-sun.s avcall-m68k.mit.S avcall-m68k.motorola.S \ + avcall-mips.c avcall-mipseb-linux.s avcall-mipsel-linux.s avcall-mipseb-macro.S avcall-mipsel-macro.S \ + avcall-mipsn32.c avcall-mipsn32eb-linux.s avcall-mipsn32el-linux.s avcall-mipsn32eb-macro.S avcall-mipsn32el-macro.S \ + avcall-mips64.c avcall-mips64eb-linux.s avcall-mips64el-linux.s avcall-mips64eb-macro.S avcall-mips64el-macro.S \ + avcall-powerpc.c \ + avcall-powerpc-aix.s \ + avcall-powerpc-linux.s avcall-powerpc-linux-macro.S avcall-powerpc-macos.s avcall-powerpc-sysv4-macro.S \ + avcall-powerpc64.c avcall-powerpc64-aix.s avcall-powerpc64-linux.S avcall-powerpc64-elfv2-linux.S \ + avcall-riscv32.c avcall-riscv32-ilp32d-linux.s avcall-riscv32-ilp32d-macro.S \ + avcall-riscv64.c avcall-riscv64-lp64d-linux.s avcall-riscv64-lp64d-macro.S \ + avcall-s390.c avcall-s390-linux.s avcall-s390-macro.S \ + avcall-s390x.c avcall-s390x-linux.s avcall-s390x-macro.S \ + avcall-sparc.c avcall-sparc-linux.s avcall-sparc-macro.S \ + avcall-sparc64.c avcall-sparc64-linux.s avcall-sparc64-macro.S \ + avcall-x86_64.c avcall-x86_64-linux.s avcall-x86_64-macro.S avcall-x86_64-x32-linux.s \ + avcall-x86_64-windows.c avcall-x86_64-windows.s avcall-x86_64-windows-macro.S \ + avcall-libapi.c \ + avcall-structcpy.c \ + avcall-compat.c \ + minitests.c minitests-c++.cc \ + tests.c +# List of distributed files generated by Makefile.maint. +GENERATED_FILES = \ + avcall.man \ + avcall-i386-msvc.c +# List of distributed files. +DISTFILES = $(SOURCE_FILES) $(GENERATED_FILES) + +distdir : $(DISTFILES) + for file in $(DISTFILES); do \ + if test -f $$file; then dir='.'; else dir='$(srcdir)'; fi; \ + cp -p "$$dir/$$file" '$(distdir)'/$$file || exit 1; \ + done + + +force : diff --git a/avcall/Makefile.maint b/avcall/Makefile.maint new file mode 100644 index 0000000..dbfa663 --- /dev/null +++ b/avcall/Makefile.maint @@ -0,0 +1,24 @@ +# maintainer -*-Makefile-*- + +LN = ln -s +RM = rm -f + +# ==================== Easily regeneratable files ==================== + +ROFF_MAN = groff -Tutf8 -mandoc + +all : avcall.man \ + avcall-i386-msvc.c + +avcall.man : avcall.3 + $(ROFF_MAN) avcall.3 > avcall.man + +avcall-i386-msvc.c : avcall-i386-macro.S + cp -p avcall-i386-macro.S avcall-i386-msvc.c + +totally-clean : force + $(RM) avcall.man + $(RM) avcall-i386-msvc.c + + +force : diff --git a/avcall/PLATFORMS b/avcall/PLATFORMS new file mode 100644 index 0000000..350b581 --- /dev/null +++ b/avcall/PLATFORMS @@ -0,0 +1,80 @@ +Supported CPUs: (Put the GNU config.guess values here.) + + CPU GNU config.guess value machine OS + + i386 i486-unknown-linux (gcc) i386/486/586 Linux + i686-unknown-gnu0.9 (gcc) i686 GNU Hurd + i386-unknown-sysv4.0 (gcc, i386 Consensys + /usr/bin/cc, /usr/ucb/cc) + i386-pc-solaris2.6 (gcc) i386/486/586 Solaris + i386-pc-solaris2.10 (gcc, cc) i386/486/586 Solaris + i486-unknown-sco3.2v4.2 (gcc, cc -Of) i386/486/586 SCO + i386-pc-cygwin32 (gcc) i386/486/586 Cygwin32 + i386-w64-mingw32 (gcc, MSVC 14) i386/486/586 Win32 + i586-unknown-freebsd11.0 (cc) i386/486/586 FreeBSD 11 + i386-unknown-dragonfly3.8 (gcc) i386/486/586 DragonFly BSD + i386-unknown-netbsdelf7.0 (gcc) i386/486/586 NetBSD 7 + i386-unknown-openbsd6.0 (gcc) i386/486/586 OpenBSD 6 + i586-pc-haiku (gcc-x86) i586 Haiku 2017 + i386-pc-minix (clang) i386/486/586 Minix 3.3 + m68k m68k-sun-sunos4.0 (cc) Sun3 SunOS 4.0.3 + m68k-unknown-linux (gcc) emulated Linux + mips mips-sgi-irix4.0.5 (gcc, SGI mips Irix 4.0.x + cc -ansi, cc -D__STDC__, cc -cckr) + mips-sgi-irix5.2 (gcc, cc -ansi, ...) SGI mips Irix 5.2 + mips-sgi-irix5.3 (gcc, cc -ansi, ...) SGI mips Irix 5.3 + mips-sgi-irix6.2 (cc -32) SGI mips3 Irix 6.2 + mips-sgi-irix6.4 (cc -32, -n32, -64) SGI mips3 Irix 6.4 + mips-sgi-irix6.5 (cc -32, -n32, SGI mips3 Irix 6.5 + gcc -mabi=n32) + mips-unknown-linux (gcc -mabi=32) emulated Linux + mips64-unknown-linux (gcc -mabi=n32,64)emulated Linux + sparc sparc-sun-sunos4.1.1 (gcc, cc) Sun4 Sparc SunOS 4.x + sparc-sun-solaris2.3 (gcc) Sun4 Sparc SunOS 5.x + sparc-sun-solaris2.4 (gcc, cc) Sun4 Sparc SunOS 5.x + sparc-sun-solaris2.10 (gcc, cc) Sun4 Sparc Solaris 10 + sparc64-sun-solaris2.10 (gcc -m64, Sun4 Sparc Solaris 10 + cc -xarch=generic64) + sparc-unknown-linux (gcc) emulated Linux + sparc64-unknown-linux (gcc) emulated Linux + sparc-unknown-netbsdelf7.1 (gcc) emulated NetBSD 7.1 + sparc64-unknown-netbsd8.0 (gcc) emulated NetBSD 8.0 + alpha alpha-dec-osf3.0 (gcc, cc) DEC Alpha OSF/1 3.0 + alpha-dec-osf4.0 (gcc, cc) DEC Alpha OSF/1 4.0 + alphaev67-unknown-linux (gcc) emulated Linux + hppa hppa1.0-hp-hpux8.00 (gcc, HP 9000/8xx HP-UX 8.0x + cc, c89, cc -Aa) + hppa1.1-hp-hpux9.05 (cc) HP 9000/8xx HP-UX 9.0x + hppa1.1-hp-hpux10.01 (cc) HP 9000/8xx HP-UX 10.0x + hppa2.0-hp-hpux10.20 (cc +DA1.1) HP 9000/8xx HP-UX 10.20 + hppa2.0w-hp-hpux11.31 (cc) HP 9000/8xx HP-UX 11.31 + hppa-unknown-linux (gcc) emulated Linux + hppa64 hppa64-hp-hpux11.31 (cc +DD64) HP 9000/8xx HP-UX 11.31 + arm armv5tejl-unknown-linux (gcc) emulated Linux + armv6l-unknown-linux (gcc) emulated Linux + armv7l-unknown-linux (gcc) emulated Linux + arm64 aarch64-unknown-linux (gcc) APM X-Gene Linux + powerpc powerpc-ibm-aix4.1.4.0 (cc) IBM RS/6000 AIX 4.1.4 + powerpc-ibm-aix7.1.3.0 (xlc, gcc) IBM POWER AIX 7.1.3 + powerpc-unknown-linux (gcc) Apple PPC LinuxPPC + powerpc-apple-darwin6.8 (gcc) Apple PPC MacOS X + powerpc-apple-darwin9.8.0 (gcc) Apple PPC MacOS X + powerpc64 powerpc-ibm-aix7.1.3.0 (gcc -maix64, IBM POWER AIX 7.1.3 + xlc -q64) + powerpc64-unknown-linux (gcc -m64) IBM POWER Linux + powerpc64le-unknown-linux (gcc) IBM POWER Linux + ia64 ia64-unknown-linux (gcc) Intel Linux + x86_64 x86_64-suse-linux (gcc) AMD64 Linux + x86_64-unknown-linux (gcc -mx32) AMD64 Linux + x86_64-pc-solaris2.10 (gcc -m64) AMD64 Solaris + x86_64-pc-solaris2.10 (cc -xarch=generic64) AMD64 Solaris + x86_64-pc-cygwin (gcc) AMD64 Windows 10 + x86_64-w64-mingw32 (gcc, MSVC 14) AMD64 Windows 10 + x86_64-unknown-freebsd11.0 (cc) AMD64 FreeBSD 11 + x86_64-unknown-netbsd7.0 (gcc) AMD64 NetBSD 7 + x86_64-unknown-openbsd6.0 (gcc) AMD64 OpenBSD 6 + s390 s390x-ibm-linux (gcc -m31) emulated Linux + s390x s390x-ibm-linux (gcc) emulated Linux + riscv32 riscv32-unknown-linux (gcc -mabi=ilp32d) emulated Linux + riscv64 riscv64-unknown-linux (gcc -mabi=lp64d) emulated Linux + diff --git a/avcall/README b/avcall/README new file mode 100644 index 0000000..b85a718 --- /dev/null +++ b/avcall/README @@ -0,0 +1,73 @@ +avcall - calling C functions with variable arguments + +This library allows arbitrary C functions to be called from embedded +interpreters, debuggers, RPC calls, etc, by building up a C +argument-list incrementally from explicitly typed arguments. This +considerably reduces the amount of boilerplate glue code required +for such applications. + +The interface is like stdargs/varargs in reverse and is intended to be as +portable as possible, however the details of function calling are highly +machine-dependent so your mileage may vary. At the very least there are +typically built-in limits on the size of the argument-list. The +argument-pushing macros all return 0 for success, < 0 for error (eg, +arg-list overflow). + + +Installation instructions: + + Configure the parent directory. Then: + cd avcall + make + make check + make install + + +Files in this package: + + Documentation: + + README this text + COPYING free software license + PLATFORMS list of supported platforms + avcall.3 manual page in Unix man format + avcall.man manual page + avcall.html manual page in HTML format + DOC documentation + + Source: + + avcall.h main include file + avcall-*.c source for the main interface function + avcall-*.[sS] its translation to assembly language + avcall-libapi.c implementation of other library API + avcall-structcpy.c auxiliary function + tests.c test program + + Building: + + Makefile.in Makefile master + + Porting: + + Makefile.devel developer's Makefile + + +Copyright notice: + +Copyright 1993-1995 Bill Triggs +Copyright 1995-2017 Bruno Haible + +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, see . + diff --git a/avcall/avcall-alist.h b/avcall/avcall-alist.h new file mode 100644 index 0000000..6651879 --- /dev/null +++ b/avcall/avcall-alist.h @@ -0,0 +1,209 @@ +/* + * Copyright 1993-1995 Bill Triggs + * Copyright 1995-2019 Bruno Haible + * + * 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, see . + */ + +#ifndef _AVCALL_INTERNAL_H +#error "Never use directly; include instead." +#endif + +/* The platform indicator symbols (__i386__, etc.) come from + - "config.h" when compiling avcall-libapi.c, + - the GCC command line options when compiling avcall-$(CPU).c. + */ + +/* These two variants of powerpc ABIs are quite different. */ +#if defined(__powerpc__) && !defined(__powerpc64__) +#if defined(_AIX) || (defined(__MACH__) && defined(__APPLE__)) +#define __powerpc_aix__ 1 +#else +#define __powerpc_sysv4__ 1 +#endif +#endif + +/* The Unix and Windows variants of x86_64 ABIs are quite different. */ +#if defined(__x86_64__) +#if defined(_WIN32) || defined(__CYGWIN__) +#define __x86_64_ms__ 1 +#else +#define __x86_64_sysv__ 1 +#endif +#endif + +/* + * Definition of the ‘__av_alist’ type. + */ +/* Note: This struct must not contain members of type 'long' or 'unsigned long', + because in the mingw port we use precompiled code that assumes 'long' is + 64-bit whereas avcall-libapi.c is then compiled by a compiler that has a + 32-bit 'long' type. */ +typedef struct +{ + /* some av_... macros need these flags */ + int flags; + /* function to be called */ + __avword (*func)(); + /* return type, address for the result */ + void* raddr; + enum __AVtype rtype; + uintptr_t rsize; + /* current pointer into the args[] array */ + __avword* aptr; + /* beginning of the args[] array */ + __avword* args; +#if defined(__hppa__) && !defined(__hppa64__) + /* end of the args[] array */ + __avword* args_end; +#endif + /* limit pointer into the args[] array */ + __avword* eptr; +#if defined(__i386__) && 0 + /* Filler word, needed if the numbers of words up to now in this structure */ + /* is odd (because on MSVC, alignof(double) = 8, normally = 4). */ + __avword filler1; +#endif +#if defined(__i386__) || defined(__m68k__) || (defined(__sparc__) && !defined(__sparc64__)) || (defined(__hppa__) && !defined(__hppa64__)) || defined(__arm__) || defined(__armhf__) || (defined(__powerpc__) && !defined(__powerpc64__)) || (defined(__s390__) && !defined(__s390x__)) || defined(__riscv32__) + /* temporary storage, used to split doubles into two words */ + union { + double _double; +#if defined(__sparc__) && !defined(__sparc64__) + long long _longlong; +#endif + __avword words[2]; + } tmp; +#endif +#if defined(__x86_64_sysv__) +#define __AV_IARG_NUM 6 + /* store the integer arguments in an extra array */ + unsigned int ianum; + __avword iargs[__AV_IARG_NUM]; +#endif +#if defined(__mips__) && !defined(__mipsn32__) && !defined(__mips64__) +#define __AV_FARG_NUM 2 + /* store the floating-point arguments in an extra array */ + unsigned int anum; + unsigned int fanum; + unsigned int farg_mask; /* bitmask of those entries in fargs[] which have a float value */ + unsigned int darg_mask; /* bitmask of those entries in dargs[] which have a double value */ + float fargs[__AV_FARG_NUM]; + double dargs[__AV_FARG_NUM]; +#endif +#if defined(__mipsn32__) || defined(__mips64__) + /* store the floating-point arguments in an extra array */ + int anum; /* redundant: (LIST).aptr = &(LIST).args[(LIST).anum] */ + unsigned int farg_mask; /* bitmask of those entries in farg[] which have a value */ + unsigned int darg_mask; /* bitmask of those entries in args[] which have a double value */ + float fargs[8]; +#endif +#if defined(__sparc64__) + /* store the floating-point arguments in an extra array */ + int anum; /* redundant: (LIST).aptr = &(LIST).args[(LIST).anum] */ + unsigned int darg_mask; /* bitmask of those entries in args[] which have a float or double value */ +#endif +#if defined(__hppa__) || defined(__hppa64__) + unsigned int farg_mask; /* bitmask of those entries in args[] which have a float value */ + unsigned int darg_mask; /* bitmask of those entries in args[] which have a double value */ +#endif +#if defined(__armhf__) +#define __AV_IARG_NUM 4 + /* The first __AV_IARG_NUM integer arguments are passed in registers, even if + some floating-point arguments have already been allocated on the stack. */ + unsigned int ianum; + /* store the floating-point arguments in an extra array */ + unsigned int fanum; /* number of fargs[] words that are occupied so far */ + unsigned int farg_mask; /* bitmask of those entries in fargs[] which have a float value */ + unsigned int darg_mask; /* bitmask of those entries in dargs[] which have a double value */ + float fargs[16]; + double dargs[8]; +#endif +#if defined(__arm64__) +#define __AV_IARG_NUM 8 + /* store the integer arguments in an extra array */ + unsigned int ianum; + __avword iargs[__AV_IARG_NUM]; +#define __AV_FARG_NUM 8 + /* store the floating-point arguments in an extra array */ + unsigned int fanum; /* number of fargs[] words that are occupied so far */ + unsigned int farg_mask; /* bitmask of those entries in fargs[] which have a float value */ + unsigned int darg_mask; /* bitmask of those entries in dargs[] which have a double value */ + float fargs[__AV_FARG_NUM]; + double dargs[__AV_FARG_NUM]; +#endif +#if defined(__ia64__) || defined(__x86_64_sysv__) + /* store the floating-point arguments in an extra array */ +#define __AV_FARG_NUM 8 + double* faptr; + double fargs[__AV_FARG_NUM]; +#endif +#if defined(__powerpc__) || defined(__powerpc64__) +#if defined(__powerpc_sysv4__) +#define __AV_IARG_NUM 8 + /* store the integer arguments in an extra array */ + unsigned int ianum; + __avword iargs[__AV_IARG_NUM]; +#define __AV_FARG_NUM 8 +#else +#define __AV_FARG_NUM 13 +#endif + /* store the floating-point arguments in an extra array */ + double* faptr; + double fargs[__AV_FARG_NUM]; +#endif +#if defined(__x86_64_ms__) + /* store the floating-point arguments in an extra array */ + int anum; /* redundant: (LIST).aptr = &(LIST).args[(LIST).anum] */ +#define __AV_FARG_NUM 4 + unsigned int farg_mask; /* bitmask of those entries in fargs[] which have a float value */ + unsigned int darg_mask; /* bitmask of those entries in dargs[] which have a double value */ + float fargs[__AV_FARG_NUM]; + double dargs[__AV_FARG_NUM]; +#endif +#if (defined(__s390__) && !defined(__s390x__)) +#define __AV_IARG_NUM 5 + /* store the integer arguments in an extra array */ + unsigned int ianum; + __avword iargs[__AV_IARG_NUM]; + /* store the floating-point arguments in an extra array */ +#define __AV_FARG_NUM 2 + unsigned int fanum; /* number of fargs[] words that are occupied so far */ + unsigned int farg_mask; /* bitmask of those entries in fargs[] which have a float value */ + unsigned int darg_mask; /* bitmask of those entries in dargs[] which have a double value */ + float fargs[__AV_FARG_NUM]; + double dargs[__AV_FARG_NUM]; +#endif +#if defined(__s390x__) +#define __AV_IARG_NUM 5 + /* store the integer arguments in an extra array */ + unsigned int ianum; + __avword iargs[__AV_IARG_NUM]; +#define __AV_FARG_NUM 4 + /* store the floating-point arguments in an extra array */ + unsigned int fanum; /* number of fargs[] words that are occupied so far */ + unsigned int farg_mask; /* bitmask of those entries in fargs[] which have a float value */ + unsigned int darg_mask; /* bitmask of those entries in dargs[] which have a double value */ + float fargs[__AV_FARG_NUM]; + double dargs[__AV_FARG_NUM]; +#endif +#if defined(__riscv32__) || defined(__riscv64__) +#define __AV_FARG_NUM 8 + /* store the floating-point arguments in an extra array */ + unsigned int fanum; /* number of fargs[] words that are occupied so far */ + unsigned int farg_mask; /* bitmask of those entries in fargs[] which have a float value */ + unsigned int darg_mask; /* bitmask of those entries in dargs[] which have a double value */ + float fargs[__AV_FARG_NUM]; + double dargs[__AV_FARG_NUM]; +#endif +} __av_alist; diff --git a/avcall/avcall-alpha-linux.s b/avcall/avcall-alpha-linux.s new file mode 100644 index 0000000..63913e8 --- /dev/null +++ b/avcall/avcall-alpha-linux.s @@ -0,0 +1,191 @@ + .set noreorder + .set volatile + .set noat + .set nomacro + .text + .align 2 + .align 4 + .globl avcall_call + .ent avcall_call +avcall_call: + .frame $15,32,$26,0 + .mask 0x4008200,-32 + ldah $29,0($27) !gpdisp!1 + lda $29,0($29) !gpdisp!1 +$avcall_call..ng: + lda $30,-32($30) + ldq $1,40($16) + ldq $3,48($16) + stq $9,8($30) + mov $16,$9 + stq $15,16($30) + mov $30,$15 + subq $1,$3,$1 + stq $26,0($30) + .prologue 1 + srl $1,3,$1 + lda $30,-2064($30) + addl $31,$1,$7 + cmple $7,6,$2 + bne $2,$L2 + mov $30,$5 + lda $6,6($31) + lda $4,48($3) + .align 4 +$L4: + lda $6,1($6) + ldq $1,0($4) + cmpeq $7,$6,$2 + lda $4,8($4) + stq $1,0($5) + lda $5,8($5) + beq $2,$L4 +$L2: + .set macro + ldq $16,0($3) + ldt $f16,0($3) + .set nomacro + lda $1,8($3) + .set macro + ldq $17,0($1) + ldt $f17,0($1) + .set nomacro + lda $2,16($3) + .set macro + ldq $18,0($2) + ldt $f18,0($2) + .set nomacro + lda $1,24($3) + .set macro + ldq $19,0($1) + ldt $f19,0($1) + .set nomacro + lda $2,32($3) + .set macro + ldq $20,0($2) + ldt $f20,0($2) + .set nomacro + lda $3,40($3) + .set macro + ldq $21,0($3) + ldt $f21,0($3) + .set nomacro + ldq $27,8($9) + jsr $26,($27),0 + ldah $29,0($26) !gpdisp!2 + lda $29,0($29) !gpdisp!2 + mov $1,$4 + ldl $2,24($9) + zapnot $2,15,$3 + cmpeq $3,1,$1 + bne $1,$L5 + beq $2,$L55 + cmpeq $3,2,$1 + bne $1,$L53 + cmpeq $3,3,$1 + bne $1,$L53 + cmpeq $3,4,$1 + bne $1,$L53 + cmpeq $3,5,$1 + bne $1,$L54 + cmpeq $3,6,$1 + bne $1,$L54 + cmpeq $3,7,$1 + bne $1,$L56 + cmpeq $3,8,$1 + bne $1,$L56 + cmpeq $3,9,$1 + bne $1,$L55 + cmpeq $3,10,$1 + bne $1,$L55 + cmpeq $3,11,$1 + bne $1,$L55 + cmpeq $3,12,$1 + bne $1,$L55 + cmpeq $3,13,$1 + bne $1,$L58 + cmpeq $3,14,$1 + bne $1,$L59 + cmpeq $3,15,$1 + bne $1,$L55 + cmpeq $3,16,$1 + beq $1,$L5 + .align 3 #realign + lda $1,512($31) + ldl $2,0($9) + and $1,$2,$1 + beq $1,$L5 + ldq $2,32($9) + cmpeq $2,1,$1 + bne $1,$L53 + cmpeq $2,2,$1 + bne $1,$L54 + cmpeq $2,4,$1 + bne $1,$L56 + cmpeq $2,8,$1 + bne $1,$L55 + cmpeq $2,16,$1 + beq $1,$L5 + ldq $1,16($9) + stq $4,8($1) + stq $0,0($1) +$L5: + mov $15,$30 + mov $31,$0 + ldq $26,0($30) + ldq $9,8($30) + ldq $15,16($30) + lda $30,32($30) + ret $31,($26),1 + bis $31,$31,$31 +$L55: + mov $15,$30 + ldq $1,16($9) + stq $0,0($1) + mov $31,$0 + ldq $26,0($30) + ldq $9,8($30) + ldq $15,16($30) + lda $30,32($30) + ret $31,($26),1 + bis $31,$31,$31 +$L53: + mov $15,$30 + ldq $1,16($9) + insbl $0,$1,$3 + ldq_u $2,0($1) + mov $31,$0 + mskbl $2,$1,$2 + bis $3,$2,$3 + stq_u $3,0($1) + ldq $26,0($30) + ldq $9,8($30) + ldq $15,16($30) + lda $30,32($30) + ret $31,($26),1 +$L54: + ldq $1,16($9) + inswl $0,$1,$3 + ldq_u $2,0($1) + mskwl $2,$1,$2 + bis $3,$2,$3 + stq_u $3,0($1) + br $31,$L5 +$L56: + ldq $1,16($9) + bis $31,$31,$31 + stl $0,0($1) + br $31,$L5 +$L58: + cvtts $f0,$f0 + ldq $1,16($9) + sts $f0,0($1) + br $31,$L5 +$L59: + ldq $1,16($9) + bis $31,$31,$31 + stt $f0,0($1) + br $31,$L5 + .end avcall_call + .ident "GCC: (GNU) 4.0.2" + .section .note.GNU-stack,"",@progbits diff --git a/avcall/avcall-alpha-macro.S b/avcall/avcall-alpha-macro.S new file mode 100644 index 0000000..e3a897d --- /dev/null +++ b/avcall/avcall-alpha-macro.S @@ -0,0 +1,192 @@ + .set noreorder + .set volatile + .set noat + .set nomacro + .text + .align 2 + .align 4 + .globl avcall_call + .ent avcall_call +avcall_call: + .frame $15,32,$26,0 + .mask 0x4008200,-32 + ldah $29,0($27) !gpdisp!1 + lda $29,0($29) !gpdisp!1 +$avcall_call..ng: + lda $30,-32($30) + ldq $1,40($16) + ldq $3,48($16) + stq $9,8($30) + mov $16,$9 + stq $15,16($30) + mov $30,$15 + subq $1,$3,$1 + stq $26,0($30) + .prologue 1 + srl $1,3,$1 + lda $30,-2064($30) + addl $31,$1,$7 + cmple $7,6,$2 + bne $2,$L2 + mov $30,$5 + lda $6,6($31) + lda $4,48($3) + .align 4 +$L4: + lda $6,1($6) + ldq $1,0($4) + cmpeq $7,$6,$2 + lda $4,8($4) + stq $1,0($5) + lda $5,8($5) + beq $2,$L4 +$L2: + .set macro + ldq $16,0($3) + ldt $f16,0($3) + .set nomacro + lda $1,8($3) + .set macro + ldq $17,0($1) + ldt $f17,0($1) + .set nomacro + lda $2,16($3) + .set macro + ldq $18,0($2) + ldt $f18,0($2) + .set nomacro + lda $1,24($3) + .set macro + ldq $19,0($1) + ldt $f19,0($1) + .set nomacro + lda $2,32($3) + .set macro + ldq $20,0($2) + ldt $f20,0($2) + .set nomacro + lda $3,40($3) + .set macro + ldq $21,0($3) + ldt $f21,0($3) + .set nomacro + ldq $27,8($9) + jsr $26,($27),0 + ldah $29,0($26) !gpdisp!2 + lda $29,0($29) !gpdisp!2 + mov $1,$4 + ldl $2,24($9) + zapnot $2,15,$3 + cmpeq $3,1,$1 + bne $1,$L5 + beq $2,$L55 + cmpeq $3,2,$1 + bne $1,$L53 + cmpeq $3,3,$1 + bne $1,$L53 + cmpeq $3,4,$1 + bne $1,$L53 + cmpeq $3,5,$1 + bne $1,$L54 + cmpeq $3,6,$1 + bne $1,$L54 + cmpeq $3,7,$1 + bne $1,$L56 + cmpeq $3,8,$1 + bne $1,$L56 + cmpeq $3,9,$1 + bne $1,$L55 + cmpeq $3,10,$1 + bne $1,$L55 + cmpeq $3,11,$1 + bne $1,$L55 + cmpeq $3,12,$1 + bne $1,$L55 + cmpeq $3,13,$1 + bne $1,$L58 + cmpeq $3,14,$1 + bne $1,$L59 + cmpeq $3,15,$1 + bne $1,$L55 + cmpeq $3,16,$1 + beq $1,$L5 + .align 3 #realign + lda $1,512($31) + ldl $2,0($9) + and $1,$2,$1 + beq $1,$L5 + ldq $2,32($9) + cmpeq $2,1,$1 + bne $1,$L53 + cmpeq $2,2,$1 + bne $1,$L54 + cmpeq $2,4,$1 + bne $1,$L56 + cmpeq $2,8,$1 + bne $1,$L55 + cmpeq $2,16,$1 + beq $1,$L5 + ldq $1,16($9) + stq $4,8($1) + stq $0,0($1) +$L5: + mov $15,$30 + mov $31,$0 + ldq $26,0($30) + ldq $9,8($30) + ldq $15,16($30) + lda $30,32($30) + ret $31,($26),1 + bis $31,$31,$31 +$L55: + mov $15,$30 + ldq $1,16($9) + stq $0,0($1) + mov $31,$0 + ldq $26,0($30) + ldq $9,8($30) + ldq $15,16($30) + lda $30,32($30) + ret $31,($26),1 + bis $31,$31,$31 +$L53: + mov $15,$30 + ldq $1,16($9) + insbl $0,$1,$3 + ldq_u $2,0($1) + mov $31,$0 + mskbl $2,$1,$2 + bis $3,$2,$3 + stq_u $3,0($1) + ldq $26,0($30) + ldq $9,8($30) + ldq $15,16($30) + lda $30,32($30) + ret $31,($26),1 +$L54: + ldq $1,16($9) + inswl $0,$1,$3 + ldq_u $2,0($1) + mskwl $2,$1,$2 + bis $3,$2,$3 + stq_u $3,0($1) + br $31,$L5 +$L56: + ldq $1,16($9) + bis $31,$31,$31 + stl $0,0($1) + br $31,$L5 +$L58: + cvtts $f0,$f0 + ldq $1,16($9) + sts $f0,0($1) + br $31,$L5 +$L59: + ldq $1,16($9) + bis $31,$31,$31 + stt $f0,0($1) + br $31,$L5 + .end avcall_call +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/avcall/avcall-alpha.c b/avcall/avcall-alpha.c new file mode 100644 index 0000000..6f05888 --- /dev/null +++ b/avcall/avcall-alpha.c @@ -0,0 +1,168 @@ +/** + Copyright 1993 Bill Triggs + Copyright 1995-2017 Bruno Haible + + 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, see . +**/ +/*---------------------------------------------------------------------- + !!! THIS ROUTINE MUST BE COMPILED gcc -O !!! + + Foreign function interface for a DEC Alpha with gcc. + + This calls a C function with an argument list built up using macros + defined in avcall.h. + + Alpha Argument Passing Conventions + + The first 6 arguments are passed in registers $16-$21 for integers, + in registers $f16-$f21 for floats. From then on, everything is passed + on the stack. + + Everything on the stack is word-aligned. + + Integers and pointers are returned in $0, floats and doubles in $f0. + To return a structure, the called function copies the value to space + pointed to by its first argument, and all other arguments are shifted + down by one. + + Compile this routine with gcc for the __asm__ extensions and with + optimisation on (-O or -O2 or -g -O) so that argframe is set to the + correct offset. + ----------------------------------------------------------------------*/ +#include "avcall-internal.h" + +#define RETURN(TYPE,VAL) (*(TYPE*)l->raddr = (TYPE)(VAL)) + +int +avcall_call(av_alist* list) +{ + register __avword* sp __asm__("$30"); /* C names for registers */ + register long arg1 __asm__("$16"); + register long arg2 __asm__("$17"); + register long arg3 __asm__("$18"); + register long arg4 __asm__("$19"); + register long arg5 __asm__("$20"); + register long arg6 __asm__("$21"); + register double fret __asm__("$f0"); + register double farg1 __asm__("$f16"); + register double farg2 __asm__("$f17"); + register double farg3 __asm__("$f18"); + register double farg4 __asm__("$f19"); + register double farg5 __asm__("$f20"); + register double farg6 __asm__("$f21"); +/*register __avword iret __asm__("$0"); */ + register __avword iret2 __asm__("$1"); + + __av_alist* l = &AV_LIST_INNER(list); + + __avword* argframe = __builtin_alloca(__AV_ALIST_WORDS * sizeof(__avword)); /* make room for argument list */ + int arglen = ((unsigned long) l->aptr - (unsigned long) l->args) / sizeof (__avword); + __avword i, i2; + + for (i = 6; i < arglen; i++) /* push excess function args */ + argframe[i-6] = l->args[i]; + + /* call function with 1st 6 args */ + /* we pass the args both in the integer registers and the floating point + registers, so we don't have to store the argument types. */ + __asm__ __volatile__ ("ldq $16,%0" : : "m" (l->args[0])); /* arg1 = l->args[0]; */ + __asm__ __volatile__ ("ldt $f16,%0" : : "m" (l->args[0])); /* farg1 = *(double*) &l->args[0]; */ + __asm__ __volatile__ ("ldq $17,%0" : : "m" (l->args[1])); /* arg2 = l->args[1]; */ + __asm__ __volatile__ ("ldt $f17,%0" : : "m" (l->args[1])); /* farg2 = *(double*) &l->args[1]; */ + __asm__ __volatile__ ("ldq $18,%0" : : "m" (l->args[2])); /* arg3 = l->args[2]; */ + __asm__ __volatile__ ("ldt $f18,%0" : : "m" (l->args[2])); /* farg3 = *(double*) &l->args[2]; */ + __asm__ __volatile__ ("ldq $19,%0" : : "m" (l->args[3])); /* arg4 = l->args[3]; */ + __asm__ __volatile__ ("ldt $f19,%0" : : "m" (l->args[3])); /* farg4 = *(double*) &l->args[3]; */ + __asm__ __volatile__ ("ldq $20,%0" : : "m" (l->args[4])); /* arg5 = l->args[4]; */ + __asm__ __volatile__ ("ldt $f20,%0" : : "m" (l->args[4])); /* farg5 = *(double*) &l->args[4]; */ + __asm__ __volatile__ ("ldq $21,%0" : : "m" (l->args[5])); /* arg6 = l->args[5]; */ + __asm__ __volatile__ ("ldt $f21,%0" : : "m" (l->args[5])); /* farg6 = *(double*) &l->args[5]; */ + i = (*l->func)(); + i2 = iret2; + /* this is apparently not needed, but better safe than sorry... */ + __asm__ __volatile__ ("" : : : + /* clobber */ "$16", "$17", "$18", "$19", "$20", "$21", + "$f16","$f17","$f18","$f19","$f20","$f21"); + + /* save return value */ + if (l->rtype == __AVvoid) { + } else + if (l->rtype == __AVword) { + RETURN(__avword, i); + } else + if (l->rtype == __AVchar) { + RETURN(char, i); + } else + if (l->rtype == __AVschar) { + RETURN(signed char, i); + } else + if (l->rtype == __AVuchar) { + RETURN(unsigned char, i); + } else + if (l->rtype == __AVshort) { + RETURN(short, i); + } else + if (l->rtype == __AVushort) { + RETURN(unsigned short, i); + } else + if (l->rtype == __AVint) { + RETURN(int, i); + } else + if (l->rtype == __AVuint) { + RETURN(unsigned int, i); + } else + if (l->rtype == __AVlong) { + RETURN(long, i); + } else + if (l->rtype == __AVulong) { + RETURN(unsigned long, i); + } else + if (l->rtype == __AVlonglong) { + RETURN(long long, i); + } else + if (l->rtype == __AVulonglong) { + RETURN(unsigned long long, i); + } else + if (l->rtype == __AVfloat) { + RETURN(float, fret); + } else + if (l->rtype == __AVdouble) { + RETURN(double, fret); + } else + if (l->rtype == __AVvoidp) { + RETURN(void*, i); + } else + if (l->rtype == __AVstruct) { + if (l->flags & __AV_REGISTER_STRUCT_RETURN) { + if (l->rsize == sizeof(char)) { + RETURN(char, i); + } else + if (l->rsize == sizeof(short)) { + RETURN(short, i); + } else + if (l->rsize == sizeof(int)) { + RETURN(int, i); + } else + if (l->rsize == sizeof(long)) { + RETURN(long, i); + } else + if (l->rsize == 2*sizeof(__avword)) { + void* raddr = l->raddr; + ((__avword*)raddr)[0] = i; + ((__avword*)raddr)[1] = i2; + } + } + } + return 0; +} diff --git a/avcall/avcall-arm-macro.S b/avcall/avcall-arm-macro.S new file mode 100644 index 0000000..da8fc5f --- /dev/null +++ b/avcall/avcall-arm-macro.S @@ -0,0 +1,112 @@ +#include "asm-arm.h" + .text + .align 2 + .global C(avcall_call) + DECLARE_FUNCTION(avcall_call) +FUNBEGIN(avcall_call) + // args = 0, pretend = 0, frame = 1024 + // frame_needed = 1, uses_anonymous_args = 0 + mov ip, sp + stmfd sp!, {r4, r5, fp, ip, lr, pc} + sub fp, ip, $4 + sub sp, sp, $1024 + add r2, r0, $20 + ldmia r2, {r2, r3} + sub r3, r2, r3 + mov ip, $4 + mov r1, r3, asr $2 + cmp ip, r1 + mov r5, r0 + bic sp, sp, $7 + ldr r4, [r0, $24] + bge L(47) + add r2, sp, $16 +L(6): + ldr r3, [r4, ip, asl $2] + add ip, ip, $1 + cmp ip, r1 + str r3, [r2, $-16] + add r2, r2, $4 + blt L(6) +L(47): + ldmia r4, {r0, r1, r2, r3} // phole ldm + mov lr, pc + ldr pc, [r5, $4] + ldr r2, [r5, $12] + cmp r2, $1 + mov ip, r0 + beq L(8) + cmp r2, $0 + beq L(57) + cmp r2, $2 + beq L(50) + cmp r2, $3 + beq L(50) + cmp r2, $4 + beq L(50) + cmp r2, $5 + beq L(49) + cmp r2, $6 + beq L(49) + cmp r2, $7 + beq L(57) + cmp r2, $8 + beq L(57) + cmp r2, $9 + beq L(57) + cmp r2, $10 + beq L(57) + sub r3, r2, $11 + cmp r3, $1 + bls L(56) + cmp r2, $13 + ldreq r3, [r5, $8] + streq r0, [r3, $0] // float + beq L(8) + cmp r2, $14 + ldreq r3, [r5, $8] + stmeqia r3, {r0-r1} // double + beq L(8) + cmp r2, $15 + beq L(57) + cmp r2, $16 + beq L(58) +L(8): + mov r0, $0 + ldmea fp, {r4, r5, fp, sp, pc} +L(58): + ldr r3, [r5, $0] + tst r3, $512 + beq L(8) + ldr r3, [r5, $16] + cmp r3, $1 + beq L(50) + cmp r3, $2 + beq L(49) + cmp r3, $4 + bhi L(43) +L(57): + ldr r3, [r5, $8] +L(48): + str ip, [r3, $0] + b L(8) +L(43): + cmp r3, $8 + bne L(8) +L(56): + ldr r3, [r5, $8] + str r1, [r3, $4] + b L(48) +L(49): + ldr r3, [r5, $8] + strh ip, [r3, $0] // movhi + b L(8) +L(50): + ldr r3, [r5, $8] + strb ip, [r3, $0] + b L(8) +L(fe1): + FUNEND(avcall_call) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",%progbits +#endif diff --git a/avcall/avcall-arm.c b/avcall/avcall-arm.c new file mode 100644 index 0000000..787d95b --- /dev/null +++ b/avcall/avcall-arm.c @@ -0,0 +1,148 @@ +/** + Copyright 1993 Bill Triggs + Copyright 1995-2017 Bruno Haible + + 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, see . +**/ +/*---------------------------------------------------------------------- + !!! THIS ROUTINE MUST BE COMPILED gcc -O !!! + + Foreign function interface for an Acorn Risc Maschine with gcc. + + This calls a C function with an argument list built up using macros + defined in avcall.h. + + ARM Argument Passing Conventions: + + All arguments, except the first 4 words which are passed in the registers + r0, r1, r2, r3, are passed on the stack with word alignment. Doubles take + two words. + In ABIs where 'double' and 'long long' have alignment 4, they are passed + entirely in registers or entirely on the stack (i.e. not the first half + in r3 and the second half on the stack). + In ABIs where 'double' and 'long long' have alignment 8, they are passed + with 2-word alignment in this word sequence (e.g. a 'double' after an + 'int' in r0 gets passed in (r2,r3), not in (r1,r2)). This implies that + they are passed entirely in registers or entirely on the stack. + Structure args are passed as true structures embedded in the argument stack. + A structure arg may be allocated partially in registers (r0,...,r3) and + partially on the stack, if no previous args already consume stack space. + To return a structure, the called function copies the return value to the + address supplied in register r0. + + Compile this routine with gcc -O (or -O2 or -g -O) to get the right + register variables, or use the assembler version. + ----------------------------------------------------------------------*/ +#include "avcall-internal.h" + +#define RETURN(TYPE,VAL) (*(TYPE*)l->raddr = (TYPE)(VAL)) + +int +avcall_call(av_alist* list) +{ + register unsigned long sp __asm__("r13"); /* C names for registers */ +/*register __avword iret __asm__("r0"); */ + register __avword iret2 __asm__("r1"); + register float fret __asm__("r0"); /* r0 */ + register double dret __asm__("r0"); /* r0,r1 */ + + __av_alist* l = &AV_LIST_INNER(list); + + __avword space[__AV_ALIST_WORDS]; /* space for callee's stack frame */ + + /* Enforce 8-bytes-alignment of the stack pointer. + We need to do it this way because the old GCC that we use to compile + this file does not support the option '-mabi=aapcs'. */ + sp &= -8; + + __avword* argframe = (__avword*) sp; /* stack offset for argument list */ + int arglen = l->aptr - l->args; + __avword i; + + for (i = 4; i < arglen; i++) /* push function args onto stack */ + argframe[i-4] = l->args[i]; + + /* call function, pass 4 args in registers */ + i = (*l->func)(l->args[0], l->args[1], l->args[2], l->args[3]); + + /* save return value */ + if (l->rtype == __AVvoid) { + } else + if (l->rtype == __AVword) { + RETURN(__avword, i); + } else + if (l->rtype == __AVchar) { + RETURN(char, i); + } else + if (l->rtype == __AVschar) { + RETURN(signed char, i); + } else + if (l->rtype == __AVuchar) { + RETURN(unsigned char, i); + } else + if (l->rtype == __AVshort) { + RETURN(short, i); + } else + if (l->rtype == __AVushort) { + RETURN(unsigned short, i); + } else + if (l->rtype == __AVint) { + RETURN(int, i); + } else + if (l->rtype == __AVuint) { + RETURN(unsigned int, i); + } else + if (l->rtype == __AVlong) { + RETURN(long, i); + } else + if (l->rtype == __AVulong) { + RETURN(unsigned long, i); + } else + if (l->rtype == __AVlonglong || l->rtype == __AVulonglong) { + void* raddr = l->raddr; + ((__avword*)raddr)[0] = i; + ((__avword*)raddr)[1] = iret2; + } else + if (l->rtype == __AVfloat) { + RETURN(float, fret); + } else + if (l->rtype == __AVdouble) { + RETURN(double, dret); + } else + if (l->rtype == __AVvoidp) { + RETURN(void*, i); + } else + if (l->rtype == __AVstruct) { + /* PCS for ARM (http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042b/IHI0042B_aapcs.pdf): + page 19: "A Composite Type not larger than 4 bytes is returned in r0." + sizeof({char a[3];}) = 3, so we have to use <= sizeof below */ + if (l->flags & __AV_REGISTER_STRUCT_RETURN) { + if (l->rsize == sizeof(char)) { /* can't occur */ + RETURN(char, i); + } else + if (l->rsize == sizeof(short)) { /* can't occur */ + RETURN(short, i); + } else + if (l->rsize <= sizeof(int)) { + RETURN(int, i); + } else + if (l->rsize == 2*sizeof(__avword)) { + void* raddr = l->raddr; + ((__avword*)raddr)[0] = i; + ((__avword*)raddr)[1] = iret2; + } + } + } + return 0; +} diff --git a/avcall/avcall-arm64-macro.S b/avcall/avcall-arm64-macro.S new file mode 100644 index 0000000..c59d0f4 --- /dev/null +++ b/avcall/avcall-arm64-macro.S @@ -0,0 +1,329 @@ +#include "asm-arm.h" + .cpu generic+fp+simd + .text + .align 2 + .p2align 3,,7 + .global C(avcall_call) + .type avcall_call, %function +FUNBEGIN(avcall_call) + stp x29, x30, [sp, -48]! + add x29, sp, 0 + ldp x11, x12, [x0, 40] + stp x19, x20, [sp, 16] + sub x11, x11, x12 + ldr w15, [x0, 64] + asr x10, x11, 3 + ldr w14, [x0, 136] + cmp w10, wzr + mov x19, x0 + str d8, [sp, 32] + sub sp, sp, $2064 + ble L(6) + mov x13, sp + mov x9, 0 + mov w11, w10 + .p2align 2 +L(87): + ldr x10, [x12, x9, lsl 3] + str x10, [x13, x9, lsl 3] + add x9, x9, 1 + cmp w11, w9 + bgt L(87) +L(6): + cbz w15, L(7) + cmp w15, 1 + ldr x0, [x19, 72] + bls L(7) + cmp w15, 2 + ldr x1, [x19, 80] + beq L(7) + cmp w15, 3 + ldr x2, [x19, 88] + beq L(7) + cmp w15, 4 + ldr x3, [x19, 96] + beq L(7) + cmp w15, 5 + ldr x4, [x19, 104] + beq L(7) + cmp w15, 6 + ldr x5, [x19, 112] + beq L(7) + cmp w15, 7 + ldr x6, [x19, 120] + beq L(7) + ldr x7, [x19, 128] + .p2align 2 +L(7): + cbz w14, L(9) + ldr w9, [x19, 144] + tbz x9, 0, L(10) + ldr d0, [x19, 184] +L(11): + cmp w14, 1 + bls L(9) + tbnz x9, 1, L(121) + ldr w10, [x19, 140] + tbz x10, 1, L(14) + ldr s1, [x19, 152] +L(14): + cmp w14, 2 + beq L(9) + tbz x9, 2, L(15) + ldr d2, [x19, 200] +L(16): + cmp w14, 3 + beq L(9) + tbnz x9, 3, L(122) + ldr w10, [x19, 140] + tbz x10, 3, L(18) + ldr s3, [x19, 160] +L(18): + cmp w14, 4 + beq L(9) + tbz x9, 4, L(19) + ldr d4, [x19, 216] +L(20): + cmp w14, 5 + beq L(9) + tbz x9, 5, L(21) + ldr d5, [x19, 224] +L(22): + cmp w14, 6 + beq L(9) + tbz x9, 6, L(23) + ldr d6, [x19, 232] +L(24): + cmp w14, 7 + beq L(9) + tbz x9, 7, L(25) + ldr d7, [x19, 240] + .p2align 2 +L(9): + ldr w9, [x19, 24] + cmp w9, 13 + beq L(123) + cmp w9, 14 + beq L(124) + ldr x9, [x19, 8] + blr x9 + mov x16, x0 + ldr w9, [x19, 24] + cmp w9, 1 + beq L(27) + cbz w9, L(119) + cmp w9, 2 + beq L(115) + cmp w9, 3 + beq L(115) + cmp w9, 4 + beq L(115) + cmp w9, 5 + beq L(116) + cmp w9, 6 + beq L(116) + cmp w9, 7 + beq L(117) + cmp w9, 8 + beq L(117) + and w12, w9, -3 + cmp w12, 9 + beq L(119) + sub w12, w9, $10 + tst w12, -3 + beq L(119) + cmp w9, 15 + beq L(119) + cmp w9, 16 + bne L(27) + ldr w9, [x19] + tbz x9, 9, L(27) + ldr x12, [x19, 32] + sub x9, x12, $1 + cmp x9, 15 + bhi L(27) + ldr x13, [x19, 16] + cmp x12, 8 + and x9, x13, 7 + and x13, x13, -8 + add x12, x12, x9 + bhi L(40) + cmp x12, 8 + lsl w11, w12, 3 + bhi L(41) + lsl w9, w9, 3 + mov x12, 2 + mov x14, 1 + sub w11, w11, $1 + lsl x14, x14, x9 + lsl x11, x12, x11 + lsl x9, x0, x9 + sub x10, x11, x14 + ldr d17, [x13] + fmov d16, x10 + fmov d8, x9 + bif v8.8b, v17.8b, v16.8b + str d8, [x13] +L(27): + add sp, x29, 0 + ldr d8, [sp, 32] + mov w0, 0 + ldp x19, x20, [sp, 16] + ldp x29, x30, [sp], 48 + ret + .p2align 3 +L(10): + ldr w10, [x19, 140] + tbz x10, 0, L(11) + ldr s0, [x19, 148] + b L(11) + .p2align 3 +L(119): + ldr x9, [x19, 16] + mov w0, 0 + str x16, [x9] + ldr d8, [x29, 32] + add sp, x29, 0 + ldp x19, x20, [sp, 16] + ldp x29, x30, [sp], 48 + ret + .p2align 3 +L(121): + ldr d1, [x19, 192] + b L(14) + .p2align 3 +L(115): + ldr x9, [x19, 16] + mov w0, 0 + strb w16, [x9] + ldr d8, [x29, 32] + add sp, x29, 0 + ldp x19, x20, [sp, 16] + ldp x29, x30, [sp], 48 + ret + .p2align 3 +L(124): + ldp x9, x20, [x19, 8] + blr x9 + str d0, [x20] + mov w0, 0 + ldr d8, [x29, 32] + add sp, x29, 0 + ldp x19, x20, [sp, 16] + ldp x29, x30, [sp], 48 + ret +L(123): + ldp x9, x20, [x19, 8] + blr x9 + str s0, [x20] + b L(27) +L(15): + ldr w10, [x19, 140] + tbz x10, 2, L(16) + ldr s2, [x19, 156] + b L(16) +L(116): + ldr x9, [x19, 16] + strh w16, [x9] + b L(27) +L(122): + ldr d3, [x19, 208] + b L(18) +L(117): + ldr x9, [x19, 16] + str w16, [x9] + b L(27) +L(19): + ldr w10, [x19, 140] + tbz x10, 4, L(20) + ldr s4, [x19, 164] + b L(20) +L(21): + ldr w10, [x19, 140] + tbz x10, 5, L(22) + ldr s5, [x19, 168] + b L(22) +L(23): + ldr w10, [x19, 140] + tbz x10, 6, L(24) + ldr s6, [x19, 172] + b L(24) +L(25): + ldr w9, [x19, 140] + tbz x9, 7, L(9) + ldr s7, [x19, 176] + b L(9) +L(41): + lsl w14, w9, 3 + neg w9, w9, lsl 3 + movi d16, -1 + add w10, w9, 64 + dup v8.8b, w14 + lsl x9, x0, x14 + ldp d17, d18, [x13] + mov x12, 2 + sub w11, w11, $65 + lsl x11, x12, x11 + ushl d16, d16, d8 + fmov d8, x9 + asr x9, x0, x10 + sub x10, x11, $1 + bsl v16.8b, v8.8b, v17.8b + fmov d8, x10 + fmov d17, x9 + str d16, [x13] + bif v17.8b, v18.8b, v8.8b + str d17, [x13, 8] + b L(27) +L(40): + lsl w14, w9, 3 + cmp x12, 16 + movi d16, -1 + lsl x15, x0, x14 + dup v8.8b, w14 + fmov d17, x15 + ushl d16, d16, d8 + ldr d8, [x13] + bsl v16.8b, v17.8b, v8.8b + str d16, [x13] + bls L(125) + lsl w12, w12, 3 + mov x15, 2 + neg w9, w9, lsl 3 + sub w12, w12, $129 + add w9, w9, 64 + lsl x12, x15, x12 + asr x11, x1, x9 + asr x10, x0, x9 + sub x9, x12, $1 + ldr d17, [x13, 16] + fmov d16, x11 + lsl x14, x1, x14 + fmov d8, x9 + orr x10, x10, x14 + bif v16.8b, v17.8b, v8.8b + fmov x11, d16 + stp x10, x11, [x13, 8] + b L(27) +L(125): + neg w9, w9, lsl 2 + lsl w12, w12, 3 + add w9, w9, 32 + mov x15, 2 + sub w12, w12, $65 + lsl x11, x1, x14 + lsl x12, x15, x12 + asr x14, x0, x9 + asr x10, x14, x9 + sub x9, x12, $1 + ldr d17, [x13, 8] + fmov d8, x9 + orr x9, x10, x11 + fmov d16, x9 + bif v16.8b, v17.8b, v8.8b + str d16, [x13, 8] + b L(27) + FUNEND(avcall_call) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",%progbits +#endif diff --git a/avcall/avcall-arm64.c b/avcall/avcall-arm64.c new file mode 100644 index 0000000..d1385d1 --- /dev/null +++ b/avcall/avcall-arm64.c @@ -0,0 +1,362 @@ +/** + Copyright 1993 Bill Triggs + Copyright 1995-2017 Bruno Haible + + 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, see . +**/ +/*---------------------------------------------------------------------- + !!! THIS ROUTINE MUST BE COMPILED gcc -O -fno-omit-frame-pointer !!! + + Foreign function interface for a Linux arm64 (a.k.a. aarch64) with gcc. + + This calls a C function with an argument list built up using macros + defined in avcall.h. + + ARM64 Argument Passing Conventions are documented in + http://infocenter.arm.com/help/topic/com.arm.doc.ihi0055b/IHI0055B_aapcs64.pdf. + + Up to 8 words are passed in integer registers (x0, ..., x7). + Up to 8 float/double arguments are passed in floating point / SIMD + registers (v0/q0/d0/s0, ..., v7/q7/d7/s7). + Arguments passed on the stack have word alignment. + Structure args larger than 16 bytes are passed as pointers to caller-made + local copies. (§ 5.4.2 rule B.3) + Structure args <= 16 bytes are passed as up to two words in registers + (§ 5.4.2 rule C.10) or otherwise on the stack (§ 5.4.2 rule C.13). + + Integers are returned in x0, x1. + Float/double values are returned in d0/s0, d1/s1. + Structures <= 16 bytes are returned in registers. To return a structure + larger than 16 bytes, the called function copies the value to space + pointed to by x8. + ----------------------------------------------------------------------*/ +#include "avcall-internal.h" + +#define RETURN(TYPE,VAL) (*(TYPE*)l->raddr = (TYPE)(VAL)) + +register __avword* sret __asm__("x8"); /* structure return pointer */ + +register __avword iarg1 __asm__("x0"); +register __avword iarg2 __asm__("x1"); +register __avword iarg3 __asm__("x2"); +register __avword iarg4 __asm__("x3"); +register __avword iarg5 __asm__("x4"); +register __avword iarg6 __asm__("x5"); +register __avword iarg7 __asm__("x6"); +register __avword iarg8 __asm__("x7"); + +register float farg1 __asm__("s0"); +register float farg2 __asm__("s1"); +register float farg3 __asm__("s2"); +register float farg4 __asm__("s3"); +register float farg5 __asm__("s4"); +register float farg6 __asm__("s5"); +register float farg7 __asm__("s6"); +register float farg8 __asm__("s7"); + +register double darg1 __asm__("d0"); +register double darg2 __asm__("d1"); +register double darg3 __asm__("d2"); +register double darg4 __asm__("d3"); +register double darg5 __asm__("d4"); +register double darg6 __asm__("d5"); +register double darg7 __asm__("d6"); +register double darg8 __asm__("d7"); + +int +avcall_call(av_alist* list) +{ + register __avword* sp __asm__("sp"); /* C names for registers */ + register __avword iretreg __asm__("x0"); + register __avword iret2reg __asm__("x1"); + register double dret __asm__("d0"); + + __av_alist* l = &AV_LIST_INNER(list); + + __avword* argframe = __builtin_alloca(__AV_ALIST_WORDS * sizeof(__avword)); /* make room for argument list */ + int arglen = l->aptr - l->args; + unsigned int ianum = l->ianum; + unsigned int fanum = l->fanum; + __avword iret, iret2; + + { + int i; + for (i = 0; i < arglen; i++) /* push function args onto stack */ + argframe[i] = l->args[i]; + } + + /* Put up to 8 integer args into registers. */ + if (ianum >= 1) { + iarg1 = l->iargs[0]; + if (ianum >= 2) { + iarg2 = l->iargs[1]; + if (ianum >= 3) { + iarg3 = l->iargs[2]; + if (ianum >= 4) { + iarg4 = l->iargs[3]; + if (ianum >= 5) { + iarg5 = l->iargs[4]; + if (ianum >= 6) { + iarg6 = l->iargs[5]; + if (ianum >= 7) { + iarg7 = l->iargs[6]; + if (ianum >= 8) { + iarg8 = l->iargs[7]; + } + } + } + } + } + } + } + } + + /* Put upto 8 floating-point args into registers. */ + if (fanum >= 1) { + if (l->darg_mask & (1 << 0)) darg1 = l->dargs[0]; + else if (l->farg_mask & (1 << 0)) farg1 = l->fargs[0]; + if (fanum >= 2) { + if (l->darg_mask & (1 << 1)) darg2 = l->dargs[1]; + else if (l->farg_mask & (1 << 1)) farg2 = l->fargs[1]; + if (fanum >= 3) { + if (l->darg_mask & (1 << 2)) darg3 = l->dargs[2]; + else if (l->farg_mask & (1 << 2)) farg3 = l->fargs[2]; + if (fanum >= 4) { + if (l->darg_mask & (1 << 3)) darg4 = l->dargs[3]; + else if (l->farg_mask & (1 << 3)) farg4 = l->fargs[3]; + if (fanum >= 5) { + if (l->darg_mask & (1 << 4)) darg5 = l->dargs[4]; + else if (l->farg_mask & (1 << 4)) farg5 = l->fargs[4]; + if (fanum >= 6) { + if (l->darg_mask & (1 << 5)) darg6 = l->dargs[5]; + else if (l->farg_mask & (1 << 5)) farg6 = l->fargs[5]; + if (fanum >= 7) { + if (l->darg_mask & (1 << 6)) darg7 = l->dargs[6]; + else if (l->farg_mask & (1 << 6)) farg7 = l->fargs[6]; + if (fanum >= 8) { + if (l->darg_mask & (1 << 7)) darg8 = l->dargs[7]; + else if (l->farg_mask & (1 << 7)) farg8 = l->fargs[7]; + } + } + } + } + } + } + } + } + + /* Call function. */ + if (l->rtype == __AVfloat) { + *(float*)l->raddr = (*(float(*)())l->func)(); + } else + if (l->rtype == __AVdouble) { + *(double*)l->raddr = (*(double(*)())l->func)(); + } else { + iret = (*l->func)(); + iret2 = iret2reg; + + /* save return value */ + if (l->rtype == __AVvoid) { + } else + if (l->rtype == __AVword) { + RETURN(__avword, iret); + } else + if (l->rtype == __AVchar) { + RETURN(char, iret); + } else + if (l->rtype == __AVschar) { + RETURN(signed char, iret); + } else + if (l->rtype == __AVuchar) { + RETURN(unsigned char, iret); + } else + if (l->rtype == __AVshort) { + RETURN(short, iret); + } else + if (l->rtype == __AVushort) { + RETURN(unsigned short, iret); + } else + if (l->rtype == __AVint) { + RETURN(int, iret); + } else + if (l->rtype == __AVuint) { + RETURN(unsigned int, iret); + } else + if (l->rtype == __AVlong || l->rtype == __AVlonglong) { + RETURN(long, iret); + } else + if (l->rtype == __AVulong || l->rtype == __AVulonglong) { + RETURN(unsigned long, iret); + } else + /* see above + if (l->rtype == __AVfloat) { + } else + if (l->rtype == __AVdouble) { + } else + */ + if (l->rtype == __AVvoidp) { + RETURN(void*, iret); + } else + if (l->rtype == __AVstruct) { + if (l->flags & __AV_REGISTER_STRUCT_RETURN) { + /* Return structs of size <= 16 in registers. */ + if (l->rsize > 0 && l->rsize <= 16) { + void* raddr = l->raddr; + #if 0 /* Unoptimized */ + if (l->rsize == 1) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + } else + if (l->rsize == 2) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + } else + if (l->rsize == 3) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + } else + if (l->rsize == 4) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + } else + if (l->rsize == 5) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>32); + } else + if (l->rsize == 6) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>40); + } else + if (l->rsize == 7) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[6] = (unsigned char)(iret>>48); + } else + if (l->rsize >= 8 && l->rsize <= 16) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[6] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[7] = (unsigned char)(iret>>56); + if (l->rsize == 8) { + } else + if (l->rsize == 9) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + } else + if (l->rsize == 10) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + } else + if (l->rsize == 11) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + } else + if (l->rsize == 12) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + } else + if (l->rsize == 13) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>32); + } else + if (l->rsize == 14) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>40); + } else + if (l->rsize == 15) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+6] = (unsigned char)(iret2>>48); + } else + if (l->rsize == 16) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+6] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+7] = (unsigned char)(iret2>>56); + } + } + #else /* Optimized: fewer conditional jumps, fewer memory accesses */ + uintptr_t count = l->rsize; /* > 0, ≤ 2*sizeof(__avword) */ + __avword* wordaddr = (__avword*)((uintptr_t)raddr & ~(uintptr_t)(sizeof(__avword)-1)); + uintptr_t start_offset = (uintptr_t)raddr & (uintptr_t)(sizeof(__avword)-1); /* ≥ 0, < sizeof(__avword) */ + uintptr_t end_offset = start_offset + count; /* > 0, < 3*sizeof(__avword) */ + if (count <= sizeof(__avword)) { + /* Use iret. */ + if (end_offset <= sizeof(__avword)) { + /* 0 < end_offset ≤ sizeof(__avword) */ + __avword mask0 = ((__avword)2 << (end_offset*8-1)) - ((__avword)1 << (start_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret << (start_offset*8))) & mask0; + } else { + /* sizeof(__avword) < end_offset < 2*sizeof(__avword), start_offset > 0 */ + __avword mask0 = - ((__avword)1 << (start_offset*8)); + __avword mask1 = ((__avword)2 << (end_offset*8-sizeof(__avword)*8-1)) - 1; + wordaddr[0] ^= (wordaddr[0] ^ (iret << (start_offset*8))) & mask0; + wordaddr[1] ^= (wordaddr[1] ^ (iret >> (sizeof(__avword)*8-start_offset*8))) & mask1; + } + } else { + /* Use iret, iret2. */ + __avword mask0 = - ((__avword)1 << (start_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret << (start_offset*8))) & mask0; + if (end_offset <= 2*sizeof(__avword)) { + /* sizeof(__avword) < end_offset ≤ 2*sizeof(__avword) */ + __avword mask1 = ((__avword)2 << (end_offset*8-sizeof(__avword)*8-1)) - 1; + wordaddr[1] ^= (wordaddr[1] ^ ((iret >> (sizeof(__avword)*4-start_offset*4) >> (sizeof(__avword)*4-start_offset*4)) | (iret2 << (start_offset*8)))) & mask1; + } else { + /* 2*sizeof(__avword) < end_offset < 3*sizeof(__avword), start_offset > 0 */ + __avword mask2 = ((__avword)2 << (end_offset*8-2*sizeof(__avword)*8-1)) - 1; + wordaddr[1] = (iret >> (sizeof(__avword)*8-start_offset*8)) | (iret2 << (start_offset*8)); + wordaddr[2] ^= (wordaddr[2] ^ (iret2 >> (sizeof(__avword)*8-start_offset*8))) & mask2; + } + } + #endif + } + } + } + } + return 0; +} diff --git a/avcall/avcall-armhf-macro.S b/avcall/avcall-armhf-macro.S new file mode 100644 index 0000000..142839f --- /dev/null +++ b/avcall/avcall-armhf-macro.S @@ -0,0 +1,346 @@ +#include "asm-arm.h" + .arch armv6 + .eabi_attribute 28, 1 + .eabi_attribute 20, 1 + .eabi_attribute 21, 1 + .eabi_attribute 23, 3 + .eabi_attribute 24, 1 + .eabi_attribute 25, 1 + .eabi_attribute 26, 1 + .eabi_attribute 30, 2 + .eabi_attribute 34, 1 + .eabi_attribute 18, 4 + .text + .align 2 + .global C(avcall_call) + .syntax unified + .arm + .fpu vfpv3-d16 + .type avcall_call, %function +FUNBEGIN(avcall_call) + // args = 0, pretend = 0, frame = 0 + // frame_needed = 1, uses_anonymous_args = 0 + push {r4, r5, fp, lr} + mov r4, r0 + ldr r0, [r0, $20] + ldr ip, [r4, $24] + sub r3, sp, $1024 + add fp, sp, $12 + sub sp, r3, $8 + sub r3, r0, ip + cmp r3, $19 + movgt r2, sp + subgt r2, r2, $4 + addgt r3, ip, $16 + ble L(6) +L(5): + ldr r1, [r3], $4 + cmp r0, r3 + str r1, [r2, $4]! + bne L(5) +L(6): + ldr r3, [r4, $48] + tst r3, $1 + beq L(4) + .syntax divided +// 87 "avcall-armhf.c" 1 + vldr.32 s0,[r4, $56] +// 0 "" 2 + .arm + .syntax unified +L(4): + tst r3, $2 + beq L(7) + .syntax divided +// 89 "avcall-armhf.c" 1 + vldr.32 s1,[r4, $60] +// 0 "" 2 + .arm + .syntax unified +L(7): + tst r3, $4 + beq L(8) + .syntax divided +// 91 "avcall-armhf.c" 1 + vldr.32 s2,[r4, $64] +// 0 "" 2 + .arm + .syntax unified +L(8): + tst r3, $8 + beq L(9) + .syntax divided +// 93 "avcall-armhf.c" 1 + vldr.32 s3,[r4, $68] +// 0 "" 2 + .arm + .syntax unified +L(9): + tst r3, $16 + beq L(10) + .syntax divided +// 95 "avcall-armhf.c" 1 + vldr.32 s4,[r4, $72] +// 0 "" 2 + .arm + .syntax unified +L(10): + tst r3, $32 + beq L(11) + .syntax divided +// 97 "avcall-armhf.c" 1 + vldr.32 s5,[r4, $76] +// 0 "" 2 + .arm + .syntax unified +L(11): + tst r3, $64 + beq L(12) + .syntax divided +// 99 "avcall-armhf.c" 1 + vldr.32 s6,[r4, $80] +// 0 "" 2 + .arm + .syntax unified +L(12): + tst r3, $128 + beq L(13) + .syntax divided +// 101 "avcall-armhf.c" 1 + vldr.32 s7,[r4, $84] +// 0 "" 2 + .arm + .syntax unified +L(13): + tst r3, $256 + beq L(14) + .syntax divided +// 103 "avcall-armhf.c" 1 + vldr.32 s8,[r4, $88] +// 0 "" 2 + .arm + .syntax unified +L(14): + tst r3, $512 + beq L(15) + .syntax divided +// 105 "avcall-armhf.c" 1 + vldr.32 s9,[r4, $92] +// 0 "" 2 + .arm + .syntax unified +L(15): + tst r3, $1024 + beq L(16) + .syntax divided +// 107 "avcall-armhf.c" 1 + vldr.32 s10,[r4, $96] +// 0 "" 2 + .arm + .syntax unified +L(16): + tst r3, $2048 + beq L(17) + .syntax divided +// 109 "avcall-armhf.c" 1 + vldr.32 s11,[r4, $100] +// 0 "" 2 + .arm + .syntax unified +L(17): + tst r3, $4096 + beq L(18) + .syntax divided +// 111 "avcall-armhf.c" 1 + vldr.32 s12,[r4, $104] +// 0 "" 2 + .arm + .syntax unified +L(18): + tst r3, $8192 + beq L(19) + .syntax divided +// 113 "avcall-armhf.c" 1 + vldr.32 s13,[r4, $108] +// 0 "" 2 + .arm + .syntax unified +L(19): + tst r3, $16384 + beq L(20) + .syntax divided +// 115 "avcall-armhf.c" 1 + vldr.32 s14,[r4, $112] +// 0 "" 2 + .arm + .syntax unified +L(20): + tst r3, $32768 + beq L(21) + .syntax divided +// 117 "avcall-armhf.c" 1 + vldr.32 s15,[r4, $116] +// 0 "" 2 + .arm + .syntax unified +L(21): + ldr r3, [r4, $52] + tst r3, $1 + beq L(22) + .syntax divided +// 121 "avcall-armhf.c" 1 + vldr.64 d0,[r4, $120] +// 0 "" 2 + .arm + .syntax unified +L(22): + tst r3, $2 + beq L(23) + .syntax divided +// 123 "avcall-armhf.c" 1 + vldr.64 d1,[r4, $128] +// 0 "" 2 + .arm + .syntax unified +L(23): + tst r3, $4 + beq L(24) + .syntax divided +// 125 "avcall-armhf.c" 1 + vldr.64 d2,[r4, $136] +// 0 "" 2 + .arm + .syntax unified +L(24): + tst r3, $8 + beq L(25) + .syntax divided +// 127 "avcall-armhf.c" 1 + vldr.64 d3,[r4, $144] +// 0 "" 2 + .arm + .syntax unified +L(25): + tst r3, $16 + beq L(26) + .syntax divided +// 129 "avcall-armhf.c" 1 + vldr.64 d4,[r4, $152] +// 0 "" 2 + .arm + .syntax unified +L(26): + tst r3, $32 + beq L(27) + .syntax divided +// 131 "avcall-armhf.c" 1 + vldr.64 d5,[r4, $160] +// 0 "" 2 + .arm + .syntax unified +L(27): + tst r3, $64 + beq L(28) + .syntax divided +// 133 "avcall-armhf.c" 1 + vldr.64 d6,[r4, $168] +// 0 "" 2 + .arm + .syntax unified +L(28): + tst r3, $128 + beq L(29) + .syntax divided +// 135 "avcall-armhf.c" 1 + vldr.64 d7,[r4, $176] +// 0 "" 2 + .arm + .syntax unified +L(29): + ldm ip, {r0, r1, r2, r3} + ldr r5, [r4, $4] + blx r5 + ldrb r3, [r4, $12] // zero_extendqisi2 + cmp r3, $1 + beq L(30) + cmp r3, $0 + beq L(130) + cmp r3, $2 + beq L(128) + cmp r3, $3 + beq L(128) + cmp r3, $4 + beq L(128) + cmp r3, $5 + beq L(131) + cmp r3, $6 + beq L(131) + cmp r3, $7 + beq L(130) + cmp r3, $8 + beq L(130) + cmp r3, $9 + beq L(130) + cmp r3, $10 + beq L(130) + sub r2, r3, $11 + cmp r2, $1 + bls L(132) + cmp r3, $13 + beq L(134) + cmp r3, $14 + beq L(135) + cmp r3, $15 + beq L(130) + cmp r3, $16 + bne L(30) + ldr r3, [r4] + tst r3, $512 + beq L(30) + ldr r3, [r4, $16] + cmp r3, $1 + beq L(128) + cmp r3, $2 + beq L(131) + cmp r3, $4 + bls L(130) + cmp r3, $8 + bne L(30) +L(132): + ldr r3, [r4, $8] + stm r3, {r0, r1} +L(30): + mov r0, $0 + sub sp, fp, $12 + // sp needed + pop {r4, r5, fp, pc} +L(130): + ldr r3, [r4, $8] + str r0, [r3] + mov r0, $0 + sub sp, fp, $12 + // sp needed + pop {r4, r5, fp, pc} +L(128): + ldr r3, [r4, $8] + strb r0, [r3] + mov r0, $0 + sub sp, fp, $12 + // sp needed + pop {r4, r5, fp, pc} +L(131): + ldr r3, [r4, $8] + strh r0, [r3] // movhi + b L(30) +L(134): + ldr r3, [r4, $8] + vstr.32 s0, [r3] + b L(30) +L(135): + ldr r3, [r4, $8] + vstr.64 d0, [r3] + b L(30) + FUNEND(avcall_call) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",%progbits +#endif diff --git a/avcall/avcall-armhf.c b/avcall/avcall-armhf.c new file mode 100644 index 0000000..68c1e7a --- /dev/null +++ b/avcall/avcall-armhf.c @@ -0,0 +1,209 @@ +/** + Copyright 1993 Bill Triggs + Copyright 1995-2017 Bruno Haible + + 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, see . +**/ +/*---------------------------------------------------------------------- + !!! THIS ROUTINE MUST BE COMPILED gcc -O !!! + + Foreign function interface for an ARM with -mfloat-abi=hard with gcc. + + This calls a C function with an argument list built up using macros + defined in avcall.h. + + ARM Argument Passing Conventions: + + All arguments, except the first 4 words which are passed in the registers + r0, r1, r2, r3, are passed on the stack with word alignment. Doubles take + two words. + In ABIs where 'double' and 'long long' have alignment 4, they are passed + entirely in registers or entirely on the stack (i.e. not the first half + in r3 and the second half on the stack). + In ABIs where 'double' and 'long long' have alignment 8, they are passed + with 2-word alignment in this word sequence (e.g. a 'double' after an + 'int' in r0 gets passed in (r2,r3), not in (r1,r2)). This implies that + they are passed entirely in registers or entirely on the stack. + Structure args are passed as true structures embedded in the argument stack. + A structure arg may be allocated partially in registers (r0,...,r3) and + partially on the stack, if no previous args already consume stack space. + To return a structure, the called function copies the return value to the + address supplied in register r0. + + In hard-float configurations (armhf): Up to 16 floats get passed in the + single-float registers s0, s1, ..., s15. A float gets returned in s0. + Up to 8 doubles gets passed in the double-float registers d0, ..., d7 + (= {s0,s1}, {s2,s3}, ..., {s14,s15}). A double gets returned in d0. + + The 4 integer args registers and the 16 float args slots are allocated + independently: 1) After more than 16 float args, integer args can still + be allocated in registers. 2) After more than 4 integer args, float args + can still be allocated in registers. + + Compile this routine with gcc -O (or -O2 or -g -O) to get the right + register variables, or use the assembler version. + ----------------------------------------------------------------------*/ +#include "avcall-internal.h" + +#define RETURN(TYPE,VAL) (*(TYPE*)l->raddr = (TYPE)(VAL)) + +int +avcall_call(av_alist* list) +{ + register unsigned long sp __asm__("r13"); /* C names for registers */ +/*register __avword iret __asm__("r0"); */ + register __avword iret2 __asm__("r1"); + register float fret __asm__("s0"); + register double dret __asm__("d0"); + + __av_alist* l = &AV_LIST_INNER(list); + + __avword* argframe = __builtin_alloca(__AV_ALIST_WORDS * sizeof(__avword)); /* make room for argument list */ + + /* Enforce 8-bytes-alignment of the stack pointer. + We need to do it this way because the old GCC that we use to compile + this file does not support the option '-mabi=aapcs'. */ + sp &= -8; + + int arglen = l->aptr - l->args; + __avword i; + + for (i = 4; i < arglen; i++) /* push function args onto stack */ + argframe[i-4] = l->args[i]; + + /* load float values into floating-point registers */ + if ((l->farg_mask >> 0) & 1) + __asm__ __volatile__ ("vldr.32 s0,%0" : : "m" (l->fargs[0])); + if ((l->farg_mask >> 1) & 1) + __asm__ __volatile__ ("vldr.32 s1,%0" : : "m" (l->fargs[1])); + if ((l->farg_mask >> 2) & 1) + __asm__ __volatile__ ("vldr.32 s2,%0" : : "m" (l->fargs[2])); + if ((l->farg_mask >> 3) & 1) + __asm__ __volatile__ ("vldr.32 s3,%0" : : "m" (l->fargs[3])); + if ((l->farg_mask >> 4) & 1) + __asm__ __volatile__ ("vldr.32 s4,%0" : : "m" (l->fargs[4])); + if ((l->farg_mask >> 5) & 1) + __asm__ __volatile__ ("vldr.32 s5,%0" : : "m" (l->fargs[5])); + if ((l->farg_mask >> 6) & 1) + __asm__ __volatile__ ("vldr.32 s6,%0" : : "m" (l->fargs[6])); + if ((l->farg_mask >> 7) & 1) + __asm__ __volatile__ ("vldr.32 s7,%0" : : "m" (l->fargs[7])); + if ((l->farg_mask >> 8) & 1) + __asm__ __volatile__ ("vldr.32 s8,%0" : : "m" (l->fargs[8])); + if ((l->farg_mask >> 9) & 1) + __asm__ __volatile__ ("vldr.32 s9,%0" : : "m" (l->fargs[9])); + if ((l->farg_mask >> 10) & 1) + __asm__ __volatile__ ("vldr.32 s10,%0" : : "m" (l->fargs[10])); + if ((l->farg_mask >> 11) & 1) + __asm__ __volatile__ ("vldr.32 s11,%0" : : "m" (l->fargs[11])); + if ((l->farg_mask >> 12) & 1) + __asm__ __volatile__ ("vldr.32 s12,%0" : : "m" (l->fargs[12])); + if ((l->farg_mask >> 13) & 1) + __asm__ __volatile__ ("vldr.32 s13,%0" : : "m" (l->fargs[13])); + if ((l->farg_mask >> 14) & 1) + __asm__ __volatile__ ("vldr.32 s14,%0" : : "m" (l->fargs[14])); + if ((l->farg_mask >> 15) & 1) + __asm__ __volatile__ ("vldr.32 s15,%0" : : "m" (l->fargs[15])); + + /* load double values into floating-point registers */ + if ((l->darg_mask >> 0) & 1) + __asm__ __volatile__ ("vldr.64 d0,%0" : : "m" (l->dargs[0])); + if ((l->darg_mask >> 1) & 1) + __asm__ __volatile__ ("vldr.64 d1,%0" : : "m" (l->dargs[1])); + if ((l->darg_mask >> 2) & 1) + __asm__ __volatile__ ("vldr.64 d2,%0" : : "m" (l->dargs[2])); + if ((l->darg_mask >> 3) & 1) + __asm__ __volatile__ ("vldr.64 d3,%0" : : "m" (l->dargs[3])); + if ((l->darg_mask >> 4) & 1) + __asm__ __volatile__ ("vldr.64 d4,%0" : : "m" (l->dargs[4])); + if ((l->darg_mask >> 5) & 1) + __asm__ __volatile__ ("vldr.64 d5,%0" : : "m" (l->dargs[5])); + if ((l->darg_mask >> 6) & 1) + __asm__ __volatile__ ("vldr.64 d6,%0" : : "m" (l->dargs[6])); + if ((l->darg_mask >> 7) & 1) + __asm__ __volatile__ ("vldr.64 d7,%0" : : "m" (l->dargs[7])); + + /* call function, pass 4 integer args in registers */ + i = (*l->func)(l->args[0], l->args[1], l->args[2], l->args[3]); + + /* save return value */ + if (l->rtype == __AVvoid) { + } else + if (l->rtype == __AVword) { + RETURN(__avword, i); + } else + if (l->rtype == __AVchar) { + RETURN(char, i); + } else + if (l->rtype == __AVschar) { + RETURN(signed char, i); + } else + if (l->rtype == __AVuchar) { + RETURN(unsigned char, i); + } else + if (l->rtype == __AVshort) { + RETURN(short, i); + } else + if (l->rtype == __AVushort) { + RETURN(unsigned short, i); + } else + if (l->rtype == __AVint) { + RETURN(int, i); + } else + if (l->rtype == __AVuint) { + RETURN(unsigned int, i); + } else + if (l->rtype == __AVlong) { + RETURN(long, i); + } else + if (l->rtype == __AVulong) { + RETURN(unsigned long, i); + } else + if (l->rtype == __AVlonglong || l->rtype == __AVulonglong) { + void* raddr = l->raddr; + ((__avword*)raddr)[0] = i; + ((__avword*)raddr)[1] = iret2; + } else + if (l->rtype == __AVfloat) { + RETURN(float, fret); + } else + if (l->rtype == __AVdouble) { + RETURN(double, dret); + } else + if (l->rtype == __AVvoidp) { + RETURN(void*, i); + } else + if (l->rtype == __AVstruct) { + /* PCS for ARM (http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042b/IHI0042B_aapcs.pdf): + page 19: "A Composite Type not larger than 4 bytes is returned in r0." + sizeof({char a[3];}) = 3, so we have to use <= sizeof below */ + if (l->flags & __AV_REGISTER_STRUCT_RETURN) { + if (l->rsize == sizeof(char)) { /* can't occur */ + RETURN(char, i); + } else + if (l->rsize == sizeof(short)) { /* can't occur */ + RETURN(short, i); + } else + if (l->rsize <= sizeof(int)) { + RETURN(int, i); + } else + if (l->rsize == 2*sizeof(__avword)) { + void* raddr = l->raddr; + ((__avword*)raddr)[0] = i; + ((__avword*)raddr)[1] = iret2; + } + } + } + return 0; +} diff --git a/avcall/avcall-compat.c b/avcall/avcall-compat.c new file mode 100644 index 0000000..a1bdf92 --- /dev/null +++ b/avcall/avcall-compat.c @@ -0,0 +1,24 @@ +/* + * Copyright 2017 Bruno Haible + * + * 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, see . + */ + +#include "config.h" + +#include + +/* A dummy symbol, so that GNU clisp's autoconfiguration recognizes this + library. */ +void __builtin_avcall (void) { abort(); } diff --git a/avcall/avcall-hppa-linux.s b/avcall/avcall-hppa-linux.s new file mode 100644 index 0000000..340466e --- /dev/null +++ b/avcall/avcall-hppa-linux.s @@ -0,0 +1,258 @@ + .LEVEL 1.1 + .text + .align 4 +.globl avcall_call + .type avcall_call,@function +avcall_call: + .PROC + .CALLINFO FRAME=128,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=5 + .ENTRY + copy %r3,%r1 + stw %r2,-20(%r30) + copy %r30,%r3 + stwm %r1,128(%r30) + stw %r5,8(%r3) + ldo -48(%r30),%r24 + ldo 15(%r24),%r21 + copy %r19,%r5 + stw %r4,12(%r3) + copy %r21,%r24 + depi 0,31,4,%r24 + copy %r26,%r4 + stw %r19,-32(%r30) + ldo 1104(%r24),%r24 + ldw 28(%r26),%r22 + ldw 20(%r26),%r20 + sub %r22,%r20,%r20 + extrs %r20,29,30,%r25 + sub %r0,%r25,%r23 + comib,<= -4,%r23,.L59 + ldo 1088(%r30),%r30 + copy %r22,%r29 +.L6: + zdep %r23,29,30,%r20 + ldo 1(%r23),%r23 + addl %r20,%r29,%r22 + addl %r20,%r24,%r20 + ldw 0(%r22),%r21 + comib,> -4,%r23,.L6 + stw %r21,0(%r20) +.L58: + ldw 12(%r4),%r21 + ldi 16,%r20 + comb,=,n %r20,%r21,.L64 +.L7: + comib,>=,n 0,%r25,.L8 + ldw 48(%r4),%r21 + extrs,>= %r21,31,1,%r0 + fldws -4(%r29),%fr4L +.L9: + comib,>=,n 1,%r25,.L8 + extrs,>= %r21,30,1,%r0 + fldws -8(%r29),%fr5L +.L11: + ldw 52(%r4),%r22 + ldi 2,%r20 + and %r22,%r20,%r20 + comiclr,= 0,%r20,%r0 + fldds -8(%r29),%fr5 +.L12: + comib,>=,n 2,%r25,.L8 + extrs,>= %r21,29,1,%r0 + fldws -12(%r29),%fr6L +.L14: + comib,>=,n 3,%r25,.L8 + extrs,>= %r21,28,1,%r0 + fldws -16(%r29),%fr7L +.L16: + ldi 8,%r20 + and %r22,%r20,%r20 + comiclr,= 0,%r20,%r0 + fldds -16(%r29),%fr7 +.L8: + ldw -16(%r29),%r23 + ldw -4(%r29),%r26 + ldw -8(%r29),%r25 + ldw -12(%r29),%r24 + ldw 4(%r4),%r22 + .CALL ARGW0=GR + bl $$dyncall,%r31 + copy %r31,%r2 + ldw 12(%r4),%r21 + copy %r5,%r19 + comib,= 1,%r21,.L19 + copy %r28,%r2 + comib,=,n 0,%r21,.L63 + comib,=,n 2,%r21,.L62 + comib,=,n 3,%r21,.L62 + comib,=,n 4,%r21,.L62 + comib,=,n 5,%r21,.L61 + comib,=,n 6,%r21,.L61 + comib,=,n 7,%r21,.L63 + comib,=,n 8,%r21,.L63 + comib,=,n 9,%r21,.L63 + comib,=,n 10,%r21,.L63 + ldo -11(%r21),%r20 + comib,<<,n 1,%r20,.L40 + ldw 8(%r4),%r20 + stw %r29,4(%r20) +.L60: + stw %r2,0(%r20) +.L19: + ldw -20(%r3),%r2 +.L67: + ldi 0,%r28 + ldw 8(%r3),%r5 + ldw 12(%r3),%r4 + ldo 64(%r3),%r30 + bv %r0(%r2) + ldwm -64(%r30),%r3 +.L40: + comib,=,n 13,%r21,.L65 + comib,=,n 14,%r21,.L66 + comib,=,n 15,%r21,.L63 + ldi 16,%r20 + comb,<>,n %r20,%r21,.L67 + ldw -20(%r3),%r2 + ldw 0(%r4),%r20 + bb,>=,n %r20,30,.L67 + ldw -20(%r3),%r2 + ldw 16(%r4),%r22 + ldo -1(%r22),%r20 + comib,<<,n 7,%r20,.L67 + ldw -20(%r3),%r2 + ldw 8(%r4),%r20 + extru %r20,31,2,%r26 + copy %r20,%r4 + depi 0,31,2,%r4 + comib,<< 4,%r22,.L51 + addl %r26,%r22,%r21 + comib,<< 4,%r21,.L52 + zdep %r21,28,29,%r20 + ldo -1(%r20),%r25 + zdep %r26,28,29,%r21 + mtsar %r25 + ldw 0(%r4),%r23 + zvdep %r28,32,%r20 + mtsar %r21 + zvdepi 2,32,%r21 + xor %r23,%r20,%r20 + mtsar %r25 + zvdepi 1,32,%r22 + sub %r21,%r22,%r21 + and %r20,%r21,%r20 + xor %r23,%r20,%r23 + b .L19 + stw %r23,0(%r4) +.L52: + subi 63,%r20,%r31 + zdep %r26,28,29,%r26 + ldo -33(%r20),%r20 + ldw 0(%r4),%r25 + mtsar %r20 + ldw 4(%r4),%r24 + zvdep %r28,32,%r23 + mtsar %r26 + zvdepi 2,32,%r22 + xor %r24,%r23,%r23 + mtsar %r31 + ldo -1(%r22),%r22 + vextrs %r28,32,%r21 + mtsar %r20 + zvdepi 1,32,%r20 + xor %r25,%r21,%r21 + sub %r0,%r20,%r20 + and %r21,%r22,%r21 + and %r23,%r20,%r23 + xor %r25,%r21,%r25 + xor %r24,%r23,%r24 + stw %r25,0(%r4) + b .L19 + stw %r24,4(%r4) +.L51: + zdep %r26,28,29,%r26 + mtsar %r26 + zvdepi 2,32,%r20 + comib,<< 8,%r21,.L55 + ldo -1(%r20),%r25 + zdep %r21,29,30,%r20 + subi 47,%r20,%r24 + zdep %r21,28,29,%r21 + mtsar %r24 + ldo -33(%r21),%r26 + vextrs %r29,32,%r22 + vextrs %r22,32,%r22 + mtsar %r26 + ldw 0(%r4),%r24 + ldw 4(%r4),%r23 + zvdep %r28,32,%r20 + or %r20,%r22,%r20 + zvdep %r29,32,%r29 + zvdepi 1,32,%r21 + xor %r24,%r20,%r20 + xor %r23,%r29,%r29 + sub %r0,%r21,%r21 + and %r20,%r25,%r20 + and %r29,%r21,%r29 + xor %r24,%r20,%r24 + xor %r23,%r29,%r23 + stw %r24,0(%r4) + b .L19 + stw %r23,4(%r4) +.L55: + zdep %r21,28,29,%r20 + ldo -65(%r20),%r31 + subi 95,%r20,%r26 + ldw 8(%r4),%r23 + mtsar %r31 + ldw 0(%r4),%r24 + zvdep %r29,32,%r22 + zvdepi 1,32,%r21 + xor %r23,%r22,%r22 + mtsar %r26 + sub %r0,%r21,%r21 + vextrs %r28,32,%r20 + and %r22,%r21,%r22 + mtsar %r31 + xor %r24,%r20,%r20 + zvdep %r28,32,%r21 + and %r20,%r25,%r20 + mtsar %r26 + xor %r24,%r20,%r24 + vextrs %r29,32,%r29 + xor %r23,%r22,%r23 + or %r21,%r29,%r21 + stw %r23,8(%r4) + stw %r24,0(%r4) + b .L19 + stw %r21,4(%r4) +.L63: + b .L60 + ldw 8(%r4),%r20 +.L66: + ldw 8(%r4),%r20 + b .L19 + fstds %fr4,0(%r20) +.L65: + ldw 8(%r4),%r20 + b .L19 + fstws %fr4L,0(%r20) +.L61: + ldw 8(%r4),%r20 + b .L19 + sth %r2,0(%r20) +.L62: + ldw 8(%r4),%r20 + b .L19 + stb %r2,0(%r20) +.L64: + b .L7 + ldw 8(%r4),%r28 +.L59: + b .L58 + ldw 28(%r26),%r29 + .EXIT + .PROCEND +.Lfe1: + .size avcall_call,.Lfe1-avcall_call + .ident "GCC: (GNU) 3.1" diff --git a/avcall/avcall-hppa-macro.S b/avcall/avcall-hppa-macro.S new file mode 100644 index 0000000..94c7b38 --- /dev/null +++ b/avcall/avcall-hppa-macro.S @@ -0,0 +1,263 @@ +#include "asm-hppa.h" + .LEVEL 1.1 + IMPORT_MILLICODE($$dyncall) + TEXT1() + TEXT2() + .align 4 +GLOBL(avcall_call) + DECLARE_FUNCTION(avcall_call) +DEF(avcall_call) + .PROC + .CALLINFO FRAME=128,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=5 + .ENTRY + copy %r3,%r1 + stw %r2,-20(%r30) + copy %r30,%r3 + stwm %r1,128(%r30) + stw %r5,8(%r3) + ldo -48(%r30),%r24 + ldo 15(%r24),%r21 + copy %r19,%r5 + stw %r4,12(%r3) + copy %r21,%r24 + depi 0,31,4,%r24 + copy %r26,%r4 + stw %r19,-32(%r30) + ldo 1104(%r24),%r24 + ldw 28(%r26),%r22 + ldw 20(%r26),%r20 + sub %r22,%r20,%r20 + extrs %r20,29,30,%r25 + sub %r0,%r25,%r23 + comib,<= -4,%r23,L(59) + ldo 1088(%r30),%r30 + copy %r22,%r29 +DEF(L(6)) + zdep %r23,29,30,%r20 + ldo 1(%r23),%r23 + addl %r20,%r29,%r22 + addl %r20,%r24,%r20 + ldw 0(%r22),%r21 + comib,> -4,%r23,L(6) + stw %r21,0(%r20) +DEF(L(58)) + ldw 12(%r4),%r21 + ldi 16,%r20 + comb,=,n %r20,%r21,L(64) +DEF(L(7)) + comib,>=,n 0,%r25,L(8) + ldw 48(%r4),%r21 + extrs,>= %r21,31,1,%r0 + fldws -4(%r29),%fr4L +DEF(L(9)) + comib,>=,n 1,%r25,L(8) + extrs,>= %r21,30,1,%r0 + fldws -8(%r29),%fr5L +DEF(L(11)) + ldw 52(%r4),%r22 + ldi 2,%r20 + and %r22,%r20,%r20 + comiclr,= 0,%r20,%r0 + fldds -8(%r29),%fr5 +DEF(L(12)) + comib,>=,n 2,%r25,L(8) + extrs,>= %r21,29,1,%r0 + fldws -12(%r29),%fr6L +DEF(L(14)) + comib,>=,n 3,%r25,L(8) + extrs,>= %r21,28,1,%r0 + fldws -16(%r29),%fr7L +DEF(L(16)) + ldi 8,%r20 + and %r22,%r20,%r20 + comiclr,= 0,%r20,%r0 + fldds -16(%r29),%fr7 +DEF(L(8)) + ldw -16(%r29),%r23 + ldw -4(%r29),%r26 + ldw -8(%r29),%r25 + ldw -12(%r29),%r24 + ldw 4(%r4),%r22 + .CALL ARGW0=GR + bl $$dyncall,%r31 + copy %r31,%r2 + ldw 12(%r4),%r21 + copy %r5,%r19 + comib,= 1,%r21,L(19) + copy %r28,%r2 + comib,=,n 0,%r21,L(63) + comib,=,n 2,%r21,L(62) + comib,=,n 3,%r21,L(62) + comib,=,n 4,%r21,L(62) + comib,=,n 5,%r21,L(61) + comib,=,n 6,%r21,L(61) + comib,=,n 7,%r21,L(63) + comib,=,n 8,%r21,L(63) + comib,=,n 9,%r21,L(63) + comib,=,n 10,%r21,L(63) + ldo -11(%r21),%r20 + comib,<<,n 1,%r20,L(40) + ldw 8(%r4),%r20 + stw %r29,4(%r20) +DEF(L(60)) + stw %r2,0(%r20) +DEF(L(19)) + ldw -20(%r3),%r2 +DEF(L(67)) + ldi 0,%r28 + ldw 8(%r3),%r5 + ldw 12(%r3),%r4 + ldo 64(%r3),%r30 + bv %r0(%r2) + ldwm -64(%r30),%r3 +DEF(L(40)) + comib,=,n 13,%r21,L(65) + comib,=,n 14,%r21,L(66) + comib,=,n 15,%r21,L(63) + ldi 16,%r20 + comb,<>,n %r20,%r21,L(67) + ldw -20(%r3),%r2 + ldw 0(%r4),%r20 + bb,>=,n %r20,30,L(67) + ldw -20(%r3),%r2 + ldw 16(%r4),%r22 + ldo -1(%r22),%r20 + comib,<<,n 7,%r20,L(67) + ldw -20(%r3),%r2 + ldw 8(%r4),%r20 + extru %r20,31,2,%r26 + copy %r20,%r4 + depi 0,31,2,%r4 + comib,<< 4,%r22,L(51) + addl %r26,%r22,%r21 + comib,<< 4,%r21,L(52) + zdep %r21,28,29,%r20 + ldo -1(%r20),%r25 + zdep %r26,28,29,%r21 + mtsar %r25 + ldw 0(%r4),%r23 + zvdep %r28,32,%r20 + mtsar %r21 + zvdepi 2,32,%r21 + xor %r23,%r20,%r20 + mtsar %r25 + zvdepi 1,32,%r22 + sub %r21,%r22,%r21 + and %r20,%r21,%r20 + xor %r23,%r20,%r23 + b L(19) + stw %r23,0(%r4) +DEF(L(52)) + subi 63,%r20,%r31 + zdep %r26,28,29,%r26 + ldo -33(%r20),%r20 + ldw 0(%r4),%r25 + mtsar %r20 + ldw 4(%r4),%r24 + zvdep %r28,32,%r23 + mtsar %r26 + zvdepi 2,32,%r22 + xor %r24,%r23,%r23 + mtsar %r31 + ldo -1(%r22),%r22 + vextrs %r28,32,%r21 + mtsar %r20 + zvdepi 1,32,%r20 + xor %r25,%r21,%r21 + sub %r0,%r20,%r20 + and %r21,%r22,%r21 + and %r23,%r20,%r23 + xor %r25,%r21,%r25 + xor %r24,%r23,%r24 + stw %r25,0(%r4) + b L(19) + stw %r24,4(%r4) +DEF(L(51)) + zdep %r26,28,29,%r26 + mtsar %r26 + zvdepi 2,32,%r20 + comib,<< 8,%r21,L(55) + ldo -1(%r20),%r25 + zdep %r21,29,30,%r20 + subi 47,%r20,%r24 + zdep %r21,28,29,%r21 + mtsar %r24 + ldo -33(%r21),%r26 + vextrs %r29,32,%r22 + vextrs %r22,32,%r22 + mtsar %r26 + ldw 0(%r4),%r24 + ldw 4(%r4),%r23 + zvdep %r28,32,%r20 + or %r20,%r22,%r20 + zvdep %r29,32,%r29 + zvdepi 1,32,%r21 + xor %r24,%r20,%r20 + xor %r23,%r29,%r29 + sub %r0,%r21,%r21 + and %r20,%r25,%r20 + and %r29,%r21,%r29 + xor %r24,%r20,%r24 + xor %r23,%r29,%r23 + stw %r24,0(%r4) + b L(19) + stw %r23,4(%r4) +DEF(L(55)) + zdep %r21,28,29,%r20 + ldo -65(%r20),%r31 + subi 95,%r20,%r26 + ldw 8(%r4),%r23 + mtsar %r31 + ldw 0(%r4),%r24 + zvdep %r29,32,%r22 + zvdepi 1,32,%r21 + xor %r23,%r22,%r22 + mtsar %r26 + sub %r0,%r21,%r21 + vextrs %r28,32,%r20 + and %r22,%r21,%r22 + mtsar %r31 + xor %r24,%r20,%r20 + zvdep %r28,32,%r21 + and %r20,%r25,%r20 + mtsar %r26 + xor %r24,%r20,%r24 + vextrs %r29,32,%r29 + xor %r23,%r22,%r23 + or %r21,%r29,%r21 + stw %r23,8(%r4) + stw %r24,0(%r4) + b L(19) + stw %r21,4(%r4) +DEF(L(63)) + b L(60) + ldw 8(%r4),%r20 +DEF(L(66)) + ldw 8(%r4),%r20 + b L(19) + fstds %fr4,0(%r20) +DEF(L(65)) + ldw 8(%r4),%r20 + b L(19) + fstws %fr4L,0(%r20) +DEF(L(61)) + ldw 8(%r4),%r20 + b L(19) + sth %r2,0(%r20) +DEF(L(62)) + ldw 8(%r4),%r20 + b L(19) + stb %r2,0(%r20) +DEF(L(64)) + b L(7) + ldw 8(%r4),%r28 +DEF(L(59)) + b L(58) + ldw 28(%r26),%r29 + .EXIT + .PROCEND +DEF(L(fe1)) + FUNEND(avcall_call) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/avcall/avcall-hppa.c b/avcall/avcall-hppa.c new file mode 100644 index 0000000..382b992 --- /dev/null +++ b/avcall/avcall-hppa.c @@ -0,0 +1,273 @@ +/** + Copyright 1993 Bill Triggs + Copyright 1995-2019 Bruno Haible + + 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, see . +**/ +/*---------------------------------------------------------------------- + !!! THIS ROUTINE MUST BE COMPILED gcc -O !!! + + Foreign function interface for a HP Precision Architecture 1.0 with gcc + + This calls a C function with an argument list built up using macros + defined in avcall.h. + + HPPA Argument Passing Conventions: + + All arguments, except the first 4 words, are passed on the stack + - growing down! - with word alignment. Doubles take two words and force + double alignment. Small structures args are passed as true structures + embedded in the argument stack. They force double alignment and - if they + don't fit entirely in the 4 register words - are passed in memory. + The first 2 words are passed like this: + %r26 = first integer arg, %r25 = second integer arg, or + %r26 = high word of double arg, %r25 = low word of double arg. + Similarly for the next 2 words, passed in %r24 and %r23. + Note that other calling conventions would be in effect if we would call + an explicitly named function! + + Structures larger than 8 bytes are passed as a pointer. In GCC >= 8 + it's a caller-made copy; with GCC < 8 and with HP cc it's the callee's + responsibility to make a copy of the structure, so that side effects + made by the callee are not visible to the caller. + + To return a structure of more than 8 bytes, the called function copies + the return value to the address supplied in register "%r28". Smaller + structures are returned in the registers %r28 (first 4 bytes) and %r29 + (next 4 bytes, if present). + + It is forbidden to modify the stack pointer. + + Compile this routine with gcc -O2 -fomit-frame-pointer to get the right + register variables. + ----------------------------------------------------------------------*/ +#include "avcall-internal.h" + +#define RETURN(TYPE,VAL) (*(TYPE*)l->raddr = (TYPE)(VAL)) + +/* This declaration tells gcc not to modify %r28. */ +register __avword* sret __asm__("%r28"); /* structure return pointer */ + +register float farg1 __asm__("%fr4"); /* fr4L */ +register float farg2 __asm__("%fr5"); /* fr5L */ +register float farg3 __asm__("%fr6"); /* fr6L */ +register float farg4 __asm__("%fr7"); /* fr7L */ +register double darg1 __asm__("%fr5"); +register double darg2 __asm__("%fr7"); + +int +avcall_call(av_alist* list) +{ + register __avword* sp __asm__("%r30"); /* C names for registers */ + register float fret __asm__("%fr4"); + register double dret __asm__("%fr4"); +/*register __avword iret1 __asm__("%r28"); */ + register __avword iret2 __asm__("%r29"); + + __av_alist* l = &AV_LIST_INNER(list); + + __avword* argframe = __builtin_alloca(__AV_ALIST_WORDS * sizeof(__avword)); /* make room for argument list */ + argframe += __AV_ALIST_WORDS + 20; + int arglen = l->args_end - l->aptr; + __avword iret; + + { + int i; + for (i = -arglen; i < -4; i++) /* push function args onto stack */ + argframe[i] = l->args_end[i]; + } + + if (l->rtype == __AVstruct) /* push struct return address */ + sret = l->raddr; + + /* The floats and doubles among the first 4 argument words are passed + * - in both general registers and floating-point registers when the + * function call is a variadic one, which means: + * - for HP cc: the call is done through a function pointer or + * directly to a function declared with a varargs prototype, + * - for GCC: the function's type is a varargs function. + * - in floating-point registers otherwise. + * To cover both cases, put these floating-point values into the general + * registers and the floating-point registers always. + */ + if (arglen >= 1) { + if (l->farg_mask & (1 << 0)) + /*__asm__ __volatile__ ("fldw %0,%%fr4R" : : "m" (*(float*)&l->args_end[-1]));*/ farg1 = *((float*)&l->args_end[-1]); + if (arglen >= 2) { + if (l->farg_mask & (1 << 1)) + /* __asm__ __volatile__ ("fldw %0,%%fr5R" : : "m" (*(float*)&l->args_end[-2])); */ farg2 = *((float*)&l->args_end[-2]); + if (l->darg_mask & (1 << 1)) + darg1 = *((double*)&l->args_end[-2]); + if (arglen >= 3) { + if (l->farg_mask & (1 << 2)) + /* __asm__ __volatile__ ("fldw %0,%%fr6R" : : "m" (*(float*)&l->args_end[-3])); */ farg3 = *((float*)&l->args_end[-3]); + if (arglen >= 4) { + if (l->farg_mask & (1 << 3)) + /* __asm__ __volatile__ ("fldw %0,%%fr7R" : : "m" (*(float*)&l->args_end[-4])); */ farg4 = *((float*)&l->args_end[-4]); + if (l->darg_mask & (1 << 3)) + darg2 = *((double*)&l->args_end[-4]); + } + } + } + } + /* call function, pass first 4 arg words in general registers */ + iret = (*l->func)(l->args_end[-1], l->args_end[-2], + l->args_end[-3], l->args_end[-4]); + + /* save return value */ + if (l->rtype == __AVvoid) { + } else + if (l->rtype == __AVword) { + RETURN(__avword, iret); + } else + if (l->rtype == __AVchar) { + RETURN(char, iret); + } else + if (l->rtype == __AVschar) { + RETURN(signed char, iret); + } else + if (l->rtype == __AVuchar) { + RETURN(unsigned char, iret); + } else + if (l->rtype == __AVshort) { + RETURN(short, iret); + } else + if (l->rtype == __AVushort) { + RETURN(unsigned short, iret); + } else + if (l->rtype == __AVint) { + RETURN(int, iret); + } else + if (l->rtype == __AVuint) { + RETURN(unsigned int, iret); + } else + if (l->rtype == __AVlong) { + RETURN(long, iret); + } else + if (l->rtype == __AVulong) { + RETURN(unsigned long, iret); + } else + if (l->rtype == __AVlonglong || l->rtype == __AVulonglong) { + void* raddr = l->raddr; + ((__avword*)raddr)[0] = iret; + ((__avword*)raddr)[1] = iret2; + } else + if (l->rtype == __AVfloat) { + RETURN(float, fret); + } else + if (l->rtype == __AVdouble) { + RETURN(double, dret); + } else + if (l->rtype == __AVvoidp) { + RETURN(void*, iret); + } else + if (l->rtype == __AVstruct) { + if (l->flags & __AV_SMALL_STRUCT_RETURN) { + /* cc, c89 and gcc >= 2.7 return structs of size <= 8 in registers. */ + if (l->rsize > 0 && l->rsize <= 8) { + /* This is really weird code, unlike all other big-endian platforms. */ + void* raddr = l->raddr; + #if 0 /* Unoptimized */ + if (l->rsize == 1) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + } else + if (l->rsize == 2) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[1] = (unsigned char)(iret); + } else + if (l->rsize == 3) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret); + } else + if (l->rsize == 4) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[3] = (unsigned char)(iret); + } else + if (l->rsize == 5) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[4] = (unsigned char)(iret2); + } else + if (l->rsize == 6) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[1] = (unsigned char)(iret); + ((unsigned char *)raddr)[2] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[3] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[4] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[5] = (unsigned char)(iret2); + } else + if (l->rsize == 7) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret); + ((unsigned char *)raddr)[3] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[4] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[5] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[6] = (unsigned char)(iret2); + } else + if (l->rsize == 8) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[3] = (unsigned char)(iret); + ((unsigned char *)raddr)[4] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[5] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[6] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[7] = (unsigned char)(iret2); + } + #else /* Optimized: fewer conditional jumps, fewer memory accesses */ + uintptr_t count = l->rsize; /* > 0, ≤ 2*sizeof(__avword) */ + __avword* wordaddr = (__avword*)((uintptr_t)raddr & ~(uintptr_t)(sizeof(__avword)-1)); + uintptr_t start_offset = (uintptr_t)raddr & (uintptr_t)(sizeof(__avword)-1); /* ≥ 0, < sizeof(__avword) */ + uintptr_t end_offset = start_offset + count; /* > 0, < 3*sizeof(__avword) */ + if (count <= sizeof(__avword)) { + /* Use iret. */ + if (end_offset <= sizeof(__avword)) { + /* 0 < end_offset ≤ sizeof(__avword) */ + __avword mask0 = ((__avword)2 << (sizeof(__avword)*8-start_offset*8-1)) - ((__avword)1 << (sizeof(__avword)*8-end_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret << (sizeof(__avword)*8-end_offset*8))) & mask0; + } else { + /* sizeof(__avword) < end_offset < 2*sizeof(__avword), start_offset > 0 */ + __avword mask0 = ((__avword)2 << (sizeof(__avword)*8-start_offset*8-1)) - 1; + __avword mask1 = - ((__avword)1 << (2*sizeof(__avword)*8-end_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret >> (end_offset*8-sizeof(__avword)*8))) & mask0; + wordaddr[1] ^= (wordaddr[1] ^ (iret << (2*sizeof(__avword)*8-end_offset*8))) & mask1; + } + } else { + /* Use iret, iret2. */ + __avword mask0 = ((__avword)2 << (sizeof(__avword)*8-start_offset*8-1)) - 1; + if (end_offset <= 2*sizeof(__avword)) { + /* sizeof(__avword) < end_offset ≤ 2*sizeof(__avword) */ + __avword mask1 = - ((__avword)1 << (2*sizeof(__avword)*8-end_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ ((iret << (2*sizeof(__avword)*8-end_offset*8)) | (iret2 >> (end_offset*4-sizeof(__avword)*4) >> (end_offset*4-sizeof(__avword)*4)))) & mask0; + wordaddr[1] ^= (wordaddr[1] ^ (iret2 << (2*sizeof(__avword)*8-end_offset*8))) & mask1; + } else { + /* 2*sizeof(__avword) < end_offset < 3*sizeof(__avword), start_offset > 0 */ + __avword mask2 = - ((__avword)1 << (3*sizeof(__avword)*8-end_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret >> (end_offset*8-2*sizeof(__avword)*8))) & mask0; + wordaddr[1] = (iret << (3*sizeof(__avword)*8-end_offset*8)) | (iret2 >> (end_offset*8-2*sizeof(__avword)*8)); + wordaddr[2] ^= (wordaddr[2] ^ (iret2 << (3*sizeof(__avword)*8-end_offset*8))) & mask2; + } + } + #endif + } + } + } + return 0; +} diff --git a/avcall/avcall-hppa64-linux.s b/avcall/avcall-hppa64-linux.s new file mode 100644 index 0000000..9e18dac --- /dev/null +++ b/avcall/avcall-hppa64-linux.s @@ -0,0 +1,532 @@ + .LEVEL 2.0w + .text + .align 8 +.globl avcall_call + .type avcall_call,@function +avcall_call: + .PROC + .CALLINFO FRAME=256,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=9 + .ENTRY + copy %r3,%r1 + std %r2,-16(%r30) + copy %r30,%r3 + std,ma %r1,256(%r30) + ldi 8,%r31 + std %r9,16(%r3) + copy %r27,%r9 + std %r8,24(%r3) + copy %r26,%r8 + std %r7,32(%r3) + ldo -80(%r30),%r7 + std %r6,40(%r3) + std %r5,48(%r3) + std %r4,56(%r3) + ldd 40(%r26),%r29 + ldd 48(%r26),%r5 + sub %r29,%r5,%r29 + extrd,s %r29,29+32-1,32,%r6 + cmpb,<= %r6,%r31,.L115 + ldo 2112(%r30),%r30 +.L6: + depd,z %r31,60,61,%r29 + ldo 1(%r31),%r31 + add,l %r29,%r5,%r2 + extrd,s %r31,63,32,%r31 + ldd 0(%r2),%r4 + add,l %r29,%r7,%r29 + cmpb,> %r6,%r31,.L6 + std %r4,0(%r29) +.L115: + ldw 24(%r8),%r31 + ldi 16,%r29 + cmpb,= %r29,%r31,.L120 + copy %r31,%r4 +.L7: + cmpib,>=,n 0,%r6,.L8 + ldw 68(%r8),%r2 + extrw,u %r2,31,1,%r29 + cmpib,=,n 0,%r29,.L9 + fldd 0(%r5),%fr4 +.L10: + cmpib,>=,n 1,%r6,.L8 + ldi 2,%r31 + and %r2,%r31,%r29 + cmpib,=,n 0,%r29,.L14 + fldd 8(%r5),%fr5 +.L15: + cmpib,>=,n 2,%r6,.L8 + ldi 4,%r31 + and %r2,%r31,%r29 + cmpib,=,n 0,%r29,.L19 + fldd 16(%r5),%fr6 +.L20: + cmpib,>=,n 3,%r6,.L8 + ldi 8,%r31 + and %r2,%r31,%r29 + cmpib,=,n 0,%r29,.L24 + fldd 24(%r5),%fr7 +.L25: + cmpib,>=,n 4,%r6,.L8 + ldi 16,%r31 + and %r2,%r31,%r29 + cmpib,=,n 0,%r29,.L29 + fldd 32(%r5),%fr8 +.L30: + cmpib,>=,n 5,%r6,.L8 + ldi 32,%r31 + and %r2,%r31,%r29 + cmpib,=,n 0,%r29,.L34 + fldd 40(%r5),%fr9 +.L35: + cmpib,>=,n 6,%r6,.L8 + ldi 64,%r31 + and %r2,%r31,%r29 + cmpib,=,n 0,%r29,.L39 + fldd 48(%r5),%fr10 +.L40: + cmpib,>=,n 7,%r6,.L8 + ldi 128,%r31 + and %r2,%r31,%r29 + cmpib,=,n 0,%r29,.L44 + fldd 56(%r5),%fr11 +.L45: + cmpiclr,>= 8,%r6,%r0 + ldo 64(%r7),%r1 +.L8: + cmpib,=,n 13,%r4,.L121 + cmpib,=,n 14,%r4,.L122 +#APP + copy %r1,%r29 +#NO_APP + ldd 8(%r8),%r31 + ldo -16(%r30),%r29 + ldd 16(%r31),%r2 + ldd 24(%r31),%r27 + bve,l (%r2),%r2 + nop + ldw 24(%r8),%r2 + copy %r9,%r27 + cmpib,= 1,%r2,.L50 + copy %r28,%r1 + cmpib,=,n 0,%r2,.L116 + cmpib,=,n 2,%r2,.L119 + cmpib,=,n 3,%r2,.L119 + cmpib,=,n 4,%r2,.L119 + cmpib,=,n 5,%r2,.L118 + cmpib,=,n 6,%r2,.L118 + cmpib,=,n 7,%r2,.L117 + cmpib,=,n 8,%r2,.L117 + cmpib,=,n 9,%r2,.L116 + cmpib,=,n 11,%r2,.L116 + cmpib,=,n 10,%r2,.L116 + cmpib,=,n 12,%r2,.L116 + cmpib,= 15,%r2,.L116 + ldi 16,%r31 + cmpb,=,n %r31,%r2,.L123 +.L50: + ldd -16(%r3),%r2 +.L138: + ldi 0,%r28 + ldd 16(%r3),%r9 + ldd 24(%r3),%r8 + ldd 32(%r3),%r7 + ldd 40(%r3),%r6 + ldd 48(%r3),%r5 + ldd 56(%r3),%r4 + ldo 64(%r3),%r30 + bve (%r2) + ldd,mb -64(%r30),%r3 +.L123: + ldw 0(%r8),%r31 + extrd,u %r31,54+1-1,1,%r31 + cmpib,= 0,%r31,.L138 + ldd -16(%r3),%r2 + ldd 32(%r8),%r2 + ldo -1(%r2),%r31 + cmpib,*<<,n 15,%r31,.L138 + ldd -16(%r3),%r2 + cmpib,*=,n 1,%r2,.L124 + cmpib,*=,n 2,%r2,.L125 + cmpib,*= 3,%r2,.L126 + extrd,s %r28,23,24,%r4 + cmpib,*= 4,%r2,.L127 + extrd,s %r28,31,32,%r5 + cmpib,*=,n 5,%r2,.L128 + cmpib,*=,n 6,%r2,.L129 + cmpib,*= 7,%r2,.L130 + ldo -8(%r2),%r31 + cmpib,*<< 8,%r31,.L50 + extrd,s %r28,7,8,%r31 + ldd 16(%r8),%r2 + stb %r31,0(%r2) + extrd,s %r28,15,16,%r4 + ldd 16(%r8),%r31 + extrd,s %r28,23,24,%r2 + stb %r4,1(%r31) + extrd,s %r28,31,32,%r5 + ldd 16(%r8),%r31 + extrd,s %r28,39,40,%r4 + stb %r2,2(%r31) + extrd,s %r28,47,48,%r6 + ldd 16(%r8),%r2 + extrd,s %r28,55,56,%r7 + stb %r5,3(%r2) + ldd 16(%r8),%r31 + stb %r4,4(%r31) + ldd 16(%r8),%r2 + stb %r6,5(%r2) + ldd 16(%r8),%r31 + stb %r7,6(%r31) + ldd 16(%r8),%r2 + stb %r28,7(%r2) + ldd 32(%r8),%r2 + cmpib,*=,n 8,%r2,.L138 + ldd -16(%r3),%r2 + cmpib,*=,n 9,%r2,.L131 + cmpib,*=,n 10,%r2,.L132 + cmpib,*=,n 11,%r2,.L133 + cmpib,*=,n 12,%r2,.L134 + cmpib,*= 13,%r2,.L135 + extrd,s %r29,7,8,%r31 + cmpib,*=,n 14,%r2,.L136 + cmpib,*= 15,%r2,.L137 + ldi 16,%r31 + cmpb,*<> %r31,%r2,.L138 + ldd -16(%r3),%r2 + ldd 16(%r8),%r2 + extrd,s %r29,7,8,%r31 + stb %r31,8(%r2) + extrd,s %r29,15,16,%r4 + ldd 16(%r8),%r31 + extrd,s %r29,23,24,%r2 + stb %r4,9(%r31) + extrd,s %r29,31,32,%r5 + ldd 16(%r8),%r31 + extrd,s %r29,39,40,%r4 + stb %r2,10(%r31) + extrd,s %r29,47,48,%r6 + ldd 16(%r8),%r2 + extrd,s %r29,55,56,%r7 + stb %r5,11(%r2) + ldd 16(%r8),%r31 + stb %r4,12(%r31) + ldd 16(%r8),%r2 + stb %r6,13(%r2) + ldd 16(%r8),%r31 + stb %r7,14(%r31) + ldd 16(%r8),%r2 + b .L50 + stb %r29,15(%r2) +.L137: + ldd 16(%r8),%r2 + extrd,s %r29,7,8,%r31 + stb %r31,8(%r2) + extrd,s %r29,15,16,%r4 + ldd 16(%r8),%r31 + extrd,s %r29,23,24,%r2 + stb %r4,9(%r31) + extrd,s %r29,31,32,%r5 + ldd 16(%r8),%r31 + extrd,s %r29,39,40,%r4 + stb %r2,10(%r31) + extrd,s %r29,47,48,%r6 + ldd 16(%r8),%r2 + extrd,s %r29,55,56,%r29 + stb %r5,11(%r2) + ldd 16(%r8),%r31 + stb %r4,12(%r31) + ldd 16(%r8),%r2 + stb %r6,13(%r2) + ldd 16(%r8),%r31 + b .L50 + stb %r29,14(%r31) +.L136: + ldd 16(%r8),%r2 + stb %r31,8(%r2) + extrd,s %r29,15,16,%r4 + ldd 16(%r8),%r31 + extrd,s %r29,23,24,%r2 + stb %r4,9(%r31) + extrd,s %r29,31,32,%r5 + ldd 16(%r8),%r31 + extrd,s %r29,39,40,%r4 + stb %r2,10(%r31) + extrd,s %r29,47,48,%r29 + ldd 16(%r8),%r31 + stb %r5,11(%r31) + ldd 16(%r8),%r2 + stb %r4,12(%r2) + ldd 16(%r8),%r31 + b .L50 + stb %r29,13(%r31) +.L135: + ldd 16(%r8),%r2 + stb %r31,8(%r2) + extrd,s %r29,15,16,%r4 + ldd 16(%r8),%r31 + extrd,s %r29,23,24,%r5 + stb %r4,9(%r31) + extrd,s %r29,31,32,%r6 + ldd 16(%r8),%r2 + extrd,s %r29,39,40,%r29 + stb %r5,10(%r2) + ldd 16(%r8),%r31 + stb %r6,11(%r31) + ldd 16(%r8),%r2 + b .L50 + stb %r29,12(%r2) +.L134: + ldd 16(%r8),%r2 + extrd,s %r29,7,8,%r31 + stb %r31,8(%r2) + extrd,s %r29,15,16,%r4 + ldd 16(%r8),%r31 + extrd,s %r29,23,24,%r5 + stb %r4,9(%r31) + extrd,s %r29,31,32,%r29 + ldd 16(%r8),%r31 + stb %r5,10(%r31) + ldd 16(%r8),%r2 + b .L50 + stb %r29,11(%r2) +.L133: + ldd 16(%r8),%r2 + extrd,s %r29,7,8,%r31 + stb %r31,8(%r2) + extrd,s %r29,15,16,%r4 + ldd 16(%r8),%r2 + extrd,s %r29,23,24,%r29 + stb %r4,9(%r2) + ldd 16(%r8),%r31 + b .L50 + stb %r29,10(%r31) +.L132: + ldd 16(%r8),%r2 + extrd,s %r29,7,8,%r31 + stb %r31,8(%r2) + extrd,s %r29,15,16,%r29 + ldd 16(%r8),%r31 + b .L50 + stb %r29,9(%r31) +.L131: + ldd 16(%r8),%r31 + extrd,s %r29,7,8,%r29 + b .L50 + stb %r29,8(%r31) +.L130: + ldd 16(%r8),%r31 + extrd,s %r28,7,8,%r29 + stb %r29,0(%r31) + extrd,s %r28,15,16,%r2 + ldd 16(%r8),%r29 + extrd,s %r28,23,24,%r31 + stb %r2,1(%r29) + extrd,s %r28,31,32,%r4 + ldd 16(%r8),%r29 + extrd,s %r28,39,40,%r2 + stb %r31,2(%r29) + extrd,s %r28,47,48,%r5 + ldd 16(%r8),%r31 + extrd,s %r28,55,56,%r6 + stb %r4,3(%r31) + ldd 16(%r8),%r29 + stb %r2,4(%r29) + ldd 16(%r8),%r31 + stb %r5,5(%r31) + ldd 16(%r8),%r29 + b .L50 + stb %r6,6(%r29) +.L129: + ldd 16(%r8),%r31 + extrd,s %r28,7,8,%r29 + stb %r29,0(%r31) + extrd,s %r28,15,16,%r2 + ldd 16(%r8),%r29 + extrd,s %r28,23,24,%r31 + stb %r2,1(%r29) + extrd,s %r28,31,32,%r4 + ldd 16(%r8),%r29 + extrd,s %r28,39,40,%r2 + stb %r31,2(%r29) + extrd,s %r28,47,48,%r5 + ldd 16(%r8),%r29 + stb %r4,3(%r29) + ldd 16(%r8),%r31 + stb %r2,4(%r31) + ldd 16(%r8),%r29 + b .L50 + stb %r5,5(%r29) +.L128: + ldd 16(%r8),%r31 + extrd,s %r28,7,8,%r29 + stb %r29,0(%r31) + extrd,s %r28,15,16,%r2 + ldd 16(%r8),%r29 + stb %r2,1(%r29) + ldd 16(%r8),%r31 + extrd,s %r28,39,40,%r2 + stb %r4,2(%r31) + ldd 16(%r8),%r29 + stb %r5,3(%r29) + ldd 16(%r8),%r31 + b .L50 + stb %r2,4(%r31) +.L127: + ldd 16(%r8),%r31 + extrd,s %r28,7,8,%r29 + stb %r29,0(%r31) + extrd,s %r28,15,16,%r2 + ldd 16(%r8),%r29 + stb %r2,1(%r29) + ldd 16(%r8),%r29 + stb %r4,2(%r29) + ldd 16(%r8),%r31 + b .L50 + stb %r5,3(%r31) +.L126: + ldd 16(%r8),%r31 + extrd,s %r28,7,8,%r29 + stb %r29,0(%r31) + extrd,s %r28,15,16,%r2 + ldd 16(%r8),%r31 + stb %r2,1(%r31) + ldd 16(%r8),%r29 + b .L50 + stb %r4,2(%r29) +.L125: + ldd 16(%r8),%r31 + extrd,s %r28,7,8,%r29 + stb %r29,0(%r31) + extrd,s %r28,15,16,%r2 + ldd 16(%r8),%r29 + b .L50 + stb %r2,1(%r29) +.L124: + ldd 16(%r8),%r31 + extrd,s %r28,7,8,%r29 + b .L50 + stb %r29,0(%r31) +.L116: + ldd 16(%r8),%r29 + b .L50 + std %r1,0(%r29) +.L117: + ldd 16(%r8),%r29 + b .L50 + stw %r1,0(%r29) +.L118: + ldd 16(%r8),%r29 + b .L50 + sth %r1,0(%r29) +.L119: + ldd 16(%r8),%r29 + b .L50 + stb %r1,0(%r29) +.L122: +#APP + copy %r1,%r29 +#NO_APP + ldd 8(%r8),%r31 + ldo -16(%r30),%r29 + ldd 16(%r31),%r2 + ldd 24(%r31),%r27 + bve,l (%r2),%r2 + nop + ldd 16(%r8),%r29 + copy %r9,%r27 + b .L50 + fstd %fr4,0(%r29) +.L121: +#APP + copy %r1,%r29 +#NO_APP + ldd 8(%r8),%r31 + ldo -16(%r30),%r29 + ldd 16(%r31),%r2 + ldd 24(%r31),%r27 + bve,l (%r2),%r2 + nop + ldd 16(%r8),%r29 + copy %r9,%r27 + b .L50 + fstw %fr4R,0(%r29) +.L44: + ldw 64(%r8),%r29 + and %r29,%r31,%r29 + cmpib,=,n 0,%r29,.L45 + ldd 56(%r5),%r19 +#APP + fldw 60(%r5),%fr11R +#NO_APP + b,n .L45 +.L39: + ldw 64(%r8),%r29 + and %r29,%r31,%r29 + cmpib,=,n 0,%r29,.L40 + ldd 48(%r5),%r20 +#APP + fldw 52(%r5),%fr10R +#NO_APP + b,n .L40 +.L34: + ldw 64(%r8),%r29 + and %r29,%r31,%r29 + cmpib,=,n 0,%r29,.L35 + ldd 40(%r5),%r21 +#APP + fldw 44(%r5),%fr9R +#NO_APP + b,n .L35 +.L29: + ldw 64(%r8),%r29 + and %r29,%r31,%r29 + cmpib,=,n 0,%r29,.L30 + ldd 32(%r5),%r22 +#APP + fldw 36(%r5),%fr8R +#NO_APP + b,n .L30 +.L24: + ldw 64(%r8),%r29 + and %r29,%r31,%r29 + cmpib,=,n 0,%r29,.L25 + ldd 24(%r5),%r23 +#APP + fldw 28(%r5),%fr7R +#NO_APP + b,n .L25 +.L19: + ldw 64(%r8),%r29 + and %r29,%r31,%r29 + cmpib,=,n 0,%r29,.L20 + ldd 16(%r5),%r24 +#APP + fldw 20(%r5),%fr6R +#NO_APP + b,n .L20 +.L14: + ldw 64(%r8),%r29 + and %r29,%r31,%r29 + cmpib,=,n 0,%r29,.L15 + ldd 8(%r5),%r25 +#APP + fldw 12(%r5),%fr5R +#NO_APP + b,n .L15 +.L9: + ldw 64(%r8),%r29 + extrw,u %r29,31,1,%r29 + cmpib,=,n 0,%r29,.L10 + ldd 0(%r5),%r26 +#APP + fldw 4(%r5),%fr4R +#NO_APP + b,n .L10 +.L120: + b .L7 + ldd 16(%r8),%r28 + .EXIT + .PROCEND +.Lfe1: + .size avcall_call,.Lfe1-avcall_call + .ident "GCC: (GNU) 3.1" diff --git a/avcall/avcall-hppa64-macro.S b/avcall/avcall-hppa64-macro.S new file mode 100644 index 0000000..0484da3 --- /dev/null +++ b/avcall/avcall-hppa64-macro.S @@ -0,0 +1,511 @@ +#include "asm-hppa64.h" + .LEVEL 2.0w + TEXT1() + TEXT2() + .align 8 +GLOBL(avcall_call) + DECLARE_FUNCTION(avcall_call) +DEF(avcall_call) + .PROC + .CALLINFO FRAME=256,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=9 + .ENTRY + copy %r3,%r1 + std %r2,-16(%r30) + copy %r30,%r3 + std,ma %r1,256(%r30) + ldi 8,%r31 + std %r9,16(%r3) + copy %r27,%r9 + std %r8,24(%r3) + copy %r26,%r8 + std %r7,32(%r3) + ldo -80(%r30),%r7 + std %r6,40(%r3) + std %r5,48(%r3) + std %r4,56(%r3) + ldd 40(%r26),%r29 + ldd 48(%r26),%r5 + sub %r29,%r5,%r29 + extrd,s %r29,29+32-1,32,%r6 + cmpb,<= %r6,%r31,L(115) + ldo 2112(%r30),%r30 +DEF(L(6)) + depd,z %r31,60,61,%r29 + ldo 1(%r31),%r31 + add,l %r29,%r5,%r2 + extrd,s %r31,63,32,%r31 + ldd 0(%r2),%r4 + add,l %r29,%r7,%r29 + cmpb,> %r6,%r31,L(6) + std %r4,0(%r29) +DEF(L(115)) + ldw 24(%r8),%r31 + ldi 16,%r29 + cmpb,= %r29,%r31,L(120) + copy %r31,%r4 +DEF(L(7)) + cmpib,>=,n 0,%r6,L(8) + ldw 68(%r8),%r2 + extrw,u %r2,31,1,%r29 + cmpib,=,n 0,%r29,L(9) + fldd 0(%r5),%fr4 +DEF(L(10)) + cmpib,>=,n 1,%r6,L(8) + ldi 2,%r31 + and %r2,%r31,%r29 + cmpib,=,n 0,%r29,L(14) + fldd 8(%r5),%fr5 +DEF(L(15)) + cmpib,>=,n 2,%r6,L(8) + ldi 4,%r31 + and %r2,%r31,%r29 + cmpib,=,n 0,%r29,L(19) + fldd 16(%r5),%fr6 +DEF(L(20)) + cmpib,>=,n 3,%r6,L(8) + ldi 8,%r31 + and %r2,%r31,%r29 + cmpib,=,n 0,%r29,L(24) + fldd 24(%r5),%fr7 +DEF(L(25)) + cmpib,>=,n 4,%r6,L(8) + ldi 16,%r31 + and %r2,%r31,%r29 + cmpib,=,n 0,%r29,L(29) + fldd 32(%r5),%fr8 +DEF(L(30)) + cmpib,>=,n 5,%r6,L(8) + ldi 32,%r31 + and %r2,%r31,%r29 + cmpib,=,n 0,%r29,L(34) + fldd 40(%r5),%fr9 +DEF(L(35)) + cmpib,>=,n 6,%r6,L(8) + ldi 64,%r31 + and %r2,%r31,%r29 + cmpib,=,n 0,%r29,L(39) + fldd 48(%r5),%fr10 +DEF(L(40)) + cmpib,>=,n 7,%r6,L(8) + ldi 128,%r31 + and %r2,%r31,%r29 + cmpib,=,n 0,%r29,L(44) + fldd 56(%r5),%fr11 +DEF(L(45)) + cmpiclr,>= 8,%r6,%r0 + ldo 64(%r7),%r1 +DEF(L(8)) + cmpib,=,n 13,%r4,L(121) + cmpib,=,n 14,%r4,L(122) + copy %r1,%r29 + ldd 8(%r8),%r31 + ldd 16(%r31),%r2 + ldd 24(%r31),%r27 + bve,l (%r2),%r2 + nop + ldw 24(%r8),%r2 + copy %r9,%r27 + cmpib,= 1,%r2,L(50) + copy %r28,%r1 + cmpib,=,n 0,%r2,L(116) + cmpib,=,n 2,%r2,L(119) + cmpib,=,n 3,%r2,L(119) + cmpib,=,n 4,%r2,L(119) + cmpib,=,n 5,%r2,L(118) + cmpib,=,n 6,%r2,L(118) + cmpib,=,n 7,%r2,L(117) + cmpib,=,n 8,%r2,L(117) + cmpib,=,n 9,%r2,L(116) + cmpib,=,n 11,%r2,L(116) + cmpib,=,n 10,%r2,L(116) + cmpib,=,n 12,%r2,L(116) + cmpib,= 15,%r2,L(116) + ldi 16,%r31 + cmpb,=,n %r31,%r2,L(123) +DEF(L(50)) + ldd -16(%r3),%r2 +DEF(L(138)) + ldi 0,%r28 + ldd 16(%r3),%r9 + ldd 24(%r3),%r8 + ldd 32(%r3),%r7 + ldd 40(%r3),%r6 + ldd 48(%r3),%r5 + ldd 56(%r3),%r4 + ldo 64(%r3),%r30 + bve (%r2) + ldd,mb -64(%r30),%r3 +DEF(L(123)) + ldw 0(%r8),%r31 + extrd,u %r31,54+1-1,1,%r31 + cmpib,= 0,%r31,L(138) + ldd -16(%r3),%r2 + ldd 32(%r8),%r2 + ldo -1(%r2),%r31 + cmpib,*<<,n 15,%r31,L(138) + ldd -16(%r3),%r2 + cmpib,*=,n 1,%r2,L(124) + cmpib,*=,n 2,%r2,L(125) + cmpib,*= 3,%r2,L(126) + extrd,s %r28,23,24,%r4 + cmpib,*= 4,%r2,L(127) + extrd,s %r28,31,32,%r5 + cmpib,*=,n 5,%r2,L(128) + cmpib,*=,n 6,%r2,L(129) + cmpib,*= 7,%r2,L(130) + ldo -8(%r2),%r31 + cmpib,*<< 8,%r31,L(50) + extrd,s %r28,7,8,%r31 + ldd 16(%r8),%r2 + stb %r31,0(%r2) + extrd,s %r28,15,16,%r4 + ldd 16(%r8),%r31 + extrd,s %r28,23,24,%r2 + stb %r4,1(%r31) + extrd,s %r28,31,32,%r5 + ldd 16(%r8),%r31 + extrd,s %r28,39,40,%r4 + stb %r2,2(%r31) + extrd,s %r28,47,48,%r6 + ldd 16(%r8),%r2 + extrd,s %r28,55,56,%r7 + stb %r5,3(%r2) + ldd 16(%r8),%r31 + stb %r4,4(%r31) + ldd 16(%r8),%r2 + stb %r6,5(%r2) + ldd 16(%r8),%r31 + stb %r7,6(%r31) + ldd 16(%r8),%r2 + stb %r28,7(%r2) + ldd 32(%r8),%r2 + cmpib,*=,n 8,%r2,L(138) + ldd -16(%r3),%r2 + cmpib,*=,n 9,%r2,L(131) + cmpib,*=,n 10,%r2,L(132) + cmpib,*=,n 11,%r2,L(133) + cmpib,*=,n 12,%r2,L(134) + cmpib,*= 13,%r2,L(135) + extrd,s %r29,7,8,%r31 + cmpib,*=,n 14,%r2,L(136) + cmpib,*= 15,%r2,L(137) + ldi 16,%r31 + cmpb,*<> %r31,%r2,L(138) + ldd -16(%r3),%r2 + ldd 16(%r8),%r2 + extrd,s %r29,7,8,%r31 + stb %r31,8(%r2) + extrd,s %r29,15,16,%r4 + ldd 16(%r8),%r31 + extrd,s %r29,23,24,%r2 + stb %r4,9(%r31) + extrd,s %r29,31,32,%r5 + ldd 16(%r8),%r31 + extrd,s %r29,39,40,%r4 + stb %r2,10(%r31) + extrd,s %r29,47,48,%r6 + ldd 16(%r8),%r2 + extrd,s %r29,55,56,%r7 + stb %r5,11(%r2) + ldd 16(%r8),%r31 + stb %r4,12(%r31) + ldd 16(%r8),%r2 + stb %r6,13(%r2) + ldd 16(%r8),%r31 + stb %r7,14(%r31) + ldd 16(%r8),%r2 + b L(50) + stb %r29,15(%r2) +DEF(L(137)) + ldd 16(%r8),%r2 + extrd,s %r29,7,8,%r31 + stb %r31,8(%r2) + extrd,s %r29,15,16,%r4 + ldd 16(%r8),%r31 + extrd,s %r29,23,24,%r2 + stb %r4,9(%r31) + extrd,s %r29,31,32,%r5 + ldd 16(%r8),%r31 + extrd,s %r29,39,40,%r4 + stb %r2,10(%r31) + extrd,s %r29,47,48,%r6 + ldd 16(%r8),%r2 + extrd,s %r29,55,56,%r29 + stb %r5,11(%r2) + ldd 16(%r8),%r31 + stb %r4,12(%r31) + ldd 16(%r8),%r2 + stb %r6,13(%r2) + ldd 16(%r8),%r31 + b L(50) + stb %r29,14(%r31) +DEF(L(136)) + ldd 16(%r8),%r2 + stb %r31,8(%r2) + extrd,s %r29,15,16,%r4 + ldd 16(%r8),%r31 + extrd,s %r29,23,24,%r2 + stb %r4,9(%r31) + extrd,s %r29,31,32,%r5 + ldd 16(%r8),%r31 + extrd,s %r29,39,40,%r4 + stb %r2,10(%r31) + extrd,s %r29,47,48,%r29 + ldd 16(%r8),%r31 + stb %r5,11(%r31) + ldd 16(%r8),%r2 + stb %r4,12(%r2) + ldd 16(%r8),%r31 + b L(50) + stb %r29,13(%r31) +DEF(L(135)) + ldd 16(%r8),%r2 + stb %r31,8(%r2) + extrd,s %r29,15,16,%r4 + ldd 16(%r8),%r31 + extrd,s %r29,23,24,%r5 + stb %r4,9(%r31) + extrd,s %r29,31,32,%r6 + ldd 16(%r8),%r2 + extrd,s %r29,39,40,%r29 + stb %r5,10(%r2) + ldd 16(%r8),%r31 + stb %r6,11(%r31) + ldd 16(%r8),%r2 + b L(50) + stb %r29,12(%r2) +DEF(L(134)) + ldd 16(%r8),%r2 + extrd,s %r29,7,8,%r31 + stb %r31,8(%r2) + extrd,s %r29,15,16,%r4 + ldd 16(%r8),%r31 + extrd,s %r29,23,24,%r5 + stb %r4,9(%r31) + extrd,s %r29,31,32,%r29 + ldd 16(%r8),%r31 + stb %r5,10(%r31) + ldd 16(%r8),%r2 + b L(50) + stb %r29,11(%r2) +DEF(L(133)) + ldd 16(%r8),%r2 + extrd,s %r29,7,8,%r31 + stb %r31,8(%r2) + extrd,s %r29,15,16,%r4 + ldd 16(%r8),%r2 + extrd,s %r29,23,24,%r29 + stb %r4,9(%r2) + ldd 16(%r8),%r31 + b L(50) + stb %r29,10(%r31) +DEF(L(132)) + ldd 16(%r8),%r2 + extrd,s %r29,7,8,%r31 + stb %r31,8(%r2) + extrd,s %r29,15,16,%r29 + ldd 16(%r8),%r31 + b L(50) + stb %r29,9(%r31) +DEF(L(131)) + ldd 16(%r8),%r31 + extrd,s %r29,7,8,%r29 + b L(50) + stb %r29,8(%r31) +DEF(L(130)) + ldd 16(%r8),%r31 + extrd,s %r28,7,8,%r29 + stb %r29,0(%r31) + extrd,s %r28,15,16,%r2 + ldd 16(%r8),%r29 + extrd,s %r28,23,24,%r31 + stb %r2,1(%r29) + extrd,s %r28,31,32,%r4 + ldd 16(%r8),%r29 + extrd,s %r28,39,40,%r2 + stb %r31,2(%r29) + extrd,s %r28,47,48,%r5 + ldd 16(%r8),%r31 + extrd,s %r28,55,56,%r6 + stb %r4,3(%r31) + ldd 16(%r8),%r29 + stb %r2,4(%r29) + ldd 16(%r8),%r31 + stb %r5,5(%r31) + ldd 16(%r8),%r29 + b L(50) + stb %r6,6(%r29) +DEF(L(129)) + ldd 16(%r8),%r31 + extrd,s %r28,7,8,%r29 + stb %r29,0(%r31) + extrd,s %r28,15,16,%r2 + ldd 16(%r8),%r29 + extrd,s %r28,23,24,%r31 + stb %r2,1(%r29) + extrd,s %r28,31,32,%r4 + ldd 16(%r8),%r29 + extrd,s %r28,39,40,%r2 + stb %r31,2(%r29) + extrd,s %r28,47,48,%r5 + ldd 16(%r8),%r29 + stb %r4,3(%r29) + ldd 16(%r8),%r31 + stb %r2,4(%r31) + ldd 16(%r8),%r29 + b L(50) + stb %r5,5(%r29) +DEF(L(128)) + ldd 16(%r8),%r31 + extrd,s %r28,7,8,%r29 + stb %r29,0(%r31) + extrd,s %r28,15,16,%r2 + ldd 16(%r8),%r29 + stb %r2,1(%r29) + ldd 16(%r8),%r31 + extrd,s %r28,39,40,%r2 + stb %r4,2(%r31) + ldd 16(%r8),%r29 + stb %r5,3(%r29) + ldd 16(%r8),%r31 + b L(50) + stb %r2,4(%r31) +DEF(L(127)) + ldd 16(%r8),%r31 + extrd,s %r28,7,8,%r29 + stb %r29,0(%r31) + extrd,s %r28,15,16,%r2 + ldd 16(%r8),%r29 + stb %r2,1(%r29) + ldd 16(%r8),%r29 + stb %r4,2(%r29) + ldd 16(%r8),%r31 + b L(50) + stb %r5,3(%r31) +DEF(L(126)) + ldd 16(%r8),%r31 + extrd,s %r28,7,8,%r29 + stb %r29,0(%r31) + extrd,s %r28,15,16,%r2 + ldd 16(%r8),%r31 + stb %r2,1(%r31) + ldd 16(%r8),%r29 + b L(50) + stb %r4,2(%r29) +DEF(L(125)) + ldd 16(%r8),%r31 + extrd,s %r28,7,8,%r29 + stb %r29,0(%r31) + extrd,s %r28,15,16,%r2 + ldd 16(%r8),%r29 + b L(50) + stb %r2,1(%r29) +DEF(L(124)) + ldd 16(%r8),%r31 + extrd,s %r28,7,8,%r29 + b L(50) + stb %r29,0(%r31) +DEF(L(116)) + ldd 16(%r8),%r29 + b L(50) + std %r1,0(%r29) +DEF(L(117)) + ldd 16(%r8),%r29 + b L(50) + stw %r1,0(%r29) +DEF(L(118)) + ldd 16(%r8),%r29 + b L(50) + sth %r1,0(%r29) +DEF(L(119)) + ldd 16(%r8),%r29 + b L(50) + stb %r1,0(%r29) +DEF(L(122)) + copy %r1,%r29 + ldd 8(%r8),%r31 + ldd 16(%r31),%r2 + ldd 24(%r31),%r27 + bve,l (%r2),%r2 + nop + ldd 16(%r8),%r29 + copy %r9,%r27 + b L(50) + fstd %fr4,0(%r29) +DEF(L(121)) + copy %r1,%r29 + ldd 8(%r8),%r31 + ldd 16(%r31),%r2 + ldd 24(%r31),%r27 + bve,l (%r2),%r2 + nop + ldd 16(%r8),%r29 + copy %r9,%r27 + b L(50) + fstw %fr4R,0(%r29) +DEF(L(44)) + ldw 64(%r8),%r29 + and %r29,%r31,%r29 + cmpib,=,n 0,%r29,L(45) + ldd 56(%r5),%r19 + fldw 60(%r5),%fr11R + b,n L(45) +DEF(L(39)) + ldw 64(%r8),%r29 + and %r29,%r31,%r29 + cmpib,=,n 0,%r29,L(40) + ldd 48(%r5),%r20 + fldw 52(%r5),%fr10R + b,n L(40) +DEF(L(34)) + ldw 64(%r8),%r29 + and %r29,%r31,%r29 + cmpib,=,n 0,%r29,L(35) + ldd 40(%r5),%r21 + fldw 44(%r5),%fr9R + b,n L(35) +DEF(L(29)) + ldw 64(%r8),%r29 + and %r29,%r31,%r29 + cmpib,=,n 0,%r29,L(30) + ldd 32(%r5),%r22 + fldw 36(%r5),%fr8R + b,n L(30) +DEF(L(24)) + ldw 64(%r8),%r29 + and %r29,%r31,%r29 + cmpib,=,n 0,%r29,L(25) + ldd 24(%r5),%r23 + fldw 28(%r5),%fr7R + b,n L(25) +DEF(L(19)) + ldw 64(%r8),%r29 + and %r29,%r31,%r29 + cmpib,=,n 0,%r29,L(20) + ldd 16(%r5),%r24 + fldw 20(%r5),%fr6R + b,n L(20) +DEF(L(14)) + ldw 64(%r8),%r29 + and %r29,%r31,%r29 + cmpib,=,n 0,%r29,L(15) + ldd 8(%r5),%r25 + fldw 12(%r5),%fr5R + b,n L(15) +DEF(L(9)) + ldw 64(%r8),%r29 + extrw,u %r29,31,1,%r29 + cmpib,=,n 0,%r29,L(10) + ldd 0(%r5),%r26 + fldw 4(%r5),%fr4R + b,n L(10) +DEF(L(120)) + b L(7) + ldd 16(%r8),%r28 + .EXIT + .PROCEND +DEF(L(fe1)) + FUNEND(avcall_call) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/avcall/avcall-hppa64.c b/avcall/avcall-hppa64.c new file mode 100644 index 0000000..e4c0d78 --- /dev/null +++ b/avcall/avcall-hppa64.c @@ -0,0 +1,402 @@ +/** + Copyright 1993 Bill Triggs + Copyright 1995-2017 Bruno Haible + + 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, see . +**/ +/*---------------------------------------------------------------------- + !!! THIS ROUTINE MUST BE COMPILED gcc -O !!! + + Foreign function interface for a HP-PA 2.0w in 64-bit mode with cc + (NB: gcc-7.1.0/gcc/config/pa/pa64-regs.h is quite incorrect. Ignore it.) + + This calls a C function with an argument list built up using macros + defined in avcall.h. + + hppa64 Argument Passing Conventions: + + Up to 8 words are passed in registers: + integer/pointer float double + 1. %r26 %fr4R %fr4 + 2. %r25 %fr5R %fr5 + 3. %r24 %fr6R %fr6 + 4. %r23 %fr7R %fr7 + 5. %r22 %fr8R %fr8 + 6. %r21 %fr9R %fr9 + 7. %r20 %fr10R %fr10 + 8. %r19 %fr11R %fr11 + The remaining arguments are passed on the stack - growing up, unlike + in 32-bit mode! -, and %r29 is the base address of this stack area. + Room is preallocated for 8 words, i.e. from address %r29-64 to %r29-1. + Among these stack arguments: + - integer/pointer occupies 1 word (right-adjusted, since big-endian), + - float occupies 1 word and is stored in the upper 4 bytes of the word, + - double occupies 1 word. + + Structs of any size are passed in the argument sequence, e.g. in integer + registers (first byte being at bits 63..56). Note that a {long,long} + struct has 2*(8 bytes) alignment. + + The return value is returned in register %r28. + Float return values are also returned in %fr4R. + Double return values are also returned in %fr4. + (How silly! Who designed this ABI?!) + + To return a structure of more than 16 bytes, the called function copies + the return value to the address supplied in register %r28. The function + also returns the pointer. + Smaller structures are returned in the registers %r28 (first 8 bytes) + and %r29 (next 8 bytes, if present). + + ----------------------------------------------------------------------*/ +#include "avcall-internal.h" + +#define RETURN(TYPE,VAL) (*(TYPE*)l->raddr = (TYPE)(VAL)) + +/* This declaration tells gcc not to modify %r28. */ +register __avword* sret __asm__("%r28"); /* structure return pointer */ + +register __avword arg1 __asm__("r26"); +register __avword arg2 __asm__("r25"); +register __avword arg3 __asm__("r24"); +register __avword arg4 __asm__("r23"); +register __avword arg5 __asm__("r22"); +register __avword arg6 __asm__("r21"); +register __avword arg7 __asm__("r20"); +register __avword arg8 __asm__("r19"); + +/*register float farg1 __asm__("fr4R");*/ +/*register float farg2 __asm__("fr5R");*/ +/*register float farg3 __asm__("fr6R");*/ +/*register float farg4 __asm__("fr7R");*/ +/*register float farg5 __asm__("fr8R");*/ +/*register float farg6 __asm__("fr9R");*/ +/*register float farg7 __asm__("fr10R");*/ +/*register float farg8 __asm__("fr11R");*/ + +register double darg1 __asm__("fr4"); +register double darg2 __asm__("fr5"); +register double darg3 __asm__("fr6"); +register double darg4 __asm__("fr7"); +register double darg5 __asm__("fr8"); +register double darg6 __asm__("fr9"); +register double darg7 __asm__("fr10"); +register double darg8 __asm__("fr11"); + +int +avcall_call(av_alist* list) +{ + register __avword* sp __asm__("%r30"); /* C names for registers */ +/*register __avword iret1 __asm__("%r28"); */ + register __avword iret2 __asm__("%r29"); + + __av_alist* l = &AV_LIST_INNER(list); + + __avword* argframe = __builtin_alloca(__AV_ALIST_WORDS * sizeof(__avword)); /* make room for argument list */ + __avword* memargptr; + int arglen = l->aptr - l->args; + __avword iret; + + { + int i; + for (i = 8; i < arglen; i++) /* push function args onto stack */ + argframe[i] = l->args[i]; + } + + if (l->rtype == __AVstruct) /* push struct return address */ + sret = l->raddr; + + /* Put args in registers */ + if (arglen >= 1) { + if (l->darg_mask & (1 << 0)) + darg1 = ((double*)&l->args[1])[-1]; + else if (l->farg_mask & (1 << 0)) + __asm__ __volatile__ ("fldw %0,%%fr4R" : : "m" (((float*)&l->args[1])[-1])); /* farg1 = ((float*)&l->args[1])[-1]; */ + else + arg1 = l->args[0]; + if (arglen >= 2) { + if (l->darg_mask & (1 << 1)) + darg2 = ((double*)&l->args[2])[-1]; + else if (l->farg_mask & (1 << 1)) + __asm__ __volatile__ ("fldw %0,%%fr5R" : : "m" (((float*)&l->args[2])[-1])); /* farg2 = ((float*)&l->args[2])[-1]; */ + else + arg2 = l->args[1]; + if (arglen >= 3) { + if (l->darg_mask & (1 << 2)) + darg3 = ((double*)&l->args[3])[-1]; + else if (l->farg_mask & (1 << 2)) + __asm__ __volatile__ ("fldw %0,%%fr6R" : : "m" (((float*)&l->args[3])[-1])); /* farg3 = ((float*)&l->args[3])[-1]; */ + else + arg3 = l->args[2]; + if (arglen >= 4) { + if (l->darg_mask & (1 << 3)) + darg4 = ((double*)&l->args[4])[-1]; + else if (l->farg_mask & (1 << 3)) + __asm__ __volatile__ ("fldw %0,%%fr7R" : : "m" (((float*)&l->args[4])[-1])); /* farg4 = ((float*)&l->args[4])[-1]; */ + else + arg4 = l->args[3]; + if (arglen >= 5) { + if (l->darg_mask & (1 << 4)) + darg5 = ((double*)&l->args[5])[-1]; + else if (l->farg_mask & (1 << 4)) + __asm__ __volatile__ ("fldw %0,%%fr8R" : : "m" (((float*)&l->args[5])[-1])); /* farg5 = ((float*)&l->args[5])[-1]; */ + else + arg5 = l->args[4]; + if (arglen >= 6) { + if (l->darg_mask & (1 << 5)) + darg6 = ((double*)&l->args[6])[-1]; + else if (l->farg_mask & (1 << 5)) + __asm__ __volatile__ ("fldw %0,%%fr9R" : : "m" (((float*)&l->args[6])[-1])); /* farg6 = ((float*)&l->args[6])[-1]; */ + else + arg6 = l->args[5]; + if (arglen >= 7) { + if (l->darg_mask & (1 << 6)) + darg7 = ((double*)&l->args[7])[-1]; + else if (l->farg_mask & (1 << 6)) + __asm__ __volatile__ ("fldw %0,%%fr10R" : : "m" (((float*)&l->args[7])[-1])); /* farg7 = ((float*)&l->args[7])[-1]; */ + else + arg7 = l->args[6]; + if (arglen >= 8) { + if (l->darg_mask & (1 << 7)) + darg8 = ((double*)&l->args[8])[-1]; + else if (l->farg_mask & (1 << 7)) + __asm__ __volatile__ ("fldw %0,%%fr11R" : : "m" (((float*)&l->args[8])[-1])); /* farg8 = ((float*)&l->args[8])[-1]; */ + else + arg8 = l->args[7]; + if (arglen > 8) { + memargptr = &argframe[8]; + } + } + } + } + } + } + } + } + } + if (l->rtype == __AVfloat) { + __asm__ __volatile__ ("copy %0,%%r29" : : "r" (memargptr)); + /* GCC generates an 'ldo -16(%r30),%r29' instruction as part of this + function call. We eliminate it through post-processing. */ + *(float*)l->raddr = (*(float(*)())l->func)(); + } else + if (l->rtype == __AVdouble) { + __asm__ __volatile__ ("copy %0,%%r29" : : "r" (memargptr)); + /* GCC generates an 'ldo -16(%r30),%r29' instruction as part of this + function call. We eliminate it through post-processing. */ + *(double*)l->raddr = (*(double(*)())l->func)(); + } else { + __asm__ __volatile__ ("copy %0,%%r29" : : "r" (memargptr)); + /* GCC generates an 'ldo -16(%r30),%r29' instruction as part of this + function call. We eliminate it through post-processing. */ + iret = (*l->func)(); + + /* save return value */ + if (l->rtype == __AVvoid) { + } else + if (l->rtype == __AVword) { + RETURN(__avword, iret); + } else + if (l->rtype == __AVchar) { + RETURN(char, iret); + } else + if (l->rtype == __AVschar) { + RETURN(signed char, iret); + } else + if (l->rtype == __AVuchar) { + RETURN(unsigned char, iret); + } else + if (l->rtype == __AVshort) { + RETURN(short, iret); + } else + if (l->rtype == __AVushort) { + RETURN(unsigned short, iret); + } else + if (l->rtype == __AVint) { + RETURN(int, iret); + } else + if (l->rtype == __AVuint) { + RETURN(unsigned int, iret); + } else + if (l->rtype == __AVlong || l->rtype == __AVlonglong) { + RETURN(long, iret); + } else + if (l->rtype == __AVulong || l->rtype == __AVulonglong) { + RETURN(unsigned long, iret); + } else + /* see above + if (l->rtype == __AVfloat) { + } else + if (l->rtype == __AVdouble) { + } else + */ + if (l->rtype == __AVvoidp) { + RETURN(void*, iret); + } else + if (l->rtype == __AVstruct) { + if (l->flags & __AV_REGISTER_STRUCT_RETURN) { + /* cc returns structs of size <= 16 in registers. */ + if (l->rsize > 0 && l->rsize <= 16) { + #if 0 + void* raddr = l->raddr; + #else + #define raddr l->raddr + #endif + #if 1 /* Unoptimized */ + if (l->rsize == 1) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + } else + if (l->rsize == 2) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>48); + } else + if (l->rsize == 3) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>40); + } else + if (l->rsize == 4) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>32); + } else + if (l->rsize == 5) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>24); + } else + if (l->rsize == 6) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>16); + } else + if (l->rsize == 7) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[6] = (unsigned char)(iret>>8); + } else + if (l->rsize >= 8 && l->rsize <= 16) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[6] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[7] = (unsigned char)(iret); + if (l->rsize == 8) { + } else + if (l->rsize == 9) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + } else + if (l->rsize == 10) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>48); + } else + if (l->rsize == 11) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>40); + } else + if (l->rsize == 12) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>32); + } else + if (l->rsize == 13) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>24); + } else + if (l->rsize == 14) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>16); + } else + if (l->rsize == 15) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+6] = (unsigned char)(iret2>>8); + } else + if (l->rsize == 16) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+6] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+7] = (unsigned char)(iret2); + } + } + #else /* Optimized: fewer conditional jumps, fewer memory accesses */ + uintptr_t count = l->rsize; /* > 0, ≤ 2*sizeof(__avword) */ + __avword* wordaddr = (__avword*)((uintptr_t)raddr & ~(uintptr_t)(sizeof(__avword)-1)); + uintptr_t start_offset = (uintptr_t)raddr & (uintptr_t)(sizeof(__avword)-1); /* ≥ 0, < sizeof(__avword) */ + uintptr_t end_offset = start_offset + count; /* > 0, < 3*sizeof(__avword) */ + if (count <= sizeof(__avword)) { + /* Use iret. */ + if (end_offset <= sizeof(__avword)) { + /* 0 < end_offset ≤ sizeof(__avword) */ + __avword mask0 = ((__avword)2 << (sizeof(__avword)*8-start_offset*8-1)) - ((__avword)1 << (sizeof(__avword)*8-end_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret >> (start_offset*8))) & mask0; + } else { + /* sizeof(__avword) < end_offset < 2*sizeof(__avword), start_offset > 0 */ + __avword mask0 = ((__avword)2 << (sizeof(__avword)*8-start_offset*8-1)) - 1; + __avword mask1 = - ((__avword)1 << (2*sizeof(__avword)*8-end_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret >> (start_offset*8))) & mask0; + wordaddr[1] ^= (wordaddr[1] ^ (iret << (sizeof(__avword)*8-start_offset*8))) & mask1; + } + } else { + /* Use iret, iret2. */ + __avword mask0 = ((__avword)2 << (sizeof(__avword)*8-start_offset*8-1)) - 1; + wordaddr[0] ^= (wordaddr[0] ^ (iret >> (start_offset*8))) & mask0; + if (end_offset <= 2*sizeof(__avword)) { + /* sizeof(__avword) < end_offset ≤ 2*sizeof(__avword) */ + __avword mask1 = - ((__avword)1 << (2*sizeof(__avword)*8-end_offset*8)); + wordaddr[1] ^= (wordaddr[1] ^ ((iret << (sizeof(__avword)*4-start_offset*4) << (sizeof(__avword)*4-start_offset*4)) | (iret2 >> (start_offset*8)))) & mask1; + } else { + /* 2*sizeof(__avword) < end_offset < 3*sizeof(__avword), start_offset > 0 */ + __avword mask2 = - ((__avword)1 << (3*sizeof(__avword)*8-end_offset*8)); + wordaddr[1] = (iret << (sizeof(__avword)*8-start_offset*8)) | (iret2 >> (start_offset*8)); + wordaddr[2] ^= (wordaddr[2] ^ (iret2 << (sizeof(__avword)*8-start_offset*8))) & mask2; + } + } + #endif + } + } + } + } + return 0; +} diff --git a/avcall/avcall-i386-linux.s b/avcall/avcall-i386-linux.s new file mode 100644 index 0000000..7c0e4f1 --- /dev/null +++ b/avcall/avcall-i386-linux.s @@ -0,0 +1,145 @@ + .file "avcall-i386.c" + .text + .align 2 + .p2align 2,,3 +.globl avcall_call + .type avcall_call,@function +avcall_call: + pushl %ebp + movl %esp, %ebp + pushl %edi + pushl %esi + movl 8(%ebp), %eax + movl 20(%eax), %edx + movl 24(%eax), %eax + subl %eax, %edx + sarl $2, %edx + xorl %esi, %esi + subl $1024, %esp + cmpl %edx, %esi + movl %esp, %edi + jge .L47 + movl %eax, %ecx + .p2align 2,,3 +.L6: + movl (%ecx,%esi,4), %eax + movl %eax, (%edi,%esi,4) + incl %esi + cmpl %edx, %esi + jl .L6 +.L47: + movl 8(%ebp), %edx + movl 12(%edx), %eax + cmpl $13, %eax + je .L55 + cmpl $14, %eax + je .L56 + movl 8(%ebp), %ecx + call *4(%ecx) + movl %eax, %esi + movl 8(%ebp), %eax + movl 12(%eax), %ecx + cmpl $1, %ecx + je .L8 + testl %ecx, %ecx + jne .L13 + movl 8(%eax), %eax +.L50: + movl %esi, (%eax) +.L8: + leal -8(%ebp), %esp + popl %esi + xorl %eax, %eax + popl %edi + leave + ret +.L13: + cmpl $2, %ecx + je .L53 + cmpl $3, %ecx + je .L53 + cmpl $4, %ecx + je .L53 + cmpl $5, %ecx + je .L57 + cmpl $6, %ecx + je .L51 + cmpl $7, %ecx + je .L48 + cmpl $8, %ecx + je .L54 + cmpl $9, %ecx + je .L48 + cmpl $10, %ecx + je .L54 + leal -11(%ecx), %eax + cmpl $1, %eax + jbe .L49 + cmpl $15, %ecx + je .L48 + cmpl $16, %ecx + jne .L8 + movl 8(%ebp), %ecx + testb $2, 1(%ecx) + je .L8 + movl 16(%ecx), %eax + cmpl $1, %eax + je .L58 + cmpl $2, %eax + je .L51 + cmpl $4, %eax + je .L48 + cmpl $8, %eax + jne .L8 +.L49: + movl 8(%ebp), %ecx + movl 8(%ecx), %eax + movl %esi, (%eax) + movl %edx, 4(%eax) + jmp .L8 +.L48: + movl 8(%ebp), %edx + movl 8(%edx), %eax + jmp .L50 +.L51: + movl 8(%ebp), %ecx + movl 8(%ecx), %eax +.L52: + movw %si, (%eax) + jmp .L8 +.L58: + movl 8(%ecx), %eax + movl %esi, %edx + movb %dl, (%eax) + jmp .L8 + .p2align 2,,3 +.L54: + movl 8(%ebp), %ecx + movl 8(%ecx), %eax + jmp .L50 +.L57: + movl 8(%ebp), %edx + movl 8(%edx), %eax + jmp .L52 +.L53: + movl 8(%ebp), %edx + movl 8(%edx), %eax + movl %esi, %ecx + movb %cl, (%eax) + jmp .L8 +.L56: + movl 8(%ebp), %eax + call *4(%eax) + movl 8(%ebp), %edx + movl 8(%edx), %eax + fstpl (%eax) + jmp .L8 +.L55: + call *4(%edx) + movl 8(%ebp), %ecx + movl 8(%ecx), %eax + fstps (%eax) + jmp .L8 +.Lfe1: + .size avcall_call,.Lfe1-avcall_call + .ident "GCC: (GNU) 3.1" diff --git a/avcall/avcall-i386-macro.S b/avcall/avcall-i386-macro.S new file mode 100644 index 0000000..59b898c --- /dev/null +++ b/avcall/avcall-i386-macro.S @@ -0,0 +1,148 @@ +#include "asm-i386.h" + TEXT() + ALIGN(2) + P2ALIGN(2,3) +GLOBL(C(avcall_call)) + DECLARE_FUNCTION(avcall_call) +FUNBEGIN(avcall_call) + INSN1(push,l ,R(ebp)) + INSN2(mov,l ,R(esp), R(ebp)) + INSN1(push,l ,R(edi)) + INSN1(push,l ,R(esi)) + INSN2(mov,l ,X4 MEM_DISP(ebp,8), R(eax)) + INSN2(mov,l ,X4 MEM_DISP(eax,20), R(edx)) + INSN2(mov,l ,X4 MEM_DISP(eax,24), R(eax)) + INSN2(sub,l ,R(eax), R(edx)) + INSN2(sar,l ,NUM(2), R(edx)) + INSN2(xor,l ,R(esi), R(esi)) + INSN2(sub,l ,NUM(1024), R(esp)) + INSN2(cmp,l ,R(edx), R(esi)) + INSN2(mov,l ,R(esp), R(edi)) + INSN1(jge,_ ,L(47)) + INSN2(mov,l ,R(eax), R(ecx)) + P2ALIGN(2,3) +L(6): + INSN2(mov,l ,X4 MEM_SHINDEX(ecx,esi,4), R(eax)) + INSN2(mov,l ,R(eax),X4 MEM_SHINDEX(edi,esi,4)) + INSN1(inc,l ,R(esi)) + INSN2(cmp,l ,R(edx), R(esi)) + INSN1(jl,_ ,L(6)) +L(47): + INSN2(mov,l ,X4 MEM_DISP(ebp,8), R(edx)) + INSN2(mov,l ,X4 MEM_DISP(edx,12), R(eax)) + INSN2(cmp,l ,NUM(13), R(eax)) + INSN1(je,_ ,L(55)) + INSN2(cmp,l ,NUM(14), R(eax)) + INSN1(je,_ ,L(56)) + INSN2(mov,l ,X4 MEM_DISP(ebp,8), R(ecx)) + INSN1(call,_ ,INDIR(X4 MEM_DISP(ecx,4))) + INSN2(mov,l ,R(eax), R(esi)) + INSN2(mov,l ,X4 MEM_DISP(ebp,8), R(eax)) + INSN2(mov,l ,X4 MEM_DISP(eax,12), R(ecx)) + INSN2(cmp,l ,NUM(1), R(ecx)) + INSN1(je,_ ,L(8)) + INSN2(test,l ,R(ecx), R(ecx)) + INSN1(jne,_ ,L(13)) + INSN2(mov,l ,X4 MEM_DISP(eax,8), R(eax)) +L(50): + INSN2(mov,l ,R(esi),X4 MEM(eax)) +L(8): + INSN2(lea,l ,X4 MEM_DISP(ebp,-8), R(esp)) + INSN1(pop,l ,R(esi)) + INSN2(xor,l ,R(eax), R(eax)) + INSN1(pop,l ,R(edi)) + leave + ret +L(13): + INSN2(cmp,l ,NUM(2), R(ecx)) + INSN1(je,_ ,L(53)) + INSN2(cmp,l ,NUM(3), R(ecx)) + INSN1(je,_ ,L(53)) + INSN2(cmp,l ,NUM(4), R(ecx)) + INSN1(je,_ ,L(53)) + INSN2(cmp,l ,NUM(5), R(ecx)) + INSN1(je,_ ,L(57)) + INSN2(cmp,l ,NUM(6), R(ecx)) + INSN1(je,_ ,L(51)) + INSN2(cmp,l ,NUM(7), R(ecx)) + INSN1(je,_ ,L(48)) + INSN2(cmp,l ,NUM(8), R(ecx)) + INSN1(je,_ ,L(54)) + INSN2(cmp,l ,NUM(9), R(ecx)) + INSN1(je,_ ,L(48)) + INSN2(cmp,l ,NUM(10), R(ecx)) + INSN1(je,_ ,L(54)) + INSN2(lea,l ,X4 MEM_DISP(ecx,-11), R(eax)) + INSN2(cmp,l ,NUM(1), R(eax)) + INSN1(jbe,_ ,L(49)) + INSN2(cmp,l ,NUM(15), R(ecx)) + INSN1(je,_ ,L(48)) + INSN2(cmp,l ,NUM(16), R(ecx)) + INSN1(jne,_ ,L(8)) + INSN2(mov,l ,X4 MEM_DISP(ebp,8), R(ecx)) + INSN2(test,b ,NUM(2),X1 MEM_DISP(ecx,1)) + INSN1(je,_ ,L(8)) + INSN2(mov,l ,X4 MEM_DISP(ecx,16), R(eax)) + INSN2(cmp,l ,NUM(1), R(eax)) + INSN1(je,_ ,L(58)) + INSN2(cmp,l ,NUM(2), R(eax)) + INSN1(je,_ ,L(51)) + INSN2(cmp,l ,NUM(4), R(eax)) + INSN1(je,_ ,L(48)) + INSN2(cmp,l ,NUM(8), R(eax)) + INSN1(jne,_ ,L(8)) +L(49): + INSN2(mov,l ,X4 MEM_DISP(ebp,8), R(ecx)) + INSN2(mov,l ,X4 MEM_DISP(ecx,8), R(eax)) + INSN2(mov,l ,R(esi),X4 MEM(eax)) + INSN2(mov,l ,R(edx),X4 MEM_DISP(eax,4)) + INSN1(jmp,_ ,L(8)) +L(48): + INSN2(mov,l ,X4 MEM_DISP(ebp,8), R(edx)) + INSN2(mov,l ,X4 MEM_DISP(edx,8), R(eax)) + INSN1(jmp,_ ,L(50)) +L(51): + INSN2(mov,l ,X4 MEM_DISP(ebp,8), R(ecx)) + INSN2(mov,l ,X4 MEM_DISP(ecx,8), R(eax)) +L(52): + INSN2(mov,w ,R(si),X2 MEM(eax)) + INSN1(jmp,_ ,L(8)) +L(58): + INSN2(mov,l ,X4 MEM_DISP(ecx,8), R(eax)) + INSN2(mov,l ,R(esi), R(edx)) + INSN2(mov,b ,R(dl),X1 MEM(eax)) + INSN1(jmp,_ ,L(8)) + P2ALIGN(2,3) +L(54): + INSN2(mov,l ,X4 MEM_DISP(ebp,8), R(ecx)) + INSN2(mov,l ,X4 MEM_DISP(ecx,8), R(eax)) + INSN1(jmp,_ ,L(50)) +L(57): + INSN2(mov,l ,X4 MEM_DISP(ebp,8), R(edx)) + INSN2(mov,l ,X4 MEM_DISP(edx,8), R(eax)) + INSN1(jmp,_ ,L(52)) +L(53): + INSN2(mov,l ,X4 MEM_DISP(ebp,8), R(edx)) + INSN2(mov,l ,X4 MEM_DISP(edx,8), R(eax)) + INSN2(mov,l ,R(esi), R(ecx)) + INSN2(mov,b ,R(cl),X1 MEM(eax)) + INSN1(jmp,_ ,L(8)) +L(56): + INSN2(mov,l ,X4 MEM_DISP(ebp,8), R(eax)) + INSN1(call,_ ,INDIR(X4 MEM_DISP(eax,4))) + INSN2(mov,l ,X4 MEM_DISP(ebp,8), R(edx)) + INSN2(mov,l ,X4 MEM_DISP(edx,8), R(eax)) + INSN1(fstp,l ,X8 MEM(eax)) + INSN1(jmp,_ ,L(8)) +L(55): + INSN1(call,_ ,INDIR(X4 MEM_DISP(edx,4))) + INSN2(mov,l ,X4 MEM_DISP(ebp,8), R(ecx)) + INSN2(mov,l ,X4 MEM_DISP(ecx,8), R(eax)) + INSN1(fstp,s ,X4 MEM(eax)) + INSN1(jmp,_ ,L(8)) +L(fe1): + FUNEND(avcall_call,L(fe1)-avcall_call) + +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/avcall/avcall-i386-msvc.c b/avcall/avcall-i386-msvc.c new file mode 100644 index 0000000..59b898c --- /dev/null +++ b/avcall/avcall-i386-msvc.c @@ -0,0 +1,148 @@ +#include "asm-i386.h" + TEXT() + ALIGN(2) + P2ALIGN(2,3) +GLOBL(C(avcall_call)) + DECLARE_FUNCTION(avcall_call) +FUNBEGIN(avcall_call) + INSN1(push,l ,R(ebp)) + INSN2(mov,l ,R(esp), R(ebp)) + INSN1(push,l ,R(edi)) + INSN1(push,l ,R(esi)) + INSN2(mov,l ,X4 MEM_DISP(ebp,8), R(eax)) + INSN2(mov,l ,X4 MEM_DISP(eax,20), R(edx)) + INSN2(mov,l ,X4 MEM_DISP(eax,24), R(eax)) + INSN2(sub,l ,R(eax), R(edx)) + INSN2(sar,l ,NUM(2), R(edx)) + INSN2(xor,l ,R(esi), R(esi)) + INSN2(sub,l ,NUM(1024), R(esp)) + INSN2(cmp,l ,R(edx), R(esi)) + INSN2(mov,l ,R(esp), R(edi)) + INSN1(jge,_ ,L(47)) + INSN2(mov,l ,R(eax), R(ecx)) + P2ALIGN(2,3) +L(6): + INSN2(mov,l ,X4 MEM_SHINDEX(ecx,esi,4), R(eax)) + INSN2(mov,l ,R(eax),X4 MEM_SHINDEX(edi,esi,4)) + INSN1(inc,l ,R(esi)) + INSN2(cmp,l ,R(edx), R(esi)) + INSN1(jl,_ ,L(6)) +L(47): + INSN2(mov,l ,X4 MEM_DISP(ebp,8), R(edx)) + INSN2(mov,l ,X4 MEM_DISP(edx,12), R(eax)) + INSN2(cmp,l ,NUM(13), R(eax)) + INSN1(je,_ ,L(55)) + INSN2(cmp,l ,NUM(14), R(eax)) + INSN1(je,_ ,L(56)) + INSN2(mov,l ,X4 MEM_DISP(ebp,8), R(ecx)) + INSN1(call,_ ,INDIR(X4 MEM_DISP(ecx,4))) + INSN2(mov,l ,R(eax), R(esi)) + INSN2(mov,l ,X4 MEM_DISP(ebp,8), R(eax)) + INSN2(mov,l ,X4 MEM_DISP(eax,12), R(ecx)) + INSN2(cmp,l ,NUM(1), R(ecx)) + INSN1(je,_ ,L(8)) + INSN2(test,l ,R(ecx), R(ecx)) + INSN1(jne,_ ,L(13)) + INSN2(mov,l ,X4 MEM_DISP(eax,8), R(eax)) +L(50): + INSN2(mov,l ,R(esi),X4 MEM(eax)) +L(8): + INSN2(lea,l ,X4 MEM_DISP(ebp,-8), R(esp)) + INSN1(pop,l ,R(esi)) + INSN2(xor,l ,R(eax), R(eax)) + INSN1(pop,l ,R(edi)) + leave + ret +L(13): + INSN2(cmp,l ,NUM(2), R(ecx)) + INSN1(je,_ ,L(53)) + INSN2(cmp,l ,NUM(3), R(ecx)) + INSN1(je,_ ,L(53)) + INSN2(cmp,l ,NUM(4), R(ecx)) + INSN1(je,_ ,L(53)) + INSN2(cmp,l ,NUM(5), R(ecx)) + INSN1(je,_ ,L(57)) + INSN2(cmp,l ,NUM(6), R(ecx)) + INSN1(je,_ ,L(51)) + INSN2(cmp,l ,NUM(7), R(ecx)) + INSN1(je,_ ,L(48)) + INSN2(cmp,l ,NUM(8), R(ecx)) + INSN1(je,_ ,L(54)) + INSN2(cmp,l ,NUM(9), R(ecx)) + INSN1(je,_ ,L(48)) + INSN2(cmp,l ,NUM(10), R(ecx)) + INSN1(je,_ ,L(54)) + INSN2(lea,l ,X4 MEM_DISP(ecx,-11), R(eax)) + INSN2(cmp,l ,NUM(1), R(eax)) + INSN1(jbe,_ ,L(49)) + INSN2(cmp,l ,NUM(15), R(ecx)) + INSN1(je,_ ,L(48)) + INSN2(cmp,l ,NUM(16), R(ecx)) + INSN1(jne,_ ,L(8)) + INSN2(mov,l ,X4 MEM_DISP(ebp,8), R(ecx)) + INSN2(test,b ,NUM(2),X1 MEM_DISP(ecx,1)) + INSN1(je,_ ,L(8)) + INSN2(mov,l ,X4 MEM_DISP(ecx,16), R(eax)) + INSN2(cmp,l ,NUM(1), R(eax)) + INSN1(je,_ ,L(58)) + INSN2(cmp,l ,NUM(2), R(eax)) + INSN1(je,_ ,L(51)) + INSN2(cmp,l ,NUM(4), R(eax)) + INSN1(je,_ ,L(48)) + INSN2(cmp,l ,NUM(8), R(eax)) + INSN1(jne,_ ,L(8)) +L(49): + INSN2(mov,l ,X4 MEM_DISP(ebp,8), R(ecx)) + INSN2(mov,l ,X4 MEM_DISP(ecx,8), R(eax)) + INSN2(mov,l ,R(esi),X4 MEM(eax)) + INSN2(mov,l ,R(edx),X4 MEM_DISP(eax,4)) + INSN1(jmp,_ ,L(8)) +L(48): + INSN2(mov,l ,X4 MEM_DISP(ebp,8), R(edx)) + INSN2(mov,l ,X4 MEM_DISP(edx,8), R(eax)) + INSN1(jmp,_ ,L(50)) +L(51): + INSN2(mov,l ,X4 MEM_DISP(ebp,8), R(ecx)) + INSN2(mov,l ,X4 MEM_DISP(ecx,8), R(eax)) +L(52): + INSN2(mov,w ,R(si),X2 MEM(eax)) + INSN1(jmp,_ ,L(8)) +L(58): + INSN2(mov,l ,X4 MEM_DISP(ecx,8), R(eax)) + INSN2(mov,l ,R(esi), R(edx)) + INSN2(mov,b ,R(dl),X1 MEM(eax)) + INSN1(jmp,_ ,L(8)) + P2ALIGN(2,3) +L(54): + INSN2(mov,l ,X4 MEM_DISP(ebp,8), R(ecx)) + INSN2(mov,l ,X4 MEM_DISP(ecx,8), R(eax)) + INSN1(jmp,_ ,L(50)) +L(57): + INSN2(mov,l ,X4 MEM_DISP(ebp,8), R(edx)) + INSN2(mov,l ,X4 MEM_DISP(edx,8), R(eax)) + INSN1(jmp,_ ,L(52)) +L(53): + INSN2(mov,l ,X4 MEM_DISP(ebp,8), R(edx)) + INSN2(mov,l ,X4 MEM_DISP(edx,8), R(eax)) + INSN2(mov,l ,R(esi), R(ecx)) + INSN2(mov,b ,R(cl),X1 MEM(eax)) + INSN1(jmp,_ ,L(8)) +L(56): + INSN2(mov,l ,X4 MEM_DISP(ebp,8), R(eax)) + INSN1(call,_ ,INDIR(X4 MEM_DISP(eax,4))) + INSN2(mov,l ,X4 MEM_DISP(ebp,8), R(edx)) + INSN2(mov,l ,X4 MEM_DISP(edx,8), R(eax)) + INSN1(fstp,l ,X8 MEM(eax)) + INSN1(jmp,_ ,L(8)) +L(55): + INSN1(call,_ ,INDIR(X4 MEM_DISP(edx,4))) + INSN2(mov,l ,X4 MEM_DISP(ebp,8), R(ecx)) + INSN2(mov,l ,X4 MEM_DISP(ecx,8), R(eax)) + INSN1(fstp,s ,X4 MEM(eax)) + INSN1(jmp,_ ,L(8)) +L(fe1): + FUNEND(avcall_call,L(fe1)-avcall_call) + +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/avcall/avcall-i386.c b/avcall/avcall-i386.c new file mode 100644 index 0000000..63d3af9 --- /dev/null +++ b/avcall/avcall-i386.c @@ -0,0 +1,147 @@ +/** + Copyright 1993 Bill Triggs + Copyright 1995-2017 Bruno Haible + + 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, see . +**/ +/*---------------------------------------------------------------------- + !!! THIS ROUTINE MUST BE COMPILED gcc -O -fno-omit-frame-pointer !!! + + Foreign function interface for a Linux i386/486 with gcc. + + This calls a C function with an argument list built up using macros + defined in avcall.h. + + i386 Argument Passing Conventions: + + All arguments are passed on the stack with word alignment. Doubles take + two words. Structure args are passed as true structures embedded in the + argument stack. Float and double returns often come from FPU registers. + + To return a structure, the called function copies the value to space + pointed to by its first argument, and all other arguments are shifted + down by one. At least on FreeBSD, the function also returns the pointer. + GCC returns structures of size 1, 2, 4, 8 like integers. + + Compile this routine with gcc -O (or -O2 -fno-omit-frame-pointer or -g -O) + to get the right register variables. For other compilers use the + pre-compiled assembler version. + + -fomit-frame-pointer is forbidden because when calling structure returning + functions (the "i = (*l->func)();" line below) the called functions pops + the return value container pointer from the stack: "ret $4" instead of + "ret". (See gcc-2.6.3 macro RETURN_POPS_ARGS.) From our point of view, %esp + gets magically incremented. A workaround would be to push the return value + container pointer using an __asm__("pushl %0" : : : ...) instruction. + Similarly, when calling functions with ‘stdcall’ linkage, %esp also gets + incremented: all arguments (including the return value container pointer) + are popped from the stack. + ----------------------------------------------------------------------*/ +#include "avcall-internal.h" + +#define RETURN(TYPE,VAL) (*(TYPE*)l->raddr = (TYPE)(VAL)) + +int +avcall_call(av_alist* list) +{ + register __avword* sp __asm__("sp"); /* C names for registers */ +/*register __avword iret __asm__("eax"); */ + register __avword iret2 __asm__("edx"); + + __av_alist* l = &AV_LIST_INNER(list); + + __avword* argframe = __builtin_alloca(__AV_ALIST_WORDS * sizeof(__avword)); /* make room for argument list */ + int arglen = l->aptr - l->args; + __avword i; + + for (i = 0; i < arglen; i++) /* push function args onto stack */ + argframe[i] = l->args[i]; + + /* call function */ + if (l->rtype == __AVfloat) { + *(float*)l->raddr = (*(float(*)())l->func)(); + } else + if (l->rtype == __AVdouble) { + *(double*)l->raddr = (*(double(*)())l->func)(); + } else { + i = (*l->func)(); + + /* save return value */ + if (l->rtype == __AVvoid) { + } else + if (l->rtype == __AVword) { + RETURN(__avword, i); + } else + if (l->rtype == __AVchar) { + RETURN(char, i); + } else + if (l->rtype == __AVschar) { + RETURN(signed char, i); + } else + if (l->rtype == __AVuchar) { + RETURN(unsigned char, i); + } else + if (l->rtype == __AVshort) { + RETURN(short, i); + } else + if (l->rtype == __AVushort) { + RETURN(unsigned short, i); + } else + if (l->rtype == __AVint) { + RETURN(int, i); + } else + if (l->rtype == __AVuint) { + RETURN(unsigned int, i); + } else + if (l->rtype == __AVlong) { + RETURN(long, i); + } else + if (l->rtype == __AVulong) { + RETURN(unsigned long, i); + } else + if (l->rtype == __AVlonglong || l->rtype == __AVulonglong) { + void* raddr = l->raddr; + ((__avword*)raddr)[0] = i; + ((__avword*)raddr)[1] = iret2; + } else + /* see above + if (l->rtype == __AVfloat) { + } else + if (l->rtype == __AVdouble) { + } else + */ + if (l->rtype == __AVvoidp) { + RETURN(void*, i); + } else + if (l->rtype == __AVstruct) { + if (l->flags & __AV_REGISTER_STRUCT_RETURN) { + if (l->rsize == sizeof(char)) { + RETURN(char, i); + } else + if (l->rsize == sizeof(short)) { + RETURN(short, i); + } else + if (l->rsize == sizeof(int)) { + RETURN(int, i); + } else + if (l->rsize == 2*sizeof(__avword)) { + void* raddr = l->raddr; + ((__avword*)raddr)[0] = i; + ((__avword*)raddr)[1] = iret2; + } + } + } + } + return 0; +} diff --git a/avcall/avcall-ia64-linux.s b/avcall/avcall-ia64-linux.s new file mode 100644 index 0000000..93df523 --- /dev/null +++ b/avcall/avcall-ia64-linux.s @@ -0,0 +1,1174 @@ + .file "avcall-ia64.c" + .pred.safe_across_calls p1-p5,p16-p63 + .text + .align 16 + .global avcall_call# + .proc avcall_call# +avcall_call: + .prologue 14, 34 + .mmi + .save ar.pfs, r35 + alloc r35 = ar.pfs, 1, 6, 8, 0 + adds r14 = 40, r32 + adds r20 = 48, r32 + .mmi + adds r16 = 64, r32 + adds r21 = 72, r32 + adds r19 = -2032, r12 + ;; + .mmb + ld8 r15 = [r14] + ld8 r17 = [r20] + nop 0 + .mii + .vframe r36 + mov r36 = r12 + .save ar.lc, r38 + mov r38 = ar.lc + mov r37 = r1 + ;; + .mmi + sub r15 = r15, r17 + ld8 r14 = [r16] + .save rp, r34 + mov r34 = b0 + .body + .mmi + nop 0 + ;; + nop 0 + shr.u r15 = r15, 3 + .mmi + sub r14 = r14, r21 + ;; + nop 0 + shr.u r18 = r14, 3 + .mmb + nop 0 + cmp4.ge p6, p7 = 8, r15 + (p6) br.cond.dptk .L2 + .mii + sub r14 = 8, r15 + addl r16 = 8, r0 + ;; + andcm r14 = -1, r14 + ;; + .mii + nop 0 + addp4 r14 = r14, r0 + ;; + mov ar.lc = r14 +.L4: + .mii + nop 0 + sxt4 r14 = r16 + adds r16 = 1, r16 + ;; + .mmi + shladd r14 = r14, 3, r0 + ;; + add r15 = r17, r14 + add r14 = r19, r14 + ;; + .mmb + adds r14 = -64, r14 + ld8 r15 = [r15] + nop 0 + ;; + .mfb + st8 [r14] = r15 + nop 0 + br.cloop.sptk.few .L4 +.L2: + .mmi + adds r33 = 24, r32 + ;; + ld4 r15 = [r33] + nop 0 + ;; + .mii + nop 0 + cmp4.ne p6, p7 = 16, r15 + ;; + (p7) adds r14 = 16, r32 + ;; + .mfi + (p7) ld8 r8 = [r14] + nop 0 + cmp4.ge p6, p7 = 0, r18 + .mfb + adds r14 = 80, r32 + nop 0 + (p6) br.cond.dpnt .L7 + ;; + .mmb + nop 0 + cmp4.ge p6, p7 = 1, r18 + nop 0 + .mfb + ldfd f8 = [r21] + nop 0 + (p6) br.cond.dpnt .L7 + ;; + .mmb + nop 0 + cmp4.ge p6, p7 = 2, r18 + nop 0 + .mfb + ldfd f9 = [r14] + nop 0 + (p7) br.cond.dptk .L71 + ;; +.L7: + .mib + nop 0 + cmp4.ne p6, p7 = 13, r15 + (p7) br.cond.dpnt .L72 + ;; +.L16: + .mib + cmp4.ne p6, p7 = 14, r15 + adds r15 = 8, r32 + (p7) br.cond.dpnt .L73 + .mmb + nop 0 + ld8 r14 = [r20] + nop 0 + ;; + .mmi + ld8 r15 = [r15] + adds r16 = 8, r14 + adds r17 = 16, r14 + .mmi + adds r18 = 24, r14 + adds r19 = 32, r14 + adds r20 = 40, r14 + .mmi + nop 0 + adds r21 = 48, r14 + adds r22 = 56, r14 + .mmi + ld8 r39 = [r14] + ;; + ld8 r14 = [r15], 8 + nop 0 + .mii + ld8 r40 = [r16] + nop 0 + ;; + mov b6 = r14 + .mmb + ld8 r1 = [r15] + ld8 r41 = [r17] + nop 0 + .mmb + ld8 r42 = [r18] + ld8 r43 = [r19] + nop 0 + .mmb + ld8 r44 = [r20] + ld8 r45 = [r21] + nop 0 + .mbb + ld8 r46 = [r22] + nop 0 + br.call.sptk.many b0 = b6 + ;; + .mmi + mov r1 = r37 + ld4 r14 = [r33] + mov r28 = r8 + ;; + .mfb + cmp4.eq p6, p7 = 1, r14 + nop 0 + (p6) br.cond.dpnt .L18 + ;; + .mib + nop 0 + cmp4.ne p6, p7 = 0, r14 + (p7) br.cond.dptk .L69 + ;; + .mfb + cmp4.ne p6, p7 = 2, r14 + nop 0 + (p7) br.cond.dpnt .L65 + ;; + .mfb + cmp4.ne p6, p7 = 3, r14 + nop 0 + (p7) br.cond.dpnt .L65 + ;; + .mfb + cmp4.ne p6, p7 = 4, r14 + nop 0 + (p7) br.cond.dpnt .L65 + ;; + .mfb + cmp4.ne p6, p7 = 5, r14 + nop 0 + (p7) br.cond.dpnt .L66 + ;; + .mfb + cmp4.ne p6, p7 = 6, r14 + nop 0 + (p7) br.cond.dpnt .L66 + ;; + .mfb + cmp4.ne p6, p7 = 7, r14 + nop 0 + (p7) br.cond.dpnt .L67 + ;; + .mfb + cmp4.ne p6, p7 = 8, r14 + nop 0 + (p7) br.cond.dpnt .L67 + ;; + .mii + nop 0 + cmp4.ne p6, p7 = 9, r14 + ;; + nop 0 + .mfb + cmp4.ne.and.orcm p6, p7 = 11, r14 + nop 0 + (p7) br.cond.dptk .L69 + ;; + .mii + nop 0 + cmp4.ne p6, p7 = 10, r14 + ;; + nop 0 + .mfb + cmp4.ne.and.orcm p6, p7 = 12, r14 + nop 0 + (p7) br.cond.dptk .L69 + ;; + .mfb + cmp4.ne p6, p7 = 15, r14 + nop 0 + (p7) br.cond.dpnt .L69 + ;; + .mib + nop 0 + cmp4.ne p6, p7 = 16, r14 + (p6) br.cond.dptk .L18 + .mmi + ld4 r14 = [r32] + ;; + nop 0 + tbit.z p6, p7 = r14, 9 + .mfb + adds r14 = 32, r32 + nop 0 + (p6) br.cond.dpnt .L18 + ;; + .mmi + ld8 r19 = [r14] + ;; + adds r14 = -1, r19 + nop 0 + ;; + .mib + cmp.ltu p6, p7 = 31, r14 + adds r14 = 16, r32 + (p6) br.cond.dpnt .L18 + ;; + .mii + ld8 r14 = [r14] + cmp.ltu p6, p7 = 8, r19 + ;; + and r17 = 7, r14 + .mii + nop 0 + and r27 = -8, r14 + ;; + nop 0 + .mfb + add r23 = r19, r17 + nop 0 + (p6) br.cond.dptk .L47 + ;; + .mib + nop 0 + cmp.ltu p6, p7 = 8, r23 + (p6) br.cond.dptk .L49 + .mmi + shladd r15 = r23, 3, r0 + addl r14 = 2, r0 + shladd r18 = r17, 3, r0 + .mmi + ld8 r17 = [r27] + ;; + adds r15 = -1, r15 + nop 0 + ;; + .mii + nop 0 + sxt4 r15 = r15 + ;; + shl r14 = r14, r15 + .mii + addl r15 = 1, r0 + shl r16 = r8, r18 + ;; + shl r15 = r15, r18 + .mii + nop 0 + xor r16 = r16, r17 + ;; + sub r14 = r14, r15 + ;; + .mmi + and r14 = r16, r14 + ;; + xor r17 = r14, r17 + nop 0 + ;; + .mfb + st8 [r27] = r17 + nop 0 + nop 0 +.L18: + .mfi + mov r8 = r0 + nop 0 + mov b0 = r34 + .mmi + nop 0 + .label_state 1 + .restore sp + mov r12 = r36 + mov ar.pfs = r35 + .mib + nop 0 + mov ar.lc = r38 + br.ret.sptk.many b0 +.L71: + .body + .copy_state 1 + .mfi + adds r14 = 88, r32 + nop 0 + cmp4.ge p6, p7 = 3, r18 + ;; + .mfb + ldfd f10 = [r14] + nop 0 + (p6) br.cond.dptk .L7 + .mfi + adds r14 = 96, r32 + nop 0 + cmp4.ge p6, p7 = 4, r18 + ;; + .mfb + ldfd f11 = [r14] + nop 0 + (p6) br.cond.dptk .L7 + .mfi + adds r14 = 104, r32 + nop 0 + cmp4.ge p6, p7 = 5, r18 + ;; + .mfb + ldfd f12 = [r14] + nop 0 + (p6) br.cond.dptk .L7 + .mfi + adds r14 = 112, r32 + nop 0 + cmp4.ge p6, p7 = 6, r18 + ;; + .mfb + ldfd f13 = [r14] + nop 0 + (p6) br.cond.dptk .L7 + .mii + adds r14 = 120, r32 + cmp4.ge p6, p7 = 7, r18 + ;; + nop 0 + .mii + ldfd f14 = [r14] + (p7) adds r14 = 128, r32 + ;; + nop 0 + .mmb + (p7) ldfd f15 = [r14] + cmp4.ne p6, p7 = 13, r15 + (p6) br.cond.dptk .L16 +.L72: + .mmb + adds r16 = 8, r32 + adds r15 = 16, r32 + nop 0 + .mfi + ld8 r14 = [r20] + nop 0 + mov ar.lc = r38 + ;; + .mmi + ld8 r33 = [r15] + ld8 r15 = [r16] + adds r17 = 8, r14 + .mmi + adds r18 = 16, r14 + adds r19 = 24, r14 + adds r20 = 32, r14 + .mmi + adds r21 = 40, r14 + adds r22 = 48, r14 + adds r23 = 56, r14 + .mii + ld8 r39 = [r14] + nop 0 + ;; + nop 0 + .mmb + ld8 r14 = [r15], 8 + ld8 r40 = [r17] + nop 0 + ;; + .mmi + ld8 r1 = [r15] + ld8 r41 = [r18] + mov b6 = r14 + .mmb + ld8 r42 = [r19] + ld8 r43 = [r20] + nop 0 + .mmb + ld8 r44 = [r21] + ld8 r45 = [r22] + nop 0 + .mbb + ld8 r46 = [r23] + nop 0 + br.call.sptk.many b0 = b6 + ;; + .mmb + .label_state 2 + .restore sp + mov r12 = r36 + mov r8 = r0 + nop 0 + .mmi + mov r1 = r37 + stfs [r33] = f8 + mov b0 = r34 + .mib + nop 0 + mov ar.pfs = r35 + br.ret.sptk.many b0 + ;; +.L69: + .body + .copy_state 2 + .mmi + adds r14 = 16, r32 + mov r8 = r0 + mov b0 = r34 + .mmi + .label_state 3 + .restore sp + mov r12 = r36 + ;; + ld8 r14 = [r14] + mov ar.pfs = r35 + .mii + nop 0 + mov ar.lc = r38 + ;; + nop 0 + .mfb + st8 [r14] = r28 + nop 0 + br.ret.sptk.many b0 +.L73: + .body + .copy_state 3 + .mmb + adds r16 = 8, r32 + adds r15 = 16, r32 + nop 0 + .mfi + ld8 r14 = [r20] + nop 0 + mov ar.lc = r38 + ;; + .mmi + ld8 r33 = [r15] + ld8 r15 = [r16] + adds r17 = 8, r14 + .mmi + adds r18 = 16, r14 + adds r19 = 24, r14 + adds r20 = 32, r14 + .mmi + adds r21 = 40, r14 + adds r22 = 48, r14 + adds r23 = 56, r14 + .mii + ld8 r39 = [r14] + nop 0 + ;; + nop 0 + .mmb + ld8 r14 = [r15], 8 + ld8 r40 = [r17] + nop 0 + ;; + .mmi + ld8 r1 = [r15] + ld8 r41 = [r18] + mov b6 = r14 + .mmb + ld8 r42 = [r19] + ld8 r43 = [r20] + nop 0 + .mmb + ld8 r44 = [r21] + ld8 r45 = [r22] + nop 0 + .mbb + ld8 r46 = [r23] + nop 0 + br.call.sptk.many b0 = b6 + ;; + .mmb + .label_state 4 + .restore sp + mov r12 = r36 + mov r8 = r0 + nop 0 + .mmi + mov r1 = r37 + stfd [r33] = f8 + mov b0 = r34 + .mib + nop 0 + mov ar.pfs = r35 + br.ret.sptk.many b0 + ;; +.L65: + .body + .copy_state 4 + .mmi + adds r14 = 16, r32 + mov r8 = r0 + mov b0 = r34 + .mmi + .label_state 5 + .restore sp + mov r12 = r36 + ;; + ld8 r14 = [r14] + mov ar.pfs = r35 + .mii + nop 0 + mov ar.lc = r38 + ;; + nop 0 + .mfb + st1 [r14] = r28 + nop 0 + br.ret.sptk.many b0 +.L66: + .body + .copy_state 5 + .mmi + adds r14 = 16, r32 + mov r8 = r0 + mov b0 = r34 + .mmi + .label_state 6 + .restore sp + mov r12 = r36 + ;; + ld8 r14 = [r14] + mov ar.pfs = r35 + .mii + nop 0 + mov ar.lc = r38 + ;; + nop 0 + .mfb + st2 [r14] = r28 + nop 0 + br.ret.sptk.many b0 +.L67: + .body + .copy_state 6 + .mmi + adds r14 = 16, r32 + mov r8 = r0 + mov b0 = r34 + .mmi + .label_state 7 + .restore sp + mov r12 = r36 + ;; + ld8 r14 = [r14] + mov ar.pfs = r35 + .mii + nop 0 + mov ar.lc = r38 + ;; + nop 0 + .mfb + st4 [r14] = r28 + nop 0 + br.ret.sptk.many b0 +.L47: + .body + .copy_state 7 + .mib + nop 0 + cmp.ltu p6, p7 = 16, r19 + (p6) br.cond.dptk .L51 + ;; + .mfi + shladd r20 = r17, 3, r0 + nop 0 + addl r14 = -1, r0 + .mii + ld8 r16 = [r27] + cmp.ltu p6, p7 = 16, r23 + ;; + nop 0 + .mii + mov r19 = r20 + shl r15 = r8, r20 + shl r14 = r14, r20 + ;; + .mmi + xor r15 = r15, r16 + ;; + and r14 = r15, r14 + nop 0 + ;; + .mii + nop 0 + xor r16 = r14, r16 + ;; + nop 0 + .mfb + st8 [r27] = r16 + nop 0 + (p6) br.cond.dptk .L53 + .mmi + shladd r17 = r17, 2, r0 + shladd r16 = r23, 3, r0 + addl r15 = 2, r0 + .mmi + adds r19 = 8, r27 + .label_state 8 + .restore sp + mov r12 = r36 + shl r20 = r9, r20 + ;; + .mmb + sub r17 = 32, r17 + adds r16 = -65, r16 + nop 0 + .mii + ld8 r18 = [r19] + mov b0 = r34 + mov ar.pfs = r35 + ;; + .mii + nop 0 + sxt4 r16 = r16 + sxt4 r17 = r17 + .mib + nop 0 + mov ar.lc = r38 + nop 0 + ;; + .mii + nop 0 + shr r14 = r8, r17 + shl r15 = r15, r16 + .mmi + mov r8 = r0 + ;; + nop 0 + shr r14 = r14, r17 + .mii + nop 0 + adds r15 = -1, r15 + ;; + or r14 = r20, r14 + ;; + .mii + nop 0 + xor r14 = r14, r18 + ;; + and r15 = r14, r15 + ;; + .mii + nop 0 + xor r18 = r15, r18 + ;; + nop 0 + .mfb + st8 [r19] = r18 + nop 0 + br.ret.sptk.many b0 +.L49: + .body + .copy_state 8 + .mmi + shladd r14 = r23, 3, r0 + addl r15 = 2, r0 + mov b0 = r34 + .mmi + shladd r18 = r17, 3, r0 + ld8 r19 = [r27] + .label_state 9 + .restore sp + mov r12 = r36 + ;; + .mmi + adds r14 = -65, r14 + sub r16 = 64, r18 + mov ar.pfs = r35 + .mii + nop 0 + mov ar.lc = r38 + ;; + sxt4 r14 = r14 + .mii + nop 0 + shl r17 = r8, r18 + ;; + shl r15 = r15, r14 + .mii + addl r14 = -1, r0 + sxt4 r16 = r16 + ;; + shr r16 = r8, r16 + .mii + mov r8 = r0 + xor r17 = r17, r19 + shl r14 = r14, r18 + .mii + nop 0 + adds r15 = -1, r15 + ;; + and r14 = r17, r14 + ;; + .mmi + xor r19 = r14, r19 + ;; + st8 [r27] = r19, 8 + nop 0 + ;; + .mmi + ld8 r14 = [r27] + ;; + xor r16 = r16, r14 + nop 0 + ;; + .mmi + and r15 = r16, r15 + ;; + xor r14 = r15, r14 + nop 0 + ;; + .mfb + st8 [r27] = r14 + nop 0 + br.ret.sptk.many b0 +.L53: + .body + .copy_state 9 + .mmi + shladd r15 = r23, 3, r0 + addl r14 = 2, r0 + sub r17 = 64, r20 + .mmi + adds r21 = 16, r27 + adds r20 = 8, r27 + shl r19 = r9, r19 + ;; + .mii + adds r15 = -129, r15 + mov b0 = r34 + sxt4 r17 = r17 + .mmi + .label_state 10 + .restore sp + mov r12 = r36 + nop 0 + mov ar.pfs = r35 + ;; + .mii + nop 0 + shr r18 = r9, r17 + sxt4 r15 = r15 + ;; + .mii + nop 0 + shl r14 = r14, r15 + shr r16 = r8, r17 + .mmi + ld8 r15 = [r21] + mov r8 = r0 + mov ar.lc = r38 + ;; + .mii + xor r18 = r18, r15 + adds r14 = -1, r14 + or r16 = r19, r16 + ;; + .mmb + and r14 = r18, r14 + st8 [r20] = r16 + nop 0 + ;; + .mii + nop 0 + xor r15 = r14, r15 + ;; + nop 0 + .mfb + st8 [r21] = r15 + nop 0 + br.ret.sptk.many b0 +.L51: + .body + .copy_state 10 + .mib + nop 0 + cmp.ltu p6, p7 = 24, r19 + (p6) br.cond.dptk .L55 + ;; + .mfi + shladd r19 = r17, 3, r0 + nop 0 + addl r14 = -1, r0 + .mii + ld8 r16 = [r27] + cmp.ltu p6, p7 = 24, r23 + ;; + nop 0 + .mii + mov r29 = r19 + shl r15 = r8, r19 + shl r14 = r14, r19 + ;; + .mmi + xor r15 = r15, r16 + ;; + and r14 = r15, r14 + nop 0 + ;; + .mii + nop 0 + xor r16 = r14, r16 + ;; + nop 0 + .mfb + st8 [r27] = r16 + nop 0 + (p6) br.cond.dptk .L57 + .mmi + shladd r14 = r17, 2, r0 + shladd r18 = r23, 3, r0 + addl r16 = 2, r0 + .mmi + adds r22 = 16, r27 + adds r20 = 8, r27 + shl r21 = r10, r29 + ;; + .mmi + sub r14 = 32, r14 + adds r18 = -65, r18 + mov b0 = r34 + .mii + .label_state 11 + .restore sp + mov r12 = r36 + shl r19 = r9, r29 + mov ar.pfs = r35 + ;; + .mii + nop 0 + sxt4 r18 = r18 + sxt4 r14 = r14 + .mib + nop 0 + mov ar.lc = r38 + nop 0 + ;; + .mii + nop 0 + shr r15 = r9, r14 + shr r17 = r8, r14 + .mii + mov r8 = r0 + nop 0 + shl r16 = r16, r18 + ;; + .mii + nop 0 + shr r15 = r15, r14 + shr r17 = r17, r14 + .mii + ld8 r14 = [r22] + nop 0 + adds r16 = -1, r16 + ;; + .mii + or r15 = r21, r15 + or r17 = r19, r17 + ;; + xor r15 = r15, r14 + .mmi + st8 [r20] = r17 + ;; + and r16 = r15, r16 + nop 0 + ;; + .mii + nop 0 + xor r14 = r16, r14 + ;; + nop 0 + .mfb + st8 [r22] = r14 + nop 0 + br.ret.sptk.many b0 +.L55: + .body + .copy_state 11 + .mfi + shladd r18 = r17, 3, r0 + nop 0 + addl r14 = -1, r0 + .mii + ld8 r16 = [r27] + cmp.ltu p6, p7 = 32, r23 + ;; + nop 0 + .mii + mov r29 = r18 + shl r15 = r8, r18 + shl r14 = r14, r18 + ;; + .mmi + xor r15 = r15, r16 + ;; + and r14 = r15, r14 + nop 0 + ;; + .mii + nop 0 + xor r16 = r14, r16 + ;; + nop 0 + .mfb + st8 [r27] = r16 + nop 0 + (p6) br.cond.dptk .L59 + .mmi + shladd r14 = r17, 2, r0 + addl r15 = 2, r0 + shl r20 = r10, r18 + .mmi + shladd r18 = r23, 3, r0 + adds r23 = 24, r27 + shl r19 = r9, r29 + ;; + .mmi + sub r14 = 32, r14 + adds r18 = -65, r18 + mov b0 = r34 + .mmi + adds r21 = 8, r27 + adds r22 = 16, r27 + .label_state 12 + .restore sp + mov r12 = r36 + .mii + nop 0 + mov ar.pfs = r35 + ;; + sxt4 r18 = r18 + .mii + nop 0 + sxt4 r14 = r14 + mov ar.lc = r38 + ;; + .mii + nop 0 + shr r16 = r8, r14 + shr r17 = r9, r14 + .mii + mov r8 = r0 + nop 0 + shl r15 = r15, r18 + ;; + .mii + nop 0 + shr r16 = r16, r14 + shr r17 = r17, r14 + .mii + ld8 r14 = [r23] + adds r15 = -1, r15 + ;; + or r16 = r19, r16 + .mmi + or r17 = r20, r17 + ;; + st8 [r21] = r16 + xor r16 = r14, r16 + .mmi + st8 [r22] = r17 + ;; + and r15 = r16, r15 + nop 0 + ;; + .mii + nop 0 + xor r14 = r15, r14 + ;; + nop 0 + .mfb + st8 [r23] = r14 + nop 0 + br.ret.sptk.many b0 +.L57: + .body + .copy_state 12 + .mmi + shladd r14 = r23, 3, r0 + addl r15 = 2, r0 + sub r16 = 64, r19 + .mmi + adds r24 = 24, r27 + adds r22 = 8, r27 + shl r21 = r10, r29 + ;; + .mii + adds r14 = -129, r14 + sxt4 r16 = r16 + shl r20 = r9, r29 + .mmi + adds r23 = 16, r27 + .label_state 13 + .restore sp + mov r12 = r36 + mov b0 = r34 + ;; + .mii + nop 0 + shr r18 = r10, r16 + sxt4 r14 = r14 + ;; + .mii + nop 0 + shl r15 = r15, r14 + shr r19 = r8, r16 + .mmi + ld8 r14 = [r24] + mov r8 = r0 + mov ar.pfs = r35 + .mib + nop 0 + shr r17 = r9, r16 + nop 0 + ;; + .mii + xor r18 = r18, r14 + mov ar.lc = r38 + adds r15 = -1, r15 + .mmi + or r19 = r20, r19 + ;; + and r15 = r18, r15 + or r17 = r21, r17 + .mii + st8 [r22] = r19 + nop 0 + ;; + xor r14 = r15, r14 + .mmb + nop 0 + st8 [r23] = r17 + nop 0 + ;; + .mfb + st8 [r24] = r14 + nop 0 + br.ret.sptk.many b0 +.L59: + .body + .copy_state 13 + .mmi + shladd r16 = r23, 3, r0 + addl r15 = 2, r0 + sub r14 = 64, r18 + .mmi + adds r24 = 8, r27 + adds r25 = 16, r27 + adds r26 = 24, r27 + ;; + .mmi + nop 0 + adds r16 = -129, r16 + sxt4 r14 = r14 + .mmi + adds r27 = 32, r27 + .restore sp + mov r12 = r36 + shl r23 = r11, r29 + ;; + .mii + nop 0 + sxt4 r16 = r16 + shr r22 = r11, r14 + ;; + .mii + nop 0 + shl r15 = r15, r16 + shr r17 = r8, r14 + .mii + mov r8 = r0 + shr r18 = r9, r14 + shr r19 = r10, r14 + .mii + ld8 r14 = [r27] + shl r20 = r9, r29 + shl r21 = r10, r29 + ;; + .mmi + xor r22 = r22, r14 + adds r15 = -1, r15 + mov b0 = r34 + ;; + .mmi + and r15 = r22, r15 + or r19 = r23, r19 + mov ar.pfs = r35 + .mmi + or r17 = r20, r17 + or r18 = r21, r18 + mov ar.lc = r38 + ;; + .mmb + xor r14 = r15, r14 + st8 [r24] = r17 + nop 0 + .mmb + st8 [r25] = r18 + st8 [r26] = r19 + nop 0 + ;; + .mfb + st8 [r27] = r14 + nop 0 + br.ret.sptk.many b0 + .endp avcall_call# + .ident "GCC: (GNU) 4.0.1" diff --git a/avcall/avcall-ia64-macro.S b/avcall/avcall-ia64-macro.S new file mode 100644 index 0000000..e0da01a --- /dev/null +++ b/avcall/avcall-ia64-macro.S @@ -0,0 +1,1177 @@ + .file "avcall-ia64.c" + .pred.safe_across_calls p1-p5,p16-p63 + .text + .align 16 + .global avcall_call# + .proc avcall_call# +avcall_call: + .prologue 14, 34 + .mmi + .save ar.pfs, r35 + alloc r35 = ar.pfs, 1, 6, 8, 0 + adds r14 = 40, r32 + adds r20 = 48, r32 + .mmi + adds r16 = 64, r32 + adds r21 = 72, r32 + adds r19 = -2032, r12 + ;; + .mmb + ld8 r15 = [r14] + ld8 r17 = [r20] + nop 0 + .mii + .vframe r36 + mov r36 = r12 + .save ar.lc, r38 + mov r38 = ar.lc + mov r37 = r1 + ;; + .mmi + sub r15 = r15, r17 + ld8 r14 = [r16] + .save rp, r34 + mov r34 = b0 + .body + .mmi + nop 0 + ;; + nop 0 + shr.u r15 = r15, 3 + .mmi + sub r14 = r14, r21 + ;; + nop 0 + shr.u r18 = r14, 3 + .mmb + nop 0 + cmp4.ge p6, p7 = 8, r15 + (p6) br.cond.dptk .L2 + .mii + sub r14 = 8, r15 + addl r16 = 8, r0 + ;; + andcm r14 = -1, r14 + ;; + .mii + nop 0 + addp4 r14 = r14, r0 + ;; + mov ar.lc = r14 +.L4: + .mii + nop 0 + sxt4 r14 = r16 + adds r16 = 1, r16 + ;; + .mmi + shladd r14 = r14, 3, r0 + ;; + add r15 = r17, r14 + add r14 = r19, r14 + ;; + .mmb + adds r14 = -64, r14 + ld8 r15 = [r15] + nop 0 + ;; + .mfb + st8 [r14] = r15 + nop 0 + br.cloop.sptk.few .L4 +.L2: + .mmi + adds r33 = 24, r32 + ;; + ld4 r15 = [r33] + nop 0 + ;; + .mii + nop 0 + cmp4.ne p6, p7 = 16, r15 + ;; + (p7) adds r14 = 16, r32 + ;; + .mfi + (p7) ld8 r8 = [r14] + nop 0 + cmp4.ge p6, p7 = 0, r18 + .mfb + adds r14 = 80, r32 + nop 0 + (p6) br.cond.dpnt .L7 + ;; + .mmb + nop 0 + cmp4.ge p6, p7 = 1, r18 + nop 0 + .mfb + ldfd f8 = [r21] + nop 0 + (p6) br.cond.dpnt .L7 + ;; + .mmb + nop 0 + cmp4.ge p6, p7 = 2, r18 + nop 0 + .mfb + ldfd f9 = [r14] + nop 0 + (p7) br.cond.dptk .L71 + ;; +.L7: + .mib + nop 0 + cmp4.ne p6, p7 = 13, r15 + (p7) br.cond.dpnt .L72 + ;; +.L16: + .mib + cmp4.ne p6, p7 = 14, r15 + adds r15 = 8, r32 + (p7) br.cond.dpnt .L73 + .mmb + nop 0 + ld8 r14 = [r20] + nop 0 + ;; + .mmi + ld8 r15 = [r15] + adds r16 = 8, r14 + adds r17 = 16, r14 + .mmi + adds r18 = 24, r14 + adds r19 = 32, r14 + adds r20 = 40, r14 + .mmi + nop 0 + adds r21 = 48, r14 + adds r22 = 56, r14 + .mmi + ld8 r39 = [r14] + ;; + ld8 r14 = [r15], 8 + nop 0 + .mii + ld8 r40 = [r16] + nop 0 + ;; + mov b6 = r14 + .mmb + ld8 r1 = [r15] + ld8 r41 = [r17] + nop 0 + .mmb + ld8 r42 = [r18] + ld8 r43 = [r19] + nop 0 + .mmb + ld8 r44 = [r20] + ld8 r45 = [r21] + nop 0 + .mbb + ld8 r46 = [r22] + nop 0 + br.call.sptk.many b0 = b6 + ;; + .mmi + mov r1 = r37 + ld4 r14 = [r33] + mov r28 = r8 + ;; + .mfb + cmp4.eq p6, p7 = 1, r14 + nop 0 + (p6) br.cond.dpnt .L18 + ;; + .mib + nop 0 + cmp4.ne p6, p7 = 0, r14 + (p7) br.cond.dptk .L69 + ;; + .mfb + cmp4.ne p6, p7 = 2, r14 + nop 0 + (p7) br.cond.dpnt .L65 + ;; + .mfb + cmp4.ne p6, p7 = 3, r14 + nop 0 + (p7) br.cond.dpnt .L65 + ;; + .mfb + cmp4.ne p6, p7 = 4, r14 + nop 0 + (p7) br.cond.dpnt .L65 + ;; + .mfb + cmp4.ne p6, p7 = 5, r14 + nop 0 + (p7) br.cond.dpnt .L66 + ;; + .mfb + cmp4.ne p6, p7 = 6, r14 + nop 0 + (p7) br.cond.dpnt .L66 + ;; + .mfb + cmp4.ne p6, p7 = 7, r14 + nop 0 + (p7) br.cond.dpnt .L67 + ;; + .mfb + cmp4.ne p6, p7 = 8, r14 + nop 0 + (p7) br.cond.dpnt .L67 + ;; + .mii + nop 0 + cmp4.ne p6, p7 = 9, r14 + ;; + nop 0 + .mfb + cmp4.ne.and.orcm p6, p7 = 11, r14 + nop 0 + (p7) br.cond.dptk .L69 + ;; + .mii + nop 0 + cmp4.ne p6, p7 = 10, r14 + ;; + nop 0 + .mfb + cmp4.ne.and.orcm p6, p7 = 12, r14 + nop 0 + (p7) br.cond.dptk .L69 + ;; + .mfb + cmp4.ne p6, p7 = 15, r14 + nop 0 + (p7) br.cond.dpnt .L69 + ;; + .mib + nop 0 + cmp4.ne p6, p7 = 16, r14 + (p6) br.cond.dptk .L18 + .mmi + ld4 r14 = [r32] + ;; + nop 0 + tbit.z p6, p7 = r14, 9 + .mfb + adds r14 = 32, r32 + nop 0 + (p6) br.cond.dpnt .L18 + ;; + .mmi + ld8 r19 = [r14] + ;; + adds r14 = -1, r19 + nop 0 + ;; + .mib + cmp.ltu p6, p7 = 31, r14 + adds r14 = 16, r32 + (p6) br.cond.dpnt .L18 + ;; + .mii + ld8 r14 = [r14] + cmp.ltu p6, p7 = 8, r19 + ;; + and r17 = 7, r14 + .mii + nop 0 + and r27 = -8, r14 + ;; + nop 0 + .mfb + add r23 = r19, r17 + nop 0 + (p6) br.cond.dptk .L47 + ;; + .mib + nop 0 + cmp.ltu p6, p7 = 8, r23 + (p6) br.cond.dptk .L49 + .mmi + shladd r15 = r23, 3, r0 + addl r14 = 2, r0 + shladd r18 = r17, 3, r0 + .mmi + ld8 r17 = [r27] + ;; + adds r15 = -1, r15 + nop 0 + ;; + .mii + nop 0 + sxt4 r15 = r15 + ;; + shl r14 = r14, r15 + .mii + addl r15 = 1, r0 + shl r16 = r8, r18 + ;; + shl r15 = r15, r18 + .mii + nop 0 + xor r16 = r16, r17 + ;; + sub r14 = r14, r15 + ;; + .mmi + and r14 = r16, r14 + ;; + xor r17 = r14, r17 + nop 0 + ;; + .mfb + st8 [r27] = r17 + nop 0 + nop 0 +.L18: + .mfi + mov r8 = r0 + nop 0 + mov b0 = r34 + .mmi + nop 0 + .label_state 1 + .restore sp + mov r12 = r36 + mov ar.pfs = r35 + .mib + nop 0 + mov ar.lc = r38 + br.ret.sptk.many b0 +.L71: + .body + .copy_state 1 + .mfi + adds r14 = 88, r32 + nop 0 + cmp4.ge p6, p7 = 3, r18 + ;; + .mfb + ldfd f10 = [r14] + nop 0 + (p6) br.cond.dptk .L7 + .mfi + adds r14 = 96, r32 + nop 0 + cmp4.ge p6, p7 = 4, r18 + ;; + .mfb + ldfd f11 = [r14] + nop 0 + (p6) br.cond.dptk .L7 + .mfi + adds r14 = 104, r32 + nop 0 + cmp4.ge p6, p7 = 5, r18 + ;; + .mfb + ldfd f12 = [r14] + nop 0 + (p6) br.cond.dptk .L7 + .mfi + adds r14 = 112, r32 + nop 0 + cmp4.ge p6, p7 = 6, r18 + ;; + .mfb + ldfd f13 = [r14] + nop 0 + (p6) br.cond.dptk .L7 + .mii + adds r14 = 120, r32 + cmp4.ge p6, p7 = 7, r18 + ;; + nop 0 + .mii + ldfd f14 = [r14] + (p7) adds r14 = 128, r32 + ;; + nop 0 + .mmb + (p7) ldfd f15 = [r14] + cmp4.ne p6, p7 = 13, r15 + (p6) br.cond.dptk .L16 +.L72: + .mmb + adds r16 = 8, r32 + adds r15 = 16, r32 + nop 0 + .mfi + ld8 r14 = [r20] + nop 0 + mov ar.lc = r38 + ;; + .mmi + ld8 r33 = [r15] + ld8 r15 = [r16] + adds r17 = 8, r14 + .mmi + adds r18 = 16, r14 + adds r19 = 24, r14 + adds r20 = 32, r14 + .mmi + adds r21 = 40, r14 + adds r22 = 48, r14 + adds r23 = 56, r14 + .mii + ld8 r39 = [r14] + nop 0 + ;; + nop 0 + .mmb + ld8 r14 = [r15], 8 + ld8 r40 = [r17] + nop 0 + ;; + .mmi + ld8 r1 = [r15] + ld8 r41 = [r18] + mov b6 = r14 + .mmb + ld8 r42 = [r19] + ld8 r43 = [r20] + nop 0 + .mmb + ld8 r44 = [r21] + ld8 r45 = [r22] + nop 0 + .mbb + ld8 r46 = [r23] + nop 0 + br.call.sptk.many b0 = b6 + ;; + .mmb + .label_state 2 + .restore sp + mov r12 = r36 + mov r8 = r0 + nop 0 + .mmi + mov r1 = r37 + stfs [r33] = f8 + mov b0 = r34 + .mib + nop 0 + mov ar.pfs = r35 + br.ret.sptk.many b0 + ;; +.L69: + .body + .copy_state 2 + .mmi + adds r14 = 16, r32 + mov r8 = r0 + mov b0 = r34 + .mmi + .label_state 3 + .restore sp + mov r12 = r36 + ;; + ld8 r14 = [r14] + mov ar.pfs = r35 + .mii + nop 0 + mov ar.lc = r38 + ;; + nop 0 + .mfb + st8 [r14] = r28 + nop 0 + br.ret.sptk.many b0 +.L73: + .body + .copy_state 3 + .mmb + adds r16 = 8, r32 + adds r15 = 16, r32 + nop 0 + .mfi + ld8 r14 = [r20] + nop 0 + mov ar.lc = r38 + ;; + .mmi + ld8 r33 = [r15] + ld8 r15 = [r16] + adds r17 = 8, r14 + .mmi + adds r18 = 16, r14 + adds r19 = 24, r14 + adds r20 = 32, r14 + .mmi + adds r21 = 40, r14 + adds r22 = 48, r14 + adds r23 = 56, r14 + .mii + ld8 r39 = [r14] + nop 0 + ;; + nop 0 + .mmb + ld8 r14 = [r15], 8 + ld8 r40 = [r17] + nop 0 + ;; + .mmi + ld8 r1 = [r15] + ld8 r41 = [r18] + mov b6 = r14 + .mmb + ld8 r42 = [r19] + ld8 r43 = [r20] + nop 0 + .mmb + ld8 r44 = [r21] + ld8 r45 = [r22] + nop 0 + .mbb + ld8 r46 = [r23] + nop 0 + br.call.sptk.many b0 = b6 + ;; + .mmb + .label_state 4 + .restore sp + mov r12 = r36 + mov r8 = r0 + nop 0 + .mmi + mov r1 = r37 + stfd [r33] = f8 + mov b0 = r34 + .mib + nop 0 + mov ar.pfs = r35 + br.ret.sptk.many b0 + ;; +.L65: + .body + .copy_state 4 + .mmi + adds r14 = 16, r32 + mov r8 = r0 + mov b0 = r34 + .mmi + .label_state 5 + .restore sp + mov r12 = r36 + ;; + ld8 r14 = [r14] + mov ar.pfs = r35 + .mii + nop 0 + mov ar.lc = r38 + ;; + nop 0 + .mfb + st1 [r14] = r28 + nop 0 + br.ret.sptk.many b0 +.L66: + .body + .copy_state 5 + .mmi + adds r14 = 16, r32 + mov r8 = r0 + mov b0 = r34 + .mmi + .label_state 6 + .restore sp + mov r12 = r36 + ;; + ld8 r14 = [r14] + mov ar.pfs = r35 + .mii + nop 0 + mov ar.lc = r38 + ;; + nop 0 + .mfb + st2 [r14] = r28 + nop 0 + br.ret.sptk.many b0 +.L67: + .body + .copy_state 6 + .mmi + adds r14 = 16, r32 + mov r8 = r0 + mov b0 = r34 + .mmi + .label_state 7 + .restore sp + mov r12 = r36 + ;; + ld8 r14 = [r14] + mov ar.pfs = r35 + .mii + nop 0 + mov ar.lc = r38 + ;; + nop 0 + .mfb + st4 [r14] = r28 + nop 0 + br.ret.sptk.many b0 +.L47: + .body + .copy_state 7 + .mib + nop 0 + cmp.ltu p6, p7 = 16, r19 + (p6) br.cond.dptk .L51 + ;; + .mfi + shladd r20 = r17, 3, r0 + nop 0 + addl r14 = -1, r0 + .mii + ld8 r16 = [r27] + cmp.ltu p6, p7 = 16, r23 + ;; + nop 0 + .mii + mov r19 = r20 + shl r15 = r8, r20 + shl r14 = r14, r20 + ;; + .mmi + xor r15 = r15, r16 + ;; + and r14 = r15, r14 + nop 0 + ;; + .mii + nop 0 + xor r16 = r14, r16 + ;; + nop 0 + .mfb + st8 [r27] = r16 + nop 0 + (p6) br.cond.dptk .L53 + .mmi + shladd r17 = r17, 2, r0 + shladd r16 = r23, 3, r0 + addl r15 = 2, r0 + .mmi + adds r19 = 8, r27 + .label_state 8 + .restore sp + mov r12 = r36 + shl r20 = r9, r20 + ;; + .mmb + sub r17 = 32, r17 + adds r16 = -65, r16 + nop 0 + .mii + ld8 r18 = [r19] + mov b0 = r34 + mov ar.pfs = r35 + ;; + .mii + nop 0 + sxt4 r16 = r16 + sxt4 r17 = r17 + .mib + nop 0 + mov ar.lc = r38 + nop 0 + ;; + .mii + nop 0 + shr r14 = r8, r17 + shl r15 = r15, r16 + .mmi + mov r8 = r0 + ;; + nop 0 + shr r14 = r14, r17 + .mii + nop 0 + adds r15 = -1, r15 + ;; + or r14 = r20, r14 + ;; + .mii + nop 0 + xor r14 = r14, r18 + ;; + and r15 = r14, r15 + ;; + .mii + nop 0 + xor r18 = r15, r18 + ;; + nop 0 + .mfb + st8 [r19] = r18 + nop 0 + br.ret.sptk.many b0 +.L49: + .body + .copy_state 8 + .mmi + shladd r14 = r23, 3, r0 + addl r15 = 2, r0 + mov b0 = r34 + .mmi + shladd r18 = r17, 3, r0 + ld8 r19 = [r27] + .label_state 9 + .restore sp + mov r12 = r36 + ;; + .mmi + adds r14 = -65, r14 + sub r16 = 64, r18 + mov ar.pfs = r35 + .mii + nop 0 + mov ar.lc = r38 + ;; + sxt4 r14 = r14 + .mii + nop 0 + shl r17 = r8, r18 + ;; + shl r15 = r15, r14 + .mii + addl r14 = -1, r0 + sxt4 r16 = r16 + ;; + shr r16 = r8, r16 + .mii + mov r8 = r0 + xor r17 = r17, r19 + shl r14 = r14, r18 + .mii + nop 0 + adds r15 = -1, r15 + ;; + and r14 = r17, r14 + ;; + .mmi + xor r19 = r14, r19 + ;; + st8 [r27] = r19, 8 + nop 0 + ;; + .mmi + ld8 r14 = [r27] + ;; + xor r16 = r16, r14 + nop 0 + ;; + .mmi + and r15 = r16, r15 + ;; + xor r14 = r15, r14 + nop 0 + ;; + .mfb + st8 [r27] = r14 + nop 0 + br.ret.sptk.many b0 +.L53: + .body + .copy_state 9 + .mmi + shladd r15 = r23, 3, r0 + addl r14 = 2, r0 + sub r17 = 64, r20 + .mmi + adds r21 = 16, r27 + adds r20 = 8, r27 + shl r19 = r9, r19 + ;; + .mii + adds r15 = -129, r15 + mov b0 = r34 + sxt4 r17 = r17 + .mmi + .label_state 10 + .restore sp + mov r12 = r36 + nop 0 + mov ar.pfs = r35 + ;; + .mii + nop 0 + shr r18 = r9, r17 + sxt4 r15 = r15 + ;; + .mii + nop 0 + shl r14 = r14, r15 + shr r16 = r8, r17 + .mmi + ld8 r15 = [r21] + mov r8 = r0 + mov ar.lc = r38 + ;; + .mii + xor r18 = r18, r15 + adds r14 = -1, r14 + or r16 = r19, r16 + ;; + .mmb + and r14 = r18, r14 + st8 [r20] = r16 + nop 0 + ;; + .mii + nop 0 + xor r15 = r14, r15 + ;; + nop 0 + .mfb + st8 [r21] = r15 + nop 0 + br.ret.sptk.many b0 +.L51: + .body + .copy_state 10 + .mib + nop 0 + cmp.ltu p6, p7 = 24, r19 + (p6) br.cond.dptk .L55 + ;; + .mfi + shladd r19 = r17, 3, r0 + nop 0 + addl r14 = -1, r0 + .mii + ld8 r16 = [r27] + cmp.ltu p6, p7 = 24, r23 + ;; + nop 0 + .mii + mov r29 = r19 + shl r15 = r8, r19 + shl r14 = r14, r19 + ;; + .mmi + xor r15 = r15, r16 + ;; + and r14 = r15, r14 + nop 0 + ;; + .mii + nop 0 + xor r16 = r14, r16 + ;; + nop 0 + .mfb + st8 [r27] = r16 + nop 0 + (p6) br.cond.dptk .L57 + .mmi + shladd r14 = r17, 2, r0 + shladd r18 = r23, 3, r0 + addl r16 = 2, r0 + .mmi + adds r22 = 16, r27 + adds r20 = 8, r27 + shl r21 = r10, r29 + ;; + .mmi + sub r14 = 32, r14 + adds r18 = -65, r18 + mov b0 = r34 + .mii + .label_state 11 + .restore sp + mov r12 = r36 + shl r19 = r9, r29 + mov ar.pfs = r35 + ;; + .mii + nop 0 + sxt4 r18 = r18 + sxt4 r14 = r14 + .mib + nop 0 + mov ar.lc = r38 + nop 0 + ;; + .mii + nop 0 + shr r15 = r9, r14 + shr r17 = r8, r14 + .mii + mov r8 = r0 + nop 0 + shl r16 = r16, r18 + ;; + .mii + nop 0 + shr r15 = r15, r14 + shr r17 = r17, r14 + .mii + ld8 r14 = [r22] + nop 0 + adds r16 = -1, r16 + ;; + .mii + or r15 = r21, r15 + or r17 = r19, r17 + ;; + xor r15 = r15, r14 + .mmi + st8 [r20] = r17 + ;; + and r16 = r15, r16 + nop 0 + ;; + .mii + nop 0 + xor r14 = r16, r14 + ;; + nop 0 + .mfb + st8 [r22] = r14 + nop 0 + br.ret.sptk.many b0 +.L55: + .body + .copy_state 11 + .mfi + shladd r18 = r17, 3, r0 + nop 0 + addl r14 = -1, r0 + .mii + ld8 r16 = [r27] + cmp.ltu p6, p7 = 32, r23 + ;; + nop 0 + .mii + mov r29 = r18 + shl r15 = r8, r18 + shl r14 = r14, r18 + ;; + .mmi + xor r15 = r15, r16 + ;; + and r14 = r15, r14 + nop 0 + ;; + .mii + nop 0 + xor r16 = r14, r16 + ;; + nop 0 + .mfb + st8 [r27] = r16 + nop 0 + (p6) br.cond.dptk .L59 + .mmi + shladd r14 = r17, 2, r0 + addl r15 = 2, r0 + shl r20 = r10, r18 + .mmi + shladd r18 = r23, 3, r0 + adds r23 = 24, r27 + shl r19 = r9, r29 + ;; + .mmi + sub r14 = 32, r14 + adds r18 = -65, r18 + mov b0 = r34 + .mmi + adds r21 = 8, r27 + adds r22 = 16, r27 + .label_state 12 + .restore sp + mov r12 = r36 + .mii + nop 0 + mov ar.pfs = r35 + ;; + sxt4 r18 = r18 + .mii + nop 0 + sxt4 r14 = r14 + mov ar.lc = r38 + ;; + .mii + nop 0 + shr r16 = r8, r14 + shr r17 = r9, r14 + .mii + mov r8 = r0 + nop 0 + shl r15 = r15, r18 + ;; + .mii + nop 0 + shr r16 = r16, r14 + shr r17 = r17, r14 + .mii + ld8 r14 = [r23] + adds r15 = -1, r15 + ;; + or r16 = r19, r16 + .mmi + or r17 = r20, r17 + ;; + st8 [r21] = r16 + xor r16 = r14, r16 + .mmi + st8 [r22] = r17 + ;; + and r15 = r16, r15 + nop 0 + ;; + .mii + nop 0 + xor r14 = r15, r14 + ;; + nop 0 + .mfb + st8 [r23] = r14 + nop 0 + br.ret.sptk.many b0 +.L57: + .body + .copy_state 12 + .mmi + shladd r14 = r23, 3, r0 + addl r15 = 2, r0 + sub r16 = 64, r19 + .mmi + adds r24 = 24, r27 + adds r22 = 8, r27 + shl r21 = r10, r29 + ;; + .mii + adds r14 = -129, r14 + sxt4 r16 = r16 + shl r20 = r9, r29 + .mmi + adds r23 = 16, r27 + .label_state 13 + .restore sp + mov r12 = r36 + mov b0 = r34 + ;; + .mii + nop 0 + shr r18 = r10, r16 + sxt4 r14 = r14 + ;; + .mii + nop 0 + shl r15 = r15, r14 + shr r19 = r8, r16 + .mmi + ld8 r14 = [r24] + mov r8 = r0 + mov ar.pfs = r35 + .mib + nop 0 + shr r17 = r9, r16 + nop 0 + ;; + .mii + xor r18 = r18, r14 + mov ar.lc = r38 + adds r15 = -1, r15 + .mmi + or r19 = r20, r19 + ;; + and r15 = r18, r15 + or r17 = r21, r17 + .mii + st8 [r22] = r19 + nop 0 + ;; + xor r14 = r15, r14 + .mmb + nop 0 + st8 [r23] = r17 + nop 0 + ;; + .mfb + st8 [r24] = r14 + nop 0 + br.ret.sptk.many b0 +.L59: + .body + .copy_state 13 + .mmi + shladd r16 = r23, 3, r0 + addl r15 = 2, r0 + sub r14 = 64, r18 + .mmi + adds r24 = 8, r27 + adds r25 = 16, r27 + adds r26 = 24, r27 + ;; + .mmi + nop 0 + adds r16 = -129, r16 + sxt4 r14 = r14 + .mmi + adds r27 = 32, r27 + .restore sp + mov r12 = r36 + shl r23 = r11, r29 + ;; + .mii + nop 0 + sxt4 r16 = r16 + shr r22 = r11, r14 + ;; + .mii + nop 0 + shl r15 = r15, r16 + shr r17 = r8, r14 + .mii + mov r8 = r0 + shr r18 = r9, r14 + shr r19 = r10, r14 + .mii + ld8 r14 = [r27] + shl r20 = r9, r29 + shl r21 = r10, r29 + ;; + .mmi + xor r22 = r22, r14 + adds r15 = -1, r15 + mov b0 = r34 + ;; + .mmi + and r15 = r22, r15 + or r19 = r23, r19 + mov ar.pfs = r35 + .mmi + or r17 = r20, r17 + or r18 = r21, r18 + mov ar.lc = r38 + ;; + .mmb + xor r14 = r15, r14 + st8 [r24] = r17 + nop 0 + .mmb + st8 [r25] = r18 + st8 [r26] = r19 + nop 0 + ;; + .mfb + st8 [r27] = r14 + nop 0 + br.ret.sptk.many b0 + .endp avcall_call# + .ident "GCC: (GNU) 4.0.1" +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/avcall/avcall-ia64.c b/avcall/avcall-ia64.c new file mode 100644 index 0000000..e49b2b8 --- /dev/null +++ b/avcall/avcall-ia64.c @@ -0,0 +1,317 @@ +/** + Copyright 1993 Bill Triggs + Copyright 1995-2017 Bruno Haible + + 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, see . +**/ +/*---------------------------------------------------------------------- + !!! THIS ROUTINE MUST BE COMPILED gcc -O !!! + + Foreign function interface for a Intel IA-64 in little-endian mode with gcc. + + This calls a C function with an argument list built up using macros + defined in avcall.h. + + IA-64 64-bit Argument Passing Conventions: + + The argument sequence is mapped linearly on the registers r32,...,r39, + and continued on the stack, in [r12+16], [r12+24], ... + Items in this sequence are word-aligned. In gcc < 3.0, structures larger + than a single word are even two-word-aligned. + Integer/pointer arguments are passed in the allocated slots (registers + or stack slots). The first 8 float/double arguments are passed in + registers f8,...,f15 instead, but their slots are kept allocated. + Structure args are passed like multiple integer arguments; except that + structures consisting only of floats or only of doubles are passed like + multiple float arguments or multiple double arguments, respectively. + + Integers and pointers are returned in r8, floats and doubles in f8. + Structures consisting only of at most 8 floats or only of at most 8 doubles + are returned in f8,...,f15. Other than that, structures of size <= 32 bytes + are returned in r8,...,r11, as if these were 4 contiguous words in memory. + Larger structures are returned in memory; the caller passes the address + of the target memory area in r8, and it is returned unmodified in r8. + ----------------------------------------------------------------------*/ +#include "avcall-internal.h" + +#define RETURN(TYPE,VAL) (*(TYPE*)l->raddr = (TYPE)(VAL)) + +register __avword* sret __asm__("r8"); /* structure return pointer */ +/*register __avword iret __asm__("r8");*/ +register __avword iret2 __asm__("r9"); +register __avword iret3 __asm__("r10"); +register __avword iret4 __asm__("r11"); +/*register float fret __asm__("f8");*/ +/*register double dret __asm__("f8");*/ +register double farg1 __asm__("f8"); +register double farg2 __asm__("f9"); +register double farg3 __asm__("f10"); +register double farg4 __asm__("f11"); +register double farg5 __asm__("f12"); +register double farg6 __asm__("f13"); +register double farg7 __asm__("f14"); +register double farg8 __asm__("f15"); + +int +avcall_call(av_alist* list) +{ + register __avword* sp __asm__("r12"); /* C names for registers */ + + __av_alist* l = &AV_LIST_INNER(list); + + __avword* argframe = (sp -= __AV_ALIST_WORDS) + 2; /* make room for argument list */ + int arglen = l->aptr - l->args; + int farglen = l->faptr - l->fargs; + __avword iret; + + { + int i; + for (i = 8; i < arglen; i++) /* push function args onto stack */ + argframe[i-8] = l->args[i]; + } + + /* struct return address */ + if (l->rtype == __AVstruct) + sret = l->raddr; + + /* put max. 8 double args in registers */ + if (farglen > 0) { + farg1 = l->fargs[0]; + if (farglen > 1) { + farg2 = l->fargs[1]; + if (farglen > 2) { + farg3 = l->fargs[2]; + if (farglen > 3) { + farg4 = l->fargs[3]; + if (farglen > 4) { + farg5 = l->fargs[4]; + if (farglen > 5) { + farg6 = l->fargs[5]; + if (farglen > 6) { + farg7 = l->fargs[6]; + if (farglen > 7) + farg8 = l->fargs[7]; + } + } + } + } + } + } + } + + /* call function, pass 8 integer and 8 double args in registers */ + if (l->rtype == __AVfloat) { + *(float*)l->raddr = (*(float(*)())l->func)(l->args[0], l->args[1], + l->args[2], l->args[3], + l->args[4], l->args[5], + l->args[6], l->args[7]); + } else + if (l->rtype == __AVdouble) { + *(double*)l->raddr = (*(double(*)())l->func)(l->args[0], l->args[1], + l->args[2], l->args[3], + l->args[4], l->args[5], + l->args[6], l->args[7]); + } else { + iret = (*l->func)(l->args[0], l->args[1], l->args[2], l->args[3], + l->args[4], l->args[5], l->args[6], l->args[7]); + + /* save return value */ + if (l->rtype == __AVvoid) { + } else + if (l->rtype == __AVword) { + RETURN(__avword, iret); + } else + if (l->rtype == __AVchar) { + RETURN(char, iret); + } else + if (l->rtype == __AVschar) { + RETURN(signed char, iret); + } else + if (l->rtype == __AVuchar) { + RETURN(unsigned char, iret); + } else + if (l->rtype == __AVshort) { + RETURN(short, iret); + } else + if (l->rtype == __AVushort) { + RETURN(unsigned short, iret); + } else + if (l->rtype == __AVint) { + RETURN(int, iret); + } else + if (l->rtype == __AVuint) { + RETURN(unsigned int, iret); + } else + if (l->rtype == __AVlong || l->rtype == __AVlonglong) { + RETURN(long, iret); + } else + if (l->rtype == __AVulong || l->rtype == __AVulonglong) { + RETURN(unsigned long, iret); + } else + /* see above + if (l->rtype == __AVfloat) { + } else + if (l->rtype == __AVdouble) { + } else + */ + if (l->rtype == __AVvoidp) { + RETURN(void*, iret); + } else + if (l->rtype == __AVstruct) { + if (l->flags & __AV_REGISTER_STRUCT_RETURN) { + /* Return structs of size <= 32 in registers. */ + if (l->rsize > 0 && l->rsize <= 32) { + void* raddr = l->raddr; + #if 0 /* Unoptimized */ + if (l->rsize >= 1) + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + if (l->rsize >= 2) + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + if (l->rsize >= 3) + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + if (l->rsize >= 4) + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + if (l->rsize >= 5) + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>32); + if (l->rsize >= 6) + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>40); + if (l->rsize >= 7) + ((unsigned char *)raddr)[6] = (unsigned char)(iret>>48); + if (l->rsize >= 8) + ((unsigned char *)raddr)[7] = (unsigned char)(iret>>56); + if (l->rsize >= 9) { + ((unsigned char *)raddr)[8] = (unsigned char)(iret2); + if (l->rsize >= 10) + ((unsigned char *)raddr)[9] = (unsigned char)(iret2>>8); + if (l->rsize >= 11) + ((unsigned char *)raddr)[10] = (unsigned char)(iret2>>16); + if (l->rsize >= 12) + ((unsigned char *)raddr)[11] = (unsigned char)(iret2>>24); + if (l->rsize >= 13) + ((unsigned char *)raddr)[12] = (unsigned char)(iret2>>32); + if (l->rsize >= 14) + ((unsigned char *)raddr)[13] = (unsigned char)(iret2>>40); + if (l->rsize >= 15) + ((unsigned char *)raddr)[14] = (unsigned char)(iret2>>48); + if (l->rsize >= 16) + ((unsigned char *)raddr)[15] = (unsigned char)(iret2>>56); + if (l->rsize >= 17) { + ((unsigned char *)raddr)[16] = (unsigned char)(iret3); + if (l->rsize >= 18) + ((unsigned char *)raddr)[17] = (unsigned char)(iret3>>8); + if (l->rsize >= 19) + ((unsigned char *)raddr)[18] = (unsigned char)(iret3>>16); + if (l->rsize >= 20) + ((unsigned char *)raddr)[19] = (unsigned char)(iret3>>24); + if (l->rsize >= 21) + ((unsigned char *)raddr)[20] = (unsigned char)(iret3>>32); + if (l->rsize >= 22) + ((unsigned char *)raddr)[21] = (unsigned char)(iret3>>40); + if (l->rsize >= 23) + ((unsigned char *)raddr)[22] = (unsigned char)(iret3>>48); + if (l->rsize >= 24) + ((unsigned char *)raddr)[23] = (unsigned char)(iret3>>56); + if (l->rsize >= 25) { + ((unsigned char *)raddr)[24] = (unsigned char)(iret4); + if (l->rsize >= 26) + ((unsigned char *)raddr)[25] = (unsigned char)(iret4>>8); + if (l->rsize >= 27) + ((unsigned char *)raddr)[26] = (unsigned char)(iret4>>16); + if (l->rsize >= 28) + ((unsigned char *)raddr)[27] = (unsigned char)(iret4>>24); + if (l->rsize >= 29) + ((unsigned char *)raddr)[28] = (unsigned char)(iret4>>32); + if (l->rsize >= 30) + ((unsigned char *)raddr)[29] = (unsigned char)(iret4>>40); + if (l->rsize >= 31) + ((unsigned char *)raddr)[30] = (unsigned char)(iret4>>48); + if (l->rsize >= 32) + ((unsigned char *)raddr)[31] = (unsigned char)(iret4>>56); + } + } + } + #else /* Optimized: fewer conditional jumps, fewer memory accesses */ + uintptr_t count = l->rsize; /* > 0, ≤ 4*sizeof(__avword) */ + __avword* wordaddr = (__avword*)((uintptr_t)raddr & ~(uintptr_t)(sizeof(__avword)-1)); + uintptr_t start_offset = (uintptr_t)raddr & (uintptr_t)(sizeof(__avword)-1); /* ≥ 0, < sizeof(__avword) */ + uintptr_t end_offset = start_offset + count; /* > 0, < 5*sizeof(__avword) */ + if (count <= sizeof(__avword)) { + /* Use iret. */ + if (end_offset <= sizeof(__avword)) { + /* 0 < end_offset ≤ sizeof(__avword) */ + __avword mask0 = ((__avword)2 << (end_offset*8-1)) - ((__avword)1 << (start_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret << (start_offset*8))) & mask0; + } else { + /* sizeof(__avword) < end_offset < 2*sizeof(__avword), start_offset > 0 */ + __avword mask0 = - ((__avword)1 << (start_offset*8)); + __avword mask1 = ((__avword)2 << (end_offset*8-sizeof(__avword)*8-1)) - 1; + wordaddr[0] ^= (wordaddr[0] ^ (iret << (start_offset*8))) & mask0; + wordaddr[1] ^= (wordaddr[1] ^ (iret >> (sizeof(__avword)*8-start_offset*8))) & mask1; + } + } else if (count <= 2*sizeof(__avword)) { + /* Use iret, iret2. */ + __avword mask0 = - ((__avword)1 << (start_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret << (start_offset*8))) & mask0; + if (end_offset <= 2*sizeof(__avword)) { + /* sizeof(__avword) < end_offset ≤ 2*sizeof(__avword) */ + __avword mask1 = ((__avword)2 << (end_offset*8-sizeof(__avword)*8-1)) - 1; + wordaddr[1] ^= (wordaddr[1] ^ ((iret >> (sizeof(__avword)*4-start_offset*4) >> (sizeof(__avword)*4-start_offset*4)) | (iret2 << (start_offset*8)))) & mask1; + } else { + /* 2*sizeof(__avword) < end_offset < 3*sizeof(__avword), start_offset > 0 */ + __avword mask2 = ((__avword)2 << (end_offset*8-2*sizeof(__avword)*8-1)) - 1; + wordaddr[1] = (iret >> (sizeof(__avword)*8-start_offset*8)) | (iret2 << (start_offset*8)); + wordaddr[2] ^= (wordaddr[2] ^ (iret2 >> (sizeof(__avword)*8-start_offset*8))) & mask2; + } + } else if (count <= 3*sizeof(__avword)) { + /* Use iret, iret2, iret3. */ + __avword mask0 = - ((__avword)1 << (start_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret << (start_offset*8))) & mask0; + if (end_offset <= 3*sizeof(__avword)) { + /* 2*sizeof(__avword) < end_offset ≤ 3*sizeof(__avword) */ + __avword mask2 = ((__avword)2 << (end_offset*8-sizeof(__avword)*8-1)) - 1; + wordaddr[1] = (iret >> (sizeof(__avword)*4-start_offset*4) >> (sizeof(__avword)*4-start_offset*4)) | (iret2 << (start_offset*8)); + wordaddr[2] ^= (wordaddr[2] ^ ((iret2 >> (sizeof(__avword)*4-start_offset*4) >> (sizeof(__avword)*4-start_offset*4)) | (iret3 << (start_offset*8)))) & mask2; + } else { + /* 3*sizeof(__avword) < end_offset < 4*sizeof(__avword), start_offset > 0 */ + __avword mask3 = ((__avword)2 << (end_offset*8-2*sizeof(__avword)*8-1)) - 1; + wordaddr[1] = (iret >> (sizeof(__avword)*8-start_offset*8)) | (iret2 << (start_offset*8)); + wordaddr[2] = (iret2 >> (sizeof(__avword)*8-start_offset*8)) | (iret3 << (start_offset*8)); + wordaddr[3] ^= (wordaddr[3] ^ (iret3 >> (sizeof(__avword)*8-start_offset*8))) & mask3; + } + } else { + /* Use iret, iret2, iret3, iret4. */ + __avword mask0 = - ((__avword)1 << (start_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret << (start_offset*8))) & mask0; + if (end_offset <= 4*sizeof(__avword)) { + /* 3*sizeof(__avword) < end_offset ≤ 4*sizeof(__avword) */ + __avword mask3 = ((__avword)2 << (end_offset*8-sizeof(__avword)*8-1)) - 1; + wordaddr[1] = (iret >> (sizeof(__avword)*4-start_offset*4) >> (sizeof(__avword)*4-start_offset*4)) | (iret2 << (start_offset*8)); + wordaddr[2] = (iret2 >> (sizeof(__avword)*4-start_offset*4) >> (sizeof(__avword)*4-start_offset*4)) | (iret3 << (start_offset*8)); + wordaddr[3] ^= (wordaddr[3] ^ ((iret >> (sizeof(__avword)*4-start_offset*4) >> (sizeof(__avword)*4-start_offset*4)) | (iret2 << (start_offset*8)))) & mask3; + } else { + /* 4*sizeof(__avword) < end_offset < 5*sizeof(__avword), start_offset > 0 */ + __avword mask4 = ((__avword)2 << (end_offset*8-2*sizeof(__avword)*8-1)) - 1; + wordaddr[1] = (iret >> (sizeof(__avword)*8-start_offset*8)) | (iret2 << (start_offset*8)); + wordaddr[2] = (iret2 >> (sizeof(__avword)*8-start_offset*8)) | (iret3 << (start_offset*8)); + wordaddr[3] = (iret3 >> (sizeof(__avword)*8-start_offset*8)) | (iret4 << (start_offset*8)); + wordaddr[4] ^= (wordaddr[4] ^ (iret4 >> (sizeof(__avword)*8-start_offset*8))) & mask4; + } + } + #endif + } + } + } + } + return 0; +} diff --git a/avcall/avcall-internal.h b/avcall/avcall-internal.h new file mode 100644 index 0000000..0357a77 --- /dev/null +++ b/avcall/avcall-internal.h @@ -0,0 +1,1508 @@ +/* + * Copyright 1993-1995 Bill Triggs + * Copyright 1995-2019 Bruno Haible + * + * 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, see . + */ + +#ifndef _AVCALL_INTERNAL_H +#define _AVCALL_INTERNAL_H + +/* Get intptr_t, uintptr_t. */ +#include "ffcall-stdint.h" + +/* Include the public definitions and "avcall-alist.h", */ +#include "avcall.h" + + +/* Verify at compile time that sizeof(__av_alist) <= __AV_ALIST_SIZE_BOUND. */ +typedef int __av_alist_verify[2*(__AV_ALIST_SIZE_BOUND - (int)sizeof(__av_alist))+1]; + +/* Conversion from the public, mostly opaque, 'av_alist*' to '__av_alist*'. */ +#define AV_LIST_INNER(list) ((list)->_av_alist_head._av_m_alist) + + +/* Delayed overflow detection */ +#if defined(__hppa__) && !defined(__hppa64__) +#define _av_overflown(LIST) ((LIST).aptr < (LIST).eptr) +#else +#define _av_overflown(LIST) ((LIST).aptr > (LIST).eptr) +#endif + + +/* + * Initialization of an __av_alist + */ + +#define __av_start(LIST,LIST_ARGS,LIST_ARGS_END,FUNC,RADDR,RETTYPE,FLAGS) \ + ((LIST).func = (FUNC), \ + (LIST).raddr = (RADDR), \ + (LIST).rtype = (RETTYPE), \ + (LIST).args = (LIST_ARGS), \ + __av_start1(LIST,LIST_ARGS_END) \ + __av_start_init_eptr(LIST,LIST_ARGS_END) \ + (LIST).flags = (FLAGS)) + +#if defined(__i386__) || defined(__m68k__) || defined(__alpha__) || (defined(__arm__) && !defined(__armhf__)) +#define __av_start1(LIST,LIST_ARGS_END) \ + (LIST).aptr = &(LIST).args[0], +#endif +#if defined(__mips__) && !defined(__mipsn32__) && !defined(__mips64__) +#define __av_start1(LIST,LIST_ARGS_END) \ + (LIST).anum = 0, \ + (LIST).fanum = 0, \ + (LIST).farg_mask = 0, \ + (LIST).darg_mask = 0, \ + (LIST).aptr = &(LIST).args[0], +#endif +#if defined(__mipsn32__) || defined(__mips64__) +#define __av_start1(LIST,LIST_ARGS_END) \ + (LIST).anum = 0, \ + (LIST).farg_mask = 0, \ + (LIST).darg_mask = 0, \ + (LIST).aptr = &(LIST).args[0], +#endif +#if defined(__sparc__) && !defined(__sparc64__) +#define __av_start1(LIST,LIST_ARGS_END) \ + (LIST).aptr = &(LIST).args[0], +#endif +#if defined(__sparc64__) +#define __av_start1(LIST,LIST_ARGS_END) \ + (LIST).anum = 0, \ + (LIST).darg_mask = 0, \ + (LIST).aptr = &(LIST).args[0], +#endif +#if defined(__hppa__) && !defined(__hppa64__) +#define __av_start1(LIST,LIST_ARGS_END) \ + (LIST).farg_mask = 0, \ + (LIST).darg_mask = 0, \ + (LIST).aptr = (LIST).args_end = (LIST_ARGS_END), +#endif +#if defined(__hppa64__) +#define __av_start1(LIST,LIST_ARGS_END) \ + (LIST).farg_mask = 0, \ + (LIST).darg_mask = 0, \ + (LIST).aptr = &(LIST).args[0], +#endif +#if defined(__armhf__) +#define __av_start1(LIST,LIST_ARGS_END) \ + (LIST).aptr = &(LIST).args[__AV_IARG_NUM], \ + (LIST).ianum = 0, \ + (LIST).fanum = 0, \ + (LIST).farg_mask = 0, \ + (LIST).darg_mask = 0, +#endif +#if defined(__arm64__) || defined(__s390__) || defined(__s390x__) +#define __av_start1(LIST,LIST_ARGS_END) \ + (LIST).aptr = &(LIST).args[0], \ + (LIST).ianum = 0, \ + (LIST).fanum = 0, \ + (LIST).farg_mask = 0, \ + (LIST).darg_mask = 0, +#endif +#if defined(__riscv32__) || defined(__riscv64__) +#define __av_start1(LIST,LIST_ARGS_END) \ + (LIST).aptr = &(LIST).args[0], \ + (LIST).fanum = 0, \ + (LIST).farg_mask = 0, \ + (LIST).darg_mask = 0, +#endif +#if defined(__powerpc_aix__) || defined(__powerpc64__) +#define __av_start1(LIST,LIST_ARGS_END) \ + (LIST).aptr = &(LIST).args[0], \ + (LIST).faptr = &(LIST).fargs[0], +#endif +#if defined(__powerpc_sysv4__) +#define __av_start1(LIST,LIST_ARGS_END) \ + (LIST).aptr = &(LIST).args[0], \ + (LIST).ianum = 0, \ + (LIST).faptr = &(LIST).fargs[0], +#endif +#if defined(__ia64__) +#define __av_start1(LIST,LIST_ARGS_END) \ + (LIST).aptr = &(LIST).args[0], \ + (LIST).faptr = &(LIST).fargs[0], +#endif +#if defined(__x86_64_sysv__) +#define __av_start1(LIST,LIST_ARGS_END) \ + (LIST).aptr = &(LIST).args[0], \ + (LIST).ianum = 0, \ + (LIST).faptr = &(LIST).fargs[0], +#endif +#if defined(__x86_64_ms__) +#define __av_start1(LIST,LIST_ARGS_END) \ + (LIST).aptr = &(LIST).args[0], \ + (LIST).anum = 0, \ + (LIST).farg_mask = 0, \ + (LIST).darg_mask = 0, +#endif + +#if defined(__hppa__) && !defined(__hppa64__) +#define __av_start_init_eptr(LIST,LIST_ARGS_END) \ + (LIST).eptr = &(LIST).args[0], +#else +#define __av_start_init_eptr(LIST,LIST_ARGS_END) \ + (LIST).eptr = (LIST_ARGS_END), +#endif + +#define __av_start_struct(LIST,LIST_ARGS,LIST_ARGS_END,FUNC,TYPE_SIZE,TYPE_SPLITTABLE,RADDR,FLAGS) \ + (__av_start(LIST,LIST_ARGS,LIST_ARGS_END,FUNC,RADDR,__AVstruct,FLAGS), \ + (LIST).rsize = (TYPE_SIZE), \ + __av_start_struct2(LIST,TYPE_SIZE,TYPE_SPLITTABLE), \ + 0) + +#if (defined(__sparc__) && !defined(__sparc64__)) +/* Return structure pointer is passed in a special register. + */ +#define __av_start_struct2(LIST,TYPE_SIZE,TYPE_SPLITTABLE) 0 +#else +#define __av_start_struct2(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ + (((LIST).flags & __AV_SMALL_STRUCT_RETURN) \ + && __av_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ + ? /* <= Word-sized structures are returned in a register. */ \ + __av_start_struct3(LIST) \ + : __av_start_struct4(LIST,TYPE_SIZE) \ + ) +/* Determines whether a structure is returned in registers, + * depending on its size and its word-splittable flag. + */ +#if (defined(__i386__) && defined(_WIN32)) +#define __av_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ + ((TYPE_SIZE) == 1 || (TYPE_SIZE) == 2 || (TYPE_SIZE) == 4 \ + || ((TYPE_SIZE) == 8 \ + && (((LIST).flags & __AV_MSVC_STRUCT_RETURN) \ + || ((TYPE_SPLITTABLE) \ + && ((LIST).flags & __AV_GCC_STRUCT_RETURN) \ + ) ) ) ) +/* Turn on __AV_REGISTER_STRUCT_RETURN if __AV_SMALL_STRUCT_RETURN was set + * and the struct will actually be returned in registers. + */ +#define __av_start_struct3(LIST) \ + ((LIST).flags |= __AV_REGISTER_STRUCT_RETURN, 0) +#endif +#if (defined(__i386__) && !defined(_WIN32)) || defined(__m68k__) || (defined(__powerpc__) && !defined(__powerpc64__)) || (defined(__s390__) && !defined(__s390x__)) +#define __av_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ + ((TYPE_SIZE) == 1 || (TYPE_SIZE) == 2 || (TYPE_SIZE) == 4 \ + || ((TYPE_SIZE) == 8 && (TYPE_SPLITTABLE) \ + && ((LIST).flags & __AV_GCC_STRUCT_RETURN) \ + ) ) +/* Turn on __AV_REGISTER_STRUCT_RETURN if __AV_SMALL_STRUCT_RETURN was set + * and the struct will actually be returned in registers. + */ +#define __av_start_struct3(LIST) \ + ((LIST).flags |= __AV_REGISTER_STRUCT_RETURN, 0) +#endif +#if defined(__arm__) || defined(__armhf__) +#define __av_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ + ((TYPE_SIZE) <= 4) +#define __av_start_struct3(LIST) \ + ((LIST).flags |= __AV_REGISTER_STRUCT_RETURN, 0) +#endif +#if defined(__alpha__) +#define __av_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ + ((TYPE_SIZE) == 1 || (TYPE_SIZE) == 2 || (TYPE_SIZE) == 4 || (TYPE_SIZE) == 8 \ + || ((TYPE_SIZE) == 16 && (TYPE_SPLITTABLE) \ + && ((LIST).flags & __AV_GCC_STRUCT_RETURN) \ + ) ) +/* Turn on __AV_REGISTER_STRUCT_RETURN if __AV_SMALL_STRUCT_RETURN was set + * and the struct will actually be returned in registers. + */ +#define __av_start_struct3(LIST) \ + ((LIST).flags |= __AV_REGISTER_STRUCT_RETURN, 0) +#endif +#if (defined(__hppa__) && !defined(__hppa64__)) || defined(__riscv32__) +#define __av_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ + ((TYPE_SIZE) <= 8) +/* Test __AV_SMALL_STRUCT_RETURN at run time. */ +#define __av_start_struct3(LIST) \ + 0 +#endif +#if defined(__mips__) && !defined(__mipsn32__) && !defined(__mips64__) +#define __av_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ + ((TYPE_SIZE) == 1 || (TYPE_SIZE) == 2 || (TYPE_SIZE) == 4) +/* Test __AV_SMALL_STRUCT_RETURN instead of __AV_REGISTER_STRUCT_RETURN. */ +#define __av_start_struct3(LIST) \ + 0 +#endif +#if defined(__mipsn32__) || defined(__mips64__) +#define __av_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ + ((LIST).flags & __AV_GCC_STRUCT_RETURN \ + ? ((TYPE_SIZE) == 1 || (TYPE_SIZE) == 2 || (TYPE_SIZE) == 4 || (TYPE_SIZE) == 8) \ + : ((TYPE_SIZE) <= 16) \ + ) +/* Turn on __AV_REGISTER_STRUCT_RETURN if __AV_SMALL_STRUCT_RETURN was set + * and the struct will actually be returned in registers. + */ +#define __av_start_struct3(LIST) \ + ((LIST).flags |= __AV_REGISTER_STRUCT_RETURN, 0) +#endif +#if (defined(__powerpc64__) && !defined(__powerpc64_elfv2__)) || defined(__s390x__) +#define __av_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ + 0 +#define __av_start_struct3(LIST) \ + 0 +#endif +#if defined(__sparc64__) || defined(__ia64__) +#define __av_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ + ((TYPE_SIZE) <= 32) +/* Turn on __AV_REGISTER_STRUCT_RETURN if __AV_SMALL_STRUCT_RETURN was set + * and the struct will actually be returned in registers. + */ +#define __av_start_struct3(LIST) \ + ((LIST).flags |= __AV_REGISTER_STRUCT_RETURN, 0) +#endif +#if defined(__hppa64__) || defined(__arm64__) || (defined(__powerpc64__) && defined(__powerpc64_elfv2__)) || defined(__x86_64_sysv__) || defined(__riscv64__) +#define __av_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ + ((TYPE_SIZE) <= 16) +/* Turn on __AV_REGISTER_STRUCT_RETURN if __AV_SMALL_STRUCT_RETURN was set + * and the struct will actually be returned in registers. + */ +#define __av_start_struct3(LIST) \ + ((LIST).flags |= __AV_REGISTER_STRUCT_RETURN, 0) +#endif +#if defined(__x86_64_ms__) +#define __av_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ + ((TYPE_SIZE) == 1 || (TYPE_SIZE) == 2 || (TYPE_SIZE) == 4 || (TYPE_SIZE) == 8) +/* Turn on __AV_REGISTER_STRUCT_RETURN if __AV_SMALL_STRUCT_RETURN was set + * and the struct will actually be returned in registers. + */ +#define __av_start_struct3(LIST) \ + ((LIST).flags |= __AV_REGISTER_STRUCT_RETURN, 0) +#endif +#if defined(__m68k__) || defined(__hppa__) || defined(__hppa64__) || defined(__arm64__) || defined(__ia64__) +/* Return structure pointer is passed in a special register. + */ +#define __av_start_struct4(LIST,TYPE_SIZE) 0 +#endif +/* Return structure pointer is passed as first arg. + */ +#if defined(__i386__) || defined(__alpha__) || (defined(__arm__) && !defined(__armhf__)) || defined(__powerpc_aix__) || defined(__powerpc64__) || defined(__riscv32__) || defined(__riscv64__) +#define __av_start_struct4(LIST,TYPE_SIZE) \ + (*(LIST).aptr++ = (__avword)((LIST).raddr), 0) +#endif +#if defined(__armhf__) +#define __av_start_struct4(LIST,TYPE_SIZE) \ + ((LIST).args[(LIST).ianum++] = (__avword)((LIST).raddr), 0) +#endif +#if defined(__mips__) || defined(__mipsn32__) || defined(__mips64__) || defined(__sparc64__) || defined(__x86_64_ms__) +#define __av_start_struct4(LIST,TYPE_SIZE) \ + (*(LIST).aptr++ = (__avword)((LIST).raddr), \ + (LIST).anum++, \ + 0 \ + ) +#endif +#if defined(__powerpc_sysv4__) || defined(__x86_64_sysv__) || defined(__s390__) || defined(__s390x__) +#if defined(__x86_64_x32__) +/* The x86_64 ABI, section 10.1, specifies that pointers are zero-extended + from 32 bits to 64 bits. */ +#define __av_start_struct4(LIST,TYPE_SIZE) \ + ((LIST).iargs[(LIST).ianum++] = (unsigned long long)(unsigned long)((LIST).raddr), 0) +#else +#define __av_start_struct4(LIST,TYPE_SIZE) \ + ((LIST).iargs[(LIST).ianum++] = (__avword)((LIST).raddr), 0) +#endif +#endif +#endif + + +/* + * av_ macros which specify the argument and its type + * In these macro definitions, + * 1. check the new value of (LIST).aptr against (LIST).eptr, then + * 2. modify (LIST).aptr (considering the alignment needed for the argument + * type), then store the argument. On little-endian machines and when + * there are no alignment considerations, it's also OK to store the + * argument and then modify (LIST).aptr. + */ + +/* + * scalar argument types + */ + +#if defined(__i386__) || defined(__m68k__) || (defined(__sparc__) && !defined(__sparc64__)) || defined(__alpha__) || defined(__hppa64__) || (defined(__arm__) && !defined(__armhf__)) || defined(__arm64__) || defined(__powerpc__) || defined(__powerpc64__) || defined(__ia64__) || defined(__x86_64_sysv__) || defined(__s390__) || defined(__s390x__) || defined(__riscv32__) || defined(__riscv64__) +/* Floats and all integer types are passed as words, + * doubles as two words (on 32-bit platforms) or one word (on 64-bit platforms). + */ +#define __av_word(LIST,VAL) \ + ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + ((LIST).aptr++, \ + ((LIST).aptr)[-1] = (__avword)(VAL), \ + 0)) +#endif +#if defined(__mips__) || defined(__mipsn32__) || defined(__mips64__) || defined(__sparc64__) || defined(__x86_64_ms__) +/* Most things are passed as integers: + */ +#define __av_word(LIST,VAL) \ + ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + ((LIST).aptr++, \ + ((LIST).aptr)[-1] = (__avword)(VAL), \ + (LIST).anum++, \ + 0)) +#endif +#if defined(__hppa__) && !defined(__hppa64__) +/* Floats and all integer types are passed as words, + * doubles as two words. + */ +#define __av_word(LIST,VAL) \ + ((LIST).aptr <= (LIST).eptr \ + ? -1 : \ + ((LIST).aptr--, \ + *(LIST).aptr = (__avword)(VAL), \ + 0)) +#endif +#if defined(__armhf__) +#define __av_word(LIST,VAL) \ + ((LIST).ianum < __AV_IARG_NUM \ + ? ((LIST).args[(LIST).ianum++] = (__avword)(VAL), 0) \ + : ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + ((LIST).aptr++, \ + ((LIST).aptr)[-1] = (__avword)(VAL), \ + 0))) +#endif + +/* integer argument types */ + +#if defined(__arm64__) || defined(__powerpc_sysv4__) || defined(__x86_64_sysv__) || defined(__s390__) || defined(__s390x__) +/* The first __AV_IARG_NUM integer arguments are passed in registers. */ +#define __av_long(LIST,VAL) \ + ((LIST).ianum < __AV_IARG_NUM \ + ? ((LIST).iargs[(LIST).ianum++] = (long)(VAL), 0) \ + : __av_word(LIST,(long)(VAL))) +#else +#define __av_long(LIST,VAL) __av_word(LIST,(long)(VAL)) +#endif + +#if defined(__arm64__) || defined(__powerpc_sysv4__) || defined(__x86_64_sysv__) || defined(__s390__) || defined(__s390x__) +/* The first __AV_IARG_NUM integer arguments are passed in registers. */ +#define __av_ulong(LIST,VAL) \ + ((LIST).ianum < __AV_IARG_NUM \ + ? ((LIST).iargs[(LIST).ianum++] = (unsigned long)(VAL), 0) \ + : __av_word(LIST,(unsigned long)(VAL))) +#else +#define __av_ulong(LIST,VAL) __av_word(LIST,(unsigned long)(VAL)) +#endif + +#if defined(__arm64__) || defined(__powerpc_sysv4__) || defined(__x86_64_sysv__) || defined(__s390__) || defined(__s390x__) +/* The first __AV_IARG_NUM integer arguments are passed in registers. */ +#if defined(__x86_64_x32__) +/* The x86_64 ABI, section 10.1, specifies that pointers are zero-extended + from 32 bits to 64 bits. */ +#define __av_ptr(LIST,VAL) \ + ((LIST).ianum < __AV_IARG_NUM \ + ? ((LIST).iargs[(LIST).ianum++] = (unsigned long long)(unsigned long)(VAL), 0) \ + : __av_word(LIST,(unsigned long long)(unsigned long)(VAL))) +#else +#define __av_ptr(LIST,VAL) \ + ((LIST).ianum < __AV_IARG_NUM \ + ? ((LIST).iargs[(LIST).ianum++] = (__avword)(VAL), 0) \ + : __av_word(LIST,VAL)) +#endif +#else +#define __av_ptr(LIST,VAL) __av_word(LIST,VAL) +#endif + +#if defined(__mips64__) || defined(__sparc64__) || defined(__alpha__) || defined(__hppa64__) || defined(__arm64__) || defined(__powerpc64__) || defined(__ia64__) || (defined(__x86_64__) && !defined(__x86_64_x32__) && !defined(__AV_LLP64)) || defined(__s390x__) || defined(__riscv64__) +/* ‘long long’ and ‘long’ are identical. */ +#define __av_longlong __av_long +#define __av_ulonglong __av_ulong +#elif defined(__mipsn32__) || (defined(__x86_64__) && defined(__AV_LLP64)) +/* ‘long long’ fits in __avword. */ +#define __av_longlong __av_word +#define __av_ulonglong(LIST,VAL) __av_word(LIST,(unsigned long long)(VAL)) +#elif defined(__i386__) || defined(__m68k__) || (defined(__mips__) && !defined(__mipsn32__) && !defined(__mips64__)) || (defined(__sparc__) && !defined(__sparc64__)) || (defined(__hppa__) && !defined(__hppa64__)) || defined(__arm__) || defined(__armhf__) || defined(__powerpc__) || defined(__x86_64_x32__) || (defined(__s390__) && !defined(__s390x__)) || defined(__riscv32__) +/* ‘long long’s are passed embedded on the arg stack. */ +#define __av_longlong(LIST,VAL) __av_arg_longlong(LIST,long long,VAL) +#define __av_ulonglong(LIST,VAL) __av_arg_longlong(LIST,unsigned long long,VAL) +#if defined(__i386__) || defined(__m68k__) || defined(__powerpc_aix__) +/* ‘long long’s are (at most) word-aligned. */ +#define __av_arg_longlong(LIST,TYPE,VAL) \ + ((LIST).aptr + sizeof(TYPE)/sizeof(__avword) > (LIST).eptr \ + ? -1 : \ + ((LIST).aptr += sizeof(TYPE)/sizeof(__avword), \ + ((TYPE*)(LIST).aptr)[-1] = (TYPE)(VAL), \ + 0)) +#endif +#if defined(__mips__) || (defined(__sparc__) && !defined(__sparc64__)) || (defined(__hppa__) && !defined(__hppa64__)) || defined(__arm__) || defined(__armhf__) || defined(__powerpc_sysv4__) || defined(__x86_64_x32__) || (defined(__s390__) && !defined(__s390x__)) || defined(__riscv32__) +/* ‘long long’s have alignment 4 or 8. */ +#if defined(__mips__) +#define __av_arg_longlong(LIST,TYPE,VAL) \ + ((__avword*)(((uintptr_t)(LIST).aptr+sizeof(TYPE)+__AV_alignof(TYPE)-1) & -(intptr_t)__AV_alignof(TYPE)) > (LIST).eptr \ + ? -1 : \ + (((LIST).aptr = (__avword*)(((uintptr_t)(LIST).aptr+sizeof(TYPE)+__AV_alignof(TYPE)-1) & -(intptr_t)__AV_alignof(TYPE))), \ + ((TYPE*)(LIST).aptr)[-1] = (TYPE)(VAL), \ + (LIST).anum++, \ + 0)) +#endif +#if defined(__sparc__) && !defined(__sparc64__) +/* Within the arg stack, the alignment is only 4, not 8. */ +/* This assumes sizeof(long long) == 2*sizeof(__avword). */ +#define __av_arg_longlong(LIST,TYPE,VAL) \ + ((LIST).aptr + sizeof(TYPE)/sizeof(__avword) > (LIST).eptr \ + ? -1 : \ + ((LIST).aptr += sizeof(TYPE)/sizeof(__avword), \ + (LIST).tmp._longlong = (TYPE)(VAL), \ + (LIST).aptr[-2] = (LIST).tmp.words[0], \ + (LIST).aptr[-1] = (LIST).tmp.words[1], \ + 0)) +#endif +#if (defined(__hppa__) && !defined(__hppa64__)) +#define __av_arg_longlong(LIST,TYPE,VAL) \ + ((__avword*)(((uintptr_t)(LIST).aptr & -(intptr_t)__AV_alignof(TYPE)) - sizeof(TYPE)) < (LIST).eptr \ + ? -1 : \ + ((LIST).aptr = (__avword*)(((uintptr_t)(LIST).aptr & -(intptr_t)__AV_alignof(TYPE)) - sizeof(TYPE)), \ + *(TYPE*)(LIST).aptr = (TYPE)(VAL), \ + 0)) +#endif +#if defined(__arm__) && !defined(__armhf__) +#define __av_arg_longlong(LIST,TYPE,VAL) \ + ((__avword*)(((uintptr_t)(LIST).aptr+sizeof(TYPE)+__AV_alignof(TYPE)-1) & -(intptr_t)__AV_alignof(TYPE)) > (LIST).eptr \ + ? -1 : \ + ((LIST).aptr = (__avword*)(((uintptr_t)(LIST).aptr+sizeof(TYPE)+__AV_alignof(TYPE)-1) & -(intptr_t)__AV_alignof(TYPE)), \ + ((TYPE*)(LIST).aptr)[-1] = (TYPE)(VAL), \ + 0)) +#endif +#if defined(__armhf__) +#define __av_arg_longlong(LIST,TYPE,VAL) \ + ((((LIST).ianum + sizeof(TYPE)/sizeof(__avword)+__AV_alignof(TYPE)/sizeof(__avword)-1) & -(intptr_t)(__AV_alignof(TYPE)/sizeof(__avword))) <= __AV_IARG_NUM \ + ? ((LIST).ianum = (((LIST).ianum + sizeof(TYPE)/sizeof(__avword)+__AV_alignof(TYPE)/sizeof(__avword)-1) & -(intptr_t)(__AV_alignof(TYPE)/sizeof(__avword))), \ + ((TYPE*)&(LIST).args[(LIST).ianum])[-1] = (TYPE)(VAL), \ + 0) \ + : ((LIST).aptr == &(LIST).args[__AV_IARG_NUM] \ + ? /* split case */ \ + ((__avword*)(((uintptr_t)&(LIST).args[(LIST).ianum]+sizeof(TYPE)+__AV_alignof(TYPE)-1) & -(intptr_t)__AV_alignof(TYPE)) > (LIST).eptr \ + ? -1 : \ + ((LIST).aptr = (__avword*)(((uintptr_t)&(LIST).args[(LIST).ianum]+sizeof(TYPE)+__AV_alignof(TYPE)-1) & -(intptr_t)__AV_alignof(TYPE)), \ + ((TYPE*)(LIST).aptr)[-1] = (TYPE)(VAL), \ + (LIST).ianum = __AV_IARG_NUM, \ + 0)) \ + : ((__avword*)(((uintptr_t)(LIST).aptr+sizeof(TYPE)+__AV_alignof(TYPE)-1) & -(intptr_t)__AV_alignof(TYPE)) > (LIST).eptr \ + ? -1 : \ + ((LIST).aptr = (__avword*)(((uintptr_t)(LIST).aptr+sizeof(TYPE)+__AV_alignof(TYPE)-1) & -(intptr_t)__AV_alignof(TYPE)), \ + ((TYPE*)(LIST).aptr)[-1] = (TYPE)(VAL), \ + (LIST).ianum = __AV_IARG_NUM, \ + 0)))) +#endif +#if defined(__powerpc_sysv4__) +#define __av_arg_longlong(LIST,TYPE,VAL) \ + ((((LIST).ianum + sizeof(TYPE)/sizeof(__avword)+__AV_alignof(TYPE)/sizeof(__avword)-1) & -(intptr_t)(__AV_alignof(TYPE)/sizeof(__avword))) <= __AV_IARG_NUM \ + ? ((LIST).ianum = (((LIST).ianum + sizeof(TYPE)/sizeof(__avword)+__AV_alignof(TYPE)/sizeof(__avword)-1) & -(intptr_t)(__AV_alignof(TYPE)/sizeof(__avword))), \ + ((TYPE*)&(LIST).iargs[(LIST).ianum])[-1] = (TYPE)(VAL), \ + 0) \ + : ((LIST).ianum = __AV_IARG_NUM, \ + ((__avword*)(((uintptr_t)(LIST).aptr+sizeof(TYPE)+__AV_alignof(TYPE)-1) & -(intptr_t)__AV_alignof(TYPE)) > (LIST).eptr \ + ? -1 : \ + ((LIST).aptr = (__avword*)(((uintptr_t)(LIST).aptr+sizeof(TYPE)+__AV_alignof(TYPE)-1) & -(intptr_t)__AV_alignof(TYPE)), \ + ((TYPE*)(LIST).aptr)[-1] = (TYPE)(VAL), \ + 0)))) +#endif +#if defined(__x86_64_x32__) +#define __av_arg_longlong(LIST,TYPE,VAL) \ + ((LIST).ianum < __AV_IARG_NUM \ + ? ((LIST).iargs[(LIST).ianum++] = (__avword)(TYPE)(VAL), 0) \ + : __av_word(LIST,(TYPE)(VAL))) +#endif +#if (defined(__s390__) && !defined(__s390x__)) +/* Within the arg stack, the alignment is only 4, not 8. */ +#define __av_arg_longlong(LIST,TYPE,VAL) \ + ((LIST).ianum + (sizeof(TYPE)+sizeof(__avword)-1)/sizeof(__avword) <= __AV_IARG_NUM \ + ? ((LIST).ianum += (sizeof(TYPE)+sizeof(__avword)-1)/sizeof(__avword), \ + ((TYPE*)&(LIST).iargs[(LIST).ianum])[-1] = (TYPE)(VAL), \ + 0) \ + : ((LIST).ianum = __AV_IARG_NUM, \ + ((__avword*)(((uintptr_t)(LIST).aptr+sizeof(TYPE)+sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)) > (LIST).eptr \ + ? -1 : \ + ((LIST).aptr = (__avword*)(((uintptr_t)(LIST).aptr+sizeof(TYPE)+sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)), \ + ((TYPE*)(LIST).aptr)[-1] = (TYPE)(VAL), \ + 0)))) +#endif +#if defined(__riscv32__) +/* Within the arg stack, the alignment is only 4, not 8. Also, the argument + may be put into one word in registers and one word on the stack. */ +#define __av_arg_longlong(LIST,TYPE,VAL) \ + (((__avword*)(((uintptr_t)(LIST).aptr+sizeof(TYPE)+sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)) > (LIST).eptr \ + ? -1 : \ + ((LIST).aptr = (__avword*)(((uintptr_t)(LIST).aptr+sizeof(TYPE)+sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)), \ + ((TYPE*)(LIST).aptr)[-1] = (TYPE)(VAL), \ + 0))) +#endif +#endif +#endif + +/* floating-point argument types */ + +#if defined(__i386__) || defined(__m68k__) || (defined(__sparc__) && !defined(__sparc64__)) + +#define _av_float(LIST,VAL) \ + ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + ((LIST).aptr++, \ + ((float*)(LIST).aptr)[-1] = (float)(VAL), \ + 0)) + +/* This assumes sizeof(double) == 2*sizeof(__avword). */ +#define _av_double(LIST,VAL) \ + ((LIST).aptr + 2 > (LIST).eptr \ + ? -1 : \ + ((LIST).aptr += 2, \ + (LIST).tmp._double = (double)(VAL), \ + (LIST).aptr[-2] = (LIST).tmp.words[0], \ + (LIST).aptr[-1] = (LIST).tmp.words[1], \ + 0)) + +#endif + +#if defined(__mips__) && !defined(__mipsn32__) && !defined(__mips64__) + +/* Up to 2 leading float or double non-varargs args can be passed in + * float registers, but we also push them into the corresponding int + * registers in case of varargs. For doubles we need to align the aptr + * to an even boundary. + */ +#define _av_float(LIST,VAL) \ + ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + ((LIST).aptr++, \ + ((LIST).anum == (LIST).fanum && (LIST).fanum < __AV_FARG_NUM \ + ? /* only floating-point arguments so far */ \ + ((LIST).farg_mask |= (unsigned int) 1 << (LIST).fanum, \ + (LIST).fargs[(LIST).fanum] = ((float*)(LIST).aptr)[-1] = (float)(VAL), \ + (LIST).fanum++, \ + 0) \ + : (((float*)(LIST).aptr)[-1] = (float)(VAL), \ + 0)), \ + (LIST).anum++, \ + 0)) + +#define _av_double(LIST,VAL) \ + ((__avword*)(((uintptr_t)(LIST).aptr+15)&-8) > (LIST).eptr \ + ? -1 : \ + ((LIST).aptr = (__avword*)(((uintptr_t)(LIST).aptr+15)&-8), \ + ((LIST).anum == (LIST).fanum && (LIST).fanum < __AV_FARG_NUM \ + ? /* only floating-point arguments so far */ \ + ((LIST).darg_mask |= (unsigned int) 1 << (LIST).fanum, \ + (LIST).dargs[(LIST).fanum] = ((double*)(LIST).aptr)[-1] = (double)(VAL), \ + (LIST).fanum++, \ + 0) \ + : (((double*)(LIST).aptr)[-1] = (double)(VAL), \ + 0)), \ + (LIST).anum++, \ + 0)) + +#endif + +#if defined(__mipsn32__) || defined(__mips64__) + +/* Up to 8 leading float or double non-varargs args can be passed in + * float registers, but we also push them into the corresponding int + * registers in case of varargs. + */ +#define _av_float(LIST,VAL) \ + ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + (((LIST).anum < 8 \ + ? ((LIST).farg_mask |= (1 << (LIST).anum), \ + (LIST).fargs[(LIST).anum] = *(float*)(LIST).aptr = (float)(VAL)) \ + : (*(float*)(LIST).aptr = (float)(VAL))), \ + (LIST).anum++, \ + (LIST).aptr++, \ + 0)) + +#define _av_double(LIST,VAL) \ + ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + (((LIST).anum < 8 && ((LIST).darg_mask |= (1 << (LIST).anum))), \ + *(double*)(LIST).aptr = (double)(VAL), \ + (LIST).anum++, \ + (LIST).aptr++, \ + 0)) + +#endif + +#if defined(__sparc64__) + +/* Up to 16 leading float or double non-varargs args can be passed in + * float registers, but we also push them into the corresponding int + * registers in case of varargs. + */ +#define _av_float(LIST,VAL) \ + ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + ((LIST).aptr++, \ + ((LIST).anum < 16 && ((LIST).darg_mask |= (1 << (LIST).anum))), \ + (((float*)(LIST).aptr)[-1] = (float)(VAL)), \ + (LIST).anum++, \ + 0)) + +#define _av_double(LIST,VAL) \ + ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + ((LIST).aptr++, \ + ((LIST).anum < 16 && ((LIST).darg_mask |= (1 << (LIST).anum))), \ + ((double*)(LIST).aptr)[-1] = (double)(VAL), \ + (LIST).anum++, \ + 0)) + +#endif + +#if defined(__alpha__) + +#define _av_double(LIST,VAL) \ + ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + ((LIST).aptr++, \ + ((double*)(LIST).aptr)[-1] = (double)(VAL), \ + 0)) + +#define _av_float(LIST,VAL) \ + ((LIST).aptr >= (LIST).eptr \ + ? -1 \ + : ((LIST).aptr++, \ + ((LIST).aptr > &(LIST).args[6] \ + ? /* These args will be fetched from memory using "lds" instructions */ \ + /* therefore store them as floats */ \ + (*(float*)((LIST).aptr-1) = (float)(VAL)) \ + : /* The first 6 args will be put into registers by "ldt" instructions */ \ + /* (see avcall-alpha.c!). Therefore store them as doubles. */ \ + /* When viewed as floats, the value will be the correct one. */\ + (*(double*)((LIST).aptr-1) = (double)(float)(VAL))), \ + 0)) + +#endif + +#if defined(__hppa__) && !defined(__hppa64__) + +#define _av_float(LIST,VAL) \ + ((LIST).aptr <= (LIST).eptr \ + ? -1 : \ + ((LIST).aptr--, \ + ((LIST).aptr >= &(LIST).args_end[-4] \ + ? ((LIST).farg_mask |= (unsigned int)1 << ((LIST).args_end - (LIST).aptr - 1), 0) \ + : 0), \ + *(float*)(LIST).aptr = (float)(VAL), \ + 0)) + +#define _av_double(LIST,VAL) \ + ((__avword*)(((uintptr_t)(LIST).aptr-sizeof(double)) & -(intptr_t)sizeof(double)) < (LIST).eptr \ + ? -1 : \ + ((LIST).aptr = (__avword*)(((uintptr_t)(LIST).aptr-sizeof(double)) & -(intptr_t)sizeof(double)), \ + ((LIST).aptr >= &(LIST).args_end[-4] \ + ? ((LIST).darg_mask |= (unsigned int)1 << ((LIST).args_end - (LIST).aptr - 1), 0) \ + : 0), \ + *(double*)(LIST).aptr = (double)(VAL), \ + 0)) + +#endif + +#if defined(__hppa64__) + +#define _av_float(LIST,VAL) \ + ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + (((LIST).aptr < &(LIST).args[8] \ + ? ((LIST).farg_mask |= (unsigned int)1 << ((LIST).aptr - (LIST).args), 0) \ + : 0), \ + (LIST).aptr++, \ + ((float*)(LIST).aptr)[-1] = (float)(VAL), \ + 0)) + +#define _av_double(LIST,VAL) \ + ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + (((LIST).aptr < &(LIST).args[8] \ + ? ((LIST).darg_mask |= (unsigned int)1 << ((LIST).aptr - (LIST).args), 0) \ + : 0), \ + (LIST).aptr++, \ + ((double*)(LIST).aptr)[-1] = (double)(VAL), \ + 0)) + +#endif + +#if defined(__arm__) && !defined(__armhf__) + +#define _av_float(LIST,VAL) \ + ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + ((LIST).aptr++, \ + ((float*)(LIST).aptr)[-1] = (float)(VAL), \ + 0)) + +#define _av_double(LIST,VAL) \ + ((__avword*)(((uintptr_t)(LIST).aptr + 15) & -8) > (LIST).eptr \ + ? -1 : \ + ((LIST).aptr = (__avword*)(((uintptr_t)(LIST).aptr + 15) & -8), \ + (LIST).tmp._double = (double)(VAL), \ + (LIST).aptr[-2] = (LIST).tmp.words[0], \ + (LIST).aptr[-1] = (LIST).tmp.words[1], \ + 0)) + +#endif + +#if defined(__armhf__) + +/* Up to 16 float or up to 8 double args can be passed in float registers. + * But they overlap: {s0,s1} = d0, {s2,s3} = d1, and so on. + */ +#define _av_float(LIST,VAL) \ + ((LIST).fanum <= 15 \ + ? ((LIST).fargs[(LIST).fanum] = (float)(VAL), \ + (LIST).farg_mask |= ((unsigned int) 1) << (LIST).fanum, \ + (LIST).fanum++, \ + 0) \ + : ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + ((*(float*)(LIST).aptr = (float)(VAL)), \ + (LIST).aptr++, \ + 0))) + +#define _av_double(LIST,VAL) \ + (((LIST).fanum % 2 ? ((LIST).fanum++, 0) : 0), \ + ((LIST).fanum <= 14 \ + ? ((LIST).dargs[(LIST).fanum / 2] = (double)(VAL), \ + (LIST).darg_mask |= ((unsigned int) 1) << ((LIST).fanum / 2), \ + (LIST).fanum += 2, \ + 0) \ + : ((LIST).aptr + 2 > (LIST).eptr \ + ? -1 : \ + ((*(double*)(LIST).aptr = (double)(VAL)), \ + (LIST).aptr += 2, \ + 0)))) + +#endif + +#if defined(__arm64__) || defined(__riscv64__) + +/* Up to __AV_FARG_NUM float or double args can be passed in float registers. + The remaining float or double args are passed in the general-purpose + argument sequence (first the integer registers, then the stack.) */ +#define _av_float(LIST,VAL) \ + ((LIST).fanum < __AV_FARG_NUM \ + ? ((LIST).fargs[(LIST).fanum] = (float)(VAL), \ + (LIST).farg_mask |= ((unsigned int) 1) << (LIST).fanum, \ + (LIST).fanum++, \ + 0) \ + : ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + ((*(float*)(LIST).aptr = (float)(VAL)), \ + (LIST).aptr++, \ + 0))) + +#define _av_double(LIST,VAL) \ + ((LIST).fanum < __AV_FARG_NUM \ + ? ((LIST).dargs[(LIST).fanum] = (double)(VAL), \ + (LIST).darg_mask |= ((unsigned int) 1) << (LIST).fanum, \ + (LIST).fanum++, \ + 0) \ + : ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + ((*(double*)(LIST).aptr = (double)(VAL)), \ + (LIST).aptr++, \ + 0))) + +#endif + +#if defined(__powerpc_aix__) + +/* Up to __AV_FARG_NUM float or double non-varargs args can be passed in + * float registers, but we also push them into the corresponding int + * registers in case of varargs. + */ + +#define _av_float(LIST,VAL) \ + ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + ((LIST).aptr++, \ + ((float*)(LIST).aptr)[-1] = (float)(VAL), \ + (LIST).faptr < &(LIST).fargs[__AV_FARG_NUM] && (*(LIST).faptr++ = (double)(float)(VAL)), \ + 0)) + +#define _av_double(LIST,VAL) \ + ((LIST).aptr + 2 > (LIST).eptr \ + ? -1 : \ + ((LIST).aptr += 2, \ + (LIST).tmp._double = (double)(VAL), \ + (LIST).aptr[-2] = (LIST).tmp.words[0], \ + (LIST).aptr[-1] = (LIST).tmp.words[1], \ + (LIST).faptr < &(LIST).fargs[__AV_FARG_NUM] && (*(LIST).faptr++ = (LIST).tmp._double), \ + 0)) + +#endif + +#if defined(__powerpc_sysv4__) + +/* Up to __AV_FARG_NUM float or double non-varargs args can be passed in + * float registers, without occupying space in the general registers. + */ + +#define _av_float(LIST,VAL) \ + ((LIST).faptr < &(LIST).fargs[__AV_FARG_NUM] \ + ? ((*(LIST).faptr++ = (double)(float)(VAL)), 0) \ + : ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + ((LIST).aptr++, \ + ((float*)(LIST).aptr)[-1] = (float)(VAL), \ + 0))) + +#define _av_double(LIST,VAL) \ + ((LIST).faptr < &(LIST).fargs[__AV_FARG_NUM] \ + ? ((*(LIST).faptr++ = (double)(VAL)), 0) \ + : ((LIST).aptr + 2 > (LIST).eptr \ + ? -1 : \ + ((LIST).aptr += 2, \ + (LIST).tmp._double = (double)(VAL), \ + (LIST).aptr[-2] = (LIST).tmp.words[0], \ + (LIST).aptr[-1] = (LIST).tmp.words[1], \ + 0))) + +#endif + +#if defined(__powerpc64__) + +/* Up to __AV_FARG_NUM float or double non-varargs args can be passed in + * float registers, but we also push them into the corresponding int + * registers in case of varargs. + */ + +#if defined(_AIX) +#define _av_float(LIST,VAL) \ + ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + ((LIST).aptr++, \ + ((float*)(LIST).aptr)[(LIST).flags & __AV_AIXCC_FLOAT_ARGS ? -2 : -1] = (float)(VAL), \ + (LIST).faptr < &(LIST).fargs[__AV_FARG_NUM] && (*(LIST).faptr++ = (double)(float)(VAL)), \ + 0)) +#elif defined(_LITTLE_ENDIAN) +#define _av_float(LIST,VAL) \ + ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + ((LIST).aptr++, \ + ((float*)(LIST).aptr)[-2] = (float)(VAL), \ + (LIST).faptr < &(LIST).fargs[__AV_FARG_NUM] && (*(LIST).faptr++ = (double)(float)(VAL)), \ + 0)) +#else /* _BIG_ENDIAN */ +#define _av_float(LIST,VAL) \ + ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + ((LIST).aptr++, \ + ((float*)(LIST).aptr)[-1] = (float)(VAL), \ + (LIST).faptr < &(LIST).fargs[__AV_FARG_NUM] && (*(LIST).faptr++ = (double)(float)(VAL)), \ + 0)) +#endif + +#define _av_double(LIST,VAL) \ + ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + ((LIST).aptr++, \ + ((double*)(LIST).aptr)[-1] = (double)(VAL), \ + (LIST).faptr < &(LIST).fargs[__AV_FARG_NUM] && (*(LIST).faptr++ = (double)(VAL)), \ + 0)) + +#endif + +#if defined(__ia64__) + +/* Up to 8 leading float or double non-varargs args can be passed in + * float registers, but we also push them into the corresponding int + * registers in case of varargs. + */ +#define _av_float(LIST,VAL) \ + ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + ((*(float*)(LIST).aptr = (float)(VAL)), \ + ((LIST).faptr < &(LIST).fargs[__AV_FARG_NUM] && (*(LIST).faptr = *(float*)(LIST).aptr, (LIST).faptr++)), \ + (LIST).aptr++, \ + 0)) + +#define _av_double(LIST,VAL) \ + ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + (*(double*)(LIST).aptr = (double)(VAL), \ + ((LIST).faptr < &(LIST).fargs[__AV_FARG_NUM] && (*(LIST).faptr = *(double*)(LIST).aptr, (LIST).faptr++)), \ + (LIST).aptr++, \ + 0)) + +#endif + +#if defined(__x86_64_sysv__) + +/* Up to 8 leading float or double args can be passed in float registers. + */ +#define _av_float(LIST,VAL) \ + ((LIST).faptr < &(LIST).fargs[__AV_FARG_NUM] \ + ? (*(LIST).faptr = 0.0, *(float*)(LIST).faptr = (float)(VAL), \ + (LIST).faptr++, \ + 0) \ + : ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + ((*(float*)(LIST).aptr = (float)(VAL)), \ + (LIST).aptr++, \ + 0))) + +#define _av_double(LIST,VAL) \ + ((LIST).faptr < &(LIST).fargs[__AV_FARG_NUM] \ + ? (*(LIST).faptr = (double)(VAL), \ + (LIST).faptr++, \ + 0) \ + : ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + ((*(double*)(LIST).aptr = (double)(VAL)), \ + (LIST).aptr++, \ + 0))) + +#endif + +#if defined(__x86_64_ms__) + +/* The float or double args among the first 4 argument words are passed + * in floating-point registers, but we also push them into the + * corresponding integer registers in case of varargs. + */ +#define _av_float(LIST,VAL) \ + ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + (((LIST).anum < 4 \ + ? ((LIST).farg_mask |= (1 << (LIST).anum), \ + (LIST).fargs[(LIST).anum] = *(float*)(LIST).aptr = (float)(VAL)) \ + : (*(float*)(LIST).aptr = (float)(VAL))), \ + (LIST).anum++, \ + (LIST).aptr++, \ + 0)) + +#define _av_double(LIST,VAL) \ + ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + (((LIST).anum < 4 \ + ? ((LIST).darg_mask |= (1 << (LIST).anum), \ + (LIST).dargs[(LIST).anum] = *(double*)(LIST).aptr = (double)(VAL)) \ + : (*(double*)(LIST).aptr = (double)(VAL))), \ + (LIST).anum++, \ + (LIST).aptr++, \ + 0)) + +#endif + +#if defined(__s390__) && !defined(__s390x__) + +/* Up to 2 float or double non-varargs args can be passed in + * float registers, without occupying space in the general registers. + */ + +#define _av_float(LIST,VAL) \ + ((LIST).fanum < __AV_FARG_NUM \ + ? ((LIST).fargs[(LIST).fanum] = (float)(VAL), \ + (LIST).farg_mask |= ((unsigned int) 1) << (LIST).fanum, \ + (LIST).fanum++, \ + 0) \ + : ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + ((LIST).aptr++, \ + ((float*)(LIST).aptr)[-1] = (float)(VAL), \ + 0))) + +#define _av_double(LIST,VAL) \ + ((LIST).fanum < __AV_FARG_NUM \ + ? ((LIST).dargs[(LIST).fanum] = (double)(VAL), \ + (LIST).darg_mask |= ((unsigned int) 1) << (LIST).fanum, \ + (LIST).fanum++, \ + 0) \ + : ((LIST).aptr + 2 > (LIST).eptr \ + ? -1 : \ + ((LIST).aptr += 2, \ + (LIST).tmp._double = (double)(VAL), \ + (LIST).aptr[-2] = (LIST).tmp.words[0], \ + (LIST).aptr[-1] = (LIST).tmp.words[1], \ + 0))) + +#endif + +#if defined(__s390x__) + +/* Up to __AV_FARG_NUM float or double args can be passed in float registers. */ +#define _av_float(LIST,VAL) \ + ((LIST).fanum < __AV_FARG_NUM \ + ? ((LIST).fargs[(LIST).fanum] = (float)(VAL), \ + (LIST).farg_mask |= ((unsigned int) 1) << (LIST).fanum, \ + (LIST).fanum++, \ + 0) \ + : ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + ((LIST).aptr++, \ + ((float*)(LIST).aptr)[-1] = (float)(VAL), \ + 0))) + +#define _av_double(LIST,VAL) \ + ((LIST).fanum < __AV_FARG_NUM \ + ? ((LIST).dargs[(LIST).fanum] = (double)(VAL), \ + (LIST).darg_mask |= ((unsigned int) 1) << (LIST).fanum, \ + (LIST).fanum++, \ + 0) \ + : ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + ((*(double*)(LIST).aptr = (double)(VAL)), \ + (LIST).aptr++, \ + 0))) + +#endif + +#if defined(__riscv32__) + +/* Up to __AV_FARG_NUM float or double args can be passed in float registers. + The remaining float or double args are passed in the general-purpose + argument sequence (first the integer registers, then the stack.) */ +#define _av_float(LIST,VAL) \ + ((LIST).fanum < __AV_FARG_NUM \ + ? ((LIST).fargs[(LIST).fanum] = (float)(VAL), \ + (LIST).farg_mask |= ((unsigned int) 1) << (LIST).fanum, \ + (LIST).fanum++, \ + 0) \ + : ((LIST).aptr >= (LIST).eptr \ + ? -1 : \ + ((*(float*)(LIST).aptr) = (float)(VAL), \ + (LIST).aptr++, \ + 0))) + +#define _av_double(LIST,VAL) \ + ((LIST).fanum < __AV_FARG_NUM \ + ? ((LIST).dargs[(LIST).fanum] = (double)(VAL), \ + (LIST).darg_mask |= ((unsigned int) 1) << (LIST).fanum, \ + (LIST).fanum++, \ + 0) \ + : ((LIST).aptr + 2 > (LIST).eptr \ + ? -1 : \ + ((LIST).aptr += 2, \ + (LIST).tmp._double = (double)(VAL), \ + (LIST).aptr[-2] = (LIST).tmp.words[0], \ + (LIST).aptr[-1] = (LIST).tmp.words[1], \ + 0))) + +#endif + +/* + * structure argument types + */ + +extern void avcall_structcpy (void* dest, const void* src, unsigned long size, unsigned long alignment); + +#define __av_struct_copy(TYPE_SIZE,TYPE_ALIGN,PLACE,VAL_ADDR) \ + avcall_structcpy(PLACE,VAL_ADDR,TYPE_SIZE,TYPE_ALIGN) + +/* Structure argument alignment. */ +#if defined(__i386__) && defined(_MSC_VER) +/* In MSVC, doubles inside structures have alignment 8, i.e. + * __AV_alignof(double) = 8, but doubles (and also structures containing + * doubles) are passed on the stack with alignment 4. Looks really weird. + */ +#define __av_struct_alignment(TYPE_ALIGN) \ + ((TYPE_ALIGN) <= 4 ? (TYPE_ALIGN) : 4) +#else +#define __av_struct_alignment(TYPE_ALIGN) \ + (TYPE_ALIGN) +#endif +#if defined(__i386__) || defined(__mips__) || defined(__mipsn32__) || defined(__mips64__) || defined(__alpha__) || defined(__hppa64__) || defined(__arm__) || defined(__armhf__) || defined(__powerpc_aix__) || defined(__powerpc64__) || defined(__ia64__) +/* Structures are passed as fully aligned structures on the arg stack. + * We align the aptr, store the structure, then fill to word alignment. + * Single-small-integer structures are NOT promoted to integers and have + * different alignment. + */ +/* little endian -> small structures < 1 word are adjusted to the left (i.e. occupy the low bits of the word) */ +#if defined(__i386__) || defined(__alpha__) || (defined(__arm__) && !defined(__armhf__) && defined(__ARMEL__)) +#define __av_struct(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + ((__avword*)(((uintptr_t)(LIST).aptr+(TYPE_SIZE)+__av_struct_alignment(TYPE_ALIGN)-1) & -(intptr_t)__av_struct_alignment(TYPE_ALIGN)) > (LIST).eptr \ + ? -1 : \ + (__av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+__av_struct_alignment(TYPE_ALIGN)-1) & -(intptr_t)__av_struct_alignment(TYPE_ALIGN)) - (TYPE_SIZE)),VAL), \ + (LIST).aptr = (__avword*)(((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+__av_struct_alignment(TYPE_ALIGN)-1) & -(intptr_t)__av_struct_alignment(TYPE_ALIGN)) +sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)), \ + 0)) +#endif +#if defined(__ia64__) +/* With GCC < 3, types larger than a word have 2-word alignment. */ +#define __av_struct(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + (((LIST).flags & __AV_OLDGCC_STRUCT_ARGS) \ + ? ((LIST).aptr = (__avword*)(((uintptr_t)(LIST).aptr+(TYPE_SIZE)+__av_struct_alignment(TYPE_ALIGN)-1) & -(intptr_t)__av_struct_alignment(TYPE_ALIGN)), \ + ((TYPE_SIZE) > sizeof(__avword) && (((LIST).aptr - &(LIST).args[0]) & 1) ? ++(LIST).aptr : 0), \ + ((LIST).aptr > (LIST).eptr \ + ? -1 : \ + (__av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)((uintptr_t)(LIST).aptr-(TYPE_SIZE)),VAL), \ + (LIST).aptr = (__avword*)(((uintptr_t)(LIST).aptr+sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)), \ + 0))) \ + : ((__avword*)(((uintptr_t)(LIST).aptr+(TYPE_SIZE)+__av_struct_alignment(TYPE_ALIGN)-1) & -(intptr_t)__av_struct_alignment(TYPE_ALIGN)) > (LIST).eptr \ + ? -1 : \ + (__av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+__av_struct_alignment(TYPE_ALIGN)-1) & -(intptr_t)__av_struct_alignment(TYPE_ALIGN)) - (TYPE_SIZE)),VAL), \ + (LIST).aptr = (__avword*)(((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+__av_struct_alignment(TYPE_ALIGN)-1) & -(intptr_t)__av_struct_alignment(TYPE_ALIGN)) +sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)), \ + 0))) +#endif +/* small structures < 1 word are adjusted depending on compiler */ +#if defined(__mips__) && !defined(__mipsn32__) && !defined(__mips64__) +#define __av_struct_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + ((__avword*)(((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) > (LIST).eptr \ + ? -1 : \ + (++(LIST).anum, \ + __av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) - (TYPE_SIZE)),VAL), \ + (LIST).aptr = (__avword*)(((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) +sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)), \ + 0)) +#define __av_struct_rightadjusted(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + ((__avword*)(((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) + sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)) > (LIST).eptr \ + ? -1 : \ + ((LIST).aptr = (__avword*)(((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) + sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)), \ + ++(LIST).anum, \ + __av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)((uintptr_t)(LIST).aptr-(TYPE_SIZE)),VAL),\ + 0)) +#define __av_struct(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + ((LIST).flags & __AV_SGICC_STRUCT_ARGS \ + ? /* SGI MIPS cc passes small structures left-adjusted, although big-endian! */\ + __av_struct_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + : /* SGI MIPS gcc passes small structures within the first four words left- \ + * adjusted, for compatibility with cc. But structures in memory are passed \ + * right-adjusted!! See gcc-2.6.3/config/mips/mips.c:function_arg(). \ + */ \ + ((LIST).aptr < &(LIST).args[4] \ + ? __av_struct_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + : __av_struct_rightadjusted(LIST,TYPE_SIZE,TYPE_ALIGN,VAL))) +#endif +#if defined(__mipsn32__) || defined(__mips64__) +/* When a structure is passed (partially) in registers, it is passed in the + * integer registers, except that doubles within the structure are passed in + * the floating point registers. Instead of distinguishing these cases, we + * always pass the structure in both the integer and the floating point + * registers. + */ +#define __av_struct_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + ((__avword*)(((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) > (LIST).eptr \ + ? -1 : \ + (__av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) - (TYPE_SIZE)),VAL), \ + (LIST).aptr = (__avword*)(((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) +sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)), \ + ((LIST).anum < 8 && ((LIST).darg_mask |= (-1 << (LIST).anum))), \ + (LIST).anum += (((((TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) + sizeof(__avword)-1) & -(intptr_t)sizeof(__avword))/sizeof(__avword), \ + (LIST).darg_mask &= (1 << ((LIST).anum < 8 ? (LIST).anum : 8)) - 1, \ + 0)) +#define __av_struct_rightadjusted(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + ((__avword*)(((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) + sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)) > (LIST).eptr \ + ? -1 : \ + ((LIST).aptr = (__avword*)(((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) + sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)), \ + __av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)((uintptr_t)(LIST).aptr-(TYPE_SIZE)),VAL), \ + ((LIST).anum < 8 && ((LIST).darg_mask |= (-1 << (LIST).anum))), \ + (LIST).anum += (((((TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) + sizeof(__avword)-1) & -(intptr_t)sizeof(__avword))/sizeof(__avword), \ + (LIST).darg_mask &= (1 << ((LIST).anum < 8 ? (LIST).anum : 8)) - 1, \ + 0)) +#define __av_struct(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + ((LIST).flags & __AV_SGICC_STRUCT_ARGS \ + ? /* SGI MIPS cc and gcc >= 3.4 passes small structures left-adjusted, although big-endian! */\ + __av_struct_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + : /* SGI MIPS gcc < 3.4 passes small structures right-adjusted. */ \ + __av_struct_rightadjusted(LIST,TYPE_SIZE,TYPE_ALIGN,VAL)) +#endif +#if (defined(__armhf__) && defined(__ARMEL__)) +#define __av_struct(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + ((((LIST).ianum*sizeof(__avword)+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) <= __AV_IARG_NUM*sizeof(__avword) \ + ? ((LIST).ianum += (((((TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) + sizeof(__avword)-1) & -(intptr_t)sizeof(__avword))/sizeof(__avword), \ + __av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)((uintptr_t)&(LIST).args[(LIST).ianum]-(TYPE_SIZE)),VAL), \ + 0) \ + : ((LIST).aptr == &(LIST).args[__AV_IARG_NUM] \ + ? /* split case */ \ + ((__avword*)(((((uintptr_t)&(LIST).args[(LIST).ianum]+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) + sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)) > (LIST).eptr \ + ? -1 : \ + (__av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)((((uintptr_t)&(LIST).args[(LIST).ianum]+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) - (TYPE_SIZE)),VAL), \ + (LIST).aptr = (__avword*)(((((uintptr_t)&(LIST).args[(LIST).ianum]+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) + sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)), \ + (LIST).ianum = __AV_IARG_NUM, \ + 0)) \ + : ((__avword*)(((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) + sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)) > (LIST).eptr \ + ? -1 : \ + (__av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) - (TYPE_SIZE)),VAL), \ + (LIST).aptr = (__avword*)(((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) + sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)), \ + (LIST).ianum = __AV_IARG_NUM, \ + 0)))) +#endif +#if defined(__powerpc__) || defined(__powerpc64__) +#define __av_struct_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + ((__avword*)(((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) > (LIST).eptr \ + ? -1 : \ + (__av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) - (TYPE_SIZE)),VAL), \ + (LIST).aptr = (__avword*)(((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) +sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)), \ + 0)) +#define __av_struct_rightadjusted(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + ((__avword*)(((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) + sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)) > (LIST).eptr \ + ? -1 : \ + ((LIST).aptr = (__avword*)(((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) + sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)), \ + __av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)((uintptr_t)(LIST).aptr-(TYPE_SIZE)),VAL), \ + 0)) +#if (defined(__powerpc__) && !defined(__powerpc64__)) || (defined(__powerpc64__) && defined(_BIG_ENDIAN)) +#define __av_struct(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + ((LIST).flags & __AV_AIXCC_STRUCT_ARGS \ + ? /* AIX cc and xlc pass small structures left-adjusted, although big-endian! */\ + __av_struct_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + : /* gcc passes small structures right-adjusted. */ \ + __av_struct_rightadjusted(LIST,TYPE_SIZE,TYPE_ALIGN,VAL)) +#endif +#if (defined(__powerpc64__) && defined(_LITTLE_ENDIAN)) +#define __av_struct(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + __av_struct_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) +#endif +#endif +/* big endian -> small structures < 1 word are adjusted to the right (i.e. occupy the high bits of the word) */ +#if (defined(__arm__) && !defined(__armhf__) && !defined(__ARMEL__)) +#define __av_struct(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + ((__avword*)(((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) + sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)) > (LIST).eptr \ + ? -1 : \ + ((LIST).aptr = (__avword*)(((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) + sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)), \ + __av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)((uintptr_t)(LIST).aptr-(TYPE_SIZE)),VAL), \ + 0)) +#endif +#if (defined(__armhf__) && !defined(__ARMEL__)) +#define __av_struct(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + ((((LIST).ianum*sizeof(__avword)+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) <= __AV_IARG_NUM*sizeof(__avword) \ + ? ((LIST).ianum += (((((TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) + sizeof(__avword)-1) & -(intptr_t)sizeof(__avword))/sizeof(__avword), \ + __av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)((uintptr_t)&(LIST).args[(LIST).ianum]-(TYPE_SIZE)),VAL), \ + 0) \ + : ((LIST).aptr == &(LIST).args[__AV_IARG_NUM] \ + ? /* split case */ \ + ((__avword*)(((((uintptr_t)&(LIST).args[(LIST).ianum]+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) + sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)) > (LIST).eptr \ + ? -1 : \ + ((LIST).aptr = (__avword*)(((((uintptr_t)&(LIST).args[(LIST).ianum]+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) + sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)), \ + __av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)((uintptr_t)(LIST).aptr-(TYPE_SIZE)),VAL), \ + (LIST).ianum = __AV_IARG_NUM, \ + 0)) \ + : ((__avword*)(((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) + sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)) > (LIST).eptr \ + ? -1 : \ + ((LIST).aptr = (__avword*)(((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) + sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)), \ + __av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)((uintptr_t)(LIST).aptr-(TYPE_SIZE)),VAL), \ + (LIST).ianum = __AV_IARG_NUM, \ + 0)))) +#endif +#if defined(__hppa64__) +/* Structures are passed left-adjusted (although big-endian!). */ +#define __av_struct_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + ((__avword*)(((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) > (LIST).eptr \ + ? -1 : \ + (__av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) - (TYPE_SIZE)),VAL), \ + (LIST).aptr = (__avword*)(((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) +sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)), \ + 0)) +#define __av_struct(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + __av_struct_leftadjusted(LIST,TYPE_SIZE,(TYPE_SIZE)>sizeof(__avword)?2*sizeof(__avword):(TYPE_ALIGN),VAL) +#endif +#endif +#if defined(__m68k__) +/* Structures are passed as embedded copies on the arg stack. + */ +#define __av_struct(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + ((__avword*)(((uintptr_t)(LIST).aptr+(TYPE_SIZE)+sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)) > (LIST).eptr \ + ? -1 : \ + ((LIST).aptr = (__avword*)(((uintptr_t)(LIST).aptr+(TYPE_SIZE)+sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)), \ + __av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)((uintptr_t)(LIST).aptr-(TYPE_SIZE)),VAL),\ + 0)) +#endif +#if (defined(__sparc__) && !defined(__sparc64__)) +/* Structures are passed as pointers to caller-made local copies. We + * grab space for the copies from the end of the argument list space + * and always use maximal (double) alignment. + */ +#define __av_struct(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + (++(LIST).aptr \ + > ((LIST).eptr = (__avword*)((uintptr_t)(LIST).eptr - (((TYPE_SIZE)+7)&-8)))\ + ? -1 : \ + (__av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)(LIST).eptr,VAL), \ + (LIST).aptr[-1] = (__avword)(LIST).eptr, \ + 0)) +#endif +#if defined(__sparc64__) +/* Structures <= 16 bytes are passed as embedded copies on the arg stack, + * left-adjusted (although big-endian!). + * When a structure is passed (partially) in registers, it is passed in the + * integer registers, except that floats and doubles within the structure + * are passed in the floating point registers. Instead of distinguishing + * these cases, we always pass the structure in both the integer and the + * floating point registers. + * Big structures are passed as pointers to caller-made local copies. + * FIXME: Shouldn't (LIST).anum be incremented in sync with (LIST).aptr ? + */ +#define __av_struct(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + ((TYPE_SIZE) > 16 \ + ? (++(LIST).aptr \ + > ((LIST).eptr = (__avword*)((uintptr_t)(LIST).eptr - (((TYPE_SIZE)+7)&-8)))\ + ? -1 : \ + (__av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)(LIST).eptr,VAL), \ + (LIST).aptr[-1] = (__avword)(LIST).eptr, \ + 0)) \ + : ((__avword*)(((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) > (LIST).eptr \ + ? -1 : \ + (__av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) - (TYPE_SIZE)),VAL), \ + (LIST).aptr = (__avword*)(((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) +sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)), \ + ((LIST).anum < 16 && ((LIST).darg_mask |= (-1 << (LIST).anum))), \ + (LIST).anum += (((((TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) + sizeof(__avword)-1) & -(intptr_t)sizeof(__avword))/sizeof(__avword), \ + (LIST).darg_mask &= (1 << ((LIST).anum < 16 ? (LIST).anum : 16)) - 1, \ + 0))) +#endif +#if defined(__hppa__) && !defined(__hppa64__) +/* Structures <= 8 bytes are passed as embedded copies on the arg stack. + * Big structures are passed as pointers (to caller-made local copies + * with GCC >= 8, without copy otherwise). + */ +#define __av_struct(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + ((TYPE_SIZE) > 8 \ + ? (--(LIST).aptr \ + < ((LIST).eptr = (__avword*)((uintptr_t)(LIST).eptr + (((TYPE_SIZE) + 7) & -8))) \ + ? -1 \ + : (__av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)((uintptr_t)(LIST).eptr - (((TYPE_SIZE) + 7) & -8)), VAL), \ + *(LIST).aptr = (__avword)((uintptr_t)(LIST).eptr - (((TYPE_SIZE) + 7) & -8)), \ + 0)) \ + : ((TYPE_SIZE) > 4 \ + ? ((__avword*)((((uintptr_t)(LIST).aptr & -8) - (intptr_t)(TYPE_SIZE)) & -8) < (LIST).eptr \ + ? -1 : \ + ((LIST).aptr = (__avword*)((((uintptr_t)(LIST).aptr & -8) - (intptr_t)(TYPE_SIZE)) & -8), \ + __av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)(LIST).aptr,VAL), \ + 0)) \ + : /* FIXME: gcc-2.6.3 passes structures <= 4 bytes in memory left-adjusted! ?? */\ + ((__avword*)(((uintptr_t)(LIST).aptr & -4) - (intptr_t)(TYPE_SIZE)) < (LIST).eptr \ + ? -1 : \ + (__av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)(((uintptr_t)(LIST).aptr & -4) - (intptr_t)(TYPE_SIZE)),VAL), \ + (LIST).aptr = (__avword*)((((uintptr_t)(LIST).aptr & -4) - (intptr_t)(TYPE_SIZE)) & -4), \ + 0)))) +#endif +#if defined(__arm64__) +/* Structures <= 16 bytes are passed as embedded copies on the arg stack. + * Big structures are passed as pointers to caller-made local copies. + */ +#define __av_struct(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + ((TYPE_SIZE) <= 16 \ + ? ((((LIST).ianum*sizeof(__avword)+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) <= __AV_IARG_NUM*sizeof(__avword) \ + ? (__av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)&(LIST).iargs[(LIST).ianum],VAL), \ + (LIST).ianum += (((((TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) + sizeof(__avword)-1) & -(intptr_t)sizeof(__avword))/sizeof(__avword), \ + 0) \ + : ((__avword*)(((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) > (LIST).eptr \ + ? -1 : \ + ((LIST).ianum = __AV_IARG_NUM, \ + __av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) - (TYPE_SIZE)),VAL), \ + (LIST).aptr = (__avword*)(((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) +sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)), \ + 0))) \ + : ((LIST).ianum < __AV_IARG_NUM \ + ? ((LIST).aptr \ + > ((LIST).eptr = (__avword*)((uintptr_t)(LIST).eptr - (((TYPE_SIZE)+7)&-8)))\ + ? -1 : \ + (__av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)(LIST).eptr,VAL), \ + (LIST).iargs[(LIST).ianum++] = (__avword)(LIST).eptr, \ + 0)) \ + : (++(LIST).aptr \ + > ((LIST).eptr = (__avword*)((uintptr_t)(LIST).eptr - (((TYPE_SIZE)+7)&-8)))\ + ? -1 : \ + (__av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)(LIST).eptr,VAL), \ + (LIST).aptr[-1] = (__avword)(LIST).eptr, \ + 0)))) +#endif +#if defined(__powerpc_sysv4__) +/* Structures are passed as pointers to caller-made local copies. We + * grab space for the copies from the end of the argument list space + * and always use maximal (double) alignment. + */ +#define __av_struct(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + ((LIST).ianum < __AV_IARG_NUM \ + ? ((LIST).aptr \ + > ((LIST).eptr = (__avword*)((uintptr_t)(LIST).eptr - (((TYPE_SIZE)+7)&-8)))\ + ? -1 : \ + (__av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)(LIST).eptr,VAL), \ + (LIST).iargs[(LIST).ianum++] = (__avword)(LIST).eptr, \ + 0)) \ + : (++(LIST).aptr \ + > ((LIST).eptr = (__avword*)((uintptr_t)(LIST).eptr - (((TYPE_SIZE)+7)&-8)))\ + ? -1 : \ + (__av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)(LIST).eptr,VAL), \ + (LIST).aptr[-1] = (__avword)(LIST).eptr, \ + 0))) +#endif +#if defined(__x86_64_sysv__) +/* Structures <= 16 bytes can be passed in integer or floating-point registers + if there is enough room for the whole number of words needed by the structure + in the corresponding iargs/fargs block. We can't distinguish the two cases + and support only passing in integer registers. Other structures are passed + on the arg stack. */ +#define __av_struct(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + (((TYPE_SIZE) <= 2*sizeof(__avword) \ + && (LIST).ianum + ((TYPE_SIZE) + sizeof(__avword)-1) / sizeof(__avword) <= __AV_IARG_NUM) \ + ? (__av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)&(LIST).iargs[(LIST).ianum],VAL), \ + (LIST).ianum += ((TYPE_SIZE) + sizeof(__avword)-1) / sizeof(__avword), \ + 0) \ + : ((__avword*)((uintptr_t)(LIST).aptr + (((TYPE_SIZE)+__av_struct_alignment(TYPE_ALIGN)-1) & -(intptr_t)__av_struct_alignment(TYPE_ALIGN))) > (LIST).eptr \ + ? -1 : \ + ((LIST).aptr = (__avword*)((uintptr_t)(LIST).aptr + (((TYPE_SIZE)+__av_struct_alignment(TYPE_ALIGN)-1) & -(intptr_t)__av_struct_alignment(TYPE_ALIGN))), \ + __av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)((uintptr_t)(LIST).aptr - (((TYPE_SIZE)+__av_struct_alignment(TYPE_ALIGN)-1) & -(intptr_t)__av_struct_alignment(TYPE_ALIGN))),VAL), \ + 0))) +#endif +#if defined(__x86_64_ms__) +/* Structures of 1, 2, 4, 8 bytes are passed as embedded copies on the arg stack. + * Big structures are passed as pointers to caller-made local copies. + */ +#define __av_struct(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + ((TYPE_SIZE) == 1 || (TYPE_SIZE) == 2 || (TYPE_SIZE) == 4 || (TYPE_SIZE) == 8 \ + ? ((__avword*)((uintptr_t)(LIST).aptr + (((TYPE_SIZE)+sizeof(__avword)-1) & -(intptr_t)sizeof(__avword))) > (LIST).eptr \ + ? -1 : \ + ((LIST).aptr = (__avword*)((uintptr_t)(LIST).aptr + (((TYPE_SIZE)+sizeof(__avword)-1) & -(intptr_t)sizeof(__avword))), \ + __av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)((uintptr_t)(LIST).aptr - (((TYPE_SIZE)+sizeof(__avword)-1) & -(intptr_t)sizeof(__avword))),VAL), \ + 0)) \ + : (++(LIST).aptr \ + > ((LIST).eptr = (__avword*)((uintptr_t)(LIST).eptr - (((TYPE_SIZE)+7)&-8)))\ + ? -1 : \ + (__av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)(LIST).eptr,VAL), \ + (LIST).aptr[-1] = (__avword)(LIST).eptr, \ + 0))) +#endif +#if defined(__s390__) || defined(__s390x__) +/* Structures of 1, 2, 4, 8 bytes are passed as embedded copies on the arg stack. + * Big structures are passed as pointers to caller-made local copies. + */ +#define __av_struct(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + ((TYPE_SIZE) == 1 || (TYPE_SIZE) == 2 || (TYPE_SIZE) == 4 || (TYPE_SIZE) == 8 \ + ? ((((LIST).ianum*sizeof(__avword)+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) <= __AV_IARG_NUM*sizeof(__avword) \ + ? ((LIST).ianum += (((((TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) + sizeof(__avword)-1) & -(intptr_t)sizeof(__avword))/sizeof(__avword), \ + __av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)((uintptr_t)&(LIST).iargs[(LIST).ianum]-(TYPE_SIZE)),VAL), \ + 0) \ + : ((__avword*)(((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) > (LIST).eptr \ + ? -1 : \ + ((LIST).ianum = __AV_IARG_NUM, \ + __av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) - (TYPE_SIZE)),VAL), \ + (LIST).aptr = (__avword*)(((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) +sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)), \ + 0))) \ + : ((LIST).ianum < __AV_IARG_NUM \ + ? ((LIST).aptr \ + > ((LIST).eptr = (__avword*)((uintptr_t)(LIST).eptr - (((TYPE_SIZE)+7)&-8)))\ + ? -1 : \ + (__av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)(LIST).eptr,VAL), \ + (LIST).iargs[(LIST).ianum++] = (__avword)(LIST).eptr, \ + 0)) \ + : (++(LIST).aptr \ + > ((LIST).eptr = (__avword*)((uintptr_t)(LIST).eptr - (((TYPE_SIZE)+7)&-8)))\ + ? -1 : \ + (__av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)(LIST).eptr,VAL), \ + (LIST).aptr[-1] = (__avword)(LIST).eptr, \ + 0)))) +#endif +#if defined(__riscv32__) || defined(__riscv64__) +/* Structures <= 16 bytes are passed as embedded copies on the arg stack. + * Big structures are passed as pointers to caller-made local copies. + */ +#define __av_struct(LIST,TYPE_SIZE,TYPE_ALIGN,VAL) \ + ((TYPE_SIZE) <= 2*sizeof(__avword) \ + ? ((__avword*)(((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) > (LIST).eptr \ + ? -1 : \ + (__av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) - (TYPE_SIZE)),VAL), \ + (LIST).aptr = (__avword*)(((((uintptr_t)(LIST).aptr+(TYPE_SIZE)+(TYPE_ALIGN)-1) & -(intptr_t)(TYPE_ALIGN)) +sizeof(__avword)-1) & -(intptr_t)sizeof(__avword)), \ + 0)) \ + : (++(LIST).aptr \ + > ((LIST).eptr = (__avword*)((uintptr_t)(LIST).eptr - (((TYPE_SIZE)+7)&-8)))\ + ? -1 : \ + (__av_struct_copy(TYPE_SIZE,TYPE_ALIGN,(void*)(LIST).eptr,VAL), \ + (LIST).aptr[-1] = (__avword)(LIST).eptr, \ + 0))) +#endif + + +#endif /* _AVCALL_INTERNAL_H */ diff --git a/avcall/avcall-libapi.c b/avcall/avcall-libapi.c new file mode 100644 index 0000000..5b22dfc --- /dev/null +++ b/avcall/avcall-libapi.c @@ -0,0 +1,79 @@ +/* + * Copyright 2017 Bruno Haible + * + * 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, see . + */ + +#include "config.h" + +#include "avcall-internal.h" + +/* This is the implementation of the library API. + The symbols that the linker sees are all prefixed with 'avcall_', + to avoid potential collisions with other libraries. */ + +int avcall_overflown (av_alist* list) +{ + return _av_overflown(AV_LIST_INNER(list)); +} + +void avcall_start (av_alist* list, __avword* list_args, __avword* list_args_end, __avword(*func)(), void* raddr, int rettype, int flags) +{ + __av_start(AV_LIST_INNER(list),list_args,list_args_end,func,raddr,rettype,flags); +} + +void avcall_start_struct (av_alist* list, __avword* list_args, __avword* list_args_end, __avword(*func)(), size_t type_size, int type_splittable, void* raddr, int flags) +{ + __av_start_struct(AV_LIST_INNER(list),list_args,list_args_end,func,type_size,type_splittable,raddr,flags); +} + +int avcall_arg_long (av_alist* list, long val) +{ + return __av_long(AV_LIST_INNER(list),val); +} + +int avcall_arg_ulong (av_alist* list, unsigned long val) +{ + return __av_ulong(AV_LIST_INNER(list),val); +} + +int avcall_arg_ptr (av_alist* list, void* val) +{ + return __av_ptr(AV_LIST_INNER(list),val); +} + +int avcall_arg_longlong (av_alist* list, long long val) +{ + return __av_longlong(AV_LIST_INNER(list),val); +} + +int avcall_arg_ulonglong (av_alist* list, unsigned long long val) +{ + return __av_ulonglong(AV_LIST_INNER(list),val); +} + +int avcall_arg_float (av_alist* list, float val) +{ + return _av_float(AV_LIST_INNER(list),val); +} + +int avcall_arg_double (av_alist* list, double val) +{ + return _av_double(AV_LIST_INNER(list),val); +} + +int avcall_arg_struct (av_alist* list, size_t type_size, size_t type_align, const void* val_addr) +{ + return __av_struct(AV_LIST_INNER(list),type_size,type_align,val_addr); +} diff --git a/avcall/avcall-m68k-linux.s b/avcall/avcall-m68k-linux.s new file mode 100644 index 0000000..6190bd9 --- /dev/null +++ b/avcall/avcall-m68k-linux.s @@ -0,0 +1,167 @@ + .file "avcall-m68k.c" + .text + .align 2 + .globl avcall_call + .type avcall_call,@function +avcall_call: + link.w %a6,#0 + movm.l #0x3820,-(%sp) + move.l 8(%a6),%a2 + lea (-1024,%sp),%sp + move.l 24(%a2),%d1 + move.l 20(%a2),%d0 + sub.l %d1,%d0 + asr.l #2,%d0 + jble .L54 + move.l %sp,%a1 + move.l %d1,%a0 + move.l %d0,%d2 + .align 2 +.L6: + move.l (%a0)+,(%a1)+ + subq.l #1,%d2 + jbne .L6 +.L54: + moveq.l #16,%d0 + cmp.l 12(%a2),%d0 + jbeq .L59 +.L7: + move.l 4(%a2),%a0 + jsr (%a0) + move.l %d0,%d2 + move.l %d1,%d3 + move.l 12(%a2),%a1 + moveq.l #1,%d1 + cmp.l %a1,%d1 + jbeq .L9 + tst.l %a1 + jbeq .L55 + moveq.l #2,%d4 + cmp.l %a1,%d4 + jbeq .L58 + moveq.l #3,%d4 + cmp.l %a1,%d4 + jbeq .L58 + moveq.l #4,%d4 + cmp.l %a1,%d4 + jbeq .L58 + moveq.l #5,%d4 + cmp.l %a1,%d4 + jbeq .L57 + moveq.l #6,%d4 + cmp.l %a1,%d4 + jbeq .L57 + moveq.l #7,%d4 + cmp.l %a1,%d4 + jbeq .L55 + moveq.l #8,%d4 + cmp.l %a1,%d4 + jbeq .L55 + moveq.l #9,%d4 + cmp.l %a1,%d4 + jbeq .L55 + moveq.l #10,%d4 + cmp.l %a1,%d4 + jbeq .L55 + lea (-11,%a1),%a0 + moveq.l #1,%d4 + cmp.l %a0,%d4 + jbcc .L56 + moveq.l #13,%d4 + cmp.l %a1,%d4 + jbeq .L60 + moveq.l #14,%d4 + cmp.l %a1,%d4 + jbeq .L61 + moveq.l #15,%d0 + cmp.l %a1,%d0 + jbeq .L55 + moveq.l #16,%d1 + cmp.l %a1,%d1 + jbne .L9 + btst #1,2(%a2) + jbeq .L9 + move.l 16(%a2),%d0 + moveq.l #1,%d4 + cmp.l %d0,%d4 + jbeq .L58 + moveq.l #2,%d1 + cmp.l %d0,%d1 + jbeq .L57 + moveq.l #4,%d4 + cmp.l %d0,%d4 + jbeq .L55 + moveq.l #8,%d1 + cmp.l %d0,%d1 + jbne .L9 +.L56: + move.l 8(%a2),%a0 + move.l %d2,(%a0) + move.l %d3,4(%a0) + jbra .L9 + .align 2 +.L55: + move.l 8(%a2),%a0 + move.l %d2,(%a0) + jbra .L9 + .align 2 +.L57: + move.l 8(%a2),%a0 + move.w %d2,(%a0) + jbra .L9 + .align 2 +.L58: + move.l 8(%a2),%a0 + move.b %d2,(%a0) + jbra .L9 + .align 2 +.L61: + btst #6,3(%a2) + jbeq .L39 + move.l 8(%a2),%a0 + fmove.d %fp0,(%a0) + jbra .L9 + .align 2 +.L39: + move.l 8(%a2),%a0 + move.l %d0,(%a0) + move.l %d1,4(%a0) + jbra .L9 + .align 2 +.L60: + move.l (%a2),%d2 + btst #6,%d2 + jbeq .L33 + move.l 8(%a2),%a0 + fmove.s %fp0,(%a0) + jbra .L9 + .align 2 +.L33: + btst #5,%d2 + jbeq .L35 + move.l 8(%a2),%a0 + move.l %d1,-(%sp) + move.l %d0,-(%sp) + fmove.d (%sp)+,%fp0 + fmove.s %fp0,(%a0) + jbra .L9 + .align 2 +.L35: + move.l 8(%a2),%a0 + move.l %d0,(%a0) + jbra .L9 + .align 2 +.L59: +#APP + move.l 8(%a2),%a1 +#NO_APP + jbra .L7 + .align 2 +.L9: + clr.l %d0 + movm.l -16(%a6),#0x41c + unlk %a6 + rts +.Lfe1: + .size avcall_call,.Lfe1-avcall_call + .ident "GCC: (GNU) 3.1" diff --git a/avcall/avcall-m68k-sun.s b/avcall/avcall-m68k-sun.s new file mode 100644 index 0000000..0ffb17c --- /dev/null +++ b/avcall/avcall-m68k-sun.s @@ -0,0 +1,163 @@ +#NO_APP + .text + .even + .globl _avcall_call +_avcall_call: + link a6,#0 + moveml #0x3820,sp@- + movel a6@(8),a2 + lea sp@(-1024),sp + movel a2@(24),d1 + movel a2@(20),d0 + subl d1,d0 + asrl #2,d0 + jle L54 + movel sp,a1 + movel d1,a0 + movel d0,d2 + .even +L6: + movel a0@+,a1@+ + subql #1,d2 + jne L6 +L54: + moveq #16,d0 + cmpl a2@(12),d0 + jeq L59 +L7: + movel a2@(4),a0 + jsr a0@ + movel d0,d2 + movel d1,d3 + movel a2@(12),a1 + moveq #1,d1 + cmpl a1,d1 + jeq L9 + tstl a1 + jeq L55 + moveq #2,d4 + cmpl a1,d4 + jeq L58 + moveq #3,d4 + cmpl a1,d4 + jeq L58 + moveq #4,d4 + cmpl a1,d4 + jeq L58 + moveq #5,d4 + cmpl a1,d4 + jeq L57 + moveq #6,d4 + cmpl a1,d4 + jeq L57 + moveq #7,d4 + cmpl a1,d4 + jeq L55 + moveq #8,d4 + cmpl a1,d4 + jeq L55 + moveq #9,d4 + cmpl a1,d4 + jeq L55 + moveq #10,d4 + cmpl a1,d4 + jeq L55 + lea a1@(-11),a0 + moveq #1,d4 + cmpl a0,d4 + jcc L56 + moveq #13,d4 + cmpl a1,d4 + jeq L60 + moveq #14,d4 + cmpl a1,d4 + jeq L61 + moveq #15,d0 + cmpl a1,d0 + jeq L55 + moveq #16,d1 + cmpl a1,d1 + jne L9 + btst #1,a2@(2) + jeq L9 + movel a2@(16),d0 + moveq #1,d4 + cmpl d0,d4 + jeq L58 + moveq #2,d1 + cmpl d0,d1 + jeq L57 + moveq #4,d4 + cmpl d0,d4 + jeq L55 + moveq #8,d1 + cmpl d0,d1 + jne L9 +L56: + movel a2@(8),a0 + movel d2,a0@ + movel d3,a0@(4) + jra L9 + .even +L55: + movel a2@(8),a0 + movel d2,a0@ + jra L9 + .even +L57: + movel a2@(8),a0 + movew d2,a0@ + jra L9 + .even +L58: + movel a2@(8),a0 + moveb d2,a0@ + jra L9 + .even +L61: + btst #6,a2@(3) + jeq L39 + movel a2@(8),a0 + fmoved fp0,a0@ + jra L9 + .even +L39: + movel a2@(8),a0 + movel d0,a0@ + movel d1,a0@(4) + jra L9 + .even +L60: + movel a2@,d2 + btst #6,d2 + jeq L33 + movel a2@(8),a0 + fmoves fp0,a0@ + jra L9 + .even +L33: + btst #5,d2 + jeq L35 + movel a2@(8),a0 + movel d1,sp@- + movel d0,sp@- + fmoved sp@+,fp0 + fmoves fp0,a0@ + jra L9 + .even +L35: + movel a2@(8),a0 + movel d0,a0@ + jra L9 + .even +L59: +#APP + movel a2@(8),a1 +#NO_APP + jra L7 + .even +L9: + clrl d0 + moveml a6@(-16),#0x41c + unlk a6 + rts diff --git a/avcall/avcall-m68k.c b/avcall/avcall-m68k.c new file mode 100644 index 0000000..2be7276 --- /dev/null +++ b/avcall/avcall-m68k.c @@ -0,0 +1,148 @@ +/** + Copyright 1993 Bill Triggs + Copyright 1995-2017 Bruno Haible + + 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, see . +**/ +/*---------------------------------------------------------------------- + !!! THIS ROUTINE MUST BE COMPILED gcc -O !!! + + Foreign function interface for a m68k Sun3 with gcc/sun-cc. + + This calls a C function with an argument list built up using macros + defined in avcall.h. + + M68k Argument Passing Conventions: + + All arguments are passed on the stack with word alignment. Doubles take + two words. Structure args are passed as true structures embedded in the + argument stack. To return a structure, the called function copies the + return value to the address supplied in register "a1". Gcc without + -fpcc-struct-return returns <= 4 byte structures as integers. + + Compile this routine with gcc -O (or -O2 or -g -O) to get the right + register variables, or use the assembler version. + ----------------------------------------------------------------------*/ +#include "avcall-internal.h" + +#define RETURN(TYPE,VAL) (*(TYPE*)l->raddr = (TYPE)(VAL)) + +int +avcall_call(av_alist* list) +{ + register __avword* sp __asm__("sp"); /* C names for registers */ + register __avword* sret __asm__("a1"); /* structure return pointer */ +/*register __avword iret __asm__("d0"); */ + register __avword iret2 __asm__("d1"); + register float fret __asm__("d0"); /* d0 */ + register double dret __asm__("d0"); /* d0,d1 */ + register float fp_fret __asm__("fp0"); + register double fp_dret __asm__("fp0"); + + __av_alist* l = &AV_LIST_INNER(list); + + __avword* argframe = __builtin_alloca(__AV_ALIST_WORDS * sizeof(__avword)); /* make room for argument list */ + int arglen = l->aptr - l->args; + __avword i; + __avword i2; + + for (i = 0; i < arglen; i++) /* push function args onto stack */ + argframe[i] = l->args[i]; + + if (l->rtype == __AVstruct) /* push struct return address */ + __asm__("move%.l %0,%/a1" : : "g" (l->raddr)); + + i = (*l->func)(); /* call function */ + i2 = iret2; + + /* save return value */ + if (l->rtype == __AVvoid) { + } else + if (l->rtype == __AVword) { + RETURN(__avword, i); + } else + if (l->rtype == __AVchar) { + RETURN(char, i); + } else + if (l->rtype == __AVschar) { + RETURN(signed char, i); + } else + if (l->rtype == __AVuchar) { + RETURN(unsigned char, i); + } else + if (l->rtype == __AVshort) { + RETURN(short, i); + } else + if (l->rtype == __AVushort) { + RETURN(unsigned short, i); + } else + if (l->rtype == __AVint) { + RETURN(int, i); + } else + if (l->rtype == __AVuint) { + RETURN(unsigned int, i); + } else + if (l->rtype == __AVlong) { + RETURN(long, i); + } else + if (l->rtype == __AVulong) { + RETURN(unsigned long, i); + } else + if (l->rtype == __AVlonglong || l->rtype == __AVulonglong) { + void* raddr = l->raddr; + ((__avword*)raddr)[0] = i; + ((__avword*)raddr)[1] = i2; + } else + if (l->rtype == __AVfloat) { + if (l->flags & __AV_FREG_FLOAT_RETURN) { + RETURN(float, fp_fret); + } else { + if (l->flags & __AV_SUNCC_FLOAT_RETURN) { + RETURN(float, (float)dret); + } else { + RETURN(float, fret); + } + } + } else + if (l->rtype == __AVdouble) { + if (l->flags & __AV_FREG_FLOAT_RETURN) { + RETURN(double, fp_dret); + } else { + RETURN(double, dret); + } + } else + if (l->rtype == __AVvoidp) { + RETURN(void*, i); + } else + if (l->rtype == __AVstruct) { + /* NB: On m68k, all structure sizes are divisible by 2. */ + if (l->flags & __AV_REGISTER_STRUCT_RETURN) { + if (l->rsize == sizeof(char)) { /* can't occur */ + RETURN(char, i); + } else + if (l->rsize == sizeof(short)) { + RETURN(short, i); + } else + if (l->rsize == sizeof(int)) { + RETURN(int, i); + } else + if (l->rsize == 2*sizeof(__avword)) { + void* raddr = l->raddr; + ((__avword*)raddr)[0] = i; + ((__avword*)raddr)[1] = i2; + } + } + } + return 0; +} diff --git a/avcall/avcall-m68k.mit.S b/avcall/avcall-m68k.mit.S new file mode 100644 index 0000000..d9591d9 --- /dev/null +++ b/avcall/avcall-m68k.mit.S @@ -0,0 +1,166 @@ +#include "asm-m68k.h" + .text + .even + .globl C(avcall_call) + DECLARE_FUNCTION(avcall_call) +FUNBEGIN(avcall_call) + link $a6,#0 + moveml #0x3820,$sp@- + movel $a6@(8),$a2 + lea $sp@(-1024),$sp + movel $a2@(24),$d1 + movel $a2@(20),$d0 + subl $d1,$d0 + asrl #2,$d0 + jle L(54) + movel $sp,$a1 + movel $d1,$a0 + movel $d0,$d2 + .even +L(6): + movel $a0@+,$a1@+ + subql #1,$d2 + jne L(6) +L(54): + moveq #16,$d0 + cmpl $a2@(12),$d0 + jeq L(59) +L(7): + movel $a2@(4),$a0 + jsr $a0@ + movel $d0,$d2 + movel $d1,$d3 + movel $a2@(12),$a1 + moveq #1,$d1 + cmpl $a1,$d1 + jeq L(9) + tstl $a1 + jeq L(55) + moveq #2,$d4 + cmpl $a1,$d4 + jeq L(58) + moveq #3,$d4 + cmpl $a1,$d4 + jeq L(58) + moveq #4,$d4 + cmpl $a1,$d4 + jeq L(58) + moveq #5,$d4 + cmpl $a1,$d4 + jeq L(57) + moveq #6,$d4 + cmpl $a1,$d4 + jeq L(57) + moveq #7,$d4 + cmpl $a1,$d4 + jeq L(55) + moveq #8,$d4 + cmpl $a1,$d4 + jeq L(55) + moveq #9,$d4 + cmpl $a1,$d4 + jeq L(55) + moveq #10,$d4 + cmpl $a1,$d4 + jeq L(55) + lea $a1@(-11),$a0 + moveq #1,$d4 + cmpl $a0,$d4 + jcc L(56) + moveq #13,$d4 + cmpl $a1,$d4 + jeq L(60) + moveq #14,$d4 + cmpl $a1,$d4 + jeq L(61) + moveq #15,$d0 + cmpl $a1,$d0 + jeq L(55) + moveq #16,$d1 + cmpl $a1,$d1 + jne L(9) + btst #1,$a2@(2) + jeq L(9) + movel $a2@(16),$d0 + moveq #1,$d4 + cmpl $d0,$d4 + jeq L(58) + moveq #2,$d1 + cmpl $d0,$d1 + jeq L(57) + moveq #4,$d4 + cmpl $d0,$d4 + jeq L(55) + moveq #8,$d1 + cmpl $d0,$d1 + jne L(9) +L(56): + movel $a2@(8),$a0 + movel $d2,$a0@ + movel $d3,$a0@(4) + jra L(9) + .even +L(55): + movel $a2@(8),$a0 + movel $d2,$a0@ + jra L(9) + .even +L(57): + movel $a2@(8),$a0 + movew $d2,$a0@ + jra L(9) + .even +L(58): + movel $a2@(8),$a0 + moveb $d2,$a0@ + jra L(9) + .even +L(61): + btst #6,$a2@(3) + jeq L(39) + movel $a2@(8),$a0 + fmoved $fp0,$a0@ + jra L(9) + .even +L(39): + movel $a2@(8),$a0 + movel $d0,$a0@ + movel $d1,$a0@(4) + jra L(9) + .even +L(60): + movel $a2@,$d2 + btst #6,$d2 + jeq L(33) + movel $a2@(8),$a0 + fmoves $fp0,$a0@ + jra L(9) + .even +L(33): + btst #5,$d2 + jeq L(35) + movel $a2@(8),$a0 + movel $d1,$sp@- + movel $d0,$sp@- + fmoved $sp@+,$fp0 + fmoves $fp0,$a0@ + jra L(9) + .even +L(35): + movel $a2@(8),$a0 + movel $d0,$a0@ + jra L(9) + .even +L(59): + movel $a2@(8),$a1 + jra L(7) + .even +L(9): + clrl $d0 + moveml $a6@(-16),#0x41c + unlk $a6 + rts +FUNEND(avcall_call) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/avcall/avcall-m68k.motorola.S b/avcall/avcall-m68k.motorola.S new file mode 100644 index 0000000..a03518d --- /dev/null +++ b/avcall/avcall-m68k.motorola.S @@ -0,0 +1,167 @@ +#include "asm-m68k.h" + .text + .align 2 + .globl C(avcall_call) + DECLARE_FUNCTION(avcall_call) +FUNBEGIN(avcall_call) + link.w %a6,#0 + movm.l #0x3820,-(%sp) + move.l 8(%a6),%a2 + lea (-1024,%sp),%sp + move.l 24(%a2),%d1 + move.l 20(%a2),%d0 + sub.l %d1,%d0 + asr.l #2,%d0 + jble L(54) + move.l %sp,%a1 + move.l %d1,%a0 + move.l %d0,%d2 + .align 2 +L(6): + move.l (%a0)+,(%a1)+ + subq.l #1,%d2 + jbne L(6) +L(54): + moveq.l #16,%d0 + cmp.l 12(%a2),%d0 + jbeq L(59) +L(7): + move.l 4(%a2),%a0 + jsr (%a0) + move.l %d0,%d2 + move.l %d1,%d3 + move.l 12(%a2),%a1 + moveq.l #1,%d1 + cmp.l %a1,%d1 + jbeq L(9) + tst.l %a1 + jbeq L(55) + moveq.l #2,%d4 + cmp.l %a1,%d4 + jbeq L(58) + moveq.l #3,%d4 + cmp.l %a1,%d4 + jbeq L(58) + moveq.l #4,%d4 + cmp.l %a1,%d4 + jbeq L(58) + moveq.l #5,%d4 + cmp.l %a1,%d4 + jbeq L(57) + moveq.l #6,%d4 + cmp.l %a1,%d4 + jbeq L(57) + moveq.l #7,%d4 + cmp.l %a1,%d4 + jbeq L(55) + moveq.l #8,%d4 + cmp.l %a1,%d4 + jbeq L(55) + moveq.l #9,%d4 + cmp.l %a1,%d4 + jbeq L(55) + moveq.l #10,%d4 + cmp.l %a1,%d4 + jbeq L(55) + lea (-11,%a1),%a0 + moveq.l #1,%d4 + cmp.l %a0,%d4 + jbcc L(56) + moveq.l #13,%d4 + cmp.l %a1,%d4 + jbeq L(60) + moveq.l #14,%d4 + cmp.l %a1,%d4 + jbeq L(61) + moveq.l #15,%d0 + cmp.l %a1,%d0 + jbeq L(55) + moveq.l #16,%d1 + cmp.l %a1,%d1 + jbne L(9) + btst #1,2(%a2) + jbeq L(9) + move.l 16(%a2),%d0 + moveq.l #1,%d4 + cmp.l %d0,%d4 + jbeq L(58) + moveq.l #2,%d1 + cmp.l %d0,%d1 + jbeq L(57) + moveq.l #4,%d4 + cmp.l %d0,%d4 + jbeq L(55) + moveq.l #8,%d1 + cmp.l %d0,%d1 + jbne L(9) +L(56): + move.l 8(%a2),%a0 + move.l %d2,(%a0) + move.l %d3,4(%a0) + jbra L(9) + .align 2 +L(55): + move.l 8(%a2),%a0 + move.l %d2,(%a0) + jbra L(9) + .align 2 +L(57): + move.l 8(%a2),%a0 + move.w %d2,(%a0) + jbra L(9) + .align 2 +L(58): + move.l 8(%a2),%a0 + move.b %d2,(%a0) + jbra L(9) + .align 2 +L(61): + btst #6,3(%a2) + jbeq L(39) + move.l 8(%a2),%a0 + fmove.d %fp0,(%a0) + jbra L(9) + .align 2 +L(39): + move.l 8(%a2),%a0 + move.l %d0,(%a0) + move.l %d1,4(%a0) + jbra L(9) + .align 2 +L(60): + move.l (%a2),%d2 + btst #6,%d2 + jbeq L(33) + move.l 8(%a2),%a0 + fmove.s %fp0,(%a0) + jbra L(9) + .align 2 +L(33): + btst #5,%d2 + jbeq L(35) + move.l 8(%a2),%a0 + move.l %d1,-(%sp) + move.l %d0,-(%sp) + fmove.d (%sp)+,%fp0 + fmove.s %fp0,(%a0) + jbra L(9) + .align 2 +L(35): + move.l 8(%a2),%a0 + move.l %d0,(%a0) + jbra L(9) + .align 2 +L(59): + move.l 8(%a2),%a1 + jbra L(7) + .align 2 +L(9): + clr.l %d0 + movm.l -16(%a6),#0x41c + unlk %a6 + rts +L(fe1): + FUNEND(avcall_call) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/avcall/avcall-mips.c b/avcall/avcall-mips.c new file mode 100644 index 0000000..390bd60 --- /dev/null +++ b/avcall/avcall-mips.c @@ -0,0 +1,155 @@ +/** + Copyright 1993 Bill Triggs + Copyright 1995-2017 Bruno Haible + Copyright 2005 Thiemo Seufer + + 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, see . +**/ +/*---------------------------------------------------------------------- + !!! THIS ROUTINE MUST BE COMPILED gcc -O !!! + + Foreign function interface for an SGI MIPS with gcc/sgi-cc. + + This calls a C function with an argument list built up using macros + defined in avcall.h. + + SGI MIPS Argument Passing Conventions + + - The entire argument list forms a structure with all the appropriate + holes & alignments, and space for this is allocated in the stack frame. + - Shorter integers are promoted to word length (sizeof(int)=sizeof(long)=4). + - Doubles are 2 words aligned on even boundaries. + - The first 4 words of the structure are passed in registers $4...$7, stack + space for these is always allocated. Remaining words are passed on the + stack. + - If the first two args are floats or doubles, they are also passed in $f12 + and $f14. But varargs functions will expect them in the integer registers + and we can't tell whether the function is varargs so we pass them both ways. + - GCC 3.3.x and 3.4.x pass the next args after two floats in $7 and on the + stack, instead of in $6, $7, and on the stack. This is a bug that is fixed + in GCC 4.0.4. We don't support these versions of GCC on mips with -mabi=32. + - Structure arguments are copies embedded in the arglist structure. + - Structure returns are pointers to caller-allocated space passed in as the + first argument of the list. The function also returns the pointer. + - Integer/pointer returns are in $2, float/double returns in $f0. + - Under IRIX 5, the called function expects to see its own address in $25. + + This file needs to be compiled with gcc for the asm extensions, but the + assembly version of it and the header file seem to work with SGI cc. + ----------------------------------------------------------------------*/ +#include "avcall-internal.h" + +#define RETURN(TYPE,VAL) (*(TYPE*)l->raddr = (TYPE)(VAL)) +#define OFFSETOF(struct,member) ((int)&(((struct*)0)->member)) + +int +avcall_call(av_alist* list) +{ + register __avword* sp __asm__("$sp"); /* C names for registers */ + register __avword iret2 __asm__("$3"); + register float fret_tmp __asm__("$f0"); + register double dret_tmp __asm__("$f0"); + + __av_alist* l = &AV_LIST_INNER(list); + + __avword *space = __builtin_alloca(__AV_ALIST_WORDS * sizeof(__avword)); /* big space for child's stack frame */ + __avword *argframe = sp; /* stack offset for argument list is 0 */ + int arglen = l->aptr - l->args; + int i; + __avword iret; + float fret; + double dret; + + /* load leading float args */ + if (l->farg_mask & (1 << 0)) + __asm__("l.s $f12,%1(%0)" : : "p" (l), "i" OFFSETOF(__av_alist,fargs[0])); + if (l->darg_mask & (1 << 0)) + __asm__("l.d $f12,%1(%0)" : : "p" (l), "i" OFFSETOF(__av_alist,dargs[0])); + if (l->farg_mask & (1 << 1)) + __asm__("l.s $f14,%1(%0)" : : "p" (l), "i" OFFSETOF(__av_alist,fargs[1])); + if (l->darg_mask & (1 << 1)) + __asm__("l.d $f14,%1(%0)" : : "p" (l), "i" OFFSETOF(__av_alist,dargs[1])); + + for (i = 4; i < arglen; i++) /* push excess function args */ + argframe[i] = l->args[i]; + + /* Note: The code of this call ought to put the address of the called function + in register $25 before the call. */ + iret = (*l->func)(l->args[0], l->args[1], /* call function with 1st 4 args */ + l->args[2], l->args[3]); + fret = fret_tmp; + dret = dret_tmp; + + /* save return value */ + if (l->rtype == __AVvoid) { + } else + if (l->rtype == __AVword) { + RETURN(__avword, iret); + } else + if (l->rtype == __AVchar) { + RETURN(char, iret); + } else + if (l->rtype == __AVschar) { + RETURN(signed char, iret); + } else + if (l->rtype == __AVuchar) { + RETURN(unsigned char, iret); + } else + if (l->rtype == __AVshort) { + RETURN(short, iret); + } else + if (l->rtype == __AVushort) { + RETURN(unsigned short, iret); + } else + if (l->rtype == __AVint) { + RETURN(int, iret); + } else + if (l->rtype == __AVuint) { + RETURN(unsigned int, iret); + } else + if (l->rtype == __AVlong) { + RETURN(long, iret); + } else + if (l->rtype == __AVulong) { + RETURN(unsigned long, iret); + } else + if (l->rtype == __AVlonglong || l->rtype == __AVulonglong) { + void* raddr = l->raddr; + ((__avword*)raddr)[0] = iret; + ((__avword*)raddr)[1] = iret2; + } else + if (l->rtype == __AVfloat) { + RETURN(float, fret); + } else + if (l->rtype == __AVdouble) { + RETURN(double, dret); + } else + if (l->rtype == __AVvoidp) { + RETURN(void*, iret); + } else + if (l->rtype == __AVstruct) { + if (l->flags & __AV_SMALL_STRUCT_RETURN) { + if (l->rsize == sizeof(char)) { + RETURN(char, iret); + } else + if (l->rsize == sizeof(short)) { + RETURN(short, iret); + } else + if (l->rsize == sizeof(int)) { + RETURN(int, iret); + } + } + } + return 0; +} diff --git a/avcall/avcall-mips64.c b/avcall/avcall-mips64.c new file mode 100644 index 0000000..2da61a5 --- /dev/null +++ b/avcall/avcall-mips64.c @@ -0,0 +1,495 @@ +/** + Copyright 1993 Bill Triggs + Copyright 1995-2017 Bruno Haible + + 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, see . +**/ +/*---------------------------------------------------------------------- + !!! THIS ROUTINE MUST BE COMPILED gcc -O !!! + + Foreign function interface for an SGI 64-bit MIPS with sgi-cc. + + This calls a C function with an argument list built up using macros + defined in avcall.h. + + SGI MIPS 64-bit Argument Passing Conventions + + - The entire argument list forms a structure with all the appropriate + holes & alignments, and space for this is allocated in the stack frame. + - Shorter integers are promoted to longword length (sizeof(long)=8). + - Doubles are 1 longword. + - Structure arguments are copies embedded in the arglist structure. + - The first 8 longwords of the structure are passed in registers $4...$11, + except that float arguments are passed in registers $f12...$f19, and + that double arguments and structure elements of type double are passed + in registers $f12...$f19. (But varargs functions may expect them in the + integer registers and we can't tell whether the function is varargs so + we pass them both ways.) + Remaining longwords are passed on the stack. No stack space is allocated + for the first 8 longwords of the structure. + - Structure returns of structures > 16 bytes: pointers to caller-allocated + space are passed in as the first argument of the list. + - Structure returns of structures <= 16 bytes: in the registers $2 (for the + first 8 bytes) and $3 (for the next 8 bytes). + A structure of 1 or 2 floats or doubles is returned in $f0 and $f2: + the first float or double in $f0, the second float or double in $f2. + - Integer/pointer returns are in $2, float/double returns in $f0. + - The called function expects to see its own address in $25. + + This file needs to be compiled with gcc for the asm extensions, but the + assembly version of it and the header file seem to work with SGI cc. + ----------------------------------------------------------------------*/ +#include "avcall-internal.h" + +#define RETURN(TYPE,VAL) (*(TYPE*)l->raddr = (TYPE)(VAL)) +#define OFFSETOF(struct,member) ((int)&(((struct*)0)->member)) + +int +avcall_call(av_alist* list) +{ + register __avword* sp __asm__("$sp"); /* C names for registers */ + register float fret __asm__("$f0"); + register double dret __asm__("$f0"); +/*register __avword iret1 __asm__("$2"); */ + register __avword iret2 __asm__("$3"); + + __av_alist* l = &AV_LIST_INNER(list); + + __avword* argframe = __builtin_alloca(__AV_ALIST_WORDS * sizeof(__avword)); /* make room for argument list */ + int arglen = l->aptr - l->args; + __avword iret; + int i; + + if (l->farg_mask) + { /* push leading float args */ + if (l->farg_mask & (1<<0)) + __asm__("lwc1 $f12,%1(%0)" : : "p" (l), "i" OFFSETOF(__av_alist,fargs[0])); + if (l->farg_mask & (1<<1)) + __asm__("lwc1 $f13,%1(%0)" : : "p" (l), "i" OFFSETOF(__av_alist,fargs[1])); + if (l->farg_mask & (1<<2)) + __asm__("lwc1 $f14,%1(%0)" : : "p" (l), "i" OFFSETOF(__av_alist,fargs[2])); + if (l->farg_mask & (1<<3)) + __asm__("lwc1 $f15,%1(%0)" : : "p" (l), "i" OFFSETOF(__av_alist,fargs[3])); + if (l->farg_mask & (1<<4)) + __asm__("lwc1 $f16,%1(%0)" : : "p" (l), "i" OFFSETOF(__av_alist,fargs[4])); + if (l->farg_mask & (1<<5)) + __asm__("lwc1 $f17,%1(%0)" : : "p" (l), "i" OFFSETOF(__av_alist,fargs[5])); + if (l->farg_mask & (1<<6)) + __asm__("lwc1 $f18,%1(%0)" : : "p" (l), "i" OFFSETOF(__av_alist,fargs[6])); + if (l->farg_mask & (1<<7)) + __asm__("lwc1 $f19,%1(%0)" : : "p" (l), "i" OFFSETOF(__av_alist,fargs[7])); + } + if (l->darg_mask) + { /* push leading double args */ + __avword* a = l->args; + if (l->darg_mask & (1<<0)) + __asm__("ldc1 $f12,%1(%0)" : : "p" (a), "i" (0 * sizeof (__avword))); + if (l->darg_mask & (1<<1)) + __asm__("ldc1 $f13,%1(%0)" : : "p" (a), "i" (1 * sizeof (__avword))); + if (l->darg_mask & (1<<2)) + __asm__("ldc1 $f14,%1(%0)" : : "p" (a), "i" (2 * sizeof (__avword))); + if (l->darg_mask & (1<<3)) + __asm__("ldc1 $f15,%1(%0)" : : "p" (a), "i" (3 * sizeof (__avword))); + if (l->darg_mask & (1<<4)) + __asm__("ldc1 $f16,%1(%0)" : : "p" (a), "i" (4 * sizeof (__avword))); + if (l->darg_mask & (1<<5)) + __asm__("ldc1 $f17,%1(%0)" : : "p" (a), "i" (5 * sizeof (__avword))); + if (l->darg_mask & (1<<6)) + __asm__("ldc1 $f18,%1(%0)" : : "p" (a), "i" (6 * sizeof (__avword))); + if (l->darg_mask & (1<<7)) + __asm__("ldc1 $f19,%1(%0)" : : "p" (a), "i" (7 * sizeof (__avword))); + } + + for (i = 8; i < arglen; i++) /* push excess function args */ + argframe[i-8] = l->args[i]; + + /* call function with 1st 8 args */ + __asm__ __volatile__ ("ld $4,%0" : : "m" (l->args[0]) : "$4"); /* arg1 = l->args[0]; */ + __asm__ __volatile__ ("ld $5,%0" : : "m" (l->args[1]) : "$5"); /* arg1 = l->args[1]; */ + __asm__ __volatile__ ("ld $6,%0" : : "m" (l->args[2]) : "$6"); /* arg1 = l->args[2]; */ + __asm__ __volatile__ ("ld $7,%0" : : "m" (l->args[3]) : "$7"); /* arg1 = l->args[3]; */ + __asm__ __volatile__ ("ld $8,%0" : : "m" (l->args[4]) : "$8"); /* arg1 = l->args[4]; */ + __asm__ __volatile__ ("ld $9,%0" : : "m" (l->args[5]) : "$9"); /* arg1 = l->args[5]; */ + __asm__ __volatile__ ("ld $10,%0" : : "m" (l->args[6]) : "$10"); /* arg1 = l->args[6]; */ + __asm__ __volatile__ ("ld $11,%0" : : "m" (l->args[7]) : "$11"); /* arg1 = l->args[7]; */ + /* Note: The code of this call ought to put the address of the called function + in register $25 before the call. */ + iret = (*l->func)(); + + /* save return value */ + if (l->rtype == __AVvoid) { + } else + if (l->rtype == __AVword) { + RETURN(__avword, iret); + } else + if (l->rtype == __AVchar) { + RETURN(char, iret); + } else + if (l->rtype == __AVschar) { + RETURN(signed char, iret); + } else + if (l->rtype == __AVuchar) { + RETURN(unsigned char, iret); + } else + if (l->rtype == __AVshort) { + RETURN(short, iret); + } else + if (l->rtype == __AVushort) { + RETURN(unsigned short, iret); + } else + if (l->rtype == __AVint) { + RETURN(int, iret); + } else + if (l->rtype == __AVuint) { + RETURN(unsigned int, iret); + } else + if (l->rtype == __AVlong) { + RETURN(long, iret); + } else + if (l->rtype == __AVulong) { + RETURN(unsigned long, iret); + } else + if (l->rtype == __AVlonglong) { + RETURN(long long, iret); + } else + if (l->rtype == __AVulonglong) { + RETURN(unsigned long long, iret); + } else + if (l->rtype == __AVfloat) { + RETURN(float, fret); + } else + if (l->rtype == __AVdouble) { + RETURN(double, dret); + } else + if (l->rtype == __AVvoidp) { + RETURN(void*, iret); + } else + if (l->rtype == __AVstruct) { + if (l->flags & __AV_REGISTER_STRUCT_RETURN) { + if (l->flags & __AV_GCC_STRUCT_RETURN) { + /* gcc returns structs of size 1,2,4,8 in registers. */ + if (l->rsize == sizeof(char)) { + RETURN(char, iret); + } else + if (l->rsize == sizeof(short)) { + RETURN(short, iret); + } else + if (l->rsize == sizeof(int)) { + RETURN(int, iret); + } else + if (l->rsize == sizeof(long)) { + RETURN(long, iret); + } + } else { + /* cc returns structs of size <= 16 in registers. */ + if (l->rsize > 0 && l->rsize <= 16) { + void* raddr = l->raddr; + #if 0 /* Unoptimized */ + if (l->rsize == 1) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + #else + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + #endif + } else + if (l->rsize == 2) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + #else + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>48); + #endif + } else + if (l->rsize == 3) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + #else + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>40); + #endif + } else + if (l->rsize == 4) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + #else + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>32); + #endif + } else + if (l->rsize == 5) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>32); + #else + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>24); + #endif + } else + if (l->rsize == 6) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>40); + #else + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>16); + #endif + } else + if (l->rsize == 7) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[6] = (unsigned char)(iret>>48); + #else + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[6] = (unsigned char)(iret>>8); + #endif + } else + if (l->rsize >= 8 && l->rsize <= 16) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[6] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[7] = (unsigned char)(iret>>56); + #else + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[6] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[7] = (unsigned char)(iret); + #endif + if (l->rsize == 8) { + } else + if (l->rsize == 9) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + #else + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + #endif + } else + if (l->rsize == 10) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + #else + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>48); + #endif + } else + if (l->rsize == 11) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + #else + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>40); + #endif + } else + if (l->rsize == 12) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + #else + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>32); + #endif + } else + if (l->rsize == 13) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>32); + #else + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>24); + #endif + } else + if (l->rsize == 14) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>40); + #else + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>16); + #endif + } else + if (l->rsize == 15) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+6] = (unsigned char)(iret2>>48); + #else + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+6] = (unsigned char)(iret2>>8); + #endif + } else + if (l->rsize == 16) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+6] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+7] = (unsigned char)(iret2>>56); + #else + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+6] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+7] = (unsigned char)(iret2); + #endif + } + } + #else /* Optimized: fewer conditional jumps, fewer memory accesses */ + uintptr_t count = l->rsize; /* > 0, ≤ 2*sizeof(__avword) */ + __avword* wordaddr = (__avword*)((uintptr_t)raddr & ~(uintptr_t)(sizeof(__avword)-1)); + uintptr_t start_offset = (uintptr_t)raddr & (uintptr_t)(sizeof(__avword)-1); /* ≥ 0, < sizeof(__avword) */ + uintptr_t end_offset = start_offset + count; /* > 0, < 3*sizeof(__avword) */ + #if defined(_MIPSEL) + if (count <= sizeof(__avword)) { + /* Use iret. */ + if (end_offset <= sizeof(__avword)) { + /* 0 < end_offset ≤ sizeof(__avword) */ + __avword mask0 = ((__avword)2 << (end_offset*8-1)) - ((__avword)1 << (start_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret << (start_offset*8))) & mask0; + } else { + /* sizeof(__avword) < end_offset < 2*sizeof(__avword), start_offset > 0 */ + __avword mask0 = - ((__avword)1 << (start_offset*8)); + __avword mask1 = ((__avword)2 << (end_offset*8-sizeof(__avword)*8-1)) - 1; + wordaddr[0] ^= (wordaddr[0] ^ (iret << (start_offset*8))) & mask0; + wordaddr[1] ^= (wordaddr[1] ^ (iret >> (sizeof(__avword)*8-start_offset*8))) & mask1; + } + } else { + /* Use iret, iret2. */ + __avword mask0 = - ((__avword)1 << (start_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret << (start_offset*8))) & mask0; + if (end_offset <= 2*sizeof(__avword)) { + /* sizeof(__avword) < end_offset ≤ 2*sizeof(__avword) */ + __avword mask1 = ((__avword)2 << (end_offset*8-sizeof(__avword)*8-1)) - 1; + wordaddr[1] ^= (wordaddr[1] ^ ((iret >> (sizeof(__avword)*4-start_offset*4) >> (sizeof(__avword)*4-start_offset*4)) | (iret2 << (start_offset*8)))) & mask1; + } else { + /* 2*sizeof(__avword) < end_offset < 3*sizeof(__avword), start_offset > 0 */ + __avword mask2 = ((__avword)2 << (end_offset*8-2*sizeof(__avword)*8-1)) - 1; + wordaddr[1] = (iret >> (sizeof(__avword)*8-start_offset*8)) | (iret2 << (start_offset*8)); + wordaddr[2] ^= (wordaddr[2] ^ (iret2 >> (sizeof(__avword)*8-start_offset*8))) & mask2; + } + } + #else + if (count <= sizeof(__avword)) { + /* Use iret. */ + if (end_offset <= sizeof(__avword)) { + /* 0 < end_offset ≤ sizeof(__avword) */ + __avword mask0 = ((__avword)2 << (sizeof(__avword)*8-start_offset*8-1)) - ((__avword)1 << (sizeof(__avword)*8-end_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret >> (start_offset*8))) & mask0; + } else { + /* sizeof(__avword) < end_offset < 2*sizeof(__avword), start_offset > 0 */ + __avword mask0 = ((__avword)2 << (sizeof(__avword)*8-start_offset*8-1)) - 1; + __avword mask1 = - ((__avword)1 << (2*sizeof(__avword)*8-end_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret >> (start_offset*8))) & mask0; + wordaddr[1] ^= (wordaddr[1] ^ (iret << (sizeof(__avword)*8-start_offset*8))) & mask1; + } + } else { + /* Use iret, iret2. */ + __avword mask0 = ((__avword)2 << (sizeof(__avword)*8-start_offset*8-1)) - 1; + wordaddr[0] ^= (wordaddr[0] ^ (iret >> (start_offset*8))) & mask0; + if (end_offset <= 2*sizeof(__avword)) { + /* sizeof(__avword) < end_offset ≤ 2*sizeof(__avword) */ + __avword mask1 = - ((__avword)1 << (2*sizeof(__avword)*8-end_offset*8)); + wordaddr[1] ^= (wordaddr[1] ^ ((iret << (sizeof(__avword)*4-start_offset*4) << (sizeof(__avword)*4-start_offset*4)) | (iret2 >> (start_offset*8)))) & mask1; + } else { + /* 2*sizeof(__avword) < end_offset < 3*sizeof(__avword), start_offset > 0 */ + __avword mask2 = - ((__avword)1 << (3*sizeof(__avword)*8-end_offset*8)); + wordaddr[1] = (iret << (sizeof(__avword)*8-start_offset*8)) | (iret2 >> (start_offset*8)); + wordaddr[2] ^= (wordaddr[2] ^ (iret2 << (sizeof(__avword)*8-start_offset*8))) & mask2; + } + } + #endif + #endif + } + } + } + } + return 0; +} diff --git a/avcall/avcall-mips64eb-linux.s b/avcall/avcall-mips64eb-linux.s new file mode 100644 index 0000000..c638618 --- /dev/null +++ b/avcall/avcall-mips64eb-linux.s @@ -0,0 +1,734 @@ + .file 1 "avcall-mips64.c" + .section .mdebug.abi64 + .previous + .nan legacy + .module fp=64 + .module oddspreg + .abicalls + .text + .align 2 + .align 3 + .globl avcall_call + .set nomips16 + .set nomicromips + .ent avcall_call + .type avcall_call, @function +avcall_call: + .frame $fp,32,$31 # vars= 0, regs= 4/0, args= 0, gp= 0 + .mask 0xd0010000,-8 + .fmask 0x00000000,0 + ld $2,40($4) + ld $12,48($4) + lw $3,68($4) + daddiu $sp,$sp,-32 + dsubu $6,$2,$12 + dsra $6,$6,3 + sd $fp,16($sp) + sd $16,0($sp) + sd $31,24($sp) + move $fp,$sp + daddiu $sp,$sp,-2064 + move $16,$4 + sll $6,$6,0 + .set noreorder + .set nomacro + beq $3,$0,.L2 + move $2,$sp + .set macro + .set reorder + + andi $4,$3,0x1 + .set noreorder + .set nomacro + beq $4,$0,.L125 + andi $4,$3,0x2 + .set macro + .set reorder + +#APP + # 77 "avcall-mips64.c" 1 + lwc1 $f12,76($16) + # 0 "" 2 +#NO_APP + andi $4,$3,0x2 +.L125: + .set noreorder + .set nomacro + beq $4,$0,.L126 + andi $4,$3,0x4 + .set macro + .set reorder + +#APP + # 79 "avcall-mips64.c" 1 + lwc1 $f13,80($16) + # 0 "" 2 +#NO_APP + andi $4,$3,0x4 +.L126: + .set noreorder + .set nomacro + beq $4,$0,.L127 + andi $4,$3,0x8 + .set macro + .set reorder + +#APP + # 81 "avcall-mips64.c" 1 + lwc1 $f14,84($16) + # 0 "" 2 +#NO_APP + andi $4,$3,0x8 +.L127: + .set noreorder + .set nomacro + beq $4,$0,.L128 + andi $4,$3,0x10 + .set macro + .set reorder + +#APP + # 83 "avcall-mips64.c" 1 + lwc1 $f15,88($16) + # 0 "" 2 +#NO_APP + andi $4,$3,0x10 +.L128: + .set noreorder + .set nomacro + beq $4,$0,.L129 + andi $4,$3,0x20 + .set macro + .set reorder + +#APP + # 85 "avcall-mips64.c" 1 + lwc1 $f16,92($16) + # 0 "" 2 +#NO_APP + andi $4,$3,0x20 +.L129: + .set noreorder + .set nomacro + beq $4,$0,.L130 + andi $4,$3,0x40 + .set macro + .set reorder + +#APP + # 87 "avcall-mips64.c" 1 + lwc1 $f17,96($16) + # 0 "" 2 +#NO_APP + andi $4,$3,0x40 +.L130: + .set noreorder + .set nomacro + beql $4,$0,.L131 + andi $3,$3,0x80 + .set macro + .set reorder + +#APP + # 89 "avcall-mips64.c" 1 + lwc1 $f18,100($16) + # 0 "" 2 +#NO_APP + andi $3,$3,0x80 +.L131: + bne $3,$0,.L118 +.L2: + lw $3,72($16) +.L124: + .set noreorder + .set nomacro + beql $3,$0,.L123 + slt $3,$6,9 + .set macro + .set reorder + + andi $4,$3,0x1 + .set noreorder + .set nomacro + beq $4,$0,.L132 + andi $4,$3,0x2 + .set macro + .set reorder + +#APP + # 97 "avcall-mips64.c" 1 + ldc1 $f12,0($12) + # 0 "" 2 +#NO_APP + andi $4,$3,0x2 +.L132: + .set noreorder + .set nomacro + beq $4,$0,.L133 + andi $4,$3,0x4 + .set macro + .set reorder + +#APP + # 99 "avcall-mips64.c" 1 + ldc1 $f13,8($12) + # 0 "" 2 +#NO_APP + andi $4,$3,0x4 +.L133: + .set noreorder + .set nomacro + beq $4,$0,.L134 + andi $4,$3,0x8 + .set macro + .set reorder + +#APP + # 101 "avcall-mips64.c" 1 + ldc1 $f14,16($12) + # 0 "" 2 +#NO_APP + andi $4,$3,0x8 +.L134: + .set noreorder + .set nomacro + beq $4,$0,.L135 + andi $4,$3,0x10 + .set macro + .set reorder + +#APP + # 103 "avcall-mips64.c" 1 + ldc1 $f15,24($12) + # 0 "" 2 +#NO_APP + andi $4,$3,0x10 +.L135: + .set noreorder + .set nomacro + beq $4,$0,.L136 + andi $4,$3,0x20 + .set macro + .set reorder + +#APP + # 105 "avcall-mips64.c" 1 + ldc1 $f16,32($12) + # 0 "" 2 +#NO_APP + andi $4,$3,0x20 +.L136: + .set noreorder + .set nomacro + beq $4,$0,.L137 + andi $4,$3,0x40 + .set macro + .set reorder + +#APP + # 107 "avcall-mips64.c" 1 + ldc1 $f17,40($12) + # 0 "" 2 +#NO_APP + andi $4,$3,0x40 +.L137: + .set noreorder + .set nomacro + beql $4,$0,.L138 + andi $3,$3,0x80 + .set macro + .set reorder + +#APP + # 109 "avcall-mips64.c" 1 + ldc1 $f18,48($12) + # 0 "" 2 +#NO_APP + andi $3,$3,0x80 +.L138: + bne $3,$0,.L119 + slt $3,$6,9 +.L123: + .set noreorder + .set nomacro + bne $3,$0,.L22 + daddiu $4,$12,64 + .set macro + .set reorder + + li $3,8 # 0x8 + .align 3 +.L21: + ld $5,0($4) + addiu $3,$3,1 + daddiu $4,$4,8 + sd $5,0($2) + .set noreorder + .set nomacro + bne $6,$3,.L21 + daddiu $2,$2,8 + .set macro + .set reorder + +.L22: +#APP + # 118 "avcall-mips64.c" 1 + ld $4,0($12) + # 0 "" 2 + # 119 "avcall-mips64.c" 1 + ld $5,8($12) + # 0 "" 2 + # 120 "avcall-mips64.c" 1 + ld $6,16($12) + # 0 "" 2 + # 121 "avcall-mips64.c" 1 + ld $7,24($12) + # 0 "" 2 + # 122 "avcall-mips64.c" 1 + ld $8,32($12) + # 0 "" 2 + # 123 "avcall-mips64.c" 1 + ld $9,40($12) + # 0 "" 2 + # 124 "avcall-mips64.c" 1 + ld $10,48($12) + # 0 "" 2 + # 125 "avcall-mips64.c" 1 + ld $11,56($12) + # 0 "" 2 +#NO_APP + ld $25,8($16) + jalr $25 + lw $4,24($16) + li $5,1 # 0x1 + .set noreorder + .set nomacro + beql $4,$5,.L139 + move $sp,$fp + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$0,.L110 + li $5,2 # 0x2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L108 + li $5,3 # 0x3 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L108 + li $5,4 # 0x4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L108 + li $5,5 # 0x5 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L111 + li $5,6 # 0x6 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L111 + li $5,7 # 0x7 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L113 + li $5,8 # 0x8 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L113 + li $5,9 # 0x9 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L110 + li $5,10 # 0xa + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L110 + li $5,11 # 0xb + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L110 + li $5,12 # 0xc + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L110 + li $5,13 # 0xd + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L120 + li $5,14 # 0xe + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L121 + li $5,15 # 0xf + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L110 + li $5,16 # 0x10 + .set macro + .set reorder + + .set noreorder + .set nomacro + bnel $4,$5,.L139 + move $sp,$fp + .set macro + .set reorder + + lw $4,0($16) + andi $5,$4,0x200 + .set noreorder + .set nomacro + beq $5,$0,.L19 + andi $4,$4,0x4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beql $4,$0,.L38 + ld $4,32($16) + .set macro + .set reorder + + ld $3,32($16) + li $4,1 # 0x1 + .set noreorder + .set nomacro + beq $3,$4,.L108 + li $4,2 # 0x2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $3,$4,.L111 + li $4,4 # 0x4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $3,$4,.L113 + li $4,8 # 0x8 + .set macro + .set reorder + + .set noreorder + .set nomacro + beql $3,$4,.L140 + ld $3,16($16) + .set macro + .set reorder + +.L19: + move $sp,$fp +.L139: + ld $31,24($sp) + ld $fp,16($sp) + ld $16,0($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + daddiu $sp,$sp,32 + .set macro + .set reorder + + .align 3 +.L110: + ld $3,16($16) + .align 3 +.L140: + sd $2,0($3) + move $sp,$fp + ld $31,24($sp) + ld $fp,16($sp) + ld $16,0($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + daddiu $sp,$sp,32 + .set macro + .set reorder + + .align 3 +.L119: +#APP + # 111 "avcall-mips64.c" 1 + ldc1 $f19,56($12) + # 0 "" 2 +#NO_APP + .set noreorder + .set nomacro + b .L123 + slt $3,$6,9 + .set macro + .set reorder + + .align 3 +.L118: +#APP + # 91 "avcall-mips64.c" 1 + lwc1 $f19,104($16) + # 0 "" 2 +#NO_APP + .set noreorder + .set nomacro + b .L124 + lw $3,72($16) + .set macro + .set reorder + + .align 3 +.L108: + ld $3,16($16) + sb $2,0($3) + move $sp,$fp + ld $31,24($sp) + ld $fp,16($sp) + ld $16,0($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + daddiu $sp,$sp,32 + .set macro + .set reorder + +.L111: + ld $3,16($16) + .set noreorder + .set nomacro + b .L19 + sh $2,0($3) + .set macro + .set reorder + +.L113: + ld $3,16($16) + .set noreorder + .set nomacro + b .L19 + sw $2,0($3) + .set macro + .set reorder + +.L120: + ld $2,16($16) + .set noreorder + .set nomacro + b .L19 + swc1 $f0,0($2) + .set macro + .set reorder + +.L121: + ld $2,16($16) + .set noreorder + .set nomacro + b .L19 + sdc1 $f0,0($2) + .set macro + .set reorder + +.L38: + daddiu $5,$4,-1 + sltu $5,$5,16 + .set noreorder + .set nomacro + beq $5,$0,.L19 + sltu $7,$4,9 + .set macro + .set reorder + + ld $6,16($16) + li $8,-8 # 0xfffffffffffffff8 + andi $5,$6,0x7 + daddu $4,$4,$5 + .set noreorder + .set nomacro + beq $7,$0,.L42 + and $6,$6,$8 + .set macro + .set reorder + + sltu $3,$4,9 + .set noreorder + .set nomacro + beq $3,$0,.L43 + subu $8,$0,$5 + .set macro + .set reorder + + subu $3,$0,$5 + sll $7,$4,0 + sll $3,$3,3 + ld $8,0($6) + addiu $3,$3,63 + subu $7,$0,$7 + li $4,2 # 0x2 + dsll $4,$4,$3 + sll $7,$7,3 + sll $5,$5,3 + li $3,1 # 0x1 + dsll $3,$3,$7 + dsra $2,$2,$5 + dsubu $3,$4,$3 + xor $2,$2,$8 + and $2,$3,$2 + xor $2,$2,$8 + .set noreorder + .set nomacro + b .L19 + sd $2,0($6) + .set macro + .set reorder + + .align 3 +.L42: + subu $9,$0,$5 + ld $11,0($6) + sll $10,$9,3 + addiu $7,$10,63 + sll $5,$5,3 + li $8,2 # 0x2 + dsll $8,$8,$7 + dsra $7,$2,$5 + daddiu $8,$8,-1 + xor $7,$7,$11 + and $7,$8,$7 + xor $7,$7,$11 + sltu $8,$4,17 + .set noreorder + .set nomacro + bne $8,$0,.L122 + sd $7,0($6) + .set macro + .set reorder + + ld $9,16($6) + sll $4,$4,0 + addiu $10,$10,64 + subu $4,$0,$4 + move $8,$3 + sll $4,$4,3 + dsll $3,$3,$10 + li $7,-1 # 0xffffffffffffffff + dsll $4,$7,$4 + xor $3,$3,$9 + dsll $2,$2,$10 + dsra $5,$8,$5 + and $3,$4,$3 + or $2,$2,$5 + xor $3,$3,$9 + sd $2,8($6) + .set noreorder + .set nomacro + b .L19 + sd $3,16($6) + .set macro + .set reorder + +.L43: + ld $11,0($6) + ld $10,8($6) + sll $7,$4,0 + sll $8,$8,3 + sll $5,$5,3 + subu $9,$0,$7 + addiu $4,$8,63 + li $7,2 # 0x2 + dsra $3,$2,$5 + dsll $4,$7,$4 + dsll $2,$2,$8 + sll $7,$9,3 + li $5,-1 # 0xffffffffffffffff + daddiu $4,$4,-1 + xor $3,$3,$11 + dsll $5,$5,$7 + xor $2,$2,$10 + and $3,$4,$3 + and $2,$5,$2 + xor $3,$3,$11 + xor $2,$2,$10 + sd $3,0($6) + .set noreorder + .set nomacro + b .L19 + sd $2,8($6) + .set macro + .set reorder + +.L122: + sll $7,$9,2 + addiu $7,$7,32 + ld $8,8($6) + dsll $2,$2,$7 + sll $4,$4,0 + dsll $7,$2,$7 + dsra $3,$3,$5 + subu $4,$0,$4 + or $3,$7,$3 + sll $4,$4,3 + li $2,-1 # 0xffffffffffffffff + xor $3,$3,$8 + dsll $2,$2,$4 + and $2,$3,$2 + xor $2,$2,$8 + .set noreorder + .set nomacro + b .L19 + sd $2,8($6) + .set macro + .set reorder + + .end avcall_call + .size avcall_call, .-avcall_call + .ident "GCC: (GNU) 5.4.0" diff --git a/avcall/avcall-mips64eb-macro.S b/avcall/avcall-mips64eb-macro.S new file mode 100644 index 0000000..6858ebf --- /dev/null +++ b/avcall/avcall-mips64eb-macro.S @@ -0,0 +1,728 @@ +#include "asm-mips.h" + .file 1 "avcall-mips64.c" + .text + .align 2 + .align 3 + .globl avcall_call + .set nomips16 + .set nomicromips + .ent avcall_call + DECLARE_FUNCTION(avcall_call) +avcall_call: + .frame $fp,32,$31 + .mask 0xd0010000,-8 + .fmask 0x00000000,0 + ld $2,40($4) + ld $12,48($4) + lw $3,68($4) + daddiu $sp,$sp,-32 + dsubu $6,$2,$12 + dsra $6,$6,3 + sd $fp,16($sp) + sd $16,0($sp) + sd $31,24($sp) + move $fp,$sp + daddiu $sp,$sp,-2064 + move $16,$4 + sll $6,$6,0 + .set noreorder + .set nomacro + beq $3,$0,.L2 + move $2,$sp + .set macro + .set reorder + + andi $4,$3,0x1 + .set noreorder + .set nomacro + beq $4,$0,.L125 + andi $4,$3,0x2 + .set macro + .set reorder + + + + lwc1 $f12,76($16) + + + andi $4,$3,0x2 +.L125: + .set noreorder + .set nomacro + beq $4,$0,.L126 + andi $4,$3,0x4 + .set macro + .set reorder + + + + lwc1 $f13,80($16) + + + andi $4,$3,0x4 +.L126: + .set noreorder + .set nomacro + beq $4,$0,.L127 + andi $4,$3,0x8 + .set macro + .set reorder + + + + lwc1 $f14,84($16) + + + andi $4,$3,0x8 +.L127: + .set noreorder + .set nomacro + beq $4,$0,.L128 + andi $4,$3,0x10 + .set macro + .set reorder + + + + lwc1 $f15,88($16) + + + andi $4,$3,0x10 +.L128: + .set noreorder + .set nomacro + beq $4,$0,.L129 + andi $4,$3,0x20 + .set macro + .set reorder + + + + lwc1 $f16,92($16) + + + andi $4,$3,0x20 +.L129: + .set noreorder + .set nomacro + beq $4,$0,.L130 + andi $4,$3,0x40 + .set macro + .set reorder + + + + lwc1 $f17,96($16) + + + andi $4,$3,0x40 +.L130: + .set noreorder + .set nomacro + beql $4,$0,.L131 + andi $3,$3,0x80 + .set macro + .set reorder + + + + lwc1 $f18,100($16) + + + andi $3,$3,0x80 +.L131: + bne $3,$0,.L118 +.L2: + lw $3,72($16) +.L124: + .set noreorder + .set nomacro + beql $3,$0,.L123 + slt $3,$6,9 + .set macro + .set reorder + + andi $4,$3,0x1 + .set noreorder + .set nomacro + beq $4,$0,.L132 + andi $4,$3,0x2 + .set macro + .set reorder + + + + ldc1 $f12,0($12) + + + andi $4,$3,0x2 +.L132: + .set noreorder + .set nomacro + beq $4,$0,.L133 + andi $4,$3,0x4 + .set macro + .set reorder + + + + ldc1 $f13,8($12) + + + andi $4,$3,0x4 +.L133: + .set noreorder + .set nomacro + beq $4,$0,.L134 + andi $4,$3,0x8 + .set macro + .set reorder + + + + ldc1 $f14,16($12) + + + andi $4,$3,0x8 +.L134: + .set noreorder + .set nomacro + beq $4,$0,.L135 + andi $4,$3,0x10 + .set macro + .set reorder + + + + ldc1 $f15,24($12) + + + andi $4,$3,0x10 +.L135: + .set noreorder + .set nomacro + beq $4,$0,.L136 + andi $4,$3,0x20 + .set macro + .set reorder + + + + ldc1 $f16,32($12) + + + andi $4,$3,0x20 +.L136: + .set noreorder + .set nomacro + beq $4,$0,.L137 + andi $4,$3,0x40 + .set macro + .set reorder + + + + ldc1 $f17,40($12) + + + andi $4,$3,0x40 +.L137: + .set noreorder + .set nomacro + beql $4,$0,.L138 + andi $3,$3,0x80 + .set macro + .set reorder + + + + ldc1 $f18,48($12) + + + andi $3,$3,0x80 +.L138: + bne $3,$0,.L119 + slt $3,$6,9 +.L123: + .set noreorder + .set nomacro + bne $3,$0,.L22 + daddiu $4,$12,64 + .set macro + .set reorder + + li $3,8 + .align 3 +.L21: + ld $5,0($4) + addiu $3,$3,1 + daddiu $4,$4,8 + sd $5,0($2) + .set noreorder + .set nomacro + bne $6,$3,.L21 + daddiu $2,$2,8 + .set macro + .set reorder + +.L22: + + + ld $4,0($12) + + + ld $5,8($12) + + + ld $6,16($12) + + + ld $7,24($12) + + + ld $8,32($12) + + + ld $9,40($12) + + + ld $10,48($12) + + + ld $11,56($12) + + + ld $25,8($16) + jalr $25 + lw $4,24($16) + li $5,1 + .set noreorder + .set nomacro + beql $4,$5,.L139 + move $sp,$fp + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$0,.L110 + li $5,2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L108 + li $5,3 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L108 + li $5,4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L108 + li $5,5 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L111 + li $5,6 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L111 + li $5,7 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L113 + li $5,8 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L113 + li $5,9 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L110 + li $5,10 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L110 + li $5,11 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L110 + li $5,12 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L110 + li $5,13 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L120 + li $5,14 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L121 + li $5,15 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L110 + li $5,16 + .set macro + .set reorder + + .set noreorder + .set nomacro + bnel $4,$5,.L139 + move $sp,$fp + .set macro + .set reorder + + lw $4,0($16) + andi $5,$4,0x200 + .set noreorder + .set nomacro + beq $5,$0,.L19 + andi $4,$4,0x4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beql $4,$0,.L38 + ld $4,32($16) + .set macro + .set reorder + + ld $3,32($16) + li $4,1 + .set noreorder + .set nomacro + beq $3,$4,.L108 + li $4,2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $3,$4,.L111 + li $4,4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $3,$4,.L113 + li $4,8 + .set macro + .set reorder + + .set noreorder + .set nomacro + beql $3,$4,.L140 + ld $3,16($16) + .set macro + .set reorder + +.L19: + move $sp,$fp +.L139: + ld $31,24($sp) + ld $fp,16($sp) + ld $16,0($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + daddiu $sp,$sp,32 + .set macro + .set reorder + + .align 3 +.L110: + ld $3,16($16) + .align 3 +.L140: + sd $2,0($3) + move $sp,$fp + ld $31,24($sp) + ld $fp,16($sp) + ld $16,0($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + daddiu $sp,$sp,32 + .set macro + .set reorder + + .align 3 +.L119: + + + ldc1 $f19,56($12) + + + .set noreorder + .set nomacro + b .L123 + slt $3,$6,9 + .set macro + .set reorder + + .align 3 +.L118: + + + lwc1 $f19,104($16) + + + .set noreorder + .set nomacro + b .L124 + lw $3,72($16) + .set macro + .set reorder + + .align 3 +.L108: + ld $3,16($16) + sb $2,0($3) + move $sp,$fp + ld $31,24($sp) + ld $fp,16($sp) + ld $16,0($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + daddiu $sp,$sp,32 + .set macro + .set reorder + +.L111: + ld $3,16($16) + .set noreorder + .set nomacro + b .L19 + sh $2,0($3) + .set macro + .set reorder + +.L113: + ld $3,16($16) + .set noreorder + .set nomacro + b .L19 + sw $2,0($3) + .set macro + .set reorder + +.L120: + ld $2,16($16) + .set noreorder + .set nomacro + b .L19 + swc1 $f0,0($2) + .set macro + .set reorder + +.L121: + ld $2,16($16) + .set noreorder + .set nomacro + b .L19 + sdc1 $f0,0($2) + .set macro + .set reorder + +.L38: + daddiu $5,$4,-1 + sltu $5,$5,16 + .set noreorder + .set nomacro + beq $5,$0,.L19 + sltu $7,$4,9 + .set macro + .set reorder + + ld $6,16($16) + li $8,-8 + andi $5,$6,0x7 + daddu $4,$4,$5 + .set noreorder + .set nomacro + beq $7,$0,.L42 + and $6,$6,$8 + .set macro + .set reorder + + sltu $3,$4,9 + .set noreorder + .set nomacro + beq $3,$0,.L43 + subu $8,$0,$5 + .set macro + .set reorder + + subu $3,$0,$5 + sll $7,$4,0 + sll $3,$3,3 + ld $8,0($6) + addiu $3,$3,63 + subu $7,$0,$7 + li $4,2 + dsll $4,$4,$3 + sll $7,$7,3 + sll $5,$5,3 + li $3,1 + dsll $3,$3,$7 + dsra $2,$2,$5 + dsubu $3,$4,$3 + xor $2,$2,$8 + and $2,$3,$2 + xor $2,$2,$8 + .set noreorder + .set nomacro + b .L19 + sd $2,0($6) + .set macro + .set reorder + + .align 3 +.L42: + subu $9,$0,$5 + ld $11,0($6) + sll $10,$9,3 + addiu $7,$10,63 + sll $5,$5,3 + li $8,2 + dsll $8,$8,$7 + dsra $7,$2,$5 + daddiu $8,$8,-1 + xor $7,$7,$11 + and $7,$8,$7 + xor $7,$7,$11 + sltu $8,$4,17 + .set noreorder + .set nomacro + bne $8,$0,.L122 + sd $7,0($6) + .set macro + .set reorder + + ld $9,16($6) + sll $4,$4,0 + addiu $10,$10,64 + subu $4,$0,$4 + move $8,$3 + sll $4,$4,3 + dsll $3,$3,$10 + li $7,-1 + dsll $4,$7,$4 + xor $3,$3,$9 + dsll $2,$2,$10 + dsra $5,$8,$5 + and $3,$4,$3 + or $2,$2,$5 + xor $3,$3,$9 + sd $2,8($6) + .set noreorder + .set nomacro + b .L19 + sd $3,16($6) + .set macro + .set reorder + +.L43: + ld $11,0($6) + ld $10,8($6) + sll $7,$4,0 + sll $8,$8,3 + sll $5,$5,3 + subu $9,$0,$7 + addiu $4,$8,63 + li $7,2 + dsra $3,$2,$5 + dsll $4,$7,$4 + dsll $2,$2,$8 + sll $7,$9,3 + li $5,-1 + daddiu $4,$4,-1 + xor $3,$3,$11 + dsll $5,$5,$7 + xor $2,$2,$10 + and $3,$4,$3 + and $2,$5,$2 + xor $3,$3,$11 + xor $2,$2,$10 + sd $3,0($6) + .set noreorder + .set nomacro + b .L19 + sd $2,8($6) + .set macro + .set reorder + +.L122: + sll $7,$9,2 + addiu $7,$7,32 + ld $8,8($6) + dsll $2,$2,$7 + sll $4,$4,0 + dsll $7,$2,$7 + dsra $3,$3,$5 + subu $4,$0,$4 + or $3,$7,$3 + sll $4,$4,3 + li $2,-1 + xor $3,$3,$8 + dsll $2,$2,$4 + and $2,$3,$2 + xor $2,$2,$8 + .set noreorder + .set nomacro + b .L19 + sd $2,8($6) + .set macro + .set reorder + + .end avcall_call + .size avcall_call, .-avcall_call diff --git a/avcall/avcall-mips64el-linux.s b/avcall/avcall-mips64el-linux.s new file mode 100644 index 0000000..ce33b01 --- /dev/null +++ b/avcall/avcall-mips64el-linux.s @@ -0,0 +1,729 @@ + .file 1 "avcall-mips64.c" + .section .mdebug.abi64 + .previous + .nan legacy + .module fp=64 + .module oddspreg + .abicalls + .text + .align 2 + .align 3 + .globl avcall_call + .set nomips16 + .set nomicromips + .ent avcall_call + .type avcall_call, @function +avcall_call: + .frame $fp,32,$31 # vars= 0, regs= 4/0, args= 0, gp= 0 + .mask 0xd0010000,-8 + .fmask 0x00000000,0 + ld $2,40($4) + ld $12,48($4) + lw $3,68($4) + daddiu $sp,$sp,-32 + dsubu $6,$2,$12 + dsra $6,$6,3 + sd $fp,16($sp) + sd $16,0($sp) + sd $31,24($sp) + move $fp,$sp + daddiu $sp,$sp,-2064 + move $16,$4 + sll $6,$6,0 + .set noreorder + .set nomacro + beq $3,$0,.L2 + move $2,$sp + .set macro + .set reorder + + andi $4,$3,0x1 + .set noreorder + .set nomacro + beq $4,$0,.L125 + andi $4,$3,0x2 + .set macro + .set reorder + +#APP + # 77 "avcall-mips64.c" 1 + lwc1 $f12,76($16) + # 0 "" 2 +#NO_APP + andi $4,$3,0x2 +.L125: + .set noreorder + .set nomacro + beq $4,$0,.L126 + andi $4,$3,0x4 + .set macro + .set reorder + +#APP + # 79 "avcall-mips64.c" 1 + lwc1 $f13,80($16) + # 0 "" 2 +#NO_APP + andi $4,$3,0x4 +.L126: + .set noreorder + .set nomacro + beq $4,$0,.L127 + andi $4,$3,0x8 + .set macro + .set reorder + +#APP + # 81 "avcall-mips64.c" 1 + lwc1 $f14,84($16) + # 0 "" 2 +#NO_APP + andi $4,$3,0x8 +.L127: + .set noreorder + .set nomacro + beq $4,$0,.L128 + andi $4,$3,0x10 + .set macro + .set reorder + +#APP + # 83 "avcall-mips64.c" 1 + lwc1 $f15,88($16) + # 0 "" 2 +#NO_APP + andi $4,$3,0x10 +.L128: + .set noreorder + .set nomacro + beq $4,$0,.L129 + andi $4,$3,0x20 + .set macro + .set reorder + +#APP + # 85 "avcall-mips64.c" 1 + lwc1 $f16,92($16) + # 0 "" 2 +#NO_APP + andi $4,$3,0x20 +.L129: + .set noreorder + .set nomacro + beq $4,$0,.L130 + andi $4,$3,0x40 + .set macro + .set reorder + +#APP + # 87 "avcall-mips64.c" 1 + lwc1 $f17,96($16) + # 0 "" 2 +#NO_APP + andi $4,$3,0x40 +.L130: + .set noreorder + .set nomacro + beql $4,$0,.L131 + andi $3,$3,0x80 + .set macro + .set reorder + +#APP + # 89 "avcall-mips64.c" 1 + lwc1 $f18,100($16) + # 0 "" 2 +#NO_APP + andi $3,$3,0x80 +.L131: + bne $3,$0,.L118 +.L2: + lw $3,72($16) +.L124: + .set noreorder + .set nomacro + beql $3,$0,.L123 + slt $3,$6,9 + .set macro + .set reorder + + andi $4,$3,0x1 + .set noreorder + .set nomacro + beq $4,$0,.L132 + andi $4,$3,0x2 + .set macro + .set reorder + +#APP + # 97 "avcall-mips64.c" 1 + ldc1 $f12,0($12) + # 0 "" 2 +#NO_APP + andi $4,$3,0x2 +.L132: + .set noreorder + .set nomacro + beq $4,$0,.L133 + andi $4,$3,0x4 + .set macro + .set reorder + +#APP + # 99 "avcall-mips64.c" 1 + ldc1 $f13,8($12) + # 0 "" 2 +#NO_APP + andi $4,$3,0x4 +.L133: + .set noreorder + .set nomacro + beq $4,$0,.L134 + andi $4,$3,0x8 + .set macro + .set reorder + +#APP + # 101 "avcall-mips64.c" 1 + ldc1 $f14,16($12) + # 0 "" 2 +#NO_APP + andi $4,$3,0x8 +.L134: + .set noreorder + .set nomacro + beq $4,$0,.L135 + andi $4,$3,0x10 + .set macro + .set reorder + +#APP + # 103 "avcall-mips64.c" 1 + ldc1 $f15,24($12) + # 0 "" 2 +#NO_APP + andi $4,$3,0x10 +.L135: + .set noreorder + .set nomacro + beq $4,$0,.L136 + andi $4,$3,0x20 + .set macro + .set reorder + +#APP + # 105 "avcall-mips64.c" 1 + ldc1 $f16,32($12) + # 0 "" 2 +#NO_APP + andi $4,$3,0x20 +.L136: + .set noreorder + .set nomacro + beq $4,$0,.L137 + andi $4,$3,0x40 + .set macro + .set reorder + +#APP + # 107 "avcall-mips64.c" 1 + ldc1 $f17,40($12) + # 0 "" 2 +#NO_APP + andi $4,$3,0x40 +.L137: + .set noreorder + .set nomacro + beql $4,$0,.L138 + andi $3,$3,0x80 + .set macro + .set reorder + +#APP + # 109 "avcall-mips64.c" 1 + ldc1 $f18,48($12) + # 0 "" 2 +#NO_APP + andi $3,$3,0x80 +.L138: + bne $3,$0,.L119 + slt $3,$6,9 +.L123: + .set noreorder + .set nomacro + bne $3,$0,.L22 + daddiu $4,$12,64 + .set macro + .set reorder + + li $3,8 # 0x8 + .align 3 +.L21: + ld $5,0($4) + addiu $3,$3,1 + daddiu $4,$4,8 + sd $5,0($2) + .set noreorder + .set nomacro + bne $6,$3,.L21 + daddiu $2,$2,8 + .set macro + .set reorder + +.L22: +#APP + # 118 "avcall-mips64.c" 1 + ld $4,0($12) + # 0 "" 2 + # 119 "avcall-mips64.c" 1 + ld $5,8($12) + # 0 "" 2 + # 120 "avcall-mips64.c" 1 + ld $6,16($12) + # 0 "" 2 + # 121 "avcall-mips64.c" 1 + ld $7,24($12) + # 0 "" 2 + # 122 "avcall-mips64.c" 1 + ld $8,32($12) + # 0 "" 2 + # 123 "avcall-mips64.c" 1 + ld $9,40($12) + # 0 "" 2 + # 124 "avcall-mips64.c" 1 + ld $10,48($12) + # 0 "" 2 + # 125 "avcall-mips64.c" 1 + ld $11,56($12) + # 0 "" 2 +#NO_APP + ld $25,8($16) + jalr $25 + lw $4,24($16) + li $5,1 # 0x1 + .set noreorder + .set nomacro + beql $4,$5,.L139 + move $sp,$fp + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$0,.L110 + li $5,2 # 0x2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L108 + li $5,3 # 0x3 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L108 + li $5,4 # 0x4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L108 + li $5,5 # 0x5 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L111 + li $5,6 # 0x6 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L111 + li $5,7 # 0x7 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L113 + li $5,8 # 0x8 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L113 + li $5,9 # 0x9 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L110 + li $5,10 # 0xa + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L110 + li $5,11 # 0xb + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L110 + li $5,12 # 0xc + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L110 + li $5,13 # 0xd + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L120 + li $5,14 # 0xe + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L121 + li $5,15 # 0xf + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L110 + li $5,16 # 0x10 + .set macro + .set reorder + + .set noreorder + .set nomacro + bnel $4,$5,.L139 + move $sp,$fp + .set macro + .set reorder + + lw $4,0($16) + andi $5,$4,0x200 + .set noreorder + .set nomacro + beq $5,$0,.L19 + andi $4,$4,0x4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beql $4,$0,.L38 + ld $5,32($16) + .set macro + .set reorder + + ld $3,32($16) + li $4,1 # 0x1 + .set noreorder + .set nomacro + beq $3,$4,.L108 + li $4,2 # 0x2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $3,$4,.L111 + li $4,4 # 0x4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $3,$4,.L113 + li $4,8 # 0x8 + .set macro + .set reorder + + .set noreorder + .set nomacro + beql $3,$4,.L140 + ld $3,16($16) + .set macro + .set reorder + +.L19: + move $sp,$fp +.L139: + ld $31,24($sp) + ld $fp,16($sp) + ld $16,0($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + daddiu $sp,$sp,32 + .set macro + .set reorder + + .align 3 +.L110: + ld $3,16($16) + .align 3 +.L140: + sd $2,0($3) + move $sp,$fp + ld $31,24($sp) + ld $fp,16($sp) + ld $16,0($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + daddiu $sp,$sp,32 + .set macro + .set reorder + + .align 3 +.L119: +#APP + # 111 "avcall-mips64.c" 1 + ldc1 $f19,56($12) + # 0 "" 2 +#NO_APP + .set noreorder + .set nomacro + b .L123 + slt $3,$6,9 + .set macro + .set reorder + + .align 3 +.L118: +#APP + # 91 "avcall-mips64.c" 1 + lwc1 $f19,104($16) + # 0 "" 2 +#NO_APP + .set noreorder + .set nomacro + b .L124 + lw $3,72($16) + .set macro + .set reorder + + .align 3 +.L108: + ld $3,16($16) + sb $2,0($3) + move $sp,$fp + ld $31,24($sp) + ld $fp,16($sp) + ld $16,0($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + daddiu $sp,$sp,32 + .set macro + .set reorder + +.L111: + ld $3,16($16) + .set noreorder + .set nomacro + b .L19 + sh $2,0($3) + .set macro + .set reorder + +.L113: + ld $3,16($16) + .set noreorder + .set nomacro + b .L19 + sw $2,0($3) + .set macro + .set reorder + +.L120: + ld $2,16($16) + .set noreorder + .set nomacro + b .L19 + swc1 $f0,0($2) + .set macro + .set reorder + +.L121: + ld $2,16($16) + .set noreorder + .set nomacro + b .L19 + sdc1 $f0,0($2) + .set macro + .set reorder + +.L38: + daddiu $4,$5,-1 + sltu $4,$4,16 + .set noreorder + .set nomacro + beq $4,$0,.L19 + sltu $7,$5,9 + .set macro + .set reorder + + ld $6,16($16) + li $8,-8 # 0xfffffffffffffff8 + andi $4,$6,0x7 + daddu $5,$5,$4 + .set noreorder + .set nomacro + beq $7,$0,.L42 + and $6,$6,$8 + .set macro + .set reorder + + sltu $3,$5,9 + .set noreorder + .set nomacro + beq $3,$0,.L43 + dsll $3,$5,3 + .set macro + .set reorder + + daddiu $3,$3,-1 + ld $7,0($6) + li $5,2 # 0x2 + sll $3,$3,0 + sll $4,$4,3 + dsll $3,$5,$3 + li $5,1 # 0x1 + dsll $5,$5,$4 + dsll $4,$2,$4 + dsubu $3,$3,$5 + xor $4,$4,$7 + and $4,$3,$4 + xor $4,$4,$7 + .set noreorder + .set nomacro + b .L19 + sd $4,0($6) + .set macro + .set reorder + + .align 3 +.L42: + ld $10,0($6) + sll $8,$4,3 + dsll $7,$2,$8 + li $9,-1 # 0xffffffffffffffff + dsll $9,$9,$8 + xor $7,$7,$10 + and $7,$9,$7 + xor $7,$7,$10 + sltu $9,$5,17 + subu $4,$0,$4 + .set noreorder + .set nomacro + bne $9,$0,.L122 + sd $7,0($6) + .set macro + .set reorder + + dsll $5,$5,3 + ld $10,16($6) + sll $4,$4,3 + daddiu $5,$5,-129 + addiu $4,$4,64 + sll $5,$5,0 + li $7,2 # 0x2 + move $9,$3 + dsll $5,$7,$5 + dsra $3,$3,$4 + daddiu $5,$5,-1 + xor $3,$3,$10 + dsra $2,$2,$4 + dsll $8,$9,$8 + and $3,$5,$3 + or $2,$2,$8 + xor $3,$3,$10 + sd $2,8($6) + .set noreorder + .set nomacro + b .L19 + sd $3,16($6) + .set macro + .set reorder + +.L43: + ld $10,0($6) + ld $9,8($6) + subu $7,$0,$4 + daddiu $3,$3,-65 + sll $4,$4,3 + li $5,2 # 0x2 + sll $3,$3,0 + sll $7,$7,3 + dsll $8,$2,$4 + dsll $3,$5,$3 + dsra $2,$2,$7 + li $5,-1 # 0xffffffffffffffff + dsll $4,$5,$4 + daddiu $3,$3,-1 + xor $5,$8,$10 + xor $2,$2,$9 + and $2,$3,$2 + and $4,$4,$5 + xor $3,$4,$10 + xor $2,$2,$9 + sd $3,0($6) + .set noreorder + .set nomacro + b .L19 + sd $2,8($6) + .set macro + .set reorder + +.L122: + sll $4,$4,2 + addiu $4,$4,32 + dsll $5,$5,3 + ld $7,8($6) + dsra $2,$2,$4 + daddiu $5,$5,-65 + dsra $4,$2,$4 + dsll $3,$3,$8 + sll $5,$5,0 + li $2,2 # 0x2 + or $3,$4,$3 + dsll $2,$2,$5 + xor $3,$3,$7 + daddiu $2,$2,-1 + and $2,$3,$2 + xor $2,$2,$7 + .set noreorder + .set nomacro + b .L19 + sd $2,8($6) + .set macro + .set reorder + + .end avcall_call + .size avcall_call, .-avcall_call + .ident "GCC: (GNU) 5.4.0" diff --git a/avcall/avcall-mips64el-macro.S b/avcall/avcall-mips64el-macro.S new file mode 100644 index 0000000..ed3df52 --- /dev/null +++ b/avcall/avcall-mips64el-macro.S @@ -0,0 +1,723 @@ +#include "asm-mips.h" + .file 1 "avcall-mips64.c" + .text + .align 2 + .align 3 + .globl avcall_call + .set nomips16 + .set nomicromips + .ent avcall_call + DECLARE_FUNCTION(avcall_call) +avcall_call: + .frame $fp,32,$31 + .mask 0xd0010000,-8 + .fmask 0x00000000,0 + ld $2,40($4) + ld $12,48($4) + lw $3,68($4) + daddiu $sp,$sp,-32 + dsubu $6,$2,$12 + dsra $6,$6,3 + sd $fp,16($sp) + sd $16,0($sp) + sd $31,24($sp) + move $fp,$sp + daddiu $sp,$sp,-2064 + move $16,$4 + sll $6,$6,0 + .set noreorder + .set nomacro + beq $3,$0,.L2 + move $2,$sp + .set macro + .set reorder + + andi $4,$3,0x1 + .set noreorder + .set nomacro + beq $4,$0,.L125 + andi $4,$3,0x2 + .set macro + .set reorder + + + + lwc1 $f12,76($16) + + + andi $4,$3,0x2 +.L125: + .set noreorder + .set nomacro + beq $4,$0,.L126 + andi $4,$3,0x4 + .set macro + .set reorder + + + + lwc1 $f13,80($16) + + + andi $4,$3,0x4 +.L126: + .set noreorder + .set nomacro + beq $4,$0,.L127 + andi $4,$3,0x8 + .set macro + .set reorder + + + + lwc1 $f14,84($16) + + + andi $4,$3,0x8 +.L127: + .set noreorder + .set nomacro + beq $4,$0,.L128 + andi $4,$3,0x10 + .set macro + .set reorder + + + + lwc1 $f15,88($16) + + + andi $4,$3,0x10 +.L128: + .set noreorder + .set nomacro + beq $4,$0,.L129 + andi $4,$3,0x20 + .set macro + .set reorder + + + + lwc1 $f16,92($16) + + + andi $4,$3,0x20 +.L129: + .set noreorder + .set nomacro + beq $4,$0,.L130 + andi $4,$3,0x40 + .set macro + .set reorder + + + + lwc1 $f17,96($16) + + + andi $4,$3,0x40 +.L130: + .set noreorder + .set nomacro + beql $4,$0,.L131 + andi $3,$3,0x80 + .set macro + .set reorder + + + + lwc1 $f18,100($16) + + + andi $3,$3,0x80 +.L131: + bne $3,$0,.L118 +.L2: + lw $3,72($16) +.L124: + .set noreorder + .set nomacro + beql $3,$0,.L123 + slt $3,$6,9 + .set macro + .set reorder + + andi $4,$3,0x1 + .set noreorder + .set nomacro + beq $4,$0,.L132 + andi $4,$3,0x2 + .set macro + .set reorder + + + + ldc1 $f12,0($12) + + + andi $4,$3,0x2 +.L132: + .set noreorder + .set nomacro + beq $4,$0,.L133 + andi $4,$3,0x4 + .set macro + .set reorder + + + + ldc1 $f13,8($12) + + + andi $4,$3,0x4 +.L133: + .set noreorder + .set nomacro + beq $4,$0,.L134 + andi $4,$3,0x8 + .set macro + .set reorder + + + + ldc1 $f14,16($12) + + + andi $4,$3,0x8 +.L134: + .set noreorder + .set nomacro + beq $4,$0,.L135 + andi $4,$3,0x10 + .set macro + .set reorder + + + + ldc1 $f15,24($12) + + + andi $4,$3,0x10 +.L135: + .set noreorder + .set nomacro + beq $4,$0,.L136 + andi $4,$3,0x20 + .set macro + .set reorder + + + + ldc1 $f16,32($12) + + + andi $4,$3,0x20 +.L136: + .set noreorder + .set nomacro + beq $4,$0,.L137 + andi $4,$3,0x40 + .set macro + .set reorder + + + + ldc1 $f17,40($12) + + + andi $4,$3,0x40 +.L137: + .set noreorder + .set nomacro + beql $4,$0,.L138 + andi $3,$3,0x80 + .set macro + .set reorder + + + + ldc1 $f18,48($12) + + + andi $3,$3,0x80 +.L138: + bne $3,$0,.L119 + slt $3,$6,9 +.L123: + .set noreorder + .set nomacro + bne $3,$0,.L22 + daddiu $4,$12,64 + .set macro + .set reorder + + li $3,8 + .align 3 +.L21: + ld $5,0($4) + addiu $3,$3,1 + daddiu $4,$4,8 + sd $5,0($2) + .set noreorder + .set nomacro + bne $6,$3,.L21 + daddiu $2,$2,8 + .set macro + .set reorder + +.L22: + + + ld $4,0($12) + + + ld $5,8($12) + + + ld $6,16($12) + + + ld $7,24($12) + + + ld $8,32($12) + + + ld $9,40($12) + + + ld $10,48($12) + + + ld $11,56($12) + + + ld $25,8($16) + jalr $25 + lw $4,24($16) + li $5,1 + .set noreorder + .set nomacro + beql $4,$5,.L139 + move $sp,$fp + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$0,.L110 + li $5,2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L108 + li $5,3 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L108 + li $5,4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L108 + li $5,5 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L111 + li $5,6 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L111 + li $5,7 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L113 + li $5,8 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L113 + li $5,9 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L110 + li $5,10 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L110 + li $5,11 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L110 + li $5,12 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L110 + li $5,13 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L120 + li $5,14 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L121 + li $5,15 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L110 + li $5,16 + .set macro + .set reorder + + .set noreorder + .set nomacro + bnel $4,$5,.L139 + move $sp,$fp + .set macro + .set reorder + + lw $4,0($16) + andi $5,$4,0x200 + .set noreorder + .set nomacro + beq $5,$0,.L19 + andi $4,$4,0x4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beql $4,$0,.L38 + ld $5,32($16) + .set macro + .set reorder + + ld $3,32($16) + li $4,1 + .set noreorder + .set nomacro + beq $3,$4,.L108 + li $4,2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $3,$4,.L111 + li $4,4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $3,$4,.L113 + li $4,8 + .set macro + .set reorder + + .set noreorder + .set nomacro + beql $3,$4,.L140 + ld $3,16($16) + .set macro + .set reorder + +.L19: + move $sp,$fp +.L139: + ld $31,24($sp) + ld $fp,16($sp) + ld $16,0($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + daddiu $sp,$sp,32 + .set macro + .set reorder + + .align 3 +.L110: + ld $3,16($16) + .align 3 +.L140: + sd $2,0($3) + move $sp,$fp + ld $31,24($sp) + ld $fp,16($sp) + ld $16,0($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + daddiu $sp,$sp,32 + .set macro + .set reorder + + .align 3 +.L119: + + + ldc1 $f19,56($12) + + + .set noreorder + .set nomacro + b .L123 + slt $3,$6,9 + .set macro + .set reorder + + .align 3 +.L118: + + + lwc1 $f19,104($16) + + + .set noreorder + .set nomacro + b .L124 + lw $3,72($16) + .set macro + .set reorder + + .align 3 +.L108: + ld $3,16($16) + sb $2,0($3) + move $sp,$fp + ld $31,24($sp) + ld $fp,16($sp) + ld $16,0($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + daddiu $sp,$sp,32 + .set macro + .set reorder + +.L111: + ld $3,16($16) + .set noreorder + .set nomacro + b .L19 + sh $2,0($3) + .set macro + .set reorder + +.L113: + ld $3,16($16) + .set noreorder + .set nomacro + b .L19 + sw $2,0($3) + .set macro + .set reorder + +.L120: + ld $2,16($16) + .set noreorder + .set nomacro + b .L19 + swc1 $f0,0($2) + .set macro + .set reorder + +.L121: + ld $2,16($16) + .set noreorder + .set nomacro + b .L19 + sdc1 $f0,0($2) + .set macro + .set reorder + +.L38: + daddiu $4,$5,-1 + sltu $4,$4,16 + .set noreorder + .set nomacro + beq $4,$0,.L19 + sltu $7,$5,9 + .set macro + .set reorder + + ld $6,16($16) + li $8,-8 + andi $4,$6,0x7 + daddu $5,$5,$4 + .set noreorder + .set nomacro + beq $7,$0,.L42 + and $6,$6,$8 + .set macro + .set reorder + + sltu $3,$5,9 + .set noreorder + .set nomacro + beq $3,$0,.L43 + dsll $3,$5,3 + .set macro + .set reorder + + daddiu $3,$3,-1 + ld $7,0($6) + li $5,2 + sll $3,$3,0 + sll $4,$4,3 + dsll $3,$5,$3 + li $5,1 + dsll $5,$5,$4 + dsll $4,$2,$4 + dsubu $3,$3,$5 + xor $4,$4,$7 + and $4,$3,$4 + xor $4,$4,$7 + .set noreorder + .set nomacro + b .L19 + sd $4,0($6) + .set macro + .set reorder + + .align 3 +.L42: + ld $10,0($6) + sll $8,$4,3 + dsll $7,$2,$8 + li $9,-1 + dsll $9,$9,$8 + xor $7,$7,$10 + and $7,$9,$7 + xor $7,$7,$10 + sltu $9,$5,17 + subu $4,$0,$4 + .set noreorder + .set nomacro + bne $9,$0,.L122 + sd $7,0($6) + .set macro + .set reorder + + dsll $5,$5,3 + ld $10,16($6) + sll $4,$4,3 + daddiu $5,$5,-129 + addiu $4,$4,64 + sll $5,$5,0 + li $7,2 + move $9,$3 + dsll $5,$7,$5 + dsra $3,$3,$4 + daddiu $5,$5,-1 + xor $3,$3,$10 + dsra $2,$2,$4 + dsll $8,$9,$8 + and $3,$5,$3 + or $2,$2,$8 + xor $3,$3,$10 + sd $2,8($6) + .set noreorder + .set nomacro + b .L19 + sd $3,16($6) + .set macro + .set reorder + +.L43: + ld $10,0($6) + ld $9,8($6) + subu $7,$0,$4 + daddiu $3,$3,-65 + sll $4,$4,3 + li $5,2 + sll $3,$3,0 + sll $7,$7,3 + dsll $8,$2,$4 + dsll $3,$5,$3 + dsra $2,$2,$7 + li $5,-1 + dsll $4,$5,$4 + daddiu $3,$3,-1 + xor $5,$8,$10 + xor $2,$2,$9 + and $2,$3,$2 + and $4,$4,$5 + xor $3,$4,$10 + xor $2,$2,$9 + sd $3,0($6) + .set noreorder + .set nomacro + b .L19 + sd $2,8($6) + .set macro + .set reorder + +.L122: + sll $4,$4,2 + addiu $4,$4,32 + dsll $5,$5,3 + ld $7,8($6) + dsra $2,$2,$4 + daddiu $5,$5,-65 + dsra $4,$2,$4 + dsll $3,$3,$8 + sll $5,$5,0 + li $2,2 + or $3,$4,$3 + dsll $2,$2,$5 + xor $3,$3,$7 + daddiu $2,$2,-1 + and $2,$3,$2 + xor $2,$2,$7 + .set noreorder + .set nomacro + b .L19 + sd $2,8($6) + .set macro + .set reorder + + .end avcall_call + .size avcall_call, .-avcall_call diff --git a/avcall/avcall-mipseb-linux.s b/avcall/avcall-mipseb-linux.s new file mode 100644 index 0000000..4a7dee3 --- /dev/null +++ b/avcall/avcall-mipseb-linux.s @@ -0,0 +1,350 @@ + .file 1 "avcall-mips.c" + .section .mdebug.abi32 + .previous + .nan legacy + .module fp=xx + .module nooddspreg + .abicalls + .text + .align 2 + .globl avcall_call + .set nomips16 + .set nomicromips + .ent avcall_call + .type avcall_call, @function +avcall_call: + .frame $fp,40,$31 # vars= 0, regs= 3/0, args= 16, gp= 8 + .mask 0xc0010000,-4 + .fmask 0x00000000,0 + lw $6,40($4) + lw $5,20($4) + lw $8,24($4) + addiu $sp,$sp,-40 + andi $2,$6,0x1 + sw $fp,32($sp) + sw $16,28($sp) + move $fp,$sp + sw $31,36($sp) + move $16,$4 + addiu $sp,$sp,-1032 + subu $4,$5,$8 + move $3,$sp + .set noreorder + .set nomacro + beq $2,$0,$L2 + sra $4,$4,2 + .set macro + .set reorder + +#APP + # 76 "avcall-mips.c" 1 + l.s $f12,48($16) + # 0 "" 2 +#NO_APP +$L2: + lw $2,44($16) + andi $7,$2,0x1 + .set noreorder + .set nomacro + beql $7,$0,$L55 + andi $6,$6,0x2 + .set macro + .set reorder + +#APP + # 78 "avcall-mips.c" 1 + l.d $f12,56($16) + # 0 "" 2 +#NO_APP + andi $6,$6,0x2 +$L55: + .set noreorder + .set nomacro + beql $6,$0,$L56 + andi $2,$2,0x2 + .set macro + .set reorder + +#APP + # 80 "avcall-mips.c" 1 + l.s $f14,52($16) + # 0 "" 2 +#NO_APP + andi $2,$2,0x2 +$L56: + .set noreorder + .set nomacro + beql $2,$0,$L57 + slt $4,$4,5 + .set macro + .set reorder + +#APP + # 82 "avcall-mips.c" 1 + l.d $f14,64($16) + # 0 "" 2 +#NO_APP + slt $4,$4,5 +$L57: + addiu $2,$8,16 + .set noreorder + .set nomacro + bne $4,$0,$L10 + addiu $3,$3,16 + .set macro + .set reorder + +$L37: + lw $4,0($2) + addiu $3,$3,4 + addiu $2,$2,4 + .set noreorder + .set nomacro + bne $5,$2,$L37 + sw $4,-4($3) + .set macro + .set reorder + +$L10: + lw $5,4($8) + lw $4,0($8) + lw $25,4($16) + lw $7,12($8) + .set noreorder + .set nomacro + jalr $25 + lw $6,8($8) + .set macro + .set reorder + + lw $4,12($16) + li $5,1 # 0x1 + .set noreorder + .set nomacro + beql $4,$5,$L58 + move $sp,$fp + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$0,$L46 + li $5,2 # 0x2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L49 + li $5,3 # 0x3 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L49 + li $5,4 # 0x4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L49 + li $5,5 # 0x5 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L50 + li $5,6 # 0x6 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L50 + li $5,7 # 0x7 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L46 + li $5,8 # 0x8 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L46 + li $5,9 # 0x9 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L46 + li $5,10 # 0xa + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L46 + addiu $5,$4,-11 + .set macro + .set reorder + + sltu $5,$5,2 + .set noreorder + .set nomacro + bnel $5,$0,$L52 + lw $4,8($16) + .set macro + .set reorder + + li $3,13 # 0xd + .set noreorder + .set nomacro + beq $4,$3,$L53 + li $3,14 # 0xe + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$3,$L54 + li $3,15 # 0xf + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$3,$L46 + li $3,16 # 0x10 + .set macro + .set reorder + + .set noreorder + .set nomacro + bnel $4,$3,$L58 + move $sp,$fp + .set macro + .set reorder + + lw $3,0($16) + andi $3,$3,0x2 + .set noreorder + .set nomacro + beq $3,$0,$L7 + li $4,1 # 0x1 + .set macro + .set reorder + + lw $3,16($16) + .set noreorder + .set nomacro + beq $3,$4,$L49 + li $4,2 # 0x2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $3,$4,$L50 + li $4,4 # 0x4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beql $3,$4,$L59 + lw $3,8($16) + .set macro + .set reorder + +$L7: + move $sp,$fp +$L58: + lw $31,36($sp) + lw $fp,32($sp) + lw $16,28($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,40 + .set macro + .set reorder + +$L46: + lw $3,8($16) +$L59: + sw $2,0($3) + move $sp,$fp + lw $31,36($sp) + lw $fp,32($sp) + lw $16,28($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,40 + .set macro + .set reorder + +$L49: + lw $3,8($16) + sb $2,0($3) + move $sp,$fp + lw $31,36($sp) + lw $fp,32($sp) + lw $16,28($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,40 + .set macro + .set reorder + +$L50: + lw $3,8($16) + .set noreorder + .set nomacro + b $L7 + sh $2,0($3) + .set macro + .set reorder + +$L53: + lw $2,8($16) + .set noreorder + .set nomacro + b $L7 + swc1 $f0,0($2) + .set macro + .set reorder + +$L52: + sw $2,0($4) + .set noreorder + .set nomacro + b $L7 + sw $3,4($4) + .set macro + .set reorder + +$L54: + lw $2,8($16) + .set noreorder + .set nomacro + b $L7 + sdc1 $f0,0($2) + .set macro + .set reorder + + .end avcall_call + .size avcall_call, .-avcall_call + .ident "GCC: (GNU) 5.4.0" diff --git a/avcall/avcall-mipseb-macro.S b/avcall/avcall-mipseb-macro.S new file mode 100644 index 0000000..e37fcd2 --- /dev/null +++ b/avcall/avcall-mipseb-macro.S @@ -0,0 +1,344 @@ +#include "asm-mips.h" + .file 1 "avcall-mips.c" + .text + .align 2 + .globl avcall_call + .set nomips16 + .set nomicromips + .ent avcall_call + DECLARE_FUNCTION(avcall_call) +avcall_call: + .frame $fp,40,$31 + .mask 0xc0010000,-4 + .fmask 0x00000000,0 + lw $6,40($4) + lw $5,20($4) + lw $8,24($4) + addiu $sp,$sp,-40 + andi $2,$6,0x1 + sw $fp,32($sp) + sw $16,28($sp) + move $fp,$sp + sw $31,36($sp) + move $16,$4 + addiu $sp,$sp,-1032 + subu $4,$5,$8 + move $3,$sp + .set noreorder + .set nomacro + beq $2,$0,$L2 + sra $4,$4,2 + .set macro + .set reorder + + + + l.s $f12,48($16) + + +$L2: + lw $2,44($16) + andi $7,$2,0x1 + .set noreorder + .set nomacro + beql $7,$0,$L55 + andi $6,$6,0x2 + .set macro + .set reorder + + + + l.d $f12,56($16) + + + andi $6,$6,0x2 +$L55: + .set noreorder + .set nomacro + beql $6,$0,$L56 + andi $2,$2,0x2 + .set macro + .set reorder + + + + l.s $f14,52($16) + + + andi $2,$2,0x2 +$L56: + .set noreorder + .set nomacro + beql $2,$0,$L57 + slt $4,$4,5 + .set macro + .set reorder + + + + l.d $f14,64($16) + + + slt $4,$4,5 +$L57: + addiu $2,$8,16 + .set noreorder + .set nomacro + bne $4,$0,$L10 + addiu $3,$3,16 + .set macro + .set reorder + +$L37: + lw $4,0($2) + addiu $3,$3,4 + addiu $2,$2,4 + .set noreorder + .set nomacro + bne $5,$2,$L37 + sw $4,-4($3) + .set macro + .set reorder + +$L10: + lw $5,4($8) + lw $4,0($8) + lw $25,4($16) + lw $7,12($8) + .set noreorder + .set nomacro + jalr $25 + lw $6,8($8) + .set macro + .set reorder + + lw $4,12($16) + li $5,1 + .set noreorder + .set nomacro + beql $4,$5,$L58 + move $sp,$fp + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$0,$L46 + li $5,2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L49 + li $5,3 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L49 + li $5,4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L49 + li $5,5 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L50 + li $5,6 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L50 + li $5,7 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L46 + li $5,8 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L46 + li $5,9 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L46 + li $5,10 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L46 + addiu $5,$4,-11 + .set macro + .set reorder + + sltu $5,$5,2 + .set noreorder + .set nomacro + bnel $5,$0,$L52 + lw $4,8($16) + .set macro + .set reorder + + li $3,13 + .set noreorder + .set nomacro + beq $4,$3,$L53 + li $3,14 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$3,$L54 + li $3,15 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$3,$L46 + li $3,16 + .set macro + .set reorder + + .set noreorder + .set nomacro + bnel $4,$3,$L58 + move $sp,$fp + .set macro + .set reorder + + lw $3,0($16) + andi $3,$3,0x2 + .set noreorder + .set nomacro + beq $3,$0,$L7 + li $4,1 + .set macro + .set reorder + + lw $3,16($16) + .set noreorder + .set nomacro + beq $3,$4,$L49 + li $4,2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $3,$4,$L50 + li $4,4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beql $3,$4,$L59 + lw $3,8($16) + .set macro + .set reorder + +$L7: + move $sp,$fp +$L58: + lw $31,36($sp) + lw $fp,32($sp) + lw $16,28($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,40 + .set macro + .set reorder + +$L46: + lw $3,8($16) +$L59: + sw $2,0($3) + move $sp,$fp + lw $31,36($sp) + lw $fp,32($sp) + lw $16,28($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,40 + .set macro + .set reorder + +$L49: + lw $3,8($16) + sb $2,0($3) + move $sp,$fp + lw $31,36($sp) + lw $fp,32($sp) + lw $16,28($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,40 + .set macro + .set reorder + +$L50: + lw $3,8($16) + .set noreorder + .set nomacro + b $L7 + sh $2,0($3) + .set macro + .set reorder + +$L53: + lw $2,8($16) + .set noreorder + .set nomacro + b $L7 + swc1 $f0,0($2) + .set macro + .set reorder + +$L52: + sw $2,0($4) + .set noreorder + .set nomacro + b $L7 + sw $3,4($4) + .set macro + .set reorder + +$L54: + lw $2,8($16) + .set noreorder + .set nomacro + b $L7 + sdc1 $f0,0($2) + .set macro + .set reorder + + .end avcall_call + .size avcall_call, .-avcall_call diff --git a/avcall/avcall-mipsel-linux.s b/avcall/avcall-mipsel-linux.s new file mode 100644 index 0000000..4a7dee3 --- /dev/null +++ b/avcall/avcall-mipsel-linux.s @@ -0,0 +1,350 @@ + .file 1 "avcall-mips.c" + .section .mdebug.abi32 + .previous + .nan legacy + .module fp=xx + .module nooddspreg + .abicalls + .text + .align 2 + .globl avcall_call + .set nomips16 + .set nomicromips + .ent avcall_call + .type avcall_call, @function +avcall_call: + .frame $fp,40,$31 # vars= 0, regs= 3/0, args= 16, gp= 8 + .mask 0xc0010000,-4 + .fmask 0x00000000,0 + lw $6,40($4) + lw $5,20($4) + lw $8,24($4) + addiu $sp,$sp,-40 + andi $2,$6,0x1 + sw $fp,32($sp) + sw $16,28($sp) + move $fp,$sp + sw $31,36($sp) + move $16,$4 + addiu $sp,$sp,-1032 + subu $4,$5,$8 + move $3,$sp + .set noreorder + .set nomacro + beq $2,$0,$L2 + sra $4,$4,2 + .set macro + .set reorder + +#APP + # 76 "avcall-mips.c" 1 + l.s $f12,48($16) + # 0 "" 2 +#NO_APP +$L2: + lw $2,44($16) + andi $7,$2,0x1 + .set noreorder + .set nomacro + beql $7,$0,$L55 + andi $6,$6,0x2 + .set macro + .set reorder + +#APP + # 78 "avcall-mips.c" 1 + l.d $f12,56($16) + # 0 "" 2 +#NO_APP + andi $6,$6,0x2 +$L55: + .set noreorder + .set nomacro + beql $6,$0,$L56 + andi $2,$2,0x2 + .set macro + .set reorder + +#APP + # 80 "avcall-mips.c" 1 + l.s $f14,52($16) + # 0 "" 2 +#NO_APP + andi $2,$2,0x2 +$L56: + .set noreorder + .set nomacro + beql $2,$0,$L57 + slt $4,$4,5 + .set macro + .set reorder + +#APP + # 82 "avcall-mips.c" 1 + l.d $f14,64($16) + # 0 "" 2 +#NO_APP + slt $4,$4,5 +$L57: + addiu $2,$8,16 + .set noreorder + .set nomacro + bne $4,$0,$L10 + addiu $3,$3,16 + .set macro + .set reorder + +$L37: + lw $4,0($2) + addiu $3,$3,4 + addiu $2,$2,4 + .set noreorder + .set nomacro + bne $5,$2,$L37 + sw $4,-4($3) + .set macro + .set reorder + +$L10: + lw $5,4($8) + lw $4,0($8) + lw $25,4($16) + lw $7,12($8) + .set noreorder + .set nomacro + jalr $25 + lw $6,8($8) + .set macro + .set reorder + + lw $4,12($16) + li $5,1 # 0x1 + .set noreorder + .set nomacro + beql $4,$5,$L58 + move $sp,$fp + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$0,$L46 + li $5,2 # 0x2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L49 + li $5,3 # 0x3 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L49 + li $5,4 # 0x4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L49 + li $5,5 # 0x5 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L50 + li $5,6 # 0x6 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L50 + li $5,7 # 0x7 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L46 + li $5,8 # 0x8 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L46 + li $5,9 # 0x9 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L46 + li $5,10 # 0xa + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L46 + addiu $5,$4,-11 + .set macro + .set reorder + + sltu $5,$5,2 + .set noreorder + .set nomacro + bnel $5,$0,$L52 + lw $4,8($16) + .set macro + .set reorder + + li $3,13 # 0xd + .set noreorder + .set nomacro + beq $4,$3,$L53 + li $3,14 # 0xe + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$3,$L54 + li $3,15 # 0xf + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$3,$L46 + li $3,16 # 0x10 + .set macro + .set reorder + + .set noreorder + .set nomacro + bnel $4,$3,$L58 + move $sp,$fp + .set macro + .set reorder + + lw $3,0($16) + andi $3,$3,0x2 + .set noreorder + .set nomacro + beq $3,$0,$L7 + li $4,1 # 0x1 + .set macro + .set reorder + + lw $3,16($16) + .set noreorder + .set nomacro + beq $3,$4,$L49 + li $4,2 # 0x2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $3,$4,$L50 + li $4,4 # 0x4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beql $3,$4,$L59 + lw $3,8($16) + .set macro + .set reorder + +$L7: + move $sp,$fp +$L58: + lw $31,36($sp) + lw $fp,32($sp) + lw $16,28($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,40 + .set macro + .set reorder + +$L46: + lw $3,8($16) +$L59: + sw $2,0($3) + move $sp,$fp + lw $31,36($sp) + lw $fp,32($sp) + lw $16,28($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,40 + .set macro + .set reorder + +$L49: + lw $3,8($16) + sb $2,0($3) + move $sp,$fp + lw $31,36($sp) + lw $fp,32($sp) + lw $16,28($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,40 + .set macro + .set reorder + +$L50: + lw $3,8($16) + .set noreorder + .set nomacro + b $L7 + sh $2,0($3) + .set macro + .set reorder + +$L53: + lw $2,8($16) + .set noreorder + .set nomacro + b $L7 + swc1 $f0,0($2) + .set macro + .set reorder + +$L52: + sw $2,0($4) + .set noreorder + .set nomacro + b $L7 + sw $3,4($4) + .set macro + .set reorder + +$L54: + lw $2,8($16) + .set noreorder + .set nomacro + b $L7 + sdc1 $f0,0($2) + .set macro + .set reorder + + .end avcall_call + .size avcall_call, .-avcall_call + .ident "GCC: (GNU) 5.4.0" diff --git a/avcall/avcall-mipsel-macro.S b/avcall/avcall-mipsel-macro.S new file mode 100644 index 0000000..e37fcd2 --- /dev/null +++ b/avcall/avcall-mipsel-macro.S @@ -0,0 +1,344 @@ +#include "asm-mips.h" + .file 1 "avcall-mips.c" + .text + .align 2 + .globl avcall_call + .set nomips16 + .set nomicromips + .ent avcall_call + DECLARE_FUNCTION(avcall_call) +avcall_call: + .frame $fp,40,$31 + .mask 0xc0010000,-4 + .fmask 0x00000000,0 + lw $6,40($4) + lw $5,20($4) + lw $8,24($4) + addiu $sp,$sp,-40 + andi $2,$6,0x1 + sw $fp,32($sp) + sw $16,28($sp) + move $fp,$sp + sw $31,36($sp) + move $16,$4 + addiu $sp,$sp,-1032 + subu $4,$5,$8 + move $3,$sp + .set noreorder + .set nomacro + beq $2,$0,$L2 + sra $4,$4,2 + .set macro + .set reorder + + + + l.s $f12,48($16) + + +$L2: + lw $2,44($16) + andi $7,$2,0x1 + .set noreorder + .set nomacro + beql $7,$0,$L55 + andi $6,$6,0x2 + .set macro + .set reorder + + + + l.d $f12,56($16) + + + andi $6,$6,0x2 +$L55: + .set noreorder + .set nomacro + beql $6,$0,$L56 + andi $2,$2,0x2 + .set macro + .set reorder + + + + l.s $f14,52($16) + + + andi $2,$2,0x2 +$L56: + .set noreorder + .set nomacro + beql $2,$0,$L57 + slt $4,$4,5 + .set macro + .set reorder + + + + l.d $f14,64($16) + + + slt $4,$4,5 +$L57: + addiu $2,$8,16 + .set noreorder + .set nomacro + bne $4,$0,$L10 + addiu $3,$3,16 + .set macro + .set reorder + +$L37: + lw $4,0($2) + addiu $3,$3,4 + addiu $2,$2,4 + .set noreorder + .set nomacro + bne $5,$2,$L37 + sw $4,-4($3) + .set macro + .set reorder + +$L10: + lw $5,4($8) + lw $4,0($8) + lw $25,4($16) + lw $7,12($8) + .set noreorder + .set nomacro + jalr $25 + lw $6,8($8) + .set macro + .set reorder + + lw $4,12($16) + li $5,1 + .set noreorder + .set nomacro + beql $4,$5,$L58 + move $sp,$fp + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$0,$L46 + li $5,2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L49 + li $5,3 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L49 + li $5,4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L49 + li $5,5 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L50 + li $5,6 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L50 + li $5,7 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L46 + li $5,8 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L46 + li $5,9 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L46 + li $5,10 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L46 + addiu $5,$4,-11 + .set macro + .set reorder + + sltu $5,$5,2 + .set noreorder + .set nomacro + bnel $5,$0,$L52 + lw $4,8($16) + .set macro + .set reorder + + li $3,13 + .set noreorder + .set nomacro + beq $4,$3,$L53 + li $3,14 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$3,$L54 + li $3,15 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$3,$L46 + li $3,16 + .set macro + .set reorder + + .set noreorder + .set nomacro + bnel $4,$3,$L58 + move $sp,$fp + .set macro + .set reorder + + lw $3,0($16) + andi $3,$3,0x2 + .set noreorder + .set nomacro + beq $3,$0,$L7 + li $4,1 + .set macro + .set reorder + + lw $3,16($16) + .set noreorder + .set nomacro + beq $3,$4,$L49 + li $4,2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $3,$4,$L50 + li $4,4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beql $3,$4,$L59 + lw $3,8($16) + .set macro + .set reorder + +$L7: + move $sp,$fp +$L58: + lw $31,36($sp) + lw $fp,32($sp) + lw $16,28($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,40 + .set macro + .set reorder + +$L46: + lw $3,8($16) +$L59: + sw $2,0($3) + move $sp,$fp + lw $31,36($sp) + lw $fp,32($sp) + lw $16,28($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,40 + .set macro + .set reorder + +$L49: + lw $3,8($16) + sb $2,0($3) + move $sp,$fp + lw $31,36($sp) + lw $fp,32($sp) + lw $16,28($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,40 + .set macro + .set reorder + +$L50: + lw $3,8($16) + .set noreorder + .set nomacro + b $L7 + sh $2,0($3) + .set macro + .set reorder + +$L53: + lw $2,8($16) + .set noreorder + .set nomacro + b $L7 + swc1 $f0,0($2) + .set macro + .set reorder + +$L52: + sw $2,0($4) + .set noreorder + .set nomacro + b $L7 + sw $3,4($4) + .set macro + .set reorder + +$L54: + lw $2,8($16) + .set noreorder + .set nomacro + b $L7 + sdc1 $f0,0($2) + .set macro + .set reorder + + .end avcall_call + .size avcall_call, .-avcall_call diff --git a/avcall/avcall-mipsn32.c b/avcall/avcall-mipsn32.c new file mode 100644 index 0000000..c776317 --- /dev/null +++ b/avcall/avcall-mipsn32.c @@ -0,0 +1,496 @@ +/** + Copyright 1993 Bill Triggs + Copyright 1995-2019 Bruno Haible + + 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, see . +**/ +/*---------------------------------------------------------------------- + !!! THIS ROUTINE MUST BE COMPILED gcc -O !!! + + Foreign function interface for an SGI 32-bit MIPS III with "cc -n32", + or gcc configured as mips-sgi-irix6. + + This calls a C function with an argument list built up using macros + defined in avcall.h. + + SGI MIPS new 32-bit Argument Passing Conventions + + - The entire argument list forms a structure with all the appropriate + holes & alignments, and space for this is allocated in the stack frame. + - Shorter integers are promoted to long long length (sizeof(long long)=8). + - Doubles are 1 longword. + - Structure arguments are copies embedded in the arglist structure. + - The first 8 longwords of the structure are passed in registers $4...$11, + except that float arguments are passed in registers $f12...$f19, and + that double arguments and structure elements of type double are passed + in registers $f12...$f19. (But varargs functions may expect them in the + integer registers and we can't tell whether the function is varargs so + we pass them both ways.) + Remaining longwords are passed on the stack. No stack space is allocated + for the first 8 longwords of the structure. + - Structure returns of structures > 16 bytes: pointers to caller-allocated + space are passed in as the first argument of the list. + - Structure returns of structures <= 16 bytes: in the registers $2 (for the + first 8 bytes) and $3 (for the next 8 bytes). + A structure of 1 or 2 floats or doubles is returned in $f0 and $f2: + the first float or double in $f0, the second float or double in $f2. + - Integer/pointer returns are in $2, float/double returns in $f0. + - The called function expects to see its own address in $25. + + This file needs to be compiled with gcc for the asm extensions, but the + assembly version of it and the header file seem to work with SGI cc. + ----------------------------------------------------------------------*/ +#include "avcall-internal.h" + +#define RETURN(TYPE,VAL) (*(TYPE*)l->raddr = (TYPE)(VAL)) +#define OFFSETOF(struct,member) ((int)&(((struct*)0)->member)) + +int +avcall_call(av_alist* list) +{ + register __avword* sp __asm__("$sp"); /* C names for registers */ + register float fret __asm__("$f0"); + register double dret __asm__("$f0"); +/*register __avword iret1 __asm__("$2"); */ + register __avword iret2 __asm__("$3"); + + __av_alist* l = &AV_LIST_INNER(list); + + __avword *argframe = __builtin_alloca(__AV_ALIST_WORDS * sizeof(__avword)); /* big space for child's stack frame */ + int arglen = l->aptr - l->args; + __avword iret; + int i; + + if (l->farg_mask) + { /* push leading float args */ + if (l->farg_mask & (1<<0)) + __asm__("lwc1 $f12,%1(%0)" : : "p" (l), "i" OFFSETOF(__av_alist,fargs[0])); + if (l->farg_mask & (1<<1)) + __asm__("lwc1 $f13,%1(%0)" : : "p" (l), "i" OFFSETOF(__av_alist,fargs[1])); + if (l->farg_mask & (1<<2)) + __asm__("lwc1 $f14,%1(%0)" : : "p" (l), "i" OFFSETOF(__av_alist,fargs[2])); + if (l->farg_mask & (1<<3)) + __asm__("lwc1 $f15,%1(%0)" : : "p" (l), "i" OFFSETOF(__av_alist,fargs[3])); + if (l->farg_mask & (1<<4)) + __asm__("lwc1 $f16,%1(%0)" : : "p" (l), "i" OFFSETOF(__av_alist,fargs[4])); + if (l->farg_mask & (1<<5)) + __asm__("lwc1 $f17,%1(%0)" : : "p" (l), "i" OFFSETOF(__av_alist,fargs[5])); + if (l->farg_mask & (1<<6)) + __asm__("lwc1 $f18,%1(%0)" : : "p" (l), "i" OFFSETOF(__av_alist,fargs[6])); + if (l->farg_mask & (1<<7)) + __asm__("lwc1 $f19,%1(%0)" : : "p" (l), "i" OFFSETOF(__av_alist,fargs[7])); + } + if (l->darg_mask) + { /* push leading double args */ + __avword* a = l->args; + if (l->darg_mask & (1<<0)) + __asm__("ldc1 $f12,%1(%0)" : : "p" (a), "i" (0 * sizeof (__avword))); + if (l->darg_mask & (1<<1)) + __asm__("ldc1 $f13,%1(%0)" : : "p" (a), "i" (1 * sizeof (__avword))); + if (l->darg_mask & (1<<2)) + __asm__("ldc1 $f14,%1(%0)" : : "p" (a), "i" (2 * sizeof (__avword))); + if (l->darg_mask & (1<<3)) + __asm__("ldc1 $f15,%1(%0)" : : "p" (a), "i" (3 * sizeof (__avword))); + if (l->darg_mask & (1<<4)) + __asm__("ldc1 $f16,%1(%0)" : : "p" (a), "i" (4 * sizeof (__avword))); + if (l->darg_mask & (1<<5)) + __asm__("ldc1 $f17,%1(%0)" : : "p" (a), "i" (5 * sizeof (__avword))); + if (l->darg_mask & (1<<6)) + __asm__("ldc1 $f18,%1(%0)" : : "p" (a), "i" (6 * sizeof (__avword))); + if (l->darg_mask & (1<<7)) + __asm__("ldc1 $f19,%1(%0)" : : "p" (a), "i" (7 * sizeof (__avword))); + } + + for (i = 8; i < arglen; i++) /* push excess function args */ + argframe[i-8] = l->args[i]; + + /* call function with 1st 8 args */ + __asm__ __volatile__ ("ld $4,%0" : : "m" (l->args[0]) : "$4"); /* arg1 = l->args[0]; */ + __asm__ __volatile__ ("ld $5,%0" : : "m" (l->args[1]) : "$5"); /* arg1 = l->args[1]; */ + __asm__ __volatile__ ("ld $6,%0" : : "m" (l->args[2]) : "$6"); /* arg1 = l->args[2]; */ + __asm__ __volatile__ ("ld $7,%0" : : "m" (l->args[3]) : "$7"); /* arg1 = l->args[3]; */ + __asm__ __volatile__ ("ld $8,%0" : : "m" (l->args[4]) : "$8"); /* arg1 = l->args[4]; */ + __asm__ __volatile__ ("ld $9,%0" : : "m" (l->args[5]) : "$9"); /* arg1 = l->args[5]; */ + __asm__ __volatile__ ("ld $10,%0" : : "m" (l->args[6]) : "$10"); /* arg1 = l->args[6]; */ + __asm__ __volatile__ ("ld $11,%0" : : "m" (l->args[7]) : "$11"); /* arg1 = l->args[7]; */ + /* Note: The code of this call ought to put the address of the called function + in register $25 before the call. */ + iret = (*l->func)(); + + /* save return value */ + if (l->rtype == __AVvoid) { + } else + if (l->rtype == __AVword) { + RETURN(__avword, iret); + } else + if (l->rtype == __AVchar) { + RETURN(char, iret); + } else + if (l->rtype == __AVschar) { + RETURN(signed char, iret); + } else + if (l->rtype == __AVuchar) { + RETURN(unsigned char, iret); + } else + if (l->rtype == __AVshort) { + RETURN(short, iret); + } else + if (l->rtype == __AVushort) { + RETURN(unsigned short, iret); + } else + if (l->rtype == __AVint) { + RETURN(int, iret); + } else + if (l->rtype == __AVuint) { + RETURN(unsigned int, iret); + } else + if (l->rtype == __AVlong) { + RETURN(long, iret); + } else + if (l->rtype == __AVulong) { + RETURN(unsigned long, iret); + } else + if (l->rtype == __AVlonglong) { + RETURN(long long, iret); + } else + if (l->rtype == __AVulonglong) { + RETURN(unsigned long long, iret); + } else + if (l->rtype == __AVfloat) { + RETURN(float, fret); + } else + if (l->rtype == __AVdouble) { + RETURN(double, dret); + } else + if (l->rtype == __AVvoidp) { + RETURN(void*, iret); + } else + if (l->rtype == __AVstruct) { + if (l->flags & __AV_REGISTER_STRUCT_RETURN) { + if (l->flags & __AV_GCC_STRUCT_RETURN) { + /* gcc returns structs of size 1,2,4,8 in registers. */ + if (l->rsize == sizeof(char)) { + RETURN(char, iret); + } else + if (l->rsize == sizeof(short)) { + RETURN(short, iret); + } else + if (l->rsize == sizeof(int)) { + RETURN(int, iret); + } else + if (l->rsize == sizeof(long long)) { + RETURN(long long, iret); + } + } else { + /* cc returns structs of size <= 16 in registers. */ + if (l->rsize > 0 && l->rsize <= 16) { + void* raddr = l->raddr; + #if 0 /* Unoptimized */ + if (l->rsize == 1) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + #else + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + #endif + } else + if (l->rsize == 2) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + #else + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>48); + #endif + } else + if (l->rsize == 3) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + #else + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>40); + #endif + } else + if (l->rsize == 4) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + #else + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>32); + #endif + } else + if (l->rsize == 5) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>32); + #else + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>24); + #endif + } else + if (l->rsize == 6) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>40); + #else + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>16); + #endif + } else + if (l->rsize == 7) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[6] = (unsigned char)(iret>>48); + #else + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[6] = (unsigned char)(iret>>8); + #endif + } else + if (l->rsize >= 8 && l->rsize <= 16) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[6] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[7] = (unsigned char)(iret>>56); + #else + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[6] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[7] = (unsigned char)(iret); + #endif + if (l->rsize == 8) { + } else + if (l->rsize == 9) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + #else + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + #endif + } else + if (l->rsize == 10) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + #else + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>48); + #endif + } else + if (l->rsize == 11) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + #else + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>40); + #endif + } else + if (l->rsize == 12) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + #else + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>32); + #endif + } else + if (l->rsize == 13) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>32); + #else + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>24); + #endif + } else + if (l->rsize == 14) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>40); + #else + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>16); + #endif + } else + if (l->rsize == 15) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+6] = (unsigned char)(iret2>>48); + #else + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+6] = (unsigned char)(iret2>>8); + #endif + } else + if (l->rsize == 16) { + #if defined(_MIPSEL) + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+6] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+7] = (unsigned char)(iret2>>56); + #else + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+6] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+7] = (unsigned char)(iret2); + #endif + } + } + #else /* Optimized: fewer conditional jumps, fewer memory accesses */ + uintptr_t count = l->rsize; /* > 0, ≤ 2*sizeof(__avword) */ + __avword* wordaddr = (__avword*)((uintptr_t)raddr & ~(uintptr_t)(sizeof(__avword)-1)); + uintptr_t start_offset = (uintptr_t)raddr & (uintptr_t)(sizeof(__avword)-1); /* ≥ 0, < sizeof(__avword) */ + uintptr_t end_offset = start_offset + count; /* > 0, < 3*sizeof(__avword) */ + #if defined(_MIPSEL) + if (count <= sizeof(__avword)) { + /* Use iret. */ + if (end_offset <= sizeof(__avword)) { + /* 0 < end_offset ≤ sizeof(__avword) */ + __avword mask0 = ((__avword)2 << (end_offset*8-1)) - ((__avword)1 << (start_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret << (start_offset*8))) & mask0; + } else { + /* sizeof(__avword) < end_offset < 2*sizeof(__avword), start_offset > 0 */ + __avword mask0 = - ((__avword)1 << (start_offset*8)); + __avword mask1 = ((__avword)2 << (end_offset*8-sizeof(__avword)*8-1)) - 1; + wordaddr[0] ^= (wordaddr[0] ^ (iret << (start_offset*8))) & mask0; + wordaddr[1] ^= (wordaddr[1] ^ (iret >> (sizeof(__avword)*8-start_offset*8))) & mask1; + } + } else { + /* Use iret, iret2. */ + __avword mask0 = - ((__avword)1 << (start_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret << (start_offset*8))) & mask0; + if (end_offset <= 2*sizeof(__avword)) { + /* sizeof(__avword) < end_offset ≤ 2*sizeof(__avword) */ + __avword mask1 = ((__avword)2 << (end_offset*8-sizeof(__avword)*8-1)) - 1; + wordaddr[1] ^= (wordaddr[1] ^ ((iret >> (sizeof(__avword)*4-start_offset*4) >> (sizeof(__avword)*4-start_offset*4)) | (iret2 << (start_offset*8)))) & mask1; + } else { + /* 2*sizeof(__avword) < end_offset < 3*sizeof(__avword), start_offset > 0 */ + __avword mask2 = ((__avword)2 << (end_offset*8-2*sizeof(__avword)*8-1)) - 1; + wordaddr[1] = (iret >> (sizeof(__avword)*8-start_offset*8)) | (iret2 << (start_offset*8)); + wordaddr[2] ^= (wordaddr[2] ^ (iret2 >> (sizeof(__avword)*8-start_offset*8))) & mask2; + } + } + #else + if (count <= sizeof(__avword)) { + /* Use iret. */ + if (end_offset <= sizeof(__avword)) { + /* 0 < end_offset ≤ sizeof(__avword) */ + __avword mask0 = ((__avword)2 << (sizeof(__avword)*8-start_offset*8-1)) - ((__avword)1 << (sizeof(__avword)*8-end_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret >> (start_offset*8))) & mask0; + } else { + /* sizeof(__avword) < end_offset < 2*sizeof(__avword), start_offset > 0 */ + __avword mask0 = ((__avword)2 << (sizeof(__avword)*8-start_offset*8-1)) - 1; + __avword mask1 = - ((__avword)1 << (2*sizeof(__avword)*8-end_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret >> (start_offset*8))) & mask0; + wordaddr[1] ^= (wordaddr[1] ^ (iret << (sizeof(__avword)*8-start_offset*8))) & mask1; + } + } else { + /* Use iret, iret2. */ + __avword mask0 = ((__avword)2 << (sizeof(__avword)*8-start_offset*8-1)) - 1; + wordaddr[0] ^= (wordaddr[0] ^ (iret >> (start_offset*8))) & mask0; + if (end_offset <= 2*sizeof(__avword)) { + /* sizeof(__avword) < end_offset ≤ 2*sizeof(__avword) */ + __avword mask1 = - ((__avword)1 << (2*sizeof(__avword)*8-end_offset*8)); + wordaddr[1] ^= (wordaddr[1] ^ ((iret << (sizeof(__avword)*4-start_offset*4) << (sizeof(__avword)*4-start_offset*4)) | (iret2 >> (start_offset*8)))) & mask1; + } else { + /* 2*sizeof(__avword) < end_offset < 3*sizeof(__avword), start_offset > 0 */ + __avword mask2 = - ((__avword)1 << (3*sizeof(__avword)*8-end_offset*8)); + wordaddr[1] = (iret << (sizeof(__avword)*8-start_offset*8)) | (iret2 >> (start_offset*8)); + wordaddr[2] ^= (wordaddr[2] ^ (iret2 << (sizeof(__avword)*8-start_offset*8))) & mask2; + } + } + #endif + #endif + } + } + } + } + return 0; +} diff --git a/avcall/avcall-mipsn32eb-linux.s b/avcall/avcall-mipsn32eb-linux.s new file mode 100644 index 0000000..531488a --- /dev/null +++ b/avcall/avcall-mipsn32eb-linux.s @@ -0,0 +1,733 @@ + .file 1 "avcall-mipsn32.c" + .section .mdebug.abiN32 + .previous + .nan legacy + .module fp=64 + .module oddspreg + .abicalls + .text + .align 2 + .align 3 + .globl avcall_call + .set nomips16 + .set nomicromips + .ent avcall_call + .type avcall_call, @function +avcall_call: + .frame $fp,32,$31 # vars= 0, regs= 4/0, args= 0, gp= 0 + .mask 0xd0010000,-8 + .fmask 0x00000000,0 + lw $5,20($4) + lw $12,24($4) + lw $2,36($4) + addiu $sp,$sp,-32 + sd $fp,16($sp) + sd $16,0($sp) + sd $31,24($sp) + move $fp,$sp + move $16,$4 + addiu $sp,$sp,-2064 + subu $4,$5,$12 + move $3,$sp + .set noreorder + .set nomacro + beq $2,$0,.L2 + sra $4,$4,3 + .set macro + .set reorder + + andi $6,$2,0x1 + .set noreorder + .set nomacro + beq $6,$0,.L125 + andi $6,$2,0x2 + .set macro + .set reorder + +#APP + # 78 "avcall-mipsn32.c" 1 + lwc1 $f12,44($16) + # 0 "" 2 +#NO_APP + andi $6,$2,0x2 +.L125: + .set noreorder + .set nomacro + beq $6,$0,.L126 + andi $6,$2,0x4 + .set macro + .set reorder + +#APP + # 80 "avcall-mipsn32.c" 1 + lwc1 $f13,48($16) + # 0 "" 2 +#NO_APP + andi $6,$2,0x4 +.L126: + .set noreorder + .set nomacro + beq $6,$0,.L127 + andi $6,$2,0x8 + .set macro + .set reorder + +#APP + # 82 "avcall-mipsn32.c" 1 + lwc1 $f14,52($16) + # 0 "" 2 +#NO_APP + andi $6,$2,0x8 +.L127: + .set noreorder + .set nomacro + beq $6,$0,.L128 + andi $6,$2,0x10 + .set macro + .set reorder + +#APP + # 84 "avcall-mipsn32.c" 1 + lwc1 $f15,56($16) + # 0 "" 2 +#NO_APP + andi $6,$2,0x10 +.L128: + .set noreorder + .set nomacro + beq $6,$0,.L129 + andi $6,$2,0x20 + .set macro + .set reorder + +#APP + # 86 "avcall-mipsn32.c" 1 + lwc1 $f16,60($16) + # 0 "" 2 +#NO_APP + andi $6,$2,0x20 +.L129: + .set noreorder + .set nomacro + beq $6,$0,.L130 + andi $6,$2,0x40 + .set macro + .set reorder + +#APP + # 88 "avcall-mipsn32.c" 1 + lwc1 $f17,64($16) + # 0 "" 2 +#NO_APP + andi $6,$2,0x40 +.L130: + .set noreorder + .set nomacro + beql $6,$0,.L131 + andi $2,$2,0x80 + .set macro + .set reorder + +#APP + # 90 "avcall-mipsn32.c" 1 + lwc1 $f18,68($16) + # 0 "" 2 +#NO_APP + andi $2,$2,0x80 +.L131: + bne $2,$0,.L118 +.L2: + lw $2,40($16) +.L124: + .set noreorder + .set nomacro + beql $2,$0,.L123 + slt $4,$4,9 + .set macro + .set reorder + + andi $6,$2,0x1 + .set noreorder + .set nomacro + beq $6,$0,.L132 + andi $6,$2,0x2 + .set macro + .set reorder + +#APP + # 98 "avcall-mipsn32.c" 1 + ldc1 $f12,0($12) + # 0 "" 2 +#NO_APP + andi $6,$2,0x2 +.L132: + .set noreorder + .set nomacro + beq $6,$0,.L133 + andi $6,$2,0x4 + .set macro + .set reorder + +#APP + # 100 "avcall-mipsn32.c" 1 + ldc1 $f13,8($12) + # 0 "" 2 +#NO_APP + andi $6,$2,0x4 +.L133: + .set noreorder + .set nomacro + beq $6,$0,.L134 + andi $6,$2,0x8 + .set macro + .set reorder + +#APP + # 102 "avcall-mipsn32.c" 1 + ldc1 $f14,16($12) + # 0 "" 2 +#NO_APP + andi $6,$2,0x8 +.L134: + .set noreorder + .set nomacro + beq $6,$0,.L135 + andi $6,$2,0x10 + .set macro + .set reorder + +#APP + # 104 "avcall-mipsn32.c" 1 + ldc1 $f15,24($12) + # 0 "" 2 +#NO_APP + andi $6,$2,0x10 +.L135: + .set noreorder + .set nomacro + beq $6,$0,.L136 + andi $6,$2,0x20 + .set macro + .set reorder + +#APP + # 106 "avcall-mipsn32.c" 1 + ldc1 $f16,32($12) + # 0 "" 2 +#NO_APP + andi $6,$2,0x20 +.L136: + .set noreorder + .set nomacro + beq $6,$0,.L137 + andi $6,$2,0x40 + .set macro + .set reorder + +#APP + # 108 "avcall-mipsn32.c" 1 + ldc1 $f17,40($12) + # 0 "" 2 +#NO_APP + andi $6,$2,0x40 +.L137: + .set noreorder + .set nomacro + beql $6,$0,.L138 + andi $2,$2,0x80 + .set macro + .set reorder + +#APP + # 110 "avcall-mipsn32.c" 1 + ldc1 $f18,48($12) + # 0 "" 2 +#NO_APP + andi $2,$2,0x80 +.L138: + bne $2,$0,.L119 + slt $4,$4,9 +.L123: + .set noreorder + .set nomacro + bne $4,$0,.L22 + addiu $2,$12,64 + .set macro + .set reorder + + .align 3 +.L83: + ld $4,0($2) + addiu $3,$3,8 + addiu $2,$2,8 + .set noreorder + .set nomacro + bne $5,$2,.L83 + sd $4,-8($3) + .set macro + .set reorder + +.L22: +#APP + # 119 "avcall-mipsn32.c" 1 + ld $4,0($12) + # 0 "" 2 + # 120 "avcall-mipsn32.c" 1 + ld $5,8($12) + # 0 "" 2 + # 121 "avcall-mipsn32.c" 1 + ld $6,16($12) + # 0 "" 2 + # 122 "avcall-mipsn32.c" 1 + ld $7,24($12) + # 0 "" 2 + # 123 "avcall-mipsn32.c" 1 + ld $8,32($12) + # 0 "" 2 + # 124 "avcall-mipsn32.c" 1 + ld $9,40($12) + # 0 "" 2 + # 125 "avcall-mipsn32.c" 1 + ld $10,48($12) + # 0 "" 2 + # 126 "avcall-mipsn32.c" 1 + ld $11,56($12) + # 0 "" 2 +#NO_APP + lw $25,4($16) + jalr $25 + lw $4,12($16) + li $5,1 # 0x1 + .set noreorder + .set nomacro + beql $4,$5,.L139 + move $sp,$fp + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$0,.L116 + li $5,2 # 0x2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L109 + li $5,3 # 0x3 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L109 + li $5,4 # 0x4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L109 + li $5,5 # 0x5 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L112 + li $5,6 # 0x6 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L112 + li $5,7 # 0x7 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L111 + li $5,8 # 0x8 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L111 + li $5,9 # 0x9 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L111 + li $5,10 # 0xa + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L111 + li $5,11 # 0xb + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L116 + li $5,12 # 0xc + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L116 + li $5,13 # 0xd + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L120 + li $5,14 # 0xe + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L121 + li $5,15 # 0xf + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L111 + li $5,16 # 0x10 + .set macro + .set reorder + + .set noreorder + .set nomacro + bnel $4,$5,.L139 + move $sp,$fp + .set macro + .set reorder + + lw $4,0($16) + andi $5,$4,0x200 + .set noreorder + .set nomacro + beq $5,$0,.L19 + andi $4,$4,0x4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beql $4,$0,.L38 + lw $4,16($16) + .set macro + .set reorder + + lw $3,16($16) + li $4,1 # 0x1 + .set noreorder + .set nomacro + beq $3,$4,.L109 + li $4,2 # 0x2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $3,$4,.L112 + li $4,4 # 0x4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $3,$4,.L111 + li $4,8 # 0x8 + .set macro + .set reorder + + .set noreorder + .set nomacro + beql $3,$4,.L140 + lw $3,8($16) + .set macro + .set reorder + +.L19: + move $sp,$fp +.L139: + ld $31,24($sp) + ld $fp,16($sp) + ld $16,0($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,32 + .set macro + .set reorder + + .align 3 +.L116: + lw $3,8($16) + .align 3 +.L140: + sd $2,0($3) + move $sp,$fp + ld $31,24($sp) + ld $fp,16($sp) + ld $16,0($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,32 + .set macro + .set reorder + + .align 3 +.L119: +#APP + # 112 "avcall-mipsn32.c" 1 + ldc1 $f19,56($12) + # 0 "" 2 +#NO_APP + .set noreorder + .set nomacro + b .L123 + slt $4,$4,9 + .set macro + .set reorder + + .align 3 +.L118: +#APP + # 92 "avcall-mipsn32.c" 1 + lwc1 $f19,72($16) + # 0 "" 2 +#NO_APP + .set noreorder + .set nomacro + b .L124 + lw $2,40($16) + .set macro + .set reorder + + .align 3 +.L109: + lw $3,8($16) + sb $2,0($3) + move $sp,$fp + ld $31,24($sp) + ld $fp,16($sp) + ld $16,0($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,32 + .set macro + .set reorder + +.L112: + lw $3,8($16) + .set noreorder + .set nomacro + b .L19 + sh $2,0($3) + .set macro + .set reorder + +.L111: + lw $3,8($16) + sw $2,0($3) + move $sp,$fp + ld $31,24($sp) + ld $fp,16($sp) + ld $16,0($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,32 + .set macro + .set reorder + +.L120: + lw $2,8($16) + .set noreorder + .set nomacro + b .L19 + swc1 $f0,0($2) + .set macro + .set reorder + +.L121: + lw $2,8($16) + .set noreorder + .set nomacro + b .L19 + sdc1 $f0,0($2) + .set macro + .set reorder + +.L38: + addiu $5,$4,-1 + sltu $5,$5,16 + .set noreorder + .set nomacro + beq $5,$0,.L19 + sltu $8,$4,9 + .set macro + .set reorder + + lw $6,8($16) + li $7,-8 # 0xfffffffffffffff8 + andi $5,$6,0x7 + and $7,$6,$7 + .set noreorder + .set nomacro + beq $8,$0,.L42 + addu $4,$4,$5 + .set macro + .set reorder + + sltu $3,$4,9 + .set noreorder + .set nomacro + beq $3,$0,.L43 + subu $6,$0,$5 + .set macro + .set reorder + + subu $3,$0,$5 + sll $3,$3,3 + ld $8,0($7) + addiu $3,$3,63 + subu $4,$0,$4 + li $6,2 # 0x2 + dsll $6,$6,$3 + sll $4,$4,3 + sll $5,$5,3 + li $3,1 # 0x1 + dsll $3,$3,$4 + dsra $2,$2,$5 + dsubu $3,$6,$3 + xor $2,$2,$8 + and $2,$3,$2 + xor $2,$2,$8 + .set noreorder + .set nomacro + b .L19 + sd $2,0($7) + .set macro + .set reorder + + .align 3 +.L42: + subu $9,$0,$5 + ld $11,0($7) + sll $10,$9,3 + addiu $6,$10,63 + sll $5,$5,3 + li $8,2 # 0x2 + dsll $8,$8,$6 + dsra $6,$2,$5 + daddiu $8,$8,-1 + xor $6,$6,$11 + and $6,$8,$6 + xor $6,$6,$11 + sltu $8,$4,17 + .set noreorder + .set nomacro + bne $8,$0,.L122 + sd $6,0($7) + .set macro + .set reorder + + ld $11,16($7) + addiu $6,$10,64 + subu $4,$0,$4 + move $8,$3 + dsll $9,$3,$6 + sll $4,$4,3 + li $3,-1 # 0xffffffffffffffff + dsll $4,$3,$4 + xor $3,$9,$11 + dsll $2,$2,$6 + dsra $5,$8,$5 + and $3,$4,$3 + or $2,$2,$5 + xor $3,$3,$11 + sd $2,8($7) + .set noreorder + .set nomacro + b .L19 + sd $3,16($7) + .set macro + .set reorder + +.L43: + ld $9,0($7) + ld $8,8($7) + sll $6,$6,3 + addiu $10,$6,63 + sll $3,$5,3 + subu $4,$0,$4 + li $5,2 # 0x2 + dsra $3,$2,$3 + dsll $5,$5,$10 + dsll $2,$2,$6 + sll $4,$4,3 + li $6,-1 # 0xffffffffffffffff + daddiu $5,$5,-1 + xor $3,$3,$9 + dsll $4,$6,$4 + xor $2,$2,$8 + and $3,$5,$3 + and $2,$4,$2 + xor $3,$3,$9 + xor $2,$2,$8 + sd $3,0($7) + .set noreorder + .set nomacro + b .L19 + sd $2,8($7) + .set macro + .set reorder + +.L122: + sll $6,$9,2 + addiu $6,$6,32 + ld $8,8($7) + dsll $2,$2,$6 + dsll $6,$2,$6 + dsra $3,$3,$5 + subu $2,$0,$4 + or $3,$6,$3 + sll $2,$2,3 + li $5,-1 # 0xffffffffffffffff + xor $3,$3,$8 + dsll $2,$5,$2 + and $2,$3,$2 + xor $2,$2,$8 + .set noreorder + .set nomacro + b .L19 + sd $2,8($7) + .set macro + .set reorder + + .end avcall_call + .size avcall_call, .-avcall_call + .ident "GCC: (GNU) 5.4.0" diff --git a/avcall/avcall-mipsn32eb-macro.S b/avcall/avcall-mipsn32eb-macro.S new file mode 100644 index 0000000..270e68b --- /dev/null +++ b/avcall/avcall-mipsn32eb-macro.S @@ -0,0 +1,727 @@ +#include "asm-mips.h" + .file 1 "avcall-mipsn32.c" + .text + .align 2 + .align 3 + .globl avcall_call + .set nomips16 + .set nomicromips + .ent avcall_call + DECLARE_FUNCTION(avcall_call) +avcall_call: + .frame $fp,32,$31 + .mask 0xd0010000,-8 + .fmask 0x00000000,0 + lw $5,20($4) + lw $12,24($4) + lw $2,36($4) + addiu $sp,$sp,-32 + sd $fp,16($sp) + sd $16,0($sp) + sd $31,24($sp) + move $fp,$sp + move $16,$4 + addiu $sp,$sp,-2064 + subu $4,$5,$12 + move $3,$sp + .set noreorder + .set nomacro + beq $2,$0,.L2 + sra $4,$4,3 + .set macro + .set reorder + + andi $6,$2,0x1 + .set noreorder + .set nomacro + beq $6,$0,.L125 + andi $6,$2,0x2 + .set macro + .set reorder + + + + lwc1 $f12,44($16) + + + andi $6,$2,0x2 +.L125: + .set noreorder + .set nomacro + beq $6,$0,.L126 + andi $6,$2,0x4 + .set macro + .set reorder + + + + lwc1 $f13,48($16) + + + andi $6,$2,0x4 +.L126: + .set noreorder + .set nomacro + beq $6,$0,.L127 + andi $6,$2,0x8 + .set macro + .set reorder + + + + lwc1 $f14,52($16) + + + andi $6,$2,0x8 +.L127: + .set noreorder + .set nomacro + beq $6,$0,.L128 + andi $6,$2,0x10 + .set macro + .set reorder + + + + lwc1 $f15,56($16) + + + andi $6,$2,0x10 +.L128: + .set noreorder + .set nomacro + beq $6,$0,.L129 + andi $6,$2,0x20 + .set macro + .set reorder + + + + lwc1 $f16,60($16) + + + andi $6,$2,0x20 +.L129: + .set noreorder + .set nomacro + beq $6,$0,.L130 + andi $6,$2,0x40 + .set macro + .set reorder + + + + lwc1 $f17,64($16) + + + andi $6,$2,0x40 +.L130: + .set noreorder + .set nomacro + beql $6,$0,.L131 + andi $2,$2,0x80 + .set macro + .set reorder + + + + lwc1 $f18,68($16) + + + andi $2,$2,0x80 +.L131: + bne $2,$0,.L118 +.L2: + lw $2,40($16) +.L124: + .set noreorder + .set nomacro + beql $2,$0,.L123 + slt $4,$4,9 + .set macro + .set reorder + + andi $6,$2,0x1 + .set noreorder + .set nomacro + beq $6,$0,.L132 + andi $6,$2,0x2 + .set macro + .set reorder + + + + ldc1 $f12,0($12) + + + andi $6,$2,0x2 +.L132: + .set noreorder + .set nomacro + beq $6,$0,.L133 + andi $6,$2,0x4 + .set macro + .set reorder + + + + ldc1 $f13,8($12) + + + andi $6,$2,0x4 +.L133: + .set noreorder + .set nomacro + beq $6,$0,.L134 + andi $6,$2,0x8 + .set macro + .set reorder + + + + ldc1 $f14,16($12) + + + andi $6,$2,0x8 +.L134: + .set noreorder + .set nomacro + beq $6,$0,.L135 + andi $6,$2,0x10 + .set macro + .set reorder + + + + ldc1 $f15,24($12) + + + andi $6,$2,0x10 +.L135: + .set noreorder + .set nomacro + beq $6,$0,.L136 + andi $6,$2,0x20 + .set macro + .set reorder + + + + ldc1 $f16,32($12) + + + andi $6,$2,0x20 +.L136: + .set noreorder + .set nomacro + beq $6,$0,.L137 + andi $6,$2,0x40 + .set macro + .set reorder + + + + ldc1 $f17,40($12) + + + andi $6,$2,0x40 +.L137: + .set noreorder + .set nomacro + beql $6,$0,.L138 + andi $2,$2,0x80 + .set macro + .set reorder + + + + ldc1 $f18,48($12) + + + andi $2,$2,0x80 +.L138: + bne $2,$0,.L119 + slt $4,$4,9 +.L123: + .set noreorder + .set nomacro + bne $4,$0,.L22 + addiu $2,$12,64 + .set macro + .set reorder + + .align 3 +.L83: + ld $4,0($2) + addiu $3,$3,8 + addiu $2,$2,8 + .set noreorder + .set nomacro + bne $5,$2,.L83 + sd $4,-8($3) + .set macro + .set reorder + +.L22: + + + ld $4,0($12) + + + ld $5,8($12) + + + ld $6,16($12) + + + ld $7,24($12) + + + ld $8,32($12) + + + ld $9,40($12) + + + ld $10,48($12) + + + ld $11,56($12) + + + lw $25,4($16) + jalr $25 + lw $4,12($16) + li $5,1 + .set noreorder + .set nomacro + beql $4,$5,.L139 + move $sp,$fp + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$0,.L116 + li $5,2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L109 + li $5,3 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L109 + li $5,4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L109 + li $5,5 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L112 + li $5,6 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L112 + li $5,7 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L111 + li $5,8 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L111 + li $5,9 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L111 + li $5,10 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L111 + li $5,11 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L116 + li $5,12 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L116 + li $5,13 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L120 + li $5,14 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L121 + li $5,15 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L111 + li $5,16 + .set macro + .set reorder + + .set noreorder + .set nomacro + bnel $4,$5,.L139 + move $sp,$fp + .set macro + .set reorder + + lw $4,0($16) + andi $5,$4,0x200 + .set noreorder + .set nomacro + beq $5,$0,.L19 + andi $4,$4,0x4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beql $4,$0,.L38 + lw $4,16($16) + .set macro + .set reorder + + lw $3,16($16) + li $4,1 + .set noreorder + .set nomacro + beq $3,$4,.L109 + li $4,2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $3,$4,.L112 + li $4,4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $3,$4,.L111 + li $4,8 + .set macro + .set reorder + + .set noreorder + .set nomacro + beql $3,$4,.L140 + lw $3,8($16) + .set macro + .set reorder + +.L19: + move $sp,$fp +.L139: + ld $31,24($sp) + ld $fp,16($sp) + ld $16,0($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,32 + .set macro + .set reorder + + .align 3 +.L116: + lw $3,8($16) + .align 3 +.L140: + sd $2,0($3) + move $sp,$fp + ld $31,24($sp) + ld $fp,16($sp) + ld $16,0($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,32 + .set macro + .set reorder + + .align 3 +.L119: + + + ldc1 $f19,56($12) + + + .set noreorder + .set nomacro + b .L123 + slt $4,$4,9 + .set macro + .set reorder + + .align 3 +.L118: + + + lwc1 $f19,72($16) + + + .set noreorder + .set nomacro + b .L124 + lw $2,40($16) + .set macro + .set reorder + + .align 3 +.L109: + lw $3,8($16) + sb $2,0($3) + move $sp,$fp + ld $31,24($sp) + ld $fp,16($sp) + ld $16,0($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,32 + .set macro + .set reorder + +.L112: + lw $3,8($16) + .set noreorder + .set nomacro + b .L19 + sh $2,0($3) + .set macro + .set reorder + +.L111: + lw $3,8($16) + sw $2,0($3) + move $sp,$fp + ld $31,24($sp) + ld $fp,16($sp) + ld $16,0($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,32 + .set macro + .set reorder + +.L120: + lw $2,8($16) + .set noreorder + .set nomacro + b .L19 + swc1 $f0,0($2) + .set macro + .set reorder + +.L121: + lw $2,8($16) + .set noreorder + .set nomacro + b .L19 + sdc1 $f0,0($2) + .set macro + .set reorder + +.L38: + addiu $5,$4,-1 + sltu $5,$5,16 + .set noreorder + .set nomacro + beq $5,$0,.L19 + sltu $8,$4,9 + .set macro + .set reorder + + lw $6,8($16) + li $7,-8 + andi $5,$6,0x7 + and $7,$6,$7 + .set noreorder + .set nomacro + beq $8,$0,.L42 + addu $4,$4,$5 + .set macro + .set reorder + + sltu $3,$4,9 + .set noreorder + .set nomacro + beq $3,$0,.L43 + subu $6,$0,$5 + .set macro + .set reorder + + subu $3,$0,$5 + sll $3,$3,3 + ld $8,0($7) + addiu $3,$3,63 + subu $4,$0,$4 + li $6,2 + dsll $6,$6,$3 + sll $4,$4,3 + sll $5,$5,3 + li $3,1 + dsll $3,$3,$4 + dsra $2,$2,$5 + dsubu $3,$6,$3 + xor $2,$2,$8 + and $2,$3,$2 + xor $2,$2,$8 + .set noreorder + .set nomacro + b .L19 + sd $2,0($7) + .set macro + .set reorder + + .align 3 +.L42: + subu $9,$0,$5 + ld $11,0($7) + sll $10,$9,3 + addiu $6,$10,63 + sll $5,$5,3 + li $8,2 + dsll $8,$8,$6 + dsra $6,$2,$5 + daddiu $8,$8,-1 + xor $6,$6,$11 + and $6,$8,$6 + xor $6,$6,$11 + sltu $8,$4,17 + .set noreorder + .set nomacro + bne $8,$0,.L122 + sd $6,0($7) + .set macro + .set reorder + + ld $11,16($7) + addiu $6,$10,64 + subu $4,$0,$4 + move $8,$3 + dsll $9,$3,$6 + sll $4,$4,3 + li $3,-1 + dsll $4,$3,$4 + xor $3,$9,$11 + dsll $2,$2,$6 + dsra $5,$8,$5 + and $3,$4,$3 + or $2,$2,$5 + xor $3,$3,$11 + sd $2,8($7) + .set noreorder + .set nomacro + b .L19 + sd $3,16($7) + .set macro + .set reorder + +.L43: + ld $9,0($7) + ld $8,8($7) + sll $6,$6,3 + addiu $10,$6,63 + sll $3,$5,3 + subu $4,$0,$4 + li $5,2 + dsra $3,$2,$3 + dsll $5,$5,$10 + dsll $2,$2,$6 + sll $4,$4,3 + li $6,-1 + daddiu $5,$5,-1 + xor $3,$3,$9 + dsll $4,$6,$4 + xor $2,$2,$8 + and $3,$5,$3 + and $2,$4,$2 + xor $3,$3,$9 + xor $2,$2,$8 + sd $3,0($7) + .set noreorder + .set nomacro + b .L19 + sd $2,8($7) + .set macro + .set reorder + +.L122: + sll $6,$9,2 + addiu $6,$6,32 + ld $8,8($7) + dsll $2,$2,$6 + dsll $6,$2,$6 + dsra $3,$3,$5 + subu $2,$0,$4 + or $3,$6,$3 + sll $2,$2,3 + li $5,-1 + xor $3,$3,$8 + dsll $2,$5,$2 + and $2,$3,$2 + xor $2,$2,$8 + .set noreorder + .set nomacro + b .L19 + sd $2,8($7) + .set macro + .set reorder + + .end avcall_call + .size avcall_call, .-avcall_call diff --git a/avcall/avcall-mipsn32el-linux.s b/avcall/avcall-mipsn32el-linux.s new file mode 100644 index 0000000..cb9019c --- /dev/null +++ b/avcall/avcall-mipsn32el-linux.s @@ -0,0 +1,731 @@ + .file 1 "avcall-mipsn32.c" + .section .mdebug.abiN32 + .previous + .nan legacy + .module fp=64 + .module oddspreg + .abicalls + .text + .align 2 + .align 3 + .globl avcall_call + .set nomips16 + .set nomicromips + .ent avcall_call + .type avcall_call, @function +avcall_call: + .frame $fp,32,$31 # vars= 0, regs= 4/0, args= 0, gp= 0 + .mask 0xd0010000,-8 + .fmask 0x00000000,0 + lw $5,20($4) + lw $12,24($4) + lw $2,36($4) + addiu $sp,$sp,-32 + sd $fp,16($sp) + sd $16,0($sp) + sd $31,24($sp) + move $fp,$sp + move $16,$4 + addiu $sp,$sp,-2064 + subu $4,$5,$12 + move $3,$sp + .set noreorder + .set nomacro + beq $2,$0,.L2 + sra $4,$4,3 + .set macro + .set reorder + + andi $6,$2,0x1 + .set noreorder + .set nomacro + beq $6,$0,.L125 + andi $6,$2,0x2 + .set macro + .set reorder + +#APP + # 78 "avcall-mipsn32.c" 1 + lwc1 $f12,44($16) + # 0 "" 2 +#NO_APP + andi $6,$2,0x2 +.L125: + .set noreorder + .set nomacro + beq $6,$0,.L126 + andi $6,$2,0x4 + .set macro + .set reorder + +#APP + # 80 "avcall-mipsn32.c" 1 + lwc1 $f13,48($16) + # 0 "" 2 +#NO_APP + andi $6,$2,0x4 +.L126: + .set noreorder + .set nomacro + beq $6,$0,.L127 + andi $6,$2,0x8 + .set macro + .set reorder + +#APP + # 82 "avcall-mipsn32.c" 1 + lwc1 $f14,52($16) + # 0 "" 2 +#NO_APP + andi $6,$2,0x8 +.L127: + .set noreorder + .set nomacro + beq $6,$0,.L128 + andi $6,$2,0x10 + .set macro + .set reorder + +#APP + # 84 "avcall-mipsn32.c" 1 + lwc1 $f15,56($16) + # 0 "" 2 +#NO_APP + andi $6,$2,0x10 +.L128: + .set noreorder + .set nomacro + beq $6,$0,.L129 + andi $6,$2,0x20 + .set macro + .set reorder + +#APP + # 86 "avcall-mipsn32.c" 1 + lwc1 $f16,60($16) + # 0 "" 2 +#NO_APP + andi $6,$2,0x20 +.L129: + .set noreorder + .set nomacro + beq $6,$0,.L130 + andi $6,$2,0x40 + .set macro + .set reorder + +#APP + # 88 "avcall-mipsn32.c" 1 + lwc1 $f17,64($16) + # 0 "" 2 +#NO_APP + andi $6,$2,0x40 +.L130: + .set noreorder + .set nomacro + beql $6,$0,.L131 + andi $2,$2,0x80 + .set macro + .set reorder + +#APP + # 90 "avcall-mipsn32.c" 1 + lwc1 $f18,68($16) + # 0 "" 2 +#NO_APP + andi $2,$2,0x80 +.L131: + bne $2,$0,.L118 +.L2: + lw $2,40($16) +.L124: + .set noreorder + .set nomacro + beql $2,$0,.L123 + slt $4,$4,9 + .set macro + .set reorder + + andi $6,$2,0x1 + .set noreorder + .set nomacro + beq $6,$0,.L132 + andi $6,$2,0x2 + .set macro + .set reorder + +#APP + # 98 "avcall-mipsn32.c" 1 + ldc1 $f12,0($12) + # 0 "" 2 +#NO_APP + andi $6,$2,0x2 +.L132: + .set noreorder + .set nomacro + beq $6,$0,.L133 + andi $6,$2,0x4 + .set macro + .set reorder + +#APP + # 100 "avcall-mipsn32.c" 1 + ldc1 $f13,8($12) + # 0 "" 2 +#NO_APP + andi $6,$2,0x4 +.L133: + .set noreorder + .set nomacro + beq $6,$0,.L134 + andi $6,$2,0x8 + .set macro + .set reorder + +#APP + # 102 "avcall-mipsn32.c" 1 + ldc1 $f14,16($12) + # 0 "" 2 +#NO_APP + andi $6,$2,0x8 +.L134: + .set noreorder + .set nomacro + beq $6,$0,.L135 + andi $6,$2,0x10 + .set macro + .set reorder + +#APP + # 104 "avcall-mipsn32.c" 1 + ldc1 $f15,24($12) + # 0 "" 2 +#NO_APP + andi $6,$2,0x10 +.L135: + .set noreorder + .set nomacro + beq $6,$0,.L136 + andi $6,$2,0x20 + .set macro + .set reorder + +#APP + # 106 "avcall-mipsn32.c" 1 + ldc1 $f16,32($12) + # 0 "" 2 +#NO_APP + andi $6,$2,0x20 +.L136: + .set noreorder + .set nomacro + beq $6,$0,.L137 + andi $6,$2,0x40 + .set macro + .set reorder + +#APP + # 108 "avcall-mipsn32.c" 1 + ldc1 $f17,40($12) + # 0 "" 2 +#NO_APP + andi $6,$2,0x40 +.L137: + .set noreorder + .set nomacro + beql $6,$0,.L138 + andi $2,$2,0x80 + .set macro + .set reorder + +#APP + # 110 "avcall-mipsn32.c" 1 + ldc1 $f18,48($12) + # 0 "" 2 +#NO_APP + andi $2,$2,0x80 +.L138: + bne $2,$0,.L119 + slt $4,$4,9 +.L123: + .set noreorder + .set nomacro + bne $4,$0,.L22 + addiu $2,$12,64 + .set macro + .set reorder + + .align 3 +.L83: + ld $4,0($2) + addiu $3,$3,8 + addiu $2,$2,8 + .set noreorder + .set nomacro + bne $5,$2,.L83 + sd $4,-8($3) + .set macro + .set reorder + +.L22: +#APP + # 119 "avcall-mipsn32.c" 1 + ld $4,0($12) + # 0 "" 2 + # 120 "avcall-mipsn32.c" 1 + ld $5,8($12) + # 0 "" 2 + # 121 "avcall-mipsn32.c" 1 + ld $6,16($12) + # 0 "" 2 + # 122 "avcall-mipsn32.c" 1 + ld $7,24($12) + # 0 "" 2 + # 123 "avcall-mipsn32.c" 1 + ld $8,32($12) + # 0 "" 2 + # 124 "avcall-mipsn32.c" 1 + ld $9,40($12) + # 0 "" 2 + # 125 "avcall-mipsn32.c" 1 + ld $10,48($12) + # 0 "" 2 + # 126 "avcall-mipsn32.c" 1 + ld $11,56($12) + # 0 "" 2 +#NO_APP + lw $25,4($16) + jalr $25 + lw $4,12($16) + li $5,1 # 0x1 + .set noreorder + .set nomacro + beql $4,$5,.L139 + move $sp,$fp + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$0,.L116 + li $5,2 # 0x2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L109 + li $5,3 # 0x3 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L109 + li $5,4 # 0x4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L109 + li $5,5 # 0x5 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L112 + li $5,6 # 0x6 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L112 + li $5,7 # 0x7 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L111 + li $5,8 # 0x8 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L111 + li $5,9 # 0x9 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L111 + li $5,10 # 0xa + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L111 + li $5,11 # 0xb + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L116 + li $5,12 # 0xc + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L116 + li $5,13 # 0xd + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L120 + li $5,14 # 0xe + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L121 + li $5,15 # 0xf + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L111 + li $5,16 # 0x10 + .set macro + .set reorder + + .set noreorder + .set nomacro + bnel $4,$5,.L139 + move $sp,$fp + .set macro + .set reorder + + lw $4,0($16) + andi $5,$4,0x200 + .set noreorder + .set nomacro + beq $5,$0,.L19 + andi $4,$4,0x4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beql $4,$0,.L38 + lw $5,16($16) + .set macro + .set reorder + + lw $3,16($16) + li $4,1 # 0x1 + .set noreorder + .set nomacro + beq $3,$4,.L109 + li $4,2 # 0x2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $3,$4,.L112 + li $4,4 # 0x4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $3,$4,.L111 + li $4,8 # 0x8 + .set macro + .set reorder + + .set noreorder + .set nomacro + beql $3,$4,.L140 + lw $3,8($16) + .set macro + .set reorder + +.L19: + move $sp,$fp +.L139: + ld $31,24($sp) + ld $fp,16($sp) + ld $16,0($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,32 + .set macro + .set reorder + + .align 3 +.L116: + lw $3,8($16) + .align 3 +.L140: + sd $2,0($3) + move $sp,$fp + ld $31,24($sp) + ld $fp,16($sp) + ld $16,0($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,32 + .set macro + .set reorder + + .align 3 +.L119: +#APP + # 112 "avcall-mipsn32.c" 1 + ldc1 $f19,56($12) + # 0 "" 2 +#NO_APP + .set noreorder + .set nomacro + b .L123 + slt $4,$4,9 + .set macro + .set reorder + + .align 3 +.L118: +#APP + # 92 "avcall-mipsn32.c" 1 + lwc1 $f19,72($16) + # 0 "" 2 +#NO_APP + .set noreorder + .set nomacro + b .L124 + lw $2,40($16) + .set macro + .set reorder + + .align 3 +.L109: + lw $3,8($16) + sb $2,0($3) + move $sp,$fp + ld $31,24($sp) + ld $fp,16($sp) + ld $16,0($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,32 + .set macro + .set reorder + +.L112: + lw $3,8($16) + .set noreorder + .set nomacro + b .L19 + sh $2,0($3) + .set macro + .set reorder + +.L111: + lw $3,8($16) + sw $2,0($3) + move $sp,$fp + ld $31,24($sp) + ld $fp,16($sp) + ld $16,0($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,32 + .set macro + .set reorder + +.L120: + lw $2,8($16) + .set noreorder + .set nomacro + b .L19 + swc1 $f0,0($2) + .set macro + .set reorder + +.L121: + lw $2,8($16) + .set noreorder + .set nomacro + b .L19 + sdc1 $f0,0($2) + .set macro + .set reorder + +.L38: + addiu $4,$5,-1 + sltu $4,$4,16 + .set noreorder + .set nomacro + beq $4,$0,.L19 + sltu $7,$5,9 + .set macro + .set reorder + + lw $6,8($16) + li $8,-8 # 0xfffffffffffffff8 + andi $4,$6,0x7 + addu $5,$5,$4 + .set noreorder + .set nomacro + beq $7,$0,.L42 + and $6,$6,$8 + .set macro + .set reorder + + sltu $3,$5,9 + .set noreorder + .set nomacro + beql $3,$0,.L43 + ld $10,0($6) + .set macro + .set reorder + + sll $5,$5,3 + ld $7,0($6) + li $3,2 # 0x2 + addiu $5,$5,-1 + sll $4,$4,3 + dsll $5,$3,$5 + li $3,1 # 0x1 + dsll $3,$3,$4 + dsll $4,$2,$4 + dsubu $3,$5,$3 + xor $2,$4,$7 + and $2,$3,$2 + xor $2,$2,$7 + .set noreorder + .set nomacro + b .L19 + sd $2,0($6) + .set macro + .set reorder + + .align 3 +.L42: + ld $10,0($6) + sll $9,$4,3 + dsll $7,$2,$9 + li $8,-1 # 0xffffffffffffffff + dsll $8,$8,$9 + xor $7,$7,$10 + and $7,$8,$7 + xor $7,$7,$10 + sltu $8,$5,17 + .set noreorder + .set nomacro + bne $8,$0,.L122 + sd $7,0($6) + .set macro + .set reorder + + subu $4,$0,$4 + ld $10,16($6) + sll $4,$4,3 + sll $5,$5,3 + addiu $4,$4,64 + addiu $5,$5,-129 + li $7,2 # 0x2 + move $8,$3 + dsll $5,$7,$5 + dsra $3,$3,$4 + daddiu $5,$5,-1 + xor $3,$3,$10 + dsra $2,$2,$4 + dsll $8,$8,$9 + and $3,$5,$3 + or $2,$2,$8 + xor $3,$3,$10 + sd $2,8($6) + .set noreorder + .set nomacro + b .L19 + sd $3,16($6) + .set macro + .set reorder + +.L43: + ld $9,8($6) + sll $3,$5,3 + subu $5,$0,$4 + addiu $8,$3,-65 + sll $4,$4,3 + sll $5,$5,3 + li $3,2 # 0x2 + dsll $7,$2,$4 + dsll $3,$3,$8 + dsra $2,$2,$5 + li $5,-1 # 0xffffffffffffffff + dsll $4,$5,$4 + daddiu $3,$3,-1 + xor $5,$7,$10 + xor $2,$2,$9 + and $2,$3,$2 + and $4,$4,$5 + xor $3,$4,$10 + xor $2,$2,$9 + sd $3,0($6) + .set noreorder + .set nomacro + b .L19 + sd $2,8($6) + .set macro + .set reorder + +.L122: + subu $7,$0,$4 + sll $7,$7,2 + addiu $7,$7,32 + ld $10,8($6) + dsra $4,$2,$7 + move $8,$3 + sll $3,$5,3 + addiu $3,$3,-65 + dsra $5,$4,$7 + dsll $2,$8,$9 + li $4,2 # 0x2 + dsll $3,$4,$3 + or $2,$5,$2 + daddiu $3,$3,-1 + xor $2,$2,$10 + and $2,$3,$2 + xor $2,$2,$10 + .set noreorder + .set nomacro + b .L19 + sd $2,8($6) + .set macro + .set reorder + + .end avcall_call + .size avcall_call, .-avcall_call + .ident "GCC: (GNU) 5.4.0" diff --git a/avcall/avcall-mipsn32el-macro.S b/avcall/avcall-mipsn32el-macro.S new file mode 100644 index 0000000..91e4fe5 --- /dev/null +++ b/avcall/avcall-mipsn32el-macro.S @@ -0,0 +1,725 @@ +#include "asm-mips.h" + .file 1 "avcall-mipsn32.c" + .text + .align 2 + .align 3 + .globl avcall_call + .set nomips16 + .set nomicromips + .ent avcall_call + DECLARE_FUNCTION(avcall_call) +avcall_call: + .frame $fp,32,$31 + .mask 0xd0010000,-8 + .fmask 0x00000000,0 + lw $5,20($4) + lw $12,24($4) + lw $2,36($4) + addiu $sp,$sp,-32 + sd $fp,16($sp) + sd $16,0($sp) + sd $31,24($sp) + move $fp,$sp + move $16,$4 + addiu $sp,$sp,-2064 + subu $4,$5,$12 + move $3,$sp + .set noreorder + .set nomacro + beq $2,$0,.L2 + sra $4,$4,3 + .set macro + .set reorder + + andi $6,$2,0x1 + .set noreorder + .set nomacro + beq $6,$0,.L125 + andi $6,$2,0x2 + .set macro + .set reorder + + + + lwc1 $f12,44($16) + + + andi $6,$2,0x2 +.L125: + .set noreorder + .set nomacro + beq $6,$0,.L126 + andi $6,$2,0x4 + .set macro + .set reorder + + + + lwc1 $f13,48($16) + + + andi $6,$2,0x4 +.L126: + .set noreorder + .set nomacro + beq $6,$0,.L127 + andi $6,$2,0x8 + .set macro + .set reorder + + + + lwc1 $f14,52($16) + + + andi $6,$2,0x8 +.L127: + .set noreorder + .set nomacro + beq $6,$0,.L128 + andi $6,$2,0x10 + .set macro + .set reorder + + + + lwc1 $f15,56($16) + + + andi $6,$2,0x10 +.L128: + .set noreorder + .set nomacro + beq $6,$0,.L129 + andi $6,$2,0x20 + .set macro + .set reorder + + + + lwc1 $f16,60($16) + + + andi $6,$2,0x20 +.L129: + .set noreorder + .set nomacro + beq $6,$0,.L130 + andi $6,$2,0x40 + .set macro + .set reorder + + + + lwc1 $f17,64($16) + + + andi $6,$2,0x40 +.L130: + .set noreorder + .set nomacro + beql $6,$0,.L131 + andi $2,$2,0x80 + .set macro + .set reorder + + + + lwc1 $f18,68($16) + + + andi $2,$2,0x80 +.L131: + bne $2,$0,.L118 +.L2: + lw $2,40($16) +.L124: + .set noreorder + .set nomacro + beql $2,$0,.L123 + slt $4,$4,9 + .set macro + .set reorder + + andi $6,$2,0x1 + .set noreorder + .set nomacro + beq $6,$0,.L132 + andi $6,$2,0x2 + .set macro + .set reorder + + + + ldc1 $f12,0($12) + + + andi $6,$2,0x2 +.L132: + .set noreorder + .set nomacro + beq $6,$0,.L133 + andi $6,$2,0x4 + .set macro + .set reorder + + + + ldc1 $f13,8($12) + + + andi $6,$2,0x4 +.L133: + .set noreorder + .set nomacro + beq $6,$0,.L134 + andi $6,$2,0x8 + .set macro + .set reorder + + + + ldc1 $f14,16($12) + + + andi $6,$2,0x8 +.L134: + .set noreorder + .set nomacro + beq $6,$0,.L135 + andi $6,$2,0x10 + .set macro + .set reorder + + + + ldc1 $f15,24($12) + + + andi $6,$2,0x10 +.L135: + .set noreorder + .set nomacro + beq $6,$0,.L136 + andi $6,$2,0x20 + .set macro + .set reorder + + + + ldc1 $f16,32($12) + + + andi $6,$2,0x20 +.L136: + .set noreorder + .set nomacro + beq $6,$0,.L137 + andi $6,$2,0x40 + .set macro + .set reorder + + + + ldc1 $f17,40($12) + + + andi $6,$2,0x40 +.L137: + .set noreorder + .set nomacro + beql $6,$0,.L138 + andi $2,$2,0x80 + .set macro + .set reorder + + + + ldc1 $f18,48($12) + + + andi $2,$2,0x80 +.L138: + bne $2,$0,.L119 + slt $4,$4,9 +.L123: + .set noreorder + .set nomacro + bne $4,$0,.L22 + addiu $2,$12,64 + .set macro + .set reorder + + .align 3 +.L83: + ld $4,0($2) + addiu $3,$3,8 + addiu $2,$2,8 + .set noreorder + .set nomacro + bne $5,$2,.L83 + sd $4,-8($3) + .set macro + .set reorder + +.L22: + + + ld $4,0($12) + + + ld $5,8($12) + + + ld $6,16($12) + + + ld $7,24($12) + + + ld $8,32($12) + + + ld $9,40($12) + + + ld $10,48($12) + + + ld $11,56($12) + + + lw $25,4($16) + jalr $25 + lw $4,12($16) + li $5,1 + .set noreorder + .set nomacro + beql $4,$5,.L139 + move $sp,$fp + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$0,.L116 + li $5,2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L109 + li $5,3 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L109 + li $5,4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L109 + li $5,5 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L112 + li $5,6 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L112 + li $5,7 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L111 + li $5,8 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L111 + li $5,9 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L111 + li $5,10 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L111 + li $5,11 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L116 + li $5,12 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L116 + li $5,13 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L120 + li $5,14 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L121 + li $5,15 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,.L111 + li $5,16 + .set macro + .set reorder + + .set noreorder + .set nomacro + bnel $4,$5,.L139 + move $sp,$fp + .set macro + .set reorder + + lw $4,0($16) + andi $5,$4,0x200 + .set noreorder + .set nomacro + beq $5,$0,.L19 + andi $4,$4,0x4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beql $4,$0,.L38 + lw $5,16($16) + .set macro + .set reorder + + lw $3,16($16) + li $4,1 + .set noreorder + .set nomacro + beq $3,$4,.L109 + li $4,2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $3,$4,.L112 + li $4,4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $3,$4,.L111 + li $4,8 + .set macro + .set reorder + + .set noreorder + .set nomacro + beql $3,$4,.L140 + lw $3,8($16) + .set macro + .set reorder + +.L19: + move $sp,$fp +.L139: + ld $31,24($sp) + ld $fp,16($sp) + ld $16,0($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,32 + .set macro + .set reorder + + .align 3 +.L116: + lw $3,8($16) + .align 3 +.L140: + sd $2,0($3) + move $sp,$fp + ld $31,24($sp) + ld $fp,16($sp) + ld $16,0($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,32 + .set macro + .set reorder + + .align 3 +.L119: + + + ldc1 $f19,56($12) + + + .set noreorder + .set nomacro + b .L123 + slt $4,$4,9 + .set macro + .set reorder + + .align 3 +.L118: + + + lwc1 $f19,72($16) + + + .set noreorder + .set nomacro + b .L124 + lw $2,40($16) + .set macro + .set reorder + + .align 3 +.L109: + lw $3,8($16) + sb $2,0($3) + move $sp,$fp + ld $31,24($sp) + ld $fp,16($sp) + ld $16,0($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,32 + .set macro + .set reorder + +.L112: + lw $3,8($16) + .set noreorder + .set nomacro + b .L19 + sh $2,0($3) + .set macro + .set reorder + +.L111: + lw $3,8($16) + sw $2,0($3) + move $sp,$fp + ld $31,24($sp) + ld $fp,16($sp) + ld $16,0($sp) + move $2,$0 + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,32 + .set macro + .set reorder + +.L120: + lw $2,8($16) + .set noreorder + .set nomacro + b .L19 + swc1 $f0,0($2) + .set macro + .set reorder + +.L121: + lw $2,8($16) + .set noreorder + .set nomacro + b .L19 + sdc1 $f0,0($2) + .set macro + .set reorder + +.L38: + addiu $4,$5,-1 + sltu $4,$4,16 + .set noreorder + .set nomacro + beq $4,$0,.L19 + sltu $7,$5,9 + .set macro + .set reorder + + lw $6,8($16) + li $8,-8 + andi $4,$6,0x7 + addu $5,$5,$4 + .set noreorder + .set nomacro + beq $7,$0,.L42 + and $6,$6,$8 + .set macro + .set reorder + + sltu $3,$5,9 + .set noreorder + .set nomacro + beql $3,$0,.L43 + ld $10,0($6) + .set macro + .set reorder + + sll $5,$5,3 + ld $7,0($6) + li $3,2 + addiu $5,$5,-1 + sll $4,$4,3 + dsll $5,$3,$5 + li $3,1 + dsll $3,$3,$4 + dsll $4,$2,$4 + dsubu $3,$5,$3 + xor $2,$4,$7 + and $2,$3,$2 + xor $2,$2,$7 + .set noreorder + .set nomacro + b .L19 + sd $2,0($6) + .set macro + .set reorder + + .align 3 +.L42: + ld $10,0($6) + sll $9,$4,3 + dsll $7,$2,$9 + li $8,-1 + dsll $8,$8,$9 + xor $7,$7,$10 + and $7,$8,$7 + xor $7,$7,$10 + sltu $8,$5,17 + .set noreorder + .set nomacro + bne $8,$0,.L122 + sd $7,0($6) + .set macro + .set reorder + + subu $4,$0,$4 + ld $10,16($6) + sll $4,$4,3 + sll $5,$5,3 + addiu $4,$4,64 + addiu $5,$5,-129 + li $7,2 + move $8,$3 + dsll $5,$7,$5 + dsra $3,$3,$4 + daddiu $5,$5,-1 + xor $3,$3,$10 + dsra $2,$2,$4 + dsll $8,$8,$9 + and $3,$5,$3 + or $2,$2,$8 + xor $3,$3,$10 + sd $2,8($6) + .set noreorder + .set nomacro + b .L19 + sd $3,16($6) + .set macro + .set reorder + +.L43: + ld $9,8($6) + sll $3,$5,3 + subu $5,$0,$4 + addiu $8,$3,-65 + sll $4,$4,3 + sll $5,$5,3 + li $3,2 + dsll $7,$2,$4 + dsll $3,$3,$8 + dsra $2,$2,$5 + li $5,-1 + dsll $4,$5,$4 + daddiu $3,$3,-1 + xor $5,$7,$10 + xor $2,$2,$9 + and $2,$3,$2 + and $4,$4,$5 + xor $3,$4,$10 + xor $2,$2,$9 + sd $3,0($6) + .set noreorder + .set nomacro + b .L19 + sd $2,8($6) + .set macro + .set reorder + +.L122: + subu $7,$0,$4 + sll $7,$7,2 + addiu $7,$7,32 + ld $10,8($6) + dsra $4,$2,$7 + move $8,$3 + sll $3,$5,3 + addiu $3,$3,-65 + dsra $5,$4,$7 + dsll $2,$8,$9 + li $4,2 + dsll $3,$4,$3 + or $2,$5,$2 + daddiu $3,$3,-1 + xor $2,$2,$10 + and $2,$3,$2 + xor $2,$2,$10 + .set noreorder + .set nomacro + b .L19 + sd $2,8($6) + .set macro + .set reorder + + .end avcall_call + .size avcall_call, .-avcall_call diff --git a/avcall/avcall-powerpc-aix.s b/avcall/avcall-powerpc-aix.s new file mode 100644 index 0000000..d345fb6 --- /dev/null +++ b/avcall/avcall-powerpc-aix.s @@ -0,0 +1,214 @@ + .file "avcall-powerpc.c" + .toc + .csect .text[PR] + .align 2 + .globl avcall_call + .globl .avcall_call + .csect avcall_call[DS] +avcall_call: + .long .avcall_call, TOC[tc0], 0 + .csect .text[PR] +.avcall_call: + .extern __mulh + .extern __mull + .extern __divss + .extern __divus + .extern __quoss + .extern __quous + mflr 0 + stw 0,8(1) + stw 30,-8(1) + stw 31,-4(1) + stw 29,-12(1) + stwu 1,-72(1) + lwz 0,20(3) + lwz 11,24(3) + mr 30,3 + subfc 0,11,0 + srawi 8,0,2 + li 3,8 + lwz 9,0(1) + cmpw 0,3,8 + mr 31,1 + stwu 9,-1040(1) + addi 0,1,71 + rlwinm 10,0,0,0,27 + bge- 0,L..89 +L..6: + slwi 9,3,2 + addi 3,3,1 + cmpw 0,3,8 + lwzx 0,9,11 + add 9,9,10 + stw 0,-32(9) + blt+ 0,L..6 +L..88: + lwz 9,40(30) + subfc 9,30,9 + addi 9,9,-44 + srawi. 9,9,3 + beq- 0,L..8 + cmpwi 0,9,1 + beq- 0,L..11 + cmpwi 0,9,2 + beq- 0,L..14 + cmpwi 0,9,3 + beq- 0,L..17 + cmpwi 0,9,4 + beq- 0,L..20 + cmpwi 0,9,5 + beq- 0,L..23 + cmpwi 0,9,6 + beq- 0,L..26 + cmpwi 0,9,7 + beq- 0,L..29 + cmpwi 0,9,8 + beq- 0,L..32 + cmpwi 0,9,9 + beq- 0,L..35 + cmpwi 0,9,10 + beq- 0,L..38 + cmpwi 0,9,11 + beq- 0,L..41 + cmpwi 0,9,12 + beq- 0,L..44 +L..47: + lfd 13,140(30) +L..44: + lfd 12,132(30) +L..41: + lfd 11,124(30) +L..38: + lfd 10,116(30) +L..35: + lfd 9,108(30) +L..32: + lfd 8,100(30) +L..29: + lfd 7,92(30) +L..26: + lfd 6,84(30) +L..23: + lfd 5,76(30) +L..20: + lfd 4,68(30) +L..17: + lfd 3,60(30) +L..14: + lfd 2,52(30) +L..11: + lfd 1,44(30) +L..8: + lwz 29,4(30) + lwz 9,24(11) + lwz 0,0(29) + lwz 10,28(11) + lwz 3,0(11) + mtctr 0 + lwz 4,4(11) + lwz 5,8(11) + lwz 6,12(11) + lwz 7,16(11) + lwz 8,20(11) + stw 2,20(1) + lwz 11,8(29) + lwz 2,4(29) + bctrl + lwz 2,20(1) + lwz 9,12(30) + cmpwi 0,9,1 + beq- 0,L..49 + cmpwi 0,9,0 + beq- 0,L..99 + cmpwi 0,9,2 + beq- 0,L..92 + cmpwi 0,9,3 + beq- 0,L..92 + cmpwi 0,9,4 + beq- 0,L..92 + cmpwi 0,9,5 + beq- 0,L..91 + cmpwi 0,9,6 + beq- 0,L..91 + cmpwi 0,9,7 + beq- 0,L..99 + cmpwi 0,9,8 + beq- 0,L..99 + cmpwi 0,9,9 + beq- 0,L..99 + cmpwi 0,9,10 + beq- 0,L..99 + addi 0,9,-11 + cmplwi 0,0,1 + ble- 0,L..98 + cmpwi 0,9,13 + beq- 0,L..100 + cmpwi 0,9,14 + beq- 0,L..101 + cmpwi 0,9,15 + beq- 0,L..99 + cmpwi 0,9,16 + beq- 0,L..102 +L..49: + lwz 1,0(1) + li 3,0 + lwz 0,8(1) + lwz 29,-12(1) + mtlr 0 + lwz 30,-8(1) + lwz 31,-4(1) + blr +L..102: + lwz 0,0(30) + andi. 9,0,512 + beq- 0,L..49 + lwz 0,16(30) + cmpwi 0,0,1 + beq- 0,L..92 + cmpwi 0,0,2 + beq- 0,L..91 + cmpwi 0,0,4 + beq- 0,L..99 + cmpwi 0,0,8 + bne+ 0,L..49 +L..98: + lwz 9,8(30) + stw 4,4(9) +L..90: + stw 3,0(9) + b L..49 +L..99: + lwz 9,8(30) + b L..90 +L..91: + lwz 9,8(30) + sth 3,0(9) + b L..49 +L..92: + lwz 9,8(30) + stb 3,0(9) + b L..49 +L..101: + lwz 9,8(30) + stfd 1,0(9) + b L..49 +L..100: + lwz 9,8(30) + frsp 0,1 + stfs 0,0(9) + b L..49 +L..89: + lwz 11,24(30) + b L..88 +LT..avcall_call: + .long 0 + .byte 0,0,32,97,128,3,1,0 + .long 0 + .long LT..avcall_call-.avcall_call + .short 11 + .byte "avcall_call" + .byte 31 + .align 2 +_section_.text: + .csect .data[RW],3 + .long _section_.text diff --git a/avcall/avcall-powerpc-linux-macro.S b/avcall/avcall-powerpc-linux-macro.S new file mode 100644 index 0000000..b67f316 --- /dev/null +++ b/avcall/avcall-powerpc-linux-macro.S @@ -0,0 +1,169 @@ + .file "avcall-powerpc.c" + .section ".text" + .align 2 + .globl avcall_call + .type avcall_call, @function +avcall_call: + .extern __mulh + .extern __mull + .extern __divss + .extern __divus + .extern __quoss + .extern __quous + stwu 1,-1056(1) + mflr 0 + stw 0,1060(1) + addi 10,1,8 + stw 30,1048(1) + mr 30,3 + lwz 0,20(30) + li 3,0 + lwz 11,24(30) + stw 31,1052(1) + mr 31,1 + subfc 0,11,0 + srawi 0,0,2 + cmpw 0,3,0 + bge- 0,.L73 + mtctr 0 +.L74: + slwi 9,3,2 + addi 3,3,1 + lwzx 0,9,11 + stwx 0,9,10 + bdnz .L74 +.L73: + lwz 9,76(30) + subfc 9,30,9 + addi 9,9,-80 + srawi. 9,9,3 + beq- 0,.L8 + cmpwi 0,9,1 + beq- 0,.L11 + cmpwi 0,9,2 + beq- 0,.L14 + cmpwi 0,9,3 + beq- 0,.L17 + cmpwi 0,9,4 + beq- 0,.L20 + cmpwi 0,9,5 + beq- 0,.L23 + cmpwi 0,9,6 + beq- 0,.L26 + cmpwi 0,9,7 + beq- 0,.L29 +.L32: + lfd 8,136(30) +.L29: + lfd 7,128(30) +.L26: + lfd 6,120(30) +.L23: + lfd 5,112(30) +.L20: + lfd 4,104(30) +.L17: + lfd 3,96(30) +.L14: + lfd 2,88(30) +.L11: + lfd 1,80(30) +.L8: + lwz 0,4(30) + lwz 9,68(30) + lwz 3,44(30) + mtctr 0 + lwz 4,48(30) + lwz 5,52(30) + lwz 6,56(30) + lwz 7,60(30) + lwz 8,64(30) + lwz 10,72(30) + crxor 6,6,6 + bctrl + lwz 9,12(30) + cmpwi 0,9,1 + beq- 0,.L34 + cmpwi 0,9,0 + beq- 0,.L84 + cmpwi 0,9,2 + beq- 0,.L77 + cmpwi 0,9,3 + beq- 0,.L77 + cmpwi 0,9,4 + beq- 0,.L77 + cmpwi 0,9,5 + beq- 0,.L76 + cmpwi 0,9,6 + beq- 0,.L76 + cmpwi 0,9,7 + beq- 0,.L84 + cmpwi 0,9,8 + beq- 0,.L84 + cmpwi 0,9,9 + beq- 0,.L84 + cmpwi 0,9,10 + beq- 0,.L84 + addi 0,9,-11 + cmplwi 0,0,1 + ble- 0,.L83 + cmpwi 0,9,13 + beq- 0,.L85 + cmpwi 0,9,14 + beq- 0,.L86 + cmpwi 0,9,15 + beq- 0,.L84 + cmpwi 0,9,16 + beq- 0,.L87 +.L34: + lwz 11,0(1) + li 3,0 + lwz 0,4(11) + lwz 30,-8(11) + lwz 31,-4(11) + mtlr 0 + mr 1,11 + blr +.L87: + lwz 0,0(30) + andi. 9,0,512 + beq- 0,.L34 + lwz 0,16(30) + cmpwi 0,0,1 + beq- 0,.L77 + cmpwi 0,0,2 + beq- 0,.L76 + cmpwi 0,0,4 + beq- 0,.L84 + cmpwi 0,0,8 + bne+ 0,.L34 +.L83: + lwz 9,8(30) + stw 4,4(9) +.L75: + stw 3,0(9) + b .L34 +.L84: + lwz 9,8(30) + b .L75 +.L76: + lwz 9,8(30) + sth 3,0(9) + b .L34 +.L77: + lwz 9,8(30) + stb 3,0(9) + b .L34 +.L86: + lwz 9,8(30) + stfd 1,0(9) + b .L34 +.L85: + frsp 0,1 + lwz 9,8(30) + stfs 0,0(9) + b .L34 + .size avcall_call, .-avcall_call +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/avcall/avcall-powerpc-linux.s b/avcall/avcall-powerpc-linux.s new file mode 100644 index 0000000..bedae2a --- /dev/null +++ b/avcall/avcall-powerpc-linux.s @@ -0,0 +1,168 @@ + .file "avcall-powerpc.c" + .section ".text" + .align 2 + .globl avcall_call + .type avcall_call, @function +avcall_call: + .extern __mulh + .extern __mull + .extern __divss + .extern __divus + .extern __quoss + .extern __quous + stwu 1,-1056(1) + mflr 0 + stw 0,1060(1) + addi 10,1,8 + stw 30,1048(1) + mr 30,3 + lwz 0,20(30) + li 3,0 + lwz 11,24(30) + stw 31,1052(1) + mr 31,1 + subfc 0,11,0 + srawi 0,0,2 + cmpw 0,3,0 + bge- 0,.L73 + mtctr 0 +.L74: + slwi 9,3,2 + addi 3,3,1 + lwzx 0,9,11 + stwx 0,9,10 + bdnz .L74 +.L73: + lwz 9,76(30) + subfc 9,30,9 + addi 9,9,-80 + srawi. 9,9,3 + beq- 0,.L8 + cmpwi 0,9,1 + beq- 0,.L11 + cmpwi 0,9,2 + beq- 0,.L14 + cmpwi 0,9,3 + beq- 0,.L17 + cmpwi 0,9,4 + beq- 0,.L20 + cmpwi 0,9,5 + beq- 0,.L23 + cmpwi 0,9,6 + beq- 0,.L26 + cmpwi 0,9,7 + beq- 0,.L29 +.L32: + lfd 8,136(30) +.L29: + lfd 7,128(30) +.L26: + lfd 6,120(30) +.L23: + lfd 5,112(30) +.L20: + lfd 4,104(30) +.L17: + lfd 3,96(30) +.L14: + lfd 2,88(30) +.L11: + lfd 1,80(30) +.L8: + lwz 0,4(30) + lwz 9,68(30) + lwz 3,44(30) + mtctr 0 + lwz 4,48(30) + lwz 5,52(30) + lwz 6,56(30) + lwz 7,60(30) + lwz 8,64(30) + lwz 10,72(30) + crxor 6,6,6 + bctrl + lwz 9,12(30) + cmpwi 0,9,1 + beq- 0,.L34 + cmpwi 0,9,0 + beq- 0,.L84 + cmpwi 0,9,2 + beq- 0,.L77 + cmpwi 0,9,3 + beq- 0,.L77 + cmpwi 0,9,4 + beq- 0,.L77 + cmpwi 0,9,5 + beq- 0,.L76 + cmpwi 0,9,6 + beq- 0,.L76 + cmpwi 0,9,7 + beq- 0,.L84 + cmpwi 0,9,8 + beq- 0,.L84 + cmpwi 0,9,9 + beq- 0,.L84 + cmpwi 0,9,10 + beq- 0,.L84 + addi 0,9,-11 + cmplwi 0,0,1 + ble- 0,.L83 + cmpwi 0,9,13 + beq- 0,.L85 + cmpwi 0,9,14 + beq- 0,.L86 + cmpwi 0,9,15 + beq- 0,.L84 + cmpwi 0,9,16 + beq- 0,.L87 +.L34: + lwz 11,0(1) + li 3,0 + lwz 0,4(11) + lwz 30,-8(11) + lwz 31,-4(11) + mtlr 0 + mr 1,11 + blr +.L87: + lwz 0,0(30) + andi. 9,0,512 + beq- 0,.L34 + lwz 0,16(30) + cmpwi 0,0,1 + beq- 0,.L77 + cmpwi 0,0,2 + beq- 0,.L76 + cmpwi 0,0,4 + beq- 0,.L84 + cmpwi 0,0,8 + bne+ 0,.L34 +.L83: + lwz 9,8(30) + stw 4,4(9) +.L75: + stw 3,0(9) + b .L34 +.L84: + lwz 9,8(30) + b .L75 +.L76: + lwz 9,8(30) + sth 3,0(9) + b .L34 +.L77: + lwz 9,8(30) + stb 3,0(9) + b .L34 +.L86: + lwz 9,8(30) + stfd 1,0(9) + b .L34 +.L85: + frsp 0,1 + lwz 9,8(30) + stfs 0,0(9) + b .L34 + .size avcall_call, .-avcall_call + .section .note.GNU-stack,"",@progbits + .ident "GCC: (GNU) 3.3.6" diff --git a/avcall/avcall-powerpc-macos.s b/avcall/avcall-powerpc-macos.s new file mode 100644 index 0000000..f76e2c0 --- /dev/null +++ b/avcall/avcall-powerpc-macos.s @@ -0,0 +1,177 @@ +.text + .align 2 + .globl _avcall_call +_avcall_call: + mflr r0 + stmw r29,-12(r1) + stw r0,8(r1) + mr r29,r3 + stwu r1,-1104(r1) + li r3,8 + lwz r0,20(r29) + mr r30,r1 + lwz r9,24(r29) + addi r10,r1,56 + subf r0,r9,r0 + srawi r11,r0,2 + cmpw cr0,r3,r11 + bge- cr0,L89 + mr r12,r9 +L6: + slwi r9,r3,2 + addi r3,r3,1 + cmpw cr0,r3,r11 + lwzx r0,r9,r12 + add r9,r9,r10 + stw r0,-32(r9) + blt+ cr0,L6 +L88: + lwz r9,40(r29) + subf r9,r29,r9 + addi r9,r9,-44 + srawi. r9,r9,3 + beq- cr0,L8 + cmpwi cr0,r9,1 + beq- cr0,L11 + cmpwi cr0,r9,2 + beq- cr0,L14 + cmpwi cr0,r9,3 + beq- cr0,L17 + cmpwi cr0,r9,4 + beq- cr0,L20 + cmpwi cr0,r9,5 + beq- cr0,L23 + cmpwi cr0,r9,6 + beq- cr0,L26 + cmpwi cr0,r9,7 + beq- cr0,L29 + cmpwi cr0,r9,8 + beq- cr0,L32 + cmpwi cr0,r9,9 + beq- cr0,L35 + cmpwi cr0,r9,10 + beq- cr0,L38 + cmpwi cr0,r9,11 + beq- cr0,L41 + cmpwi cr0,r9,12 + beq- cr0,L44 +L47: + lfd f13,140(r29) +L44: + lfd f12,132(r29) +L41: + lfd f11,124(r29) +L38: + lfd f10,116(r29) +L35: + lfd f9,108(r29) +L32: + lfd f8,100(r29) +L29: + lfd f7,92(r29) +L26: + lfd f6,84(r29) +L23: + lfd f5,76(r29) +L20: + lfd f4,68(r29) +L17: + lfd f3,60(r29) +L14: + lfd f2,52(r29) +L11: + lfd f1,44(r29) +L8: + lwz r0,4(r29) + lwz r9,24(r12) + lwz r10,28(r12) + mtctr r0 + lwz r3,0(r12) + lwz r4,4(r12) + lwz r5,8(r12) + lwz r6,12(r12) + lwz r7,16(r12) + lwz r8,20(r12) + bctrl + lwz r9,12(r29) + cmpwi cr0,r9,1 + beq- cr0,L49 + cmpwi cr0,r9,0 + beq- cr0,L99 + cmpwi cr0,r9,2 + beq- cr0,L92 + cmpwi cr0,r9,3 + beq- cr0,L92 + cmpwi cr0,r9,4 + beq- cr0,L92 + cmpwi cr0,r9,5 + beq- cr0,L91 + cmpwi cr0,r9,6 + beq- cr0,L91 + cmpwi cr0,r9,7 + beq- cr0,L99 + cmpwi cr0,r9,8 + beq- cr0,L99 + cmpwi cr0,r9,9 + beq- cr0,L99 + cmpwi cr0,r9,10 + beq- cr0,L99 + addi r0,r9,-11 + cmplwi cr0,r0,1 + ble- cr0,L98 + cmpwi cr0,r9,13 + beq- cr0,L100 + cmpwi cr0,r9,14 + beq- cr0,L101 + cmpwi cr0,r9,15 + beq- cr0,L99 + cmpwi cr0,r9,16 + beq- cr0,L102 +L49: + lwz r1,0(r1) + li r3,0 + lwz r0,8(r1) + lmw r29,-12(r1) + mtlr r0 + blr +L102: + lwz r0,0(r29) + andi. r9,r0,512 + beq- cr0,L49 + lwz r0,16(r29) + cmpwi cr0,r0,1 + beq- cr0,L92 + cmpwi cr0,r0,2 + beq- cr0,L91 + cmpwi cr0,r0,4 + beq- cr0,L99 + cmpwi cr0,r0,8 + bne+ cr0,L49 +L98: + lwz r9,8(r29) + stw r4,4(r9) +L90: + stw r3,0(r9) + b L49 +L99: + lwz r9,8(r29) + b L90 +L91: + lwz r9,8(r29) + sth r3,0(r9) + b L49 +L92: + lwz r9,8(r29) + stb r3,0(r9) + b L49 +L101: + lwz r9,8(r29) + stfd f1,0(r9) + b L49 +L100: + lwz r9,8(r29) + stfs f1,0(r9) + b L49 +L89: + lwz r12,24(r29) + b L88 diff --git a/avcall/avcall-powerpc-sysv4-macro.S b/avcall/avcall-powerpc-sysv4-macro.S new file mode 100644 index 0000000..b67f316 --- /dev/null +++ b/avcall/avcall-powerpc-sysv4-macro.S @@ -0,0 +1,169 @@ + .file "avcall-powerpc.c" + .section ".text" + .align 2 + .globl avcall_call + .type avcall_call, @function +avcall_call: + .extern __mulh + .extern __mull + .extern __divss + .extern __divus + .extern __quoss + .extern __quous + stwu 1,-1056(1) + mflr 0 + stw 0,1060(1) + addi 10,1,8 + stw 30,1048(1) + mr 30,3 + lwz 0,20(30) + li 3,0 + lwz 11,24(30) + stw 31,1052(1) + mr 31,1 + subfc 0,11,0 + srawi 0,0,2 + cmpw 0,3,0 + bge- 0,.L73 + mtctr 0 +.L74: + slwi 9,3,2 + addi 3,3,1 + lwzx 0,9,11 + stwx 0,9,10 + bdnz .L74 +.L73: + lwz 9,76(30) + subfc 9,30,9 + addi 9,9,-80 + srawi. 9,9,3 + beq- 0,.L8 + cmpwi 0,9,1 + beq- 0,.L11 + cmpwi 0,9,2 + beq- 0,.L14 + cmpwi 0,9,3 + beq- 0,.L17 + cmpwi 0,9,4 + beq- 0,.L20 + cmpwi 0,9,5 + beq- 0,.L23 + cmpwi 0,9,6 + beq- 0,.L26 + cmpwi 0,9,7 + beq- 0,.L29 +.L32: + lfd 8,136(30) +.L29: + lfd 7,128(30) +.L26: + lfd 6,120(30) +.L23: + lfd 5,112(30) +.L20: + lfd 4,104(30) +.L17: + lfd 3,96(30) +.L14: + lfd 2,88(30) +.L11: + lfd 1,80(30) +.L8: + lwz 0,4(30) + lwz 9,68(30) + lwz 3,44(30) + mtctr 0 + lwz 4,48(30) + lwz 5,52(30) + lwz 6,56(30) + lwz 7,60(30) + lwz 8,64(30) + lwz 10,72(30) + crxor 6,6,6 + bctrl + lwz 9,12(30) + cmpwi 0,9,1 + beq- 0,.L34 + cmpwi 0,9,0 + beq- 0,.L84 + cmpwi 0,9,2 + beq- 0,.L77 + cmpwi 0,9,3 + beq- 0,.L77 + cmpwi 0,9,4 + beq- 0,.L77 + cmpwi 0,9,5 + beq- 0,.L76 + cmpwi 0,9,6 + beq- 0,.L76 + cmpwi 0,9,7 + beq- 0,.L84 + cmpwi 0,9,8 + beq- 0,.L84 + cmpwi 0,9,9 + beq- 0,.L84 + cmpwi 0,9,10 + beq- 0,.L84 + addi 0,9,-11 + cmplwi 0,0,1 + ble- 0,.L83 + cmpwi 0,9,13 + beq- 0,.L85 + cmpwi 0,9,14 + beq- 0,.L86 + cmpwi 0,9,15 + beq- 0,.L84 + cmpwi 0,9,16 + beq- 0,.L87 +.L34: + lwz 11,0(1) + li 3,0 + lwz 0,4(11) + lwz 30,-8(11) + lwz 31,-4(11) + mtlr 0 + mr 1,11 + blr +.L87: + lwz 0,0(30) + andi. 9,0,512 + beq- 0,.L34 + lwz 0,16(30) + cmpwi 0,0,1 + beq- 0,.L77 + cmpwi 0,0,2 + beq- 0,.L76 + cmpwi 0,0,4 + beq- 0,.L84 + cmpwi 0,0,8 + bne+ 0,.L34 +.L83: + lwz 9,8(30) + stw 4,4(9) +.L75: + stw 3,0(9) + b .L34 +.L84: + lwz 9,8(30) + b .L75 +.L76: + lwz 9,8(30) + sth 3,0(9) + b .L34 +.L77: + lwz 9,8(30) + stb 3,0(9) + b .L34 +.L86: + lwz 9,8(30) + stfd 1,0(9) + b .L34 +.L85: + frsp 0,1 + lwz 9,8(30) + stfs 0,0(9) + b .L34 + .size avcall_call, .-avcall_call +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/avcall/avcall-powerpc.c b/avcall/avcall-powerpc.c new file mode 100644 index 0000000..5d1b6f8 --- /dev/null +++ b/avcall/avcall-powerpc.c @@ -0,0 +1,216 @@ +/** + Copyright 1993 Bill Triggs + Copyright 1995-2017 Bruno Haible + Copyright 2000 Adam Fedor + Copyright 2004 Paul Guyot + + 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, see . +**/ +/*---------------------------------------------------------------------- + !!! THIS ROUTINE MUST BE COMPILED gcc -O !!! + + Foreign function interface for an IBM RS/6000 with gcc + + This calls a C function with an argument list built up using macros + defined in avcall.h. + + RS6000 Argument Passing Conventions: + + All arguments, except the first 8 words, are passed on the stack with + word alignment. Doubles take two words. The first 13 doubles and floats + are also passed in floating-point-registers. + To return a structure, the called function copies the value to space + pointed to by its first argument, and all other arguments are shifted + down by one. + + Differences between AIX and SysV.4 argument passing conventions: + - AIX: the first 13 doubles and floats are passed in FP registers, + and when they do, there is still room allocated for them in the + argument sequence (integer regs or stack). + SysV.4: the first 8 doubles and floats are passed in FP registers, + and no room is allocated for them in the argument sequence. + - AIX: Structures are passed in the argument sequence. + SysV.4: Structures are passed by reference: only a pointer appears in + the argument sequence. + - AIX: Long longs are only word aligned. + SysV.4: Long longs are two-word aligned, both when passed in registers + (pairs: 3/4, 5/6, 7/8, 9/10) and when passed on the stack. (Recall + that the stack is always 8-byte aligned). + + Compile this routine with gcc -O (or -O2 -fno-omit-frame-pointer or -g -O) + to get the right register variables. For other compilers use the + pre-compiled assembler version. + ----------------------------------------------------------------------*/ +#include "avcall-internal.h" + +#if defined(_AIX) || (defined(__MACH__) && defined(__APPLE__)) /* __powerpc_aix__ */ +#define STACK_OFFSET 14 +#else /* __powerpc_sysv4__ */ +#define STACK_OFFSET 2 +#endif + +#define RETURN(TYPE,VAL) (*(TYPE*)l->raddr = (TYPE)(VAL)) + +register double farg1 __asm__("fr1"); +register double farg2 __asm__("fr2"); +register double farg3 __asm__("fr3"); +register double farg4 __asm__("fr4"); +register double farg5 __asm__("fr5"); +register double farg6 __asm__("fr6"); +register double farg7 __asm__("fr7"); +register double farg8 __asm__("fr8"); +register double farg9 __asm__("fr9"); +register double farg10 __asm__("fr10"); +register double farg11 __asm__("fr11"); +register double farg12 __asm__("fr12"); +register double farg13 __asm__("fr13"); + +int +avcall_call(av_alist* list) +{ + register __avword* sp __asm__("r1"); /* C names for registers */ +/*register __avword iret __asm__("r3"); */ + register __avword iret2 __asm__("r4"); + register float fret __asm__("fr1"); + register double dret __asm__("fr1"); + + __av_alist* l = &AV_LIST_INNER(list); + +#if defined(_AIX) /* for some reason, this does not work on Mac OS X and Linux! */ + __avword* argframe = __builtin_alloca(__AV_ALIST_WORDS * sizeof(__avword)); /* make room for argument list */ +#else + __avword space[__AV_ALIST_WORDS]; /* space for callee's stack frame */ + __avword* argframe = sp + STACK_OFFSET;/* stack offset for argument list */ +#endif + int arglen = l->aptr - l->args; + __avword i; +#if defined(_AIX) || (defined(__MACH__) && defined(__APPLE__)) /* __powerpc_aix__ */ + int farglen = 0; + + for (i = (8-farglen); i < arglen; i++) /* push function args onto stack */ + argframe[i-8+farglen] = l->args[i]; +#else /* __powerpc_sysv4__ */ + for (i = 0; i < arglen; i++) /* push function args onto stack */ + argframe[i] = l->args[i]; +#endif + + /* pass first 13 floating-point args in registers */ + arglen = l->faptr - l->fargs; + if (arglen == 0) goto fargs0; + else if (arglen == 1) goto fargs1; + else if (arglen == 2) goto fargs2; + else if (arglen == 3) goto fargs3; + else if (arglen == 4) goto fargs4; + else if (arglen == 5) goto fargs5; + else if (arglen == 6) goto fargs6; + else if (arglen == 7) goto fargs7; + else if (arglen == 8) goto fargs8; +#if defined(_AIX) || (defined(__MACH__) && defined(__APPLE__)) /* __powerpc_aix__ */ + else if (arglen == 9) goto fargs9; + else if (arglen == 10) goto fargs10; + else if (arglen == 11) goto fargs11; + else if (arglen == 12) goto fargs12; + else if (arglen == 13) goto fargs13; + fargs13: farg13 = l->fargs[12]; + fargs12: farg12 = l->fargs[11]; + fargs11: farg11 = l->fargs[10]; + fargs10: farg10 = l->fargs[9]; + fargs9: farg9 = l->fargs[8]; +#endif + fargs8: farg8 = l->fargs[7]; + fargs7: farg7 = l->fargs[6]; + fargs6: farg6 = l->fargs[5]; + fargs5: farg5 = l->fargs[4]; + fargs4: farg4 = l->fargs[3]; + fargs3: farg3 = l->fargs[2]; + fargs2: farg2 = l->fargs[1]; + fargs1: farg1 = l->fargs[0]; + fargs0: ; + +#if defined(_AIX) || (defined(__MACH__) && defined(__APPLE__)) /* __powerpc_aix__ */ + /* call function, pass 8 args in registers */ + i = (*l->func)(l->args[0], l->args[1], l->args[2], l->args[3], + l->args[4], l->args[5], l->args[6], l->args[7]); +#else /* __powerpc_sysv4__ */ + i = (*l->func)(l->iargs[0], l->iargs[1], l->iargs[2], l->iargs[3], + l->iargs[4], l->iargs[5], l->iargs[6], l->iargs[7]); +#endif + + /* save return value */ + if (l->rtype == __AVvoid) { + } else + if (l->rtype == __AVword) { + RETURN(__avword, i); + } else + if (l->rtype == __AVchar) { + RETURN(char, i); + } else + if (l->rtype == __AVschar) { + RETURN(signed char, i); + } else + if (l->rtype == __AVuchar) { + RETURN(unsigned char, i); + } else + if (l->rtype == __AVshort) { + RETURN(short, i); + } else + if (l->rtype == __AVushort) { + RETURN(unsigned short, i); + } else + if (l->rtype == __AVint) { + RETURN(int, i); + } else + if (l->rtype == __AVuint) { + RETURN(unsigned int, i); + } else + if (l->rtype == __AVlong) { + RETURN(long, i); + } else + if (l->rtype == __AVulong) { + RETURN(unsigned long, i); + } else + if (l->rtype == __AVlonglong || l->rtype == __AVulonglong) { + void* raddr = l->raddr; + ((__avword*)raddr)[0] = i; + ((__avword*)raddr)[1] = iret2; + } else + if (l->rtype == __AVfloat) { + RETURN(float, fret); + } else + if (l->rtype == __AVdouble) { + RETURN(double, dret); + } else + if (l->rtype == __AVvoidp) { + RETURN(void*, i); + } else + if (l->rtype == __AVstruct) { + if (l->flags & __AV_REGISTER_STRUCT_RETURN) { + if (l->rsize == sizeof(char)) { + RETURN(char, i); + } else + if (l->rsize == sizeof(short)) { + RETURN(short, i); + } else + if (l->rsize == sizeof(int)) { + RETURN(int, i); + } else + if (l->rsize == 2*sizeof(__avword)) { + void* raddr = l->raddr; + ((__avword*)raddr)[0] = i; + ((__avword*)raddr)[1] = iret2; + } + } + } + return 0; +} diff --git a/avcall/avcall-powerpc64-aix.s b/avcall/avcall-powerpc64-aix.s new file mode 100644 index 0000000..b0248fc --- /dev/null +++ b/avcall/avcall-powerpc64-aix.s @@ -0,0 +1,207 @@ + .file "avcall-powerpc64.c" + .csect .text[PR] + .toc + .csect .text[PR] + .align 2 + .align 4 + .globl avcall_call + .globl .avcall_call + .csect avcall_call[DS],3 +avcall_call: + .llong .avcall_call, TOC[tc0], 0 + .csect .text[PR] +.avcall_call: + mflr 0 + std 30,-16(1) + std 31,-8(1) + mr 30,3 + std 0,16(1) + stdu 1,-128(1) + ld 3,48(3) + ld 9,40(30) + ld 10,0(1) + mr 31,1 + subf 9,3,9 + stdu 10,-2064(1) + sradi 9,9,3 + cmpwi 7,9,8 + ble 7,L..6 + addi 10,9,-9 + addi 8,1,112 + rldicl 10,10,0,32 + addi 9,3,56 + addi 10,10,8 + addi 8,8,-8 + sldi 10,10,3 + add 10,3,10 + .align 4 +L..5: + ldu 7,8(9) + stdu 7,8(8) + cmpld 7,10,9 + bne 7,L..5 +L..6: + ld 10,64(30) + addi 9,30,72 + subf 9,9,10 + sradi 9,9,3 + extsw 9,9 + cmpwi 7,9,0 + ble 7,L..4 + cmpwi 7,9,1 + beq 7,L..7 + cmpwi 7,9,2 + beq 7,L..8 + cmpwi 7,9,3 + beq 7,L..9 + cmpwi 7,9,4 + beq 7,L..10 + cmpwi 7,9,5 + beq 7,L..11 + cmpwi 7,9,6 + beq 7,L..12 + cmpwi 7,9,7 + beq 7,L..13 + cmpwi 7,9,8 + beq 7,L..14 + cmpwi 7,9,9 + beq 7,L..15 + cmpwi 7,9,10 + beq 7,L..16 + cmpwi 7,9,11 + beq 7,L..17 + cmpwi 7,9,12 + beq 7,L..18 + lfd 13,168(30) +L..18: + lfd 12,160(30) +L..17: + lfd 11,152(30) +L..16: + lfd 10,144(30) +L..15: + lfd 9,136(30) +L..14: + lfd 8,128(30) +L..13: + lfd 7,120(30) +L..12: + lfd 6,112(30) +L..11: + lfd 5,104(30) +L..10: + lfd 4,96(30) +L..9: + lfd 3,88(30) +L..8: + lfd 2,80(30) +L..7: + lfd 1,72(30) +L..4: + ld 9,48(3) + ld 10,56(3) + ld 8,40(3) + ld 7,32(3) + ld 6,24(3) + ld 5,16(3) + ld 4,8(3) + ld 3,0(3) + std 2,40(1) + ld 12,8(30) + ld 0,0(12) + ld 11,16(12) + mtctr 0 + ld 2,8(12) + bctrl + ld 2,40(1) + lwz 9,24(30) + cmplwi 7,9,1 + beq 7,L..19 + cmpdi 7,9,0 + beq 7,L..36 + cmplwi 7,9,2 + beq 7,L..38 + cmplwi 7,9,3 + beq 7,L..38 + cmplwi 7,9,4 + beq 7,L..38 + cmplwi 7,9,5 + beq 7,L..39 + cmplwi 7,9,6 + beq 7,L..39 + cmplwi 7,9,7 + beq 7,L..40 + cmplwi 7,9,8 + beq 7,L..40 + cmplwi 7,9,9 + beq 7,L..36 + cmplwi 7,9,10 + beq 7,L..36 + cmplwi 7,9,11 + beq 7,L..36 + cmplwi 7,9,12 + beq 7,L..36 + cmplwi 7,9,13 + beq 7,L..42 + cmplwi 7,9,14 + beq 7,L..43 + cmplwi 7,9,15 + beq 7,L..36 +L..19: + addi 1,31,128 + ld 0,16(1) + ld 30,-16(1) + li 3,0 + ld 31,-8(1) + mtlr 0 + blr + .align 4 +L..36: + ld 9,16(30) + std 3,0(9) + addi 1,31,128 + li 3,0 + ld 0,16(1) + ld 30,-16(1) + ld 31,-8(1) + mtlr 0 + blr + .align 4 +L..38: + ld 9,16(30) + stb 3,0(9) + addi 1,31,128 + li 3,0 + ld 0,16(1) + ld 30,-16(1) + ld 31,-8(1) + mtlr 0 + blr +L..39: + ld 9,16(30) + sth 3,0(9) + b L..19 +L..40: + ld 9,16(30) + stw 3,0(9) + b L..19 +L..42: + ld 9,16(30) + stfs 1,0(9) + b L..19 +L..43: + ld 9,16(30) + stfd 1,0(9) + b L..19 +LT..avcall_call: + .long 0 + .byte 0,0,32,97,128,2,1,0 + .long 0 + .long LT..avcall_call-.avcall_call + .short 11 + .byte "avcall_call" + .byte 31 + .align 2 +_section_.text: + .csect .data[RW],4 + .llong _section_.text diff --git a/avcall/avcall-powerpc64-elfv2-linux.S b/avcall/avcall-powerpc64-elfv2-linux.S new file mode 100644 index 0000000..3ffa3e6 --- /dev/null +++ b/avcall/avcall-powerpc64-elfv2-linux.S @@ -0,0 +1,304 @@ + .file "avcall-powerpc64.c" + .machine power4 + .abiversion 2 + .section ".toc","aw" + .section ".text" + .align 2 + .p2align 4,,15 + .globl avcall_call + .type avcall_call, @function +avcall_call: +0: addis 2,12,.TOC.-0b@ha + addi 2,2,.TOC.-0b@l + .localentry avcall_call,.-avcall_call + mflr 0 + std 30,-16(1) + std 31,-8(1) + mr 30,3 + std 0,16(1) + stdu 1,-112(1) + ld 3,48(3) + ld 9,40(30) + mr 31,1 + ld 10,0(1) + subf 9,3,9 + stdu 10,-2064(1) + sradi 9,9,3 + cmpwi 7,9,8 + ble 7,.L6 + addi 10,9,-9 + addi 8,1,96 + addi 9,3,56 + rldicl 10,10,0,32 + addi 8,8,-8 + addi 10,10,8 + sldi 10,10,3 + add 10,3,10 + .p2align 4,,15 +.L5: + ldu 7,8(9) + cmpld 7,10,9 + stdu 7,8(8) + bne 7,.L5 +.L6: + ld 10,64(30) + addi 9,30,72 + subf 9,9,10 + sradi 9,9,3 + extsw 9,9 + cmpwi 7,9,0 + ble 7,.L4 + cmpwi 7,9,1 + beq 7,.L7 + cmpwi 7,9,2 + beq 7,.L8 + cmpwi 7,9,3 + beq 7,.L9 + cmpwi 7,9,4 + beq 7,.L10 + cmpwi 7,9,5 + beq 7,.L11 + cmpwi 7,9,6 + beq 7,.L12 + cmpwi 7,9,7 + beq 7,.L13 + cmpwi 7,9,8 + beq 7,.L14 + cmpwi 7,9,9 + beq 7,.L15 + cmpwi 7,9,10 + beq 7,.L16 + cmpwi 7,9,11 + beq 7,.L17 + cmpwi 7,9,12 + beq 7,.L18 + lfd 13,168(30) +.L18: + lfd 12,160(30) +.L17: + lfd 11,152(30) +.L16: + lfd 10,144(30) +.L15: + lfd 9,136(30) +.L14: + lfd 8,128(30) +.L13: + lfd 7,120(30) +.L12: + lfd 6,112(30) +.L11: + lfd 5,104(30) +.L10: + lfd 4,96(30) +.L9: + lfd 3,88(30) +.L8: + lfd 2,80(30) +.L7: + lfd 1,72(30) +.L4: + ld 11,8(30) + ld 9,48(3) + ld 10,56(3) + ld 8,40(3) + ld 7,32(3) + ld 6,24(3) + ld 5,16(3) + ld 4,8(3) + mtctr 11 + ld 3,0(3) + mr 12,11 + std 2,24(1) + bctrl + ld 2,24(1) + lwz 9,24(30) + cmplwi 7,9,1 + beq 7,.L19 + cmpdi 7,9,0 + beq 7,.L50 + cmplwi 7,9,2 + beq 7,.L45 + cmplwi 7,9,3 + beq 7,.L45 + cmplwi 7,9,4 + beq 7,.L45 + cmplwi 7,9,5 + beq 7,.L46 + cmplwi 7,9,6 + beq 7,.L46 + cmplwi 7,9,7 + beq 7,.L47 + cmplwi 7,9,8 + beq 7,.L47 + cmplwi 7,9,9 + beq 7,.L50 + cmplwi 7,9,10 + beq 7,.L50 + cmplwi 7,9,11 + beq 7,.L50 + cmplwi 7,9,12 + beq 7,.L50 + cmplwi 7,9,13 + beq 7,.L52 + cmplwi 7,9,14 + beq 7,.L53 + cmplwi 7,9,15 + beq 7,.L50 + cmplwi 7,9,16 + bne 7,.L19 + lwz 9,0(30) + rldicl. 10,9,55,63 + beq 0,.L19 + ld 10,32(30) + addi 9,10,-1 + cmpldi 7,9,15 + bgt 7,.L19 + ld 8,16(30) + cmpldi 7,10,8 + rldicl 9,8,0,61 + rldicr 8,8,0,60 + add 10,10,9 + bgt 7,.L35 + cmpldi 7,10,8 + bgt 7,.L36 + slwi 10,10,3 + li 7,2 + ld 6,0(8) + slwi 9,9,3 + addi 10,10,-1 + sld 10,7,10 + li 7,1 + sld 7,7,9 + sld 9,3,9 + subf 10,7,10 + xor 9,9,6 + and 9,10,9 + xor 9,9,6 + std 9,0(8) +.L19: + addi 1,31,112 + li 3,0 + ld 0,16(1) + ld 30,-16(1) + ld 31,-8(1) + mtlr 0 + blr + .p2align 4,,15 +.L50: + ld 9,16(30) + std 3,0(9) + addi 1,31,112 + li 3,0 + ld 0,16(1) + ld 30,-16(1) + ld 31,-8(1) + mtlr 0 + blr + .p2align 4,,15 +.L45: + ld 9,16(30) + stb 3,0(9) + addi 1,31,112 + li 3,0 + ld 0,16(1) + ld 30,-16(1) + ld 31,-8(1) + mtlr 0 + blr +.L46: + ld 9,16(30) + sth 3,0(9) + b .L19 +.L47: + ld 9,16(30) + stw 3,0(9) + b .L19 +.L52: + ld 9,16(30) + stfs 1,0(9) + b .L19 +.L53: + ld 9,16(30) + stfd 1,0(9) + b .L19 +.L36: + rldicl 9,9,0,32 + slwi 10,10,3 + ld 11,0(8) + ld 4,8(8) + li 7,2 + mulli 6,9,-8 + addi 10,10,-65 + slwi 9,9,3 + sld 10,7,10 + sld 5,3,9 + li 7,-1 + addi 6,6,64 + addi 10,10,-1 + sld 7,7,9 + srad 3,3,6 + xor 6,5,11 + xor 9,3,4 + and 7,7,6 + and 9,10,9 + xor 10,7,11 + xor 9,9,4 + std 10,0(8) + std 9,8(8) + b .L19 +.L35: + rldicl 9,9,0,32 + ld 11,0(8) + li 6,-1 + cmpldi 7,10,16 + slwi 5,9,3 + sld 7,3,5 + sld 6,6,5 + xor 7,7,11 + and 7,6,7 + xor 7,7,11 + std 7,0(8) + ble 7,.L54 + mulli 9,9,-8 + ld 11,16(8) + slwi 10,10,3 + li 7,2 + addi 10,10,-129 + addi 9,9,64 + sld 7,7,10 + srad 6,4,9 + srad 3,3,9 + addi 7,7,-1 + sld 9,4,5 + xor 10,6,11 + or 9,3,9 + and 10,7,10 + std 9,8(8) + xor 10,10,11 + std 10,16(8) + b .L19 +.L54: + mulli 9,9,-4 + slwi 10,10,3 + ld 11,8(8) + sld 4,4,5 + addi 10,10,-65 + li 6,2 + addi 9,9,32 + sld 10,6,10 + srad 3,3,9 + srad 9,3,9 + or 7,9,4 + addi 9,10,-1 + xor 10,7,11 + and 9,10,9 + xor 9,9,11 + std 9,8(8) + b .L19 + .long 0 + .byte 0,0,0,1,128,2,0,0 + .size avcall_call,.-avcall_call +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/avcall/avcall-powerpc64-linux.S b/avcall/avcall-powerpc64-linux.S new file mode 100644 index 0000000..83537fe --- /dev/null +++ b/avcall/avcall-powerpc64-linux.S @@ -0,0 +1,202 @@ + .file "avcall-powerpc64.c" + .machine power4 + .section ".toc","aw" + .section ".text" + .align 2 + .p2align 4,,15 + .globl avcall_call + .section ".opd","aw" + .align 3 +avcall_call: + .quad .L.avcall_call,.TOC.@tocbase,0 + .previous + .type avcall_call, @function +.L.avcall_call: + mflr 0 + std 30,-16(1) + std 31,-8(1) + mr 30,3 + std 0,16(1) + stdu 1,-128(1) + ld 3,48(3) + ld 9,40(30) + mr 31,1 + ld 10,0(1) + subf 9,3,9 + stdu 10,-2064(1) + sradi 9,9,3 + cmpwi 7,9,8 + ble 7,.L6 + addi 10,9,-9 + addi 8,1,112 + addi 9,3,56 + rldicl 10,10,0,32 + addi 8,8,-8 + addi 10,10,8 + sldi 10,10,3 + add 10,3,10 + .p2align 4,,15 +.L5: + ldu 7,8(9) + cmpld 7,10,9 + stdu 7,8(8) + bne 7,.L5 +.L6: + ld 10,64(30) + addi 9,30,72 + subf 9,9,10 + sradi 9,9,3 + extsw 9,9 + cmpwi 7,9,0 + ble 7,.L4 + cmpwi 7,9,1 + beq 7,.L7 + cmpwi 7,9,2 + beq 7,.L8 + cmpwi 7,9,3 + beq 7,.L9 + cmpwi 7,9,4 + beq 7,.L10 + cmpwi 7,9,5 + beq 7,.L11 + cmpwi 7,9,6 + beq 7,.L12 + cmpwi 7,9,7 + beq 7,.L13 + cmpwi 7,9,8 + beq 7,.L14 + cmpwi 7,9,9 + beq 7,.L15 + cmpwi 7,9,10 + beq 7,.L16 + cmpwi 7,9,11 + beq 7,.L17 + cmpwi 7,9,12 + beq 7,.L18 + lfd 13,168(30) +.L18: + lfd 12,160(30) +.L17: + lfd 11,152(30) +.L16: + lfd 10,144(30) +.L15: + lfd 9,136(30) +.L14: + lfd 8,128(30) +.L13: + lfd 7,120(30) +.L12: + lfd 6,112(30) +.L11: + lfd 5,104(30) +.L10: + lfd 4,96(30) +.L9: + lfd 3,88(30) +.L8: + lfd 2,80(30) +.L7: + lfd 1,72(30) +.L4: + ld 9,48(3) + ld 10,56(3) + ld 8,40(3) + ld 7,32(3) + ld 6,24(3) + ld 5,16(3) + ld 4,8(3) + ld 3,0(3) + std 2,40(1) + ld 12,8(30) + ld 0,0(12) + ld 11,16(12) + mtctr 0 + ld 2,8(12) + bctrl + ld 2,40(1) + lwz 9,24(30) + cmplwi 7,9,1 + beq 7,.L19 + cmpdi 7,9,0 + beq 7,.L36 + cmplwi 7,9,2 + beq 7,.L38 + cmplwi 7,9,3 + beq 7,.L38 + cmplwi 7,9,4 + beq 7,.L38 + cmplwi 7,9,5 + beq 7,.L39 + cmplwi 7,9,6 + beq 7,.L39 + cmplwi 7,9,7 + beq 7,.L40 + cmplwi 7,9,8 + beq 7,.L40 + cmplwi 7,9,9 + beq 7,.L36 + cmplwi 7,9,10 + beq 7,.L36 + cmplwi 7,9,11 + beq 7,.L36 + cmplwi 7,9,12 + beq 7,.L36 + cmplwi 7,9,13 + beq 7,.L42 + cmplwi 7,9,14 + beq 7,.L43 + cmplwi 7,9,15 + beq 7,.L36 +.L19: + addi 1,31,128 + li 3,0 + ld 0,16(1) + ld 30,-16(1) + ld 31,-8(1) + mtlr 0 + blr + .p2align 4,,15 +.L36: + ld 9,16(30) + std 3,0(9) + addi 1,31,128 + li 3,0 + ld 0,16(1) + ld 30,-16(1) + ld 31,-8(1) + mtlr 0 + blr + .p2align 4,,15 +.L38: + ld 9,16(30) + stb 3,0(9) + addi 1,31,128 + li 3,0 + ld 0,16(1) + ld 30,-16(1) + ld 31,-8(1) + mtlr 0 + blr +.L39: + ld 9,16(30) + sth 3,0(9) + b .L19 +.L40: + ld 9,16(30) + stw 3,0(9) + b .L19 +.L42: + ld 9,16(30) + stfs 1,0(9) + b .L19 +.L43: + ld 9,16(30) + stfd 1,0(9) + b .L19 + .long 0 + .byte 0,0,0,1,128,2,0,0 + .size avcall_call,.-.L.avcall_call +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/avcall/avcall-powerpc64.c b/avcall/avcall-powerpc64.c new file mode 100644 index 0000000..f0d64d2 --- /dev/null +++ b/avcall/avcall-powerpc64.c @@ -0,0 +1,330 @@ +/** + Copyright 1993 Bill Triggs + Copyright 1995-2017 Bruno Haible + Copyright 2000 Adam Fedor + Copyright 2004 Paul Guyot + + 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, see . +**/ +/*---------------------------------------------------------------------- + !!! THIS ROUTINE MUST BE COMPILED gcc -O !!! + + Foreign function interface for a 64-bit PowerPC with gcc + + This calls a C function with an argument list built up using macros + defined in avcall.h. + + PowerPC64 Argument Passing Conventions: + + All arguments, except the first 8 words, are passed on the stack with + word alignment. The first 13 doubles and floats are also passed in + floating-point-registers. + To return a structure, the called function copies the value to space + pointed to by its first argument, and all other arguments are shifted + down by one. + + The AIX argument passing conventions are used: + - the first 13 doubles and floats are passed in FP registers, + and when they do, there is still room allocated for them in the + argument sequence (integer regs or stack). + - Structures are passed in the argument sequence. But structures + containing floats or doubles are passed in FP registers?! + + Compile this routine with gcc -O (or -O2 -fno-omit-frame-pointer or -g -O) + to get the right register variables. For other compilers use the + pre-compiled assembler version. + ----------------------------------------------------------------------*/ +#include "avcall-internal.h" + +#define RETURN(TYPE,VAL) (*(TYPE*)l->raddr = (TYPE)(VAL)) + +register double farg1 __asm__("fr1"); +register double farg2 __asm__("fr2"); +register double farg3 __asm__("fr3"); +register double farg4 __asm__("fr4"); +register double farg5 __asm__("fr5"); +register double farg6 __asm__("fr6"); +register double farg7 __asm__("fr7"); +register double farg8 __asm__("fr8"); +register double farg9 __asm__("fr9"); +register double farg10 __asm__("fr10"); +register double farg11 __asm__("fr11"); +register double farg12 __asm__("fr12"); +register double farg13 __asm__("fr13"); + +int +avcall_call(av_alist* list) +{ + register __avword* sp __asm__("r1"); /* C names for registers */ +/*register __avword iret __asm__("r3"); */ + register __avword iret2 __asm__("r4"); + register float fret __asm__("fr1"); + register double dret __asm__("fr1"); + + __av_alist* l = &AV_LIST_INNER(list); + + __avword* argframe = __builtin_alloca(__AV_ALIST_WORDS * sizeof(__avword)); /* make room for argument list */ + int arglen = l->aptr - l->args; + __avword iret; + int i; + + for (i = 8; i < arglen; i++) /* push function args onto stack */ + argframe[i-8] = l->args[i]; + + /* pass first 13 floating-point args in registers */ + arglen = l->faptr - l->fargs; + if (arglen > 0) { + if (arglen > 1) { + if (arglen > 2) { + if (arglen > 3) { + if (arglen > 4) { + if (arglen > 5) { + if (arglen > 6) { + if (arglen > 7) { + if (arglen > 8) { + if (arglen > 9) { + if (arglen > 10) { + if (arglen > 11) { + if (arglen > 12) { + farg13 = l->fargs[12]; + } + farg12 = l->fargs[11]; + } + farg11 = l->fargs[10]; + } + farg10 = l->fargs[9]; + } + farg9 = l->fargs[8]; + } + farg8 = l->fargs[7]; + } + farg7 = l->fargs[6]; + } + farg6 = l->fargs[5]; + } + farg5 = l->fargs[4]; + } + farg4 = l->fargs[3]; + } + farg3 = l->fargs[2]; + } + farg2 = l->fargs[1]; + } + farg1 = l->fargs[0]; + } + /* call function, pass 8 args in registers */ + iret = (*l->func)(l->args[0], l->args[1], l->args[2], l->args[3], + l->args[4], l->args[5], l->args[6], l->args[7]); + + /* save return value */ + if (l->rtype == __AVvoid) { + } else + if (l->rtype == __AVword) { + RETURN(__avword, iret); + } else + if (l->rtype == __AVchar) { + RETURN(char, iret); + } else + if (l->rtype == __AVschar) { + RETURN(signed char, iret); + } else + if (l->rtype == __AVuchar) { + RETURN(unsigned char, iret); + } else + if (l->rtype == __AVshort) { + RETURN(short, iret); + } else + if (l->rtype == __AVushort) { + RETURN(unsigned short, iret); + } else + if (l->rtype == __AVint) { + RETURN(int, iret); + } else + if (l->rtype == __AVuint) { + RETURN(unsigned int, iret); + } else + if (l->rtype == __AVlong) { + RETURN(long, iret); + } else + if (l->rtype == __AVulong) { + RETURN(unsigned long, iret); + } else + if (l->rtype == __AVlonglong) { + RETURN(long long, iret); + } else + if (l->rtype == __AVulonglong) { + RETURN(unsigned long long, iret); + } else + if (l->rtype == __AVfloat) { + RETURN(float, fret); + } else + if (l->rtype == __AVdouble) { + RETURN(double, dret); + } else + if (l->rtype == __AVvoidp) { + RETURN(void*, iret); + } else + if (l->rtype == __AVstruct) { +#ifdef __powerpc64_elfv2__ + if (l->flags & __AV_REGISTER_STRUCT_RETURN) { + /* In the ELFv2 ABI, gcc returns structs of size <= 16 in registers. */ + if (l->rsize > 0 && l->rsize <= 16) { + void* raddr = l->raddr; + #if 0 /* Unoptimized */ + if (l->rsize == 1) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + } else + if (l->rsize == 2) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + } else + if (l->rsize == 3) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + } else + if (l->rsize == 4) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + } else + if (l->rsize == 5) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>32); + } else + if (l->rsize == 6) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>40); + } else + if (l->rsize == 7) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[6] = (unsigned char)(iret>>48); + } else + if (l->rsize >= 8 && l->rsize <= 16) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[6] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[7] = (unsigned char)(iret>>56); + if (l->rsize == 8) { + } else + if (l->rsize == 9) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + } else + if (l->rsize == 10) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + } else + if (l->rsize == 11) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + } else + if (l->rsize == 12) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + } else + if (l->rsize == 13) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>32); + } else + if (l->rsize == 14) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>40); + } else + if (l->rsize == 15) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+6] = (unsigned char)(iret2>>48); + } else + if (l->rsize == 16) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+6] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+7] = (unsigned char)(iret2>>56); + } + } + #else /* Optimized: fewer conditional jumps, fewer memory accesses */ + uintptr_t count = l->rsize; /* > 0, ≤ 2*sizeof(__avword) */ + __avword* wordaddr = (__avword*)((uintptr_t)raddr & ~(uintptr_t)(sizeof(__avword)-1)); + uintptr_t start_offset = (uintptr_t)raddr & (uintptr_t)(sizeof(__avword)-1); /* ≥ 0, < sizeof(__avword) */ + uintptr_t end_offset = start_offset + count; /* > 0, < 3*sizeof(__avword) */ + if (count <= sizeof(__avword)) { + /* Use iret. */ + if (end_offset <= sizeof(__avword)) { + /* 0 < end_offset ≤ sizeof(__avword) */ + __avword mask0 = ((__avword)2 << (end_offset*8-1)) - ((__avword)1 << (start_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret << (start_offset*8))) & mask0; + } else { + /* sizeof(__avword) < end_offset < 2*sizeof(__avword), start_offset > 0 */ + __avword mask0 = - ((__avword)1 << (start_offset*8)); + __avword mask1 = ((__avword)2 << (end_offset*8-sizeof(__avword)*8-1)) - 1; + wordaddr[0] ^= (wordaddr[0] ^ (iret << (start_offset*8))) & mask0; + wordaddr[1] ^= (wordaddr[1] ^ (iret >> (sizeof(__avword)*8-start_offset*8))) & mask1; + } + } else { + /* Use iret, iret2. */ + __avword mask0 = - ((__avword)1 << (start_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret << (start_offset*8))) & mask0; + if (end_offset <= 2*sizeof(__avword)) { + /* sizeof(__avword) < end_offset ≤ 2*sizeof(__avword) */ + __avword mask1 = ((__avword)2 << (end_offset*8-sizeof(__avword)*8-1)) - 1; + wordaddr[1] ^= (wordaddr[1] ^ ((iret >> (sizeof(__avword)*4-start_offset*4) >> (sizeof(__avword)*4-start_offset*4)) | (iret2 << (start_offset*8)))) & mask1; + } else { + /* 2*sizeof(__avword) < end_offset < 3*sizeof(__avword), start_offset > 0 */ + __avword mask2 = ((__avword)2 << (end_offset*8-2*sizeof(__avword)*8-1)) - 1; + wordaddr[1] = (iret >> (sizeof(__avword)*8-start_offset*8)) | (iret2 << (start_offset*8)); + wordaddr[2] ^= (wordaddr[2] ^ (iret2 >> (sizeof(__avword)*8-start_offset*8))) & mask2; + } + } + #endif + } + } +#endif + } + return 0; +} diff --git a/avcall/avcall-riscv32-ilp32d-linux.s b/avcall/avcall-riscv32-ilp32d-linux.s new file mode 100644 index 0000000..fbbb9d6 --- /dev/null +++ b/avcall/avcall-riscv32-ilp32d-linux.s @@ -0,0 +1,327 @@ + .file "avcall-riscv32.c" + .option pic + .text + .align 1 + .globl avcall_call + .type avcall_call, @function +avcall_call: + add sp,sp,-32 + sw ra,28(sp) + sw s0,24(sp) + sw s1,20(sp) + sw s2,16(sp) + sw s3,12(sp) + sw s4,8(sp) + sw s5,4(sp) + add s0,sp,32 + lw t2,24(a0) + lw t0,20(a0) + li t3,32 + mv s1,a0 + sub t0,t0,t2 + add sp,sp,-1040 + lw ra,40(a0) + ble t0,t3,.L2 + mv t1,sp + sra t6,t0,2 + add t4,t2,32 + li t3,8 +.L3: + lw t5,0(t4) + add t3,t3,1 + add t4,t4,4 + sw t5,0(t1) + add t1,t1,4 + bgt t6,t3,.L3 +.L4: + li t1,4 + lw a0,0(t2) + bgt t0,t1,.L81 +.L5: + beqz ra,.L8 + lw t1,48(s1) + and t3,t1,1 + beqz t3,.L9 + fld fa0,88(s1) +.L10: + li t3,1 + bleu ra,t3,.L8 + and t3,t1,2 + bnez t3,.L82 + lw t3,44(s1) + and t3,t3,2 + beqz t3,.L13 + flw fa1,56(s1) +.L13: + li t3,2 + beq ra,t3,.L8 + and t3,t1,4 + beqz t3,.L14 + fld fa2,104(s1) +.L15: + li t3,3 + beq ra,t3,.L8 + and t3,t1,8 + bnez t3,.L83 + lw t3,44(s1) + and t3,t3,8 + beqz t3,.L17 + flw fa3,64(s1) +.L17: + li t3,4 + beq ra,t3,.L8 + and t3,t1,16 + beqz t3,.L18 + fld fa4,120(s1) +.L19: + li t3,5 + beq ra,t3,.L8 + and t3,t1,32 + beqz t3,.L20 + fld fa5,128(s1) +.L21: + li t3,6 + beq ra,t3,.L8 + and t3,t1,64 + beqz t3,.L22 + fld fa6,136(s1) +.L23: + li t3,7 + beq ra,t3,.L8 + and t1,t1,128 + beqz t1,.L24 + fld fa7,144(s1) +.L8: + lw t1,12(s1) + li t3,13 + lw t4,4(s1) + bne t1,t3,.L25 + lw s1,8(s1) + jalr t4 + fsw fa0,0(s1) +.L26: + add sp,s0,-32 + lw ra,28(sp) + li a0,0 + lw s0,24(sp) + lw s1,20(sp) + lw s2,16(sp) + lw s3,12(sp) + lw s4,8(sp) + lw s5,4(sp) + add sp,sp,32 + jr ra +.L81: + li t1,8 + lw a1,4(t2) + ble t0,t1,.L5 + li t1,12 + lw a2,8(t2) + ble t0,t1,.L5 + li t1,16 + lw a3,12(t2) + ble t0,t1,.L5 + li t1,20 + lw a4,16(t2) + ble t0,t1,.L5 + li t1,24 + lw a5,20(t2) + ble t0,t1,.L5 + li t1,28 + lw a6,24(t2) + ble t0,t1,.L5 + lw a7,28(t2) + j .L5 +.L9: + lw t3,44(s1) + and t3,t3,1 + beqz t3,.L10 + flw fa0,52(s1) + j .L10 +.L25: + li t3,14 + beq t1,t3,.L84 + jalr t4 + lw t1,12(s1) + li t4,1 + mv t3,a0 + beq t1,t4,.L26 + beqz t1,.L79 + li t4,2 + beq t1,t4,.L74 + li t4,3 + beq t1,t4,.L74 + li t4,4 + beq t1,t4,.L74 + li t4,5 + beq t1,t4,.L75 + li t4,6 + beq t1,t4,.L75 + li t4,7 + beq t1,t4,.L79 + li s4,8 + beq t1,s4,.L79 + li t4,9 + beq t1,t4,.L79 + li t4,10 + beq t1,t4,.L79 + add t6,t1,-11 + li t4,1 + bleu t6,t4,.L85 + li t6,15 + beq t1,t6,.L79 + li t6,16 + bne t1,t6,.L26 + lw t1,0(s1) + and t1,t1,2 + beqz t1,.L26 + lw s3,16(s1) + li t1,7 + add t6,s3,-1 + bgtu t6,t1,.L26 + lw t6,8(s1) + li s5,4 + and t0,t6,-4 + lw t2,0(t0) + and t6,t6,3 + sll s2,t6,3 + sll s1,a0,s2 + add t1,s3,t6 + sll t4,t4,s2 + xor s1,s1,t2 + bgtu s3,s5,.L40 + bgtu t1,s5,.L41 + sll t1,t1,3 + add t3,t1,-1 + li t1,2 + sll t1,t1,t3 + sub t1,t1,t4 + and t1,t1,s1 + xor t1,t1,t2 + sw t1,0(t0) + j .L26 +.L82: + fld fa1,96(s1) + j .L13 +.L84: + lw s1,8(s1) + jalr t4 + fsd fa0,0(s1) + j .L26 +.L2: + blez t0,.L5 + j .L4 +.L14: + lw t3,44(s1) + and t3,t3,4 + beqz t3,.L15 + flw fa2,60(s1) + j .L15 +.L79: + lw t1,8(s1) + sw t3,0(t1) + j .L26 +.L83: + fld fa3,112(s1) + j .L17 +.L74: + lw t1,8(s1) + sb t3,0(t1) + j .L26 +.L18: + lw t3,44(s1) + and t3,t3,16 + beqz t3,.L19 + flw fa4,68(s1) + j .L19 +.L75: + lw t1,8(s1) + sh t3,0(t1) + j .L26 +.L20: + lw t3,44(s1) + and t3,t3,32 + beqz t3,.L21 + flw fa5,72(s1) + j .L21 +.L22: + lw t3,44(s1) + and t3,t3,64 + beqz t3,.L23 + flw fa6,76(s1) + j .L23 +.L24: + lw t1,44(s1) + and t1,t1,128 + beqz t1,.L8 + flw fa7,80(s1) + j .L8 +.L85: + lw t1,8(s1) + sw a0,0(t1) + sw a1,4(t1) + j .L26 +.L41: + li t5,-8 + mul t6,t6,t5 + lw s2,4(t0) + sll t1,t1,3 + add t5,t1,-33 + li t1,2 + sll t1,t1,t5 + sub t4,zero,t4 + add t1,t1,-1 + and t4,t4,s1 + xor t4,t4,t2 + sra t3,a0,t6 + xor t3,t3,s2 + and t1,t1,t3 + xor t1,t1,s2 + sw t4,0(t0) + sw t1,4(t0) + j .L26 +.L40: + sub t4,zero,t4 + and t4,t4,s1 + xor t4,t4,t2 + sw t4,0(t0) + sll s1,a1,s2 + bleu t1,s4,.L86 + li t4,-8 + mul t6,t6,t4 + sll t1,t1,3 + li t2,2 + add t1,t1,-65 + lw s2,8(t0) + sll t1,t2,t1 + add t2,t1,-1 + add t1,t6,32 + sra t4,a1,t1 + xor t4,t4,s2 + sra t1,a0,t1 + and t3,t2,t4 + or t1,t1,s1 + xor t3,t3,s2 + sw t1,4(t0) + sw t3,8(t0) + j .L26 +.L86: + li t4,-4 + mul t4,t6,t4 + sll t1,t1,3 + lw t6,4(t0) + add t5,t1,-33 + li t1,2 + sll t1,t1,t5 + add t1,t1,-1 + add t4,t4,16 + sra t3,a0,t4 + sra t3,t3,t4 + or t3,t3,s1 + xor t3,t3,t6 + and t1,t1,t3 + xor t1,t1,t6 + sw t1,4(t0) + j .L26 + .size avcall_call, .-avcall_call + .ident "GCC: (GNU) 7.3.0" diff --git a/avcall/avcall-riscv32-ilp32d-macro.S b/avcall/avcall-riscv32-ilp32d-macro.S new file mode 100644 index 0000000..2a14861 --- /dev/null +++ b/avcall/avcall-riscv32-ilp32d-macro.S @@ -0,0 +1,329 @@ + .file "avcall-riscv32.c" + .option pic + .text + .align 1 + .globl avcall_call + .type avcall_call, @function +avcall_call: + add sp,sp,-32 + sw ra,28(sp) + sw s0,24(sp) + sw s1,20(sp) + sw s2,16(sp) + sw s3,12(sp) + sw s4,8(sp) + sw s5,4(sp) + add s0,sp,32 + lw t2,24(a0) + lw t0,20(a0) + li t3,32 + mv s1,a0 + sub t0,t0,t2 + add sp,sp,-1040 + lw ra,40(a0) + ble t0,t3,.L2 + mv t1,sp + sra t6,t0,2 + add t4,t2,32 + li t3,8 +.L3: + lw t5,0(t4) + add t3,t3,1 + add t4,t4,4 + sw t5,0(t1) + add t1,t1,4 + bgt t6,t3,.L3 +.L4: + li t1,4 + lw a0,0(t2) + bgt t0,t1,.L81 +.L5: + beqz ra,.L8 + lw t1,48(s1) + and t3,t1,1 + beqz t3,.L9 + fld fa0,88(s1) +.L10: + li t3,1 + bleu ra,t3,.L8 + and t3,t1,2 + bnez t3,.L82 + lw t3,44(s1) + and t3,t3,2 + beqz t3,.L13 + flw fa1,56(s1) +.L13: + li t3,2 + beq ra,t3,.L8 + and t3,t1,4 + beqz t3,.L14 + fld fa2,104(s1) +.L15: + li t3,3 + beq ra,t3,.L8 + and t3,t1,8 + bnez t3,.L83 + lw t3,44(s1) + and t3,t3,8 + beqz t3,.L17 + flw fa3,64(s1) +.L17: + li t3,4 + beq ra,t3,.L8 + and t3,t1,16 + beqz t3,.L18 + fld fa4,120(s1) +.L19: + li t3,5 + beq ra,t3,.L8 + and t3,t1,32 + beqz t3,.L20 + fld fa5,128(s1) +.L21: + li t3,6 + beq ra,t3,.L8 + and t3,t1,64 + beqz t3,.L22 + fld fa6,136(s1) +.L23: + li t3,7 + beq ra,t3,.L8 + and t1,t1,128 + beqz t1,.L24 + fld fa7,144(s1) +.L8: + lw t1,12(s1) + li t3,13 + lw t4,4(s1) + bne t1,t3,.L25 + lw s1,8(s1) + jalr t4 + fsw fa0,0(s1) +.L26: + add sp,s0,-32 + lw ra,28(sp) + li a0,0 + lw s0,24(sp) + lw s1,20(sp) + lw s2,16(sp) + lw s3,12(sp) + lw s4,8(sp) + lw s5,4(sp) + add sp,sp,32 + jr ra +.L81: + li t1,8 + lw a1,4(t2) + ble t0,t1,.L5 + li t1,12 + lw a2,8(t2) + ble t0,t1,.L5 + li t1,16 + lw a3,12(t2) + ble t0,t1,.L5 + li t1,20 + lw a4,16(t2) + ble t0,t1,.L5 + li t1,24 + lw a5,20(t2) + ble t0,t1,.L5 + li t1,28 + lw a6,24(t2) + ble t0,t1,.L5 + lw a7,28(t2) + j .L5 +.L9: + lw t3,44(s1) + and t3,t3,1 + beqz t3,.L10 + flw fa0,52(s1) + j .L10 +.L25: + li t3,14 + beq t1,t3,.L84 + jalr t4 + lw t1,12(s1) + li t4,1 + mv t3,a0 + beq t1,t4,.L26 + beqz t1,.L79 + li t4,2 + beq t1,t4,.L74 + li t4,3 + beq t1,t4,.L74 + li t4,4 + beq t1,t4,.L74 + li t4,5 + beq t1,t4,.L75 + li t4,6 + beq t1,t4,.L75 + li t4,7 + beq t1,t4,.L79 + li s4,8 + beq t1,s4,.L79 + li t4,9 + beq t1,t4,.L79 + li t4,10 + beq t1,t4,.L79 + add t6,t1,-11 + li t4,1 + bleu t6,t4,.L85 + li t6,15 + beq t1,t6,.L79 + li t6,16 + bne t1,t6,.L26 + lw t1,0(s1) + and t1,t1,2 + beqz t1,.L26 + lw s3,16(s1) + li t1,7 + add t6,s3,-1 + bgtu t6,t1,.L26 + lw t6,8(s1) + li s5,4 + and t0,t6,-4 + lw t2,0(t0) + and t6,t6,3 + sll s2,t6,3 + sll s1,a0,s2 + add t1,s3,t6 + sll t4,t4,s2 + xor s1,s1,t2 + bgtu s3,s5,.L40 + bgtu t1,s5,.L41 + sll t1,t1,3 + add t3,t1,-1 + li t1,2 + sll t1,t1,t3 + sub t1,t1,t4 + and t1,t1,s1 + xor t1,t1,t2 + sw t1,0(t0) + j .L26 +.L82: + fld fa1,96(s1) + j .L13 +.L84: + lw s1,8(s1) + jalr t4 + fsd fa0,0(s1) + j .L26 +.L2: + blez t0,.L5 + j .L4 +.L14: + lw t3,44(s1) + and t3,t3,4 + beqz t3,.L15 + flw fa2,60(s1) + j .L15 +.L79: + lw t1,8(s1) + sw t3,0(t1) + j .L26 +.L83: + fld fa3,112(s1) + j .L17 +.L74: + lw t1,8(s1) + sb t3,0(t1) + j .L26 +.L18: + lw t3,44(s1) + and t3,t3,16 + beqz t3,.L19 + flw fa4,68(s1) + j .L19 +.L75: + lw t1,8(s1) + sh t3,0(t1) + j .L26 +.L20: + lw t3,44(s1) + and t3,t3,32 + beqz t3,.L21 + flw fa5,72(s1) + j .L21 +.L22: + lw t3,44(s1) + and t3,t3,64 + beqz t3,.L23 + flw fa6,76(s1) + j .L23 +.L24: + lw t1,44(s1) + and t1,t1,128 + beqz t1,.L8 + flw fa7,80(s1) + j .L8 +.L85: + lw t1,8(s1) + sw a0,0(t1) + sw a1,4(t1) + j .L26 +.L41: + li t5,-8 + mul t6,t6,t5 + lw s2,4(t0) + sll t1,t1,3 + add t5,t1,-33 + li t1,2 + sll t1,t1,t5 + sub t4,zero,t4 + add t1,t1,-1 + and t4,t4,s1 + xor t4,t4,t2 + sra t3,a0,t6 + xor t3,t3,s2 + and t1,t1,t3 + xor t1,t1,s2 + sw t4,0(t0) + sw t1,4(t0) + j .L26 +.L40: + sub t4,zero,t4 + and t4,t4,s1 + xor t4,t4,t2 + sw t4,0(t0) + sll s1,a1,s2 + bleu t1,s4,.L86 + li t4,-8 + mul t6,t6,t4 + sll t1,t1,3 + li t2,2 + add t1,t1,-65 + lw s2,8(t0) + sll t1,t2,t1 + add t2,t1,-1 + add t1,t6,32 + sra t4,a1,t1 + xor t4,t4,s2 + sra t1,a0,t1 + and t3,t2,t4 + or t1,t1,s1 + xor t3,t3,s2 + sw t1,4(t0) + sw t3,8(t0) + j .L26 +.L86: + li t4,-4 + mul t4,t6,t4 + sll t1,t1,3 + lw t6,4(t0) + add t5,t1,-33 + li t1,2 + sll t1,t1,t5 + add t1,t1,-1 + add t4,t4,16 + sra t3,a0,t4 + sra t3,t3,t4 + or t3,t3,s1 + xor t3,t3,t6 + and t1,t1,t3 + xor t1,t1,t6 + sw t1,4(t0) + j .L26 + .size avcall_call, .-avcall_call +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/avcall/avcall-riscv32.c b/avcall/avcall-riscv32.c new file mode 100644 index 0000000..7b70fd9 --- /dev/null +++ b/avcall/avcall-riscv32.c @@ -0,0 +1,280 @@ +/** + Copyright 1993 Bill Triggs + Copyright 1995-2019 Bruno Haible + + 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, see . +**/ +/*---------------------------------------------------------------------- + Foreign function interface for a Linux riscv32 with ILP32 ABI. + + This calls a C function with an argument list built up using macros + defined in avcall.h. + + RISC-V Argument Passing Conventions are documented in + https://people.eecs.berkeley.edu/~krste/papers/riscv-spec-v2.1.pdf + chapter 20. + ----------------------------------------------------------------------*/ +#include "avcall-internal.h" + +#define RETURN(TYPE,VAL) (*(TYPE*)l->raddr = (TYPE)(VAL)) + +register __avword iarg1 __asm__("a0"); +register __avword iarg2 __asm__("a1"); +register __avword iarg3 __asm__("a2"); +register __avword iarg4 __asm__("a3"); +register __avword iarg5 __asm__("a4"); +register __avword iarg6 __asm__("a5"); +register __avword iarg7 __asm__("a6"); +register __avword iarg8 __asm__("a7"); + +register float farg1 __asm__("fa0"); +register float farg2 __asm__("fa1"); +register float farg3 __asm__("fa2"); +register float farg4 __asm__("fa3"); +register float farg5 __asm__("fa4"); +register float farg6 __asm__("fa5"); +register float farg7 __asm__("fa6"); +register float farg8 __asm__("fa7"); + +register double darg1 __asm__("fa0"); +register double darg2 __asm__("fa1"); +register double darg3 __asm__("fa2"); +register double darg4 __asm__("fa3"); +register double darg5 __asm__("fa4"); +register double darg6 __asm__("fa5"); +register double darg7 __asm__("fa6"); +register double darg8 __asm__("fa7"); + +int +avcall_call(av_alist* list) +{ + register __avword iretreg __asm__("a0"); + register __avword iret2reg __asm__("a1"); + register double dret __asm__("fa0"); + + __av_alist* l = &AV_LIST_INNER(list); + + __avword* argframe = __builtin_alloca(__AV_ALIST_WORDS * sizeof(__avword)); /* make room for argument list */ + int arglen = l->aptr - l->args; + unsigned int fanum = l->fanum; + + { + int i; + for (i = 8; i < arglen; i++) /* push function args onto stack */ + argframe[i-8] = l->args[i]; + } + + /* Put up to 8 integer args into registers. */ + if (arglen >= 1) { + iarg1 = l->args[0]; + if (arglen >= 2) { + iarg2 = l->args[1]; + if (arglen >= 3) { + iarg3 = l->args[2]; + if (arglen >= 4) { + iarg4 = l->args[3]; + if (arglen >= 5) { + iarg5 = l->args[4]; + if (arglen >= 6) { + iarg6 = l->args[5]; + if (arglen >= 7) { + iarg7 = l->args[6]; + if (arglen >= 8) { + iarg8 = l->args[7]; + } + } + } + } + } + } + } + } + + /* Put upto 8 floating-point args into registers. */ + if (fanum >= 1) { + if (l->darg_mask & (1 << 0)) darg1 = l->dargs[0]; + else if (l->farg_mask & (1 << 0)) farg1 = l->fargs[0]; + if (fanum >= 2) { + if (l->darg_mask & (1 << 1)) darg2 = l->dargs[1]; + else if (l->farg_mask & (1 << 1)) farg2 = l->fargs[1]; + if (fanum >= 3) { + if (l->darg_mask & (1 << 2)) darg3 = l->dargs[2]; + else if (l->farg_mask & (1 << 2)) farg3 = l->fargs[2]; + if (fanum >= 4) { + if (l->darg_mask & (1 << 3)) darg4 = l->dargs[3]; + else if (l->farg_mask & (1 << 3)) farg4 = l->fargs[3]; + if (fanum >= 5) { + if (l->darg_mask & (1 << 4)) darg5 = l->dargs[4]; + else if (l->farg_mask & (1 << 4)) farg5 = l->fargs[4]; + if (fanum >= 6) { + if (l->darg_mask & (1 << 5)) darg6 = l->dargs[5]; + else if (l->farg_mask & (1 << 5)) farg6 = l->fargs[5]; + if (fanum >= 7) { + if (l->darg_mask & (1 << 6)) darg7 = l->dargs[6]; + else if (l->farg_mask & (1 << 6)) farg7 = l->fargs[6]; + if (fanum >= 8) { + if (l->darg_mask & (1 << 7)) darg8 = l->dargs[7]; + else if (l->farg_mask & (1 << 7)) farg8 = l->fargs[7]; + } + } + } + } + } + } + } + } + + /* Call function. */ + if (l->rtype == __AVfloat) { + *(float*)l->raddr = (*(float(*)())l->func)(); + } else + if (l->rtype == __AVdouble) { + *(double*)l->raddr = (*(double(*)())l->func)(); + } else { + __avword iret, iret2; + + iret = (*l->func)(); + iret2 = iret2reg; + + /* save return value */ + if (l->rtype == __AVvoid) { + } else + if (l->rtype == __AVword) { + RETURN(__avword, iret); + } else + if (l->rtype == __AVchar) { + RETURN(char, iret); + } else + if (l->rtype == __AVschar) { + RETURN(signed char, iret); + } else + if (l->rtype == __AVuchar) { + RETURN(unsigned char, iret); + } else + if (l->rtype == __AVshort) { + RETURN(short, iret); + } else + if (l->rtype == __AVushort) { + RETURN(unsigned short, iret); + } else + if (l->rtype == __AVint) { + RETURN(int, iret); + } else + if (l->rtype == __AVuint) { + RETURN(unsigned int, iret); + } else + if (l->rtype == __AVlong) { + RETURN(long, iret); + } else + if (l->rtype == __AVulong) { + RETURN(unsigned long, iret); + } else + if (l->rtype == __AVlonglong || l->rtype == __AVulonglong) { + void* raddr = l->raddr; + ((__avword*)raddr)[0] = iret; + ((__avword*)raddr)[1] = iret2; + } else + /* see above + if (l->rtype == __AVfloat) { + } else + if (l->rtype == __AVdouble) { + } else + */ + if (l->rtype == __AVvoidp) { + RETURN(void*, iret); + } else + if (l->rtype == __AVstruct) { + if (l->flags & __AV_SMALL_STRUCT_RETURN) { + /* Return structs of size <= 8 in registers. */ + if (l->rsize > 0 && l->rsize <= 8) { + void* raddr = l->raddr; + #if 0 /* Unoptimized */ + if (l->rsize == 1) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + } else + if (l->rsize == 2) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + } else + if (l->rsize == 3) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + } else + if (l->rsize >= 4 && l->rsize <= 8) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + if (l->rsize == 4) { + } else + if (l->rsize == 5) { + ((unsigned char *)raddr)[4+0] = (unsigned char)(iret2); + } else + if (l->rsize == 6) { + ((unsigned char *)raddr)[4+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[4+1] = (unsigned char)(iret2>>8); + } else + if (l->rsize == 7) { + ((unsigned char *)raddr)[4+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[4+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[4+2] = (unsigned char)(iret2>>16); + } else + if (l->rsize == 8) { + ((unsigned char *)raddr)[4+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[4+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[4+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[4+3] = (unsigned char)(iret2>>24); + } + } + #else /* Optimized: fewer conditional jumps, fewer memory accesses */ + uintptr_t count = l->rsize; /* > 0, ≤ 2*sizeof(__avword) */ + __avword* wordaddr = (__avword*)((uintptr_t)raddr & ~(uintptr_t)(sizeof(__avword)-1)); + uintptr_t start_offset = (uintptr_t)raddr & (uintptr_t)(sizeof(__avword)-1); /* ≥ 0, < sizeof(__avword) */ + uintptr_t end_offset = start_offset + count; /* > 0, < 3*sizeof(__avword) */ + if (count <= sizeof(__avword)) { + /* Use iret. */ + if (end_offset <= sizeof(__avword)) { + /* 0 < end_offset ≤ sizeof(__avword) */ + __avword mask0 = ((__avword)2 << (end_offset*8-1)) - ((__avword)1 << (start_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret << (start_offset*8))) & mask0; + } else { + /* sizeof(__avword) < end_offset < 2*sizeof(__avword), start_offset > 0 */ + __avword mask0 = - ((__avword)1 << (start_offset*8)); + __avword mask1 = ((__avword)2 << (end_offset*8-sizeof(__avword)*8-1)) - 1; + wordaddr[0] ^= (wordaddr[0] ^ (iret << (start_offset*8))) & mask0; + wordaddr[1] ^= (wordaddr[1] ^ (iret >> (sizeof(__avword)*8-start_offset*8))) & mask1; + } + } else { + /* Use iret, iret2. */ + __avword mask0 = - ((__avword)1 << (start_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret << (start_offset*8))) & mask0; + if (end_offset <= 2*sizeof(__avword)) { + /* sizeof(__avword) < end_offset ≤ 2*sizeof(__avword) */ + __avword mask1 = ((__avword)2 << (end_offset*8-sizeof(__avword)*8-1)) - 1; + wordaddr[1] ^= (wordaddr[1] ^ ((iret >> (sizeof(__avword)*4-start_offset*4) >> (sizeof(__avword)*4-start_offset*4)) | (iret2 << (start_offset*8)))) & mask1; + } else { + /* 2*sizeof(__avword) < end_offset < 3*sizeof(__avword), start_offset > 0 */ + __avword mask2 = ((__avword)2 << (end_offset*8-2*sizeof(__avword)*8-1)) - 1; + wordaddr[1] = (iret >> (sizeof(__avword)*8-start_offset*8)) | (iret2 << (start_offset*8)); + wordaddr[2] ^= (wordaddr[2] ^ (iret2 >> (sizeof(__avword)*8-start_offset*8))) & mask2; + } + } + #endif + } + } + } + } + return 0; +} diff --git a/avcall/avcall-riscv64-lp64d-linux.s b/avcall/avcall-riscv64-lp64d-linux.s new file mode 100644 index 0000000..bd8cf68 --- /dev/null +++ b/avcall/avcall-riscv64-lp64d-linux.s @@ -0,0 +1,329 @@ + .file "avcall-riscv64.c" + .option pic + .text + .align 1 + .globl avcall_call + .type avcall_call, @function +avcall_call: + add sp,sp,-64 + sd s0,48(sp) + sd s1,40(sp) + sd ra,56(sp) + sd s2,32(sp) + sd s3,24(sp) + sd s4,16(sp) + sd s5,8(sp) + sd s6,0(sp) + add s0,sp,64 + ld t6,48(a0) + ld t3,40(a0) + li t1,-4096 + add t1,t1,2032 + sub t3,t3,t6 + sra t3,t3,3 + sext.w t0,t3 + li t4,8 + mv s1,a0 + add sp,sp,t1 + lw t2,64(a0) + ble t0,t4,.L2 + addw t3,t3,-9 + sll t3,t3,32 + srl t3,t3,29 + mv t1,sp + add t3,t3,8 + add t4,t6,64 + add t3,t1,t3 +.L3: + ld t5,0(t4) + add t1,t1,8 + add t4,t4,8 + sd t5,-8(t1) + bne t3,t1,.L3 +.L4: + li t1,1 + ld a0,0(t6) + beq t0,t1,.L5 + li t1,2 + ld a1,8(t6) + beq t0,t1,.L5 + li t1,3 + ld a2,16(t6) + beq t0,t1,.L5 + li t1,4 + ld a3,24(t6) + beq t0,t1,.L5 + li t1,5 + ld a4,32(t6) + beq t0,t1,.L5 + li t1,6 + ld a5,40(t6) + beq t0,t1,.L5 + li t1,7 + ld a6,48(t6) + beq t0,t1,.L5 + ld a7,56(t6) +.L5: + beqz t2,.L8 + lw t1,72(s1) + and t3,t1,1 + beqz t3,.L9 + fld fa0,112(s1) +.L10: + li t3,1 + bleu t2,t3,.L8 + and t3,t1,2 + bnez t3,.L79 + lw t3,68(s1) + and t3,t3,2 + beqz t3,.L13 + flw fa1,80(s1) +.L13: + li t3,2 + beq t2,t3,.L8 + and t3,t1,4 + beqz t3,.L14 + fld fa2,128(s1) +.L15: + li t3,3 + beq t2,t3,.L8 + and t3,t1,8 + bnez t3,.L80 + lw t3,68(s1) + and t3,t3,8 + beqz t3,.L17 + flw fa3,88(s1) +.L17: + li t3,4 + beq t2,t3,.L8 + and t3,t1,16 + beqz t3,.L18 + fld fa4,144(s1) +.L19: + li t3,5 + beq t2,t3,.L8 + and t3,t1,32 + beqz t3,.L20 + fld fa5,152(s1) +.L21: + li t3,6 + beq t2,t3,.L8 + and t3,t1,64 + beqz t3,.L22 + fld fa6,160(s1) +.L23: + li t3,7 + beq t2,t3,.L8 + and t1,t1,128 + beqz t1,.L24 + fld fa7,168(s1) +.L8: + lw t1,24(s1) + li t3,13 + ld t4,8(s1) + bne t1,t3,.L25 + ld s1,16(s1) + jalr t4 + fsw fa0,0(s1) +.L26: + add sp,s0,-64 + ld ra,56(sp) + li a0,0 + ld s0,48(sp) + ld s1,40(sp) + ld s2,32(sp) + ld s3,24(sp) + ld s4,16(sp) + ld s5,8(sp) + ld s6,0(sp) + add sp,sp,64 + jr ra +.L9: + lw t3,68(s1) + and t3,t3,1 + beqz t3,.L10 + flw fa0,76(s1) + j .L10 +.L25: + li t3,14 + beq t1,t3,.L81 + jalr t4 + lw t1,24(s1) + li t4,1 + mv t3,a0 + beq t1,t4,.L26 + beqz t1,.L77 + li t4,2 + beq t1,t4,.L73 + li t4,3 + beq t1,t4,.L73 + li t4,4 + beq t1,t4,.L73 + li t4,5 + beq t1,t4,.L74 + li t4,6 + beq t1,t4,.L74 + li t4,7 + beq t1,t4,.L75 + li s4,8 + beq t1,s4,.L75 + and t4,t1,-3 + li t6,9 + beq t4,t6,.L77 + addw t4,t1,-10 + and t4,t4,-3 + sext.w t4,t4 + beqz t4,.L77 + li t6,15 + beq t1,t6,.L77 + li t4,16 + bne t1,t4,.L26 + lw t4,0(s1) + and t4,t4,512 + beqz t4,.L26 + ld s6,32(s1) + add t4,s6,-1 + bgtu t4,t6,.L26 + ld t6,16(s1) + li t4,1 + and s1,t6,7 + and t6,t6,-8 + sext.w s3,s1 + ld t0,0(t6) + sll s5,s3,3 + add s1,s6,s1 + sll t2,a0,s5 + sll t4,t4,s5 + xor t2,t2,t0 + sllw s2,s1,3 + bgtu s6,s4,.L39 + bgtu s1,s4,.L40 + addw s2,s2,-1 + li t1,2 + sll t1,t1,s2 + sub t1,t1,t4 + and t1,t1,t2 + xor t1,t1,t0 + sd t1,0(t6) + j .L26 +.L79: + fld fa1,120(s1) + j .L13 +.L81: + ld s1,16(s1) + jalr t4 + fsd fa0,0(s1) + j .L26 +.L2: + blez t0,.L5 + j .L4 +.L14: + lw t3,68(s1) + and t3,t3,4 + beqz t3,.L15 + flw fa2,84(s1) + j .L15 +.L77: + ld t1,16(s1) + sd t3,0(t1) + j .L26 +.L80: + fld fa3,136(s1) + j .L17 +.L73: + ld t1,16(s1) + sb t3,0(t1) + j .L26 +.L18: + lw t3,68(s1) + and t3,t3,16 + beqz t3,.L19 + flw fa4,92(s1) + j .L19 +.L74: + ld t1,16(s1) + sh t3,0(t1) + j .L26 +.L20: + lw t3,68(s1) + and t3,t3,32 + beqz t3,.L21 + flw fa5,96(s1) + j .L21 +.L75: + ld t1,16(s1) + sw t3,0(t1) + j .L26 +.L22: + lw t3,68(s1) + and t3,t3,64 + beqz t3,.L23 + flw fa6,100(s1) + j .L23 +.L24: + lw t1,68(s1) + and t1,t1,128 + beqz t1,.L8 + flw fa7,104(s1) + j .L8 +.L40: + li t1,-8 + mulw t1,t1,s3 + ld s1,8(t6) + addw s2,s2,-65 + li t5,2 + sll t5,t5,s2 + sub t4,zero,t4 + add t5,t5,-1 + and t4,t4,t2 + xor t4,t4,t0 + sd t4,0(t6) + sra t1,a0,t1 + xor t1,t1,s1 + and t1,t1,t5 + xor t1,t1,s1 + sd t1,8(t6) + j .L26 +.L39: + sub t4,zero,t4 + and t4,t4,t2 + xor t4,t4,t0 + sd t4,0(t6) + sll t2,a1,s5 + bleu s1,t1,.L82 + li t1,-8 + mulw t1,t1,s3 + ld s1,16(t6) + addw t4,s2,-129 + li t0,2 + sll t0,t0,t4 + add t0,t0,-1 + addw t1,t1,64 + sra t4,a1,t1 + xor t4,t4,s1 + sra t1,a0,t1 + and t3,t0,t4 + or t1,t1,t2 + xor t3,t3,s1 + sd t1,8(t6) + sd t3,16(t6) + j .L26 +.L82: + li t1,-4 + mulw t1,t1,s3 + addw t4,s2,-65 + li t5,2 + sll t5,t5,t4 + ld t0,8(t6) + add t5,t5,-1 + addw t4,t1,32 + sra t1,a0,t4 + sra t1,t1,t4 + or t1,t1,t2 + xor t1,t1,t0 + and t1,t1,t5 + xor t1,t1,t0 + sd t1,8(t6) + j .L26 + .size avcall_call, .-avcall_call + .ident "GCC: (GNU) 7.3.0" diff --git a/avcall/avcall-riscv64-lp64d-macro.S b/avcall/avcall-riscv64-lp64d-macro.S new file mode 100644 index 0000000..e768f32 --- /dev/null +++ b/avcall/avcall-riscv64-lp64d-macro.S @@ -0,0 +1,331 @@ + .file "avcall-riscv64.c" + .option pic + .text + .align 1 + .globl avcall_call + .type avcall_call, @function +avcall_call: + add sp,sp,-64 + sd s0,48(sp) + sd s1,40(sp) + sd ra,56(sp) + sd s2,32(sp) + sd s3,24(sp) + sd s4,16(sp) + sd s5,8(sp) + sd s6,0(sp) + add s0,sp,64 + ld t6,48(a0) + ld t3,40(a0) + li t1,-4096 + add t1,t1,2032 + sub t3,t3,t6 + sra t3,t3,3 + sext.w t0,t3 + li t4,8 + mv s1,a0 + add sp,sp,t1 + lw t2,64(a0) + ble t0,t4,.L2 + addw t3,t3,-9 + sll t3,t3,32 + srl t3,t3,29 + mv t1,sp + add t3,t3,8 + add t4,t6,64 + add t3,t1,t3 +.L3: + ld t5,0(t4) + add t1,t1,8 + add t4,t4,8 + sd t5,-8(t1) + bne t3,t1,.L3 +.L4: + li t1,1 + ld a0,0(t6) + beq t0,t1,.L5 + li t1,2 + ld a1,8(t6) + beq t0,t1,.L5 + li t1,3 + ld a2,16(t6) + beq t0,t1,.L5 + li t1,4 + ld a3,24(t6) + beq t0,t1,.L5 + li t1,5 + ld a4,32(t6) + beq t0,t1,.L5 + li t1,6 + ld a5,40(t6) + beq t0,t1,.L5 + li t1,7 + ld a6,48(t6) + beq t0,t1,.L5 + ld a7,56(t6) +.L5: + beqz t2,.L8 + lw t1,72(s1) + and t3,t1,1 + beqz t3,.L9 + fld fa0,112(s1) +.L10: + li t3,1 + bleu t2,t3,.L8 + and t3,t1,2 + bnez t3,.L79 + lw t3,68(s1) + and t3,t3,2 + beqz t3,.L13 + flw fa1,80(s1) +.L13: + li t3,2 + beq t2,t3,.L8 + and t3,t1,4 + beqz t3,.L14 + fld fa2,128(s1) +.L15: + li t3,3 + beq t2,t3,.L8 + and t3,t1,8 + bnez t3,.L80 + lw t3,68(s1) + and t3,t3,8 + beqz t3,.L17 + flw fa3,88(s1) +.L17: + li t3,4 + beq t2,t3,.L8 + and t3,t1,16 + beqz t3,.L18 + fld fa4,144(s1) +.L19: + li t3,5 + beq t2,t3,.L8 + and t3,t1,32 + beqz t3,.L20 + fld fa5,152(s1) +.L21: + li t3,6 + beq t2,t3,.L8 + and t3,t1,64 + beqz t3,.L22 + fld fa6,160(s1) +.L23: + li t3,7 + beq t2,t3,.L8 + and t1,t1,128 + beqz t1,.L24 + fld fa7,168(s1) +.L8: + lw t1,24(s1) + li t3,13 + ld t4,8(s1) + bne t1,t3,.L25 + ld s1,16(s1) + jalr t4 + fsw fa0,0(s1) +.L26: + add sp,s0,-64 + ld ra,56(sp) + li a0,0 + ld s0,48(sp) + ld s1,40(sp) + ld s2,32(sp) + ld s3,24(sp) + ld s4,16(sp) + ld s5,8(sp) + ld s6,0(sp) + add sp,sp,64 + jr ra +.L9: + lw t3,68(s1) + and t3,t3,1 + beqz t3,.L10 + flw fa0,76(s1) + j .L10 +.L25: + li t3,14 + beq t1,t3,.L81 + jalr t4 + lw t1,24(s1) + li t4,1 + mv t3,a0 + beq t1,t4,.L26 + beqz t1,.L77 + li t4,2 + beq t1,t4,.L73 + li t4,3 + beq t1,t4,.L73 + li t4,4 + beq t1,t4,.L73 + li t4,5 + beq t1,t4,.L74 + li t4,6 + beq t1,t4,.L74 + li t4,7 + beq t1,t4,.L75 + li s4,8 + beq t1,s4,.L75 + and t4,t1,-3 + li t6,9 + beq t4,t6,.L77 + addw t4,t1,-10 + and t4,t4,-3 + sext.w t4,t4 + beqz t4,.L77 + li t6,15 + beq t1,t6,.L77 + li t4,16 + bne t1,t4,.L26 + lw t4,0(s1) + and t4,t4,512 + beqz t4,.L26 + ld s6,32(s1) + add t4,s6,-1 + bgtu t4,t6,.L26 + ld t6,16(s1) + li t4,1 + and s1,t6,7 + and t6,t6,-8 + sext.w s3,s1 + ld t0,0(t6) + sll s5,s3,3 + add s1,s6,s1 + sll t2,a0,s5 + sll t4,t4,s5 + xor t2,t2,t0 + sllw s2,s1,3 + bgtu s6,s4,.L39 + bgtu s1,s4,.L40 + addw s2,s2,-1 + li t1,2 + sll t1,t1,s2 + sub t1,t1,t4 + and t1,t1,t2 + xor t1,t1,t0 + sd t1,0(t6) + j .L26 +.L79: + fld fa1,120(s1) + j .L13 +.L81: + ld s1,16(s1) + jalr t4 + fsd fa0,0(s1) + j .L26 +.L2: + blez t0,.L5 + j .L4 +.L14: + lw t3,68(s1) + and t3,t3,4 + beqz t3,.L15 + flw fa2,84(s1) + j .L15 +.L77: + ld t1,16(s1) + sd t3,0(t1) + j .L26 +.L80: + fld fa3,136(s1) + j .L17 +.L73: + ld t1,16(s1) + sb t3,0(t1) + j .L26 +.L18: + lw t3,68(s1) + and t3,t3,16 + beqz t3,.L19 + flw fa4,92(s1) + j .L19 +.L74: + ld t1,16(s1) + sh t3,0(t1) + j .L26 +.L20: + lw t3,68(s1) + and t3,t3,32 + beqz t3,.L21 + flw fa5,96(s1) + j .L21 +.L75: + ld t1,16(s1) + sw t3,0(t1) + j .L26 +.L22: + lw t3,68(s1) + and t3,t3,64 + beqz t3,.L23 + flw fa6,100(s1) + j .L23 +.L24: + lw t1,68(s1) + and t1,t1,128 + beqz t1,.L8 + flw fa7,104(s1) + j .L8 +.L40: + li t1,-8 + mulw t1,t1,s3 + ld s1,8(t6) + addw s2,s2,-65 + li t5,2 + sll t5,t5,s2 + sub t4,zero,t4 + add t5,t5,-1 + and t4,t4,t2 + xor t4,t4,t0 + sd t4,0(t6) + sra t1,a0,t1 + xor t1,t1,s1 + and t1,t1,t5 + xor t1,t1,s1 + sd t1,8(t6) + j .L26 +.L39: + sub t4,zero,t4 + and t4,t4,t2 + xor t4,t4,t0 + sd t4,0(t6) + sll t2,a1,s5 + bleu s1,t1,.L82 + li t1,-8 + mulw t1,t1,s3 + ld s1,16(t6) + addw t4,s2,-129 + li t0,2 + sll t0,t0,t4 + add t0,t0,-1 + addw t1,t1,64 + sra t4,a1,t1 + xor t4,t4,s1 + sra t1,a0,t1 + and t3,t0,t4 + or t1,t1,t2 + xor t3,t3,s1 + sd t1,8(t6) + sd t3,16(t6) + j .L26 +.L82: + li t1,-4 + mulw t1,t1,s3 + addw t4,s2,-65 + li t5,2 + sll t5,t5,t4 + ld t0,8(t6) + add t5,t5,-1 + addw t4,t1,32 + sra t1,a0,t4 + sra t1,t1,t4 + or t1,t1,t2 + xor t1,t1,t0 + and t1,t1,t5 + xor t1,t1,t0 + sd t1,8(t6) + j .L26 + .size avcall_call, .-avcall_call +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/avcall/avcall-riscv64.c b/avcall/avcall-riscv64.c new file mode 100644 index 0000000..eb6e115 --- /dev/null +++ b/avcall/avcall-riscv64.c @@ -0,0 +1,343 @@ +/** + Copyright 1993 Bill Triggs + Copyright 1995-2019 Bruno Haible + + 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, see . +**/ +/*---------------------------------------------------------------------- + Foreign function interface for a Linux riscv64 with LP64 ABI. + + This calls a C function with an argument list built up using macros + defined in avcall.h. + + RISC-V Argument Passing Conventions are documented in + https://people.eecs.berkeley.edu/~krste/papers/riscv-spec-v2.1.pdf + chapter 20. + ----------------------------------------------------------------------*/ +#include "avcall-internal.h" + +#define RETURN(TYPE,VAL) (*(TYPE*)l->raddr = (TYPE)(VAL)) + +register __avword iarg1 __asm__("a0"); +register __avword iarg2 __asm__("a1"); +register __avword iarg3 __asm__("a2"); +register __avword iarg4 __asm__("a3"); +register __avword iarg5 __asm__("a4"); +register __avword iarg6 __asm__("a5"); +register __avword iarg7 __asm__("a6"); +register __avword iarg8 __asm__("a7"); + +register float farg1 __asm__("fa0"); +register float farg2 __asm__("fa1"); +register float farg3 __asm__("fa2"); +register float farg4 __asm__("fa3"); +register float farg5 __asm__("fa4"); +register float farg6 __asm__("fa5"); +register float farg7 __asm__("fa6"); +register float farg8 __asm__("fa7"); + +register double darg1 __asm__("fa0"); +register double darg2 __asm__("fa1"); +register double darg3 __asm__("fa2"); +register double darg4 __asm__("fa3"); +register double darg5 __asm__("fa4"); +register double darg6 __asm__("fa5"); +register double darg7 __asm__("fa6"); +register double darg8 __asm__("fa7"); + +int +avcall_call(av_alist* list) +{ + register __avword iretreg __asm__("a0"); + register __avword iret2reg __asm__("a1"); + register double dret __asm__("fa0"); + + __av_alist* l = &AV_LIST_INNER(list); + + __avword* argframe = __builtin_alloca(__AV_ALIST_WORDS * sizeof(__avword)); /* make room for argument list */ + int arglen = l->aptr - l->args; + unsigned int fanum = l->fanum; + + { + int i; + for (i = 8; i < arglen; i++) /* push function args onto stack */ + argframe[i-8] = l->args[i]; + } + + /* Put up to 8 integer args into registers. */ + if (arglen >= 1) { + iarg1 = l->args[0]; + if (arglen >= 2) { + iarg2 = l->args[1]; + if (arglen >= 3) { + iarg3 = l->args[2]; + if (arglen >= 4) { + iarg4 = l->args[3]; + if (arglen >= 5) { + iarg5 = l->args[4]; + if (arglen >= 6) { + iarg6 = l->args[5]; + if (arglen >= 7) { + iarg7 = l->args[6]; + if (arglen >= 8) { + iarg8 = l->args[7]; + } + } + } + } + } + } + } + } + + /* Put upto 8 floating-point args into registers. */ + if (fanum >= 1) { + if (l->darg_mask & (1 << 0)) darg1 = l->dargs[0]; + else if (l->farg_mask & (1 << 0)) farg1 = l->fargs[0]; + if (fanum >= 2) { + if (l->darg_mask & (1 << 1)) darg2 = l->dargs[1]; + else if (l->farg_mask & (1 << 1)) farg2 = l->fargs[1]; + if (fanum >= 3) { + if (l->darg_mask & (1 << 2)) darg3 = l->dargs[2]; + else if (l->farg_mask & (1 << 2)) farg3 = l->fargs[2]; + if (fanum >= 4) { + if (l->darg_mask & (1 << 3)) darg4 = l->dargs[3]; + else if (l->farg_mask & (1 << 3)) farg4 = l->fargs[3]; + if (fanum >= 5) { + if (l->darg_mask & (1 << 4)) darg5 = l->dargs[4]; + else if (l->farg_mask & (1 << 4)) farg5 = l->fargs[4]; + if (fanum >= 6) { + if (l->darg_mask & (1 << 5)) darg6 = l->dargs[5]; + else if (l->farg_mask & (1 << 5)) farg6 = l->fargs[5]; + if (fanum >= 7) { + if (l->darg_mask & (1 << 6)) darg7 = l->dargs[6]; + else if (l->farg_mask & (1 << 6)) farg7 = l->fargs[6]; + if (fanum >= 8) { + if (l->darg_mask & (1 << 7)) darg8 = l->dargs[7]; + else if (l->farg_mask & (1 << 7)) farg8 = l->fargs[7]; + } + } + } + } + } + } + } + } + + /* Call function. */ + if (l->rtype == __AVfloat) { + *(float*)l->raddr = (*(float(*)())l->func)(); + } else + if (l->rtype == __AVdouble) { + *(double*)l->raddr = (*(double(*)())l->func)(); + } else { + __avword iret, iret2; + + iret = (*l->func)(); + iret2 = iret2reg; + + /* save return value */ + if (l->rtype == __AVvoid) { + } else + if (l->rtype == __AVword) { + RETURN(__avword, iret); + } else + if (l->rtype == __AVchar) { + RETURN(char, iret); + } else + if (l->rtype == __AVschar) { + RETURN(signed char, iret); + } else + if (l->rtype == __AVuchar) { + RETURN(unsigned char, iret); + } else + if (l->rtype == __AVshort) { + RETURN(short, iret); + } else + if (l->rtype == __AVushort) { + RETURN(unsigned short, iret); + } else + if (l->rtype == __AVint) { + RETURN(int, iret); + } else + if (l->rtype == __AVuint) { + RETURN(unsigned int, iret); + } else + if (l->rtype == __AVlong || l->rtype == __AVlonglong) { + RETURN(long, iret); + } else + if (l->rtype == __AVulong || l->rtype == __AVulonglong) { + RETURN(unsigned long, iret); + } else + /* see above + if (l->rtype == __AVfloat) { + } else + if (l->rtype == __AVdouble) { + } else + */ + if (l->rtype == __AVvoidp) { + RETURN(void*, iret); + } else + if (l->rtype == __AVstruct) { + if (l->flags & __AV_REGISTER_STRUCT_RETURN) { + /* Return structs of size <= 16 in registers. */ + if (l->rsize > 0 && l->rsize <= 16) { + void* raddr = l->raddr; + #if 0 /* Unoptimized */ + if (l->rsize == 1) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + } else + if (l->rsize == 2) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + } else + if (l->rsize == 3) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + } else + if (l->rsize == 4) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + } else + if (l->rsize == 5) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>32); + } else + if (l->rsize == 6) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>40); + } else + if (l->rsize == 7) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[6] = (unsigned char)(iret>>48); + } else + if (l->rsize >= 8 && l->rsize <= 16) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[6] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[7] = (unsigned char)(iret>>56); + if (l->rsize == 8) { + } else + if (l->rsize == 9) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + } else + if (l->rsize == 10) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + } else + if (l->rsize == 11) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + } else + if (l->rsize == 12) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + } else + if (l->rsize == 13) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>32); + } else + if (l->rsize == 14) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>40); + } else + if (l->rsize == 15) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+6] = (unsigned char)(iret2>>48); + } else + if (l->rsize == 16) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+6] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+7] = (unsigned char)(iret2>>56); + } + } + #else /* Optimized: fewer conditional jumps, fewer memory accesses */ + uintptr_t count = l->rsize; /* > 0, ≤ 2*sizeof(__avword) */ + __avword* wordaddr = (__avword*)((uintptr_t)raddr & ~(uintptr_t)(sizeof(__avword)-1)); + uintptr_t start_offset = (uintptr_t)raddr & (uintptr_t)(sizeof(__avword)-1); /* ≥ 0, < sizeof(__avword) */ + uintptr_t end_offset = start_offset + count; /* > 0, < 3*sizeof(__avword) */ + if (count <= sizeof(__avword)) { + /* Use iret. */ + if (end_offset <= sizeof(__avword)) { + /* 0 < end_offset ≤ sizeof(__avword) */ + __avword mask0 = ((__avword)2 << (end_offset*8-1)) - ((__avword)1 << (start_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret << (start_offset*8))) & mask0; + } else { + /* sizeof(__avword) < end_offset < 2*sizeof(__avword), start_offset > 0 */ + __avword mask0 = - ((__avword)1 << (start_offset*8)); + __avword mask1 = ((__avword)2 << (end_offset*8-sizeof(__avword)*8-1)) - 1; + wordaddr[0] ^= (wordaddr[0] ^ (iret << (start_offset*8))) & mask0; + wordaddr[1] ^= (wordaddr[1] ^ (iret >> (sizeof(__avword)*8-start_offset*8))) & mask1; + } + } else { + /* Use iret, iret2. */ + __avword mask0 = - ((__avword)1 << (start_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret << (start_offset*8))) & mask0; + if (end_offset <= 2*sizeof(__avword)) { + /* sizeof(__avword) < end_offset ≤ 2*sizeof(__avword) */ + __avword mask1 = ((__avword)2 << (end_offset*8-sizeof(__avword)*8-1)) - 1; + wordaddr[1] ^= (wordaddr[1] ^ ((iret >> (sizeof(__avword)*4-start_offset*4) >> (sizeof(__avword)*4-start_offset*4)) | (iret2 << (start_offset*8)))) & mask1; + } else { + /* 2*sizeof(__avword) < end_offset < 3*sizeof(__avword), start_offset > 0 */ + __avword mask2 = ((__avword)2 << (end_offset*8-2*sizeof(__avword)*8-1)) - 1; + wordaddr[1] = (iret >> (sizeof(__avword)*8-start_offset*8)) | (iret2 << (start_offset*8)); + wordaddr[2] ^= (wordaddr[2] ^ (iret2 >> (sizeof(__avword)*8-start_offset*8))) & mask2; + } + } + #endif + } + } + } + } + return 0; +} diff --git a/avcall/avcall-s390-linux.s b/avcall/avcall-s390-linux.s new file mode 100644 index 0000000..7680874 --- /dev/null +++ b/avcall/avcall-s390-linux.s @@ -0,0 +1,148 @@ + .file "avcall-s390.c" +.text + .align 4 +.globl avcall_call + .type avcall_call,@function +avcall_call: + stm %r6,%r15,24(%r15) + bras %r13,.LTN0_0 +.LT0_0: +.LC0: + .long 1 +.LTN0_0: + lr %r14,%r15 + ahi %r15,-96 + lr %r10,%r2 + lr %r11,%r15 + lhi %r2,0 + st %r14,0(%r15) + l %r1,0(%r15) + ahi %r15,-1032 + l %r3,20(%r10) + l %r4,24(%r10) + sr %r3,%r4 + sra %r3,2 + la %r5,96(%r15) + st %r1,0(%r15) + cr %r2,%r3 + l %r0,64(%r10) + jhe .L55 +.L6: + lr %r1,%r2 + sll %r1,2 + ahi %r2,1 + cr %r2,%r3 + l %r9,0(%r1,%r4) + st %r9,0(%r1,%r5) + jl .L6 +.L55: + ltr %r0,%r0 + je .L7 + l %r1,72(%r10) + tml %r1,1 + je .L8 + ld %f0,88(%r10) +.L9: + cl %r0,.LC0-.LT0_0(%r13) + jle .L7 + tml %r1,2 + je .L12 + ld %f2,96(%r10) +.L7: + l %r1,4(%r10) + l %r4,52(%r10) + l %r2,44(%r10) + l %r3,48(%r10) + l %r5,56(%r10) + l %r6,60(%r10) + basr %r14,%r1 + l %r4,12(%r10) + chi %r4,1 + je .L16 + ltr %r4,%r4 + je .L65 + chi %r4,2 + je .L58 + chi %r4,3 + je .L58 + chi %r4,4 + je .L58 + chi %r4,5 + je .L57 + chi %r4,6 + je .L57 + chi %r4,7 + je .L65 + chi %r4,8 + je .L65 + chi %r4,9 + je .L65 + chi %r4,10 + je .L65 + lr %r1,%r4 + ahi %r1,-11 + cl %r1,.LC0-.LT0_0(%r13) + jle .L64 + chi %r4,13 + je .L66 + chi %r4,14 + je .L67 + chi %r4,15 + je .L65 + chi %r4,16 + je .L68 +.L16: + lhi %r2,0 + l %r4,152(%r11) + lm %r6,%r15,120(%r11) + br %r4 +.L68: + tm 2(%r10),2 + je .L16 + l %r1,16(%r10) + chi %r1,1 + je .L58 + chi %r1,2 + je .L57 + chi %r1,4 + je .L65 + chi %r1,8 + jne .L16 +.L64: + l %r1,8(%r10) + st %r3,4(%r1) +.L56: + st %r2,0(%r1) + j .L16 +.L65: + l %r1,8(%r10) + j .L56 +.L57: + l %r1,8(%r10) + sth %r2,0(%r1) + j .L16 +.L58: + l %r1,8(%r10) + stc %r2,0(%r1) + j .L16 +.L67: + l %r1,8(%r10) + std %f0,0(%r1) + j .L16 +.L66: + l %r1,8(%r10) + ste %f0,0(%r1) + j .L16 +.L12: + tm 71(%r10),2 + je .L7 + le %f2,80(%r10) + j .L7 +.L8: + tm 71(%r10),1 + je .L9 + le %f0,76(%r10) + j .L9 +.Lfe1: + .size avcall_call,.Lfe1-avcall_call + .ident "GCC: (GNU) 3.1" diff --git a/avcall/avcall-s390-macro.S b/avcall/avcall-s390-macro.S new file mode 100644 index 0000000..267b4c3 --- /dev/null +++ b/avcall/avcall-s390-macro.S @@ -0,0 +1,150 @@ + .file "avcall-s390.c" +.text + .align 4 +.globl avcall_call + .type avcall_call,@function +avcall_call: + stm %r6,%r15,24(%r15) + bras %r13,.LTN0_0 +.LT0_0: +.LC0: + .long 1 +.LTN0_0: + lr %r14,%r15 + ahi %r15,-96 + lr %r10,%r2 + lr %r11,%r15 + lhi %r2,0 + st %r14,0(%r15) + l %r1,0(%r15) + ahi %r15,-1032 + l %r3,20(%r10) + l %r4,24(%r10) + sr %r3,%r4 + sra %r3,2 + la %r5,96(%r15) + st %r1,0(%r15) + cr %r2,%r3 + l %r0,64(%r10) + jhe .L55 +.L6: + lr %r1,%r2 + sll %r1,2 + ahi %r2,1 + cr %r2,%r3 + l %r9,0(%r1,%r4) + st %r9,0(%r1,%r5) + jl .L6 +.L55: + ltr %r0,%r0 + je .L7 + l %r1,72(%r10) + tml %r1,1 + je .L8 + ld %f0,88(%r10) +.L9: + cl %r0,.LC0-.LT0_0(%r13) + jle .L7 + tml %r1,2 + je .L12 + ld %f2,96(%r10) +.L7: + l %r1,4(%r10) + l %r4,52(%r10) + l %r2,44(%r10) + l %r3,48(%r10) + l %r5,56(%r10) + l %r6,60(%r10) + basr %r14,%r1 + l %r4,12(%r10) + chi %r4,1 + je .L16 + ltr %r4,%r4 + je .L65 + chi %r4,2 + je .L58 + chi %r4,3 + je .L58 + chi %r4,4 + je .L58 + chi %r4,5 + je .L57 + chi %r4,6 + je .L57 + chi %r4,7 + je .L65 + chi %r4,8 + je .L65 + chi %r4,9 + je .L65 + chi %r4,10 + je .L65 + lr %r1,%r4 + ahi %r1,-11 + cl %r1,.LC0-.LT0_0(%r13) + jle .L64 + chi %r4,13 + je .L66 + chi %r4,14 + je .L67 + chi %r4,15 + je .L65 + chi %r4,16 + je .L68 +.L16: + lhi %r2,0 + l %r4,152(%r11) + lm %r6,%r15,120(%r11) + br %r4 +.L68: + tm 2(%r10),2 + je .L16 + l %r1,16(%r10) + chi %r1,1 + je .L58 + chi %r1,2 + je .L57 + chi %r1,4 + je .L65 + chi %r1,8 + jne .L16 +.L64: + l %r1,8(%r10) + st %r3,4(%r1) +.L56: + st %r2,0(%r1) + j .L16 +.L65: + l %r1,8(%r10) + j .L56 +.L57: + l %r1,8(%r10) + sth %r2,0(%r1) + j .L16 +.L58: + l %r1,8(%r10) + stc %r2,0(%r1) + j .L16 +.L67: + l %r1,8(%r10) + std %f0,0(%r1) + j .L16 +.L66: + l %r1,8(%r10) + ste %f0,0(%r1) + j .L16 +.L12: + tm 71(%r10),2 + je .L7 + le %f2,80(%r10) + j .L7 +.L8: + tm 71(%r10),1 + je .L9 + le %f0,76(%r10) + j .L9 +.Lfe1: + .size avcall_call,.Lfe1-avcall_call +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/avcall/avcall-s390.c b/avcall/avcall-s390.c new file mode 100644 index 0000000..d2cb117 --- /dev/null +++ b/avcall/avcall-s390.c @@ -0,0 +1,146 @@ +/** + Copyright 1993 Bill Triggs + Copyright 1995-2017 Bruno Haible + Copyright 2001 Gerhard Tonn + + 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, see . +**/ +/*---------------------------------------------------------------------- + + Foreign function interface for an IBM S/390 with gcc + + This calls a C function with an argument list built up using macros + defined in avcall.h. + + S390 Argument Passing Conventions: + + All arguments, except the first 5 words, are passed on the stack with + word alignment. Doubles take two words. The first 2 doubles and floats + are also passed in floating-point-registers. + To return a structure, the called function copies the value to space + pointed to by its first argument, and all other arguments are shifted + down by one. + + Compile this routine with gcc -O2 to get the right register variables. + For other compilers use the pre-compiled assembler version. + ----------------------------------------------------------------------*/ +#include "avcall-internal.h" + +#define RETURN(TYPE,VAL) (*(TYPE*)l->raddr = (TYPE)(VAL)) + +register float farg1 __asm__("f0"); +register float farg2 __asm__("f2"); +register double darg1 __asm__("f0"); +register double darg2 __asm__("f2"); + +int +avcall_call(av_alist* list) +{ + register __avword* sp __asm__("r15"); /* C names for registers */ +/*register __avword iret __asm__("r2"); */ + register __avword iret2 __asm__("r3"); + register float fret __asm__("f0"); + register double dret __asm__("f0"); + + __av_alist* l = &AV_LIST_INNER(list); + + __avword* argframe = __builtin_alloca(__AV_ALIST_WORDS * sizeof(__avword)); /* make room for argument list */ + int arglen = l->aptr - l->args; + unsigned int fanum = l->fanum; + __avword i; + + for (i = 0; i < arglen; i++) /* push function args onto stack */ + argframe[i] = l->args[i]; + + /* Put upto 2 floating-point args into registers. */ + if (fanum >= 1) { + if (l->darg_mask & (1 << 0)) darg1 = l->dargs[0]; + else if (l->farg_mask & (1 << 0)) farg1 = l->fargs[0]; + if (fanum >= 2) { + if (l->darg_mask & (1 << 1)) darg2 = l->dargs[1]; + else if (l->farg_mask & (1 << 1)) farg2 = l->fargs[1]; + } + } + + /* call function, pass 5 args in registers */ + i = (*l->func)(l->iargs[0], l->iargs[1], l->iargs[2], l->iargs[3], + l->iargs[4]); + + /* save return value */ + if (l->rtype == __AVvoid) { + } else + if (l->rtype == __AVword) { + RETURN(__avword, i); + } else + if (l->rtype == __AVchar) { + RETURN(char, i); + } else + if (l->rtype == __AVschar) { + RETURN(signed char, i); + } else + if (l->rtype == __AVuchar) { + RETURN(unsigned char, i); + } else + if (l->rtype == __AVshort) { + RETURN(short, i); + } else + if (l->rtype == __AVushort) { + RETURN(unsigned short, i); + } else + if (l->rtype == __AVint) { + RETURN(int, i); + } else + if (l->rtype == __AVuint) { + RETURN(unsigned int, i); + } else + if (l->rtype == __AVlong) { + RETURN(long, i); + } else + if (l->rtype == __AVulong) { + RETURN(unsigned long, i); + } else + if (l->rtype == __AVlonglong || l->rtype == __AVulonglong) { + void* raddr = l->raddr; + ((__avword*)raddr)[0] = i; + ((__avword*)raddr)[1] = iret2; + } else + if (l->rtype == __AVfloat) { + RETURN(float, fret); + } else + if (l->rtype == __AVdouble) { + RETURN(double, dret); + } else + if (l->rtype == __AVvoidp) { + RETURN(void*, i); + } else + if (l->rtype == __AVstruct) { + if (l->flags & __AV_REGISTER_STRUCT_RETURN) { + if (l->rsize == sizeof(char)) { + RETURN(char, i); + } else + if (l->rsize == sizeof(short)) { + RETURN(short, i); + } else + if (l->rsize == sizeof(int)) { + RETURN(int, i); + } else + if (l->rsize == 2*sizeof(__avword)) { + void* raddr = l->raddr; + ((__avword*)raddr)[0] = i; + ((__avword*)raddr)[1] = iret2; + } + } + } + return 0; +} diff --git a/avcall/avcall-s390x-linux.s b/avcall/avcall-s390x-linux.s new file mode 100644 index 0000000..a76a9a0 --- /dev/null +++ b/avcall/avcall-s390x-linux.s @@ -0,0 +1,269 @@ + .file "avcall-s390x.c" +.text + .align 8 +.globl avcall_call + .type avcall_call, @function +avcall_call: +.LFB0: + .cfi_startproc + stmg %r7,%r15,56(%r15) + .cfi_offset 7, -104 + .cfi_offset 8, -96 + .cfi_offset 9, -88 + .cfi_offset 10, -80 + .cfi_offset 11, -72 + .cfi_offset 12, -64 + .cfi_offset 13, -56 + .cfi_offset 14, -48 + .cfi_offset 15, -40 + larl %r13,.L78 + aghi %r15,-176 + .cfi_def_cfa_offset 336 + lgr %r11,%r15 + .cfi_def_cfa_register 11 + aghi %r15,-2056 + lg %r9,48(%r2) + lg %r1,40(%r2) + sgr %r1,%r9 + srag %r1,%r1,3 + stg %r2,168(%r11) + stg %r6,160(%r11) + ltr %r1,%r1 + la %r8,160(%r15) + l %r0,64(%r2) + l %r7,112(%r2) + jle .L6 + ahi %r1,-1 + llgfr %r1,%r1 + aghi %r1,1 + lghi %r14,0 +.L5: + lg %r10,0(%r14,%r9) + stg %r10,0(%r14,%r8) + aghi %r14,8 + brctg %r1,.L5 +.L6: + ltr %r0,%r0 + je .L7 + lg %r1,168(%r11) + cl %r0,.L79-.L78(%r13) + lg %r2,72(%r1) + jle .L7 + chi %r0,2 + lg %r3,80(%r1) + je .L7 + chi %r0,3 + lg %r4,88(%r1) + je .L7 + chi %r0,4 + lg %r5,96(%r1) + jne .L73 +.L7: + ltr %r7,%r7 + je .L9 + lg %r10,168(%r11) + l %r1,120(%r10) + tmll %r1,1 + je .L10 + ld %f0,144(%r10) +.L11: + cl %r7,.L79-.L78(%r13) + jle .L9 + tmll %r1,2 + lg %r10,168(%r11) + jne .L74 + tm 119(%r10),2 + je .L14 + le %f2,128(%r10) +.L14: + chi %r7,2 + je .L9 + tmll %r1,4 + lg %r10,168(%r11) + je .L15 + ld %f4,160(%r10) +.L16: + chi %r7,3 + je .L9 + tmll %r1,8 + lg %r1,168(%r11) + jne .L75 + tm 119(%r1),8 + je .L9 + le %f6,136(%r1) +.L9: + lg %r1,168(%r11) + l %r1,24(%r1) + chi %r1,13 + je .L76 + chi %r1,14 + je .L77 + lg %r10,168(%r11) + lg %r1,8(%r10) + basr %r14,%r1 + l %r1,24(%r10) + chi %r1,1 + lgr %r0,%r2 + je .L19 + ltr %r1,%r1 + je .L67 + chi %r1,2 + je .L69 + chi %r1,3 + je .L69 + chi %r1,4 + je .L69 + chi %r1,5 + je .L71 + chi %r1,6 + je .L71 + chi %r1,7 + je .L70 + chi %r1,8 + je .L70 + lr %r9,%r1 + nill %r9,65533 + chi %r9,9 + je .L67 + chi %r1,10 + je .L67 + chi %r1,12 + je .L67 + chi %r1,15 + je .L67 +.L19: + lg %r4,288(%r11) + lg %r6,160(%r11) + lghi %r2,0 + lmg %r7,%r15,232(%r11) + .cfi_remember_state + .cfi_restore 15 + .cfi_restore 14 + .cfi_restore 13 + .cfi_restore 12 + .cfi_restore 11 + .cfi_restore 10 + .cfi_restore 9 + .cfi_restore 8 + .cfi_restore 7 + .cfi_def_cfa 15, 160 + br %r4 +.L10: + .cfi_restore_state + lg %r10,168(%r11) + tm 119(%r10),1 + je .L11 + le %f0,124(%r10) + j .L11 +.L67: + lg %r1,168(%r11) + lghi %r2,0 + lg %r1,16(%r1) + stg %r0,0(%r1) + lg %r4,288(%r11) + lg %r6,160(%r11) + lmg %r7,%r15,232(%r11) + .cfi_remember_state + .cfi_restore 7 + .cfi_restore 8 + .cfi_restore 9 + .cfi_restore 10 + .cfi_restore 11 + .cfi_restore 12 + .cfi_restore 13 + .cfi_restore 14 + .cfi_restore 15 + .cfi_def_cfa 15, 160 + br %r4 +.L74: + .cfi_restore_state + ld %f2,152(%r10) + j .L14 +.L69: + lg %r1,168(%r11) + lghi %r2,0 + lg %r1,16(%r1) + stc %r0,0(%r1) + lg %r4,288(%r11) + lg %r6,160(%r11) + lmg %r7,%r15,232(%r11) + .cfi_remember_state + .cfi_restore 7 + .cfi_restore 8 + .cfi_restore 9 + .cfi_restore 10 + .cfi_restore 11 + .cfi_restore 12 + .cfi_restore 13 + .cfi_restore 14 + .cfi_restore 15 + .cfi_def_cfa 15, 160 + br %r4 +.L77: + .cfi_restore_state + lg %r0,168(%r11) + lgr %r1,%r0 + lgr %r10,%r0 + lg %r1,8(%r1) + lg %r10,16(%r10) + basr %r14,%r1 + lg %r4,288(%r11) + std %f0,0(%r10) + lg %r6,160(%r11) + lghi %r2,0 + lmg %r7,%r15,232(%r11) + .cfi_remember_state + .cfi_restore 7 + .cfi_restore 8 + .cfi_restore 9 + .cfi_restore 10 + .cfi_restore 11 + .cfi_restore 12 + .cfi_restore 13 + .cfi_restore 14 + .cfi_restore 15 + .cfi_def_cfa 15, 160 + br %r4 +.L76: + .cfi_restore_state + lg %r0,168(%r11) + lgr %r1,%r0 + lgr %r10,%r0 + lg %r1,8(%r1) + lg %r10,16(%r10) + basr %r14,%r1 + ste %f0,0(%r10) + j .L19 +.L15: + tm 119(%r10),4 + je .L16 + le %f4,132(%r10) + j .L16 +.L71: + lg %r1,168(%r11) + lg %r1,16(%r1) + sth %r0,0(%r1) + j .L19 +.L73: + lg %r6,104(%r1) + j .L7 +.L75: + ld %f6,168(%r1) + j .L9 +.L70: + lg %r1,168(%r11) + lg %r1,16(%r1) + st %r0,0(%r1) + j .L19 + .section .rodata + .align 8 +.L78: +.L79: + .long 1 + .align 2 + .previous + .cfi_endproc +.LFE0: + .size avcall_call, .-avcall_call + .ident "GCC: (GNU) 5.4.0" + .section .note.GNU-stack,"",@progbits diff --git a/avcall/avcall-s390x-macro.S b/avcall/avcall-s390x-macro.S new file mode 100644 index 0000000..6fafcc3 --- /dev/null +++ b/avcall/avcall-s390x-macro.S @@ -0,0 +1,270 @@ + .file "avcall-s390x.c" +.text + .align 8 +.globl avcall_call + .type avcall_call, @function +avcall_call: +.LFB0: + .cfi_startproc + stmg %r7,%r15,56(%r15) + .cfi_offset 7, -104 + .cfi_offset 8, -96 + .cfi_offset 9, -88 + .cfi_offset 10, -80 + .cfi_offset 11, -72 + .cfi_offset 12, -64 + .cfi_offset 13, -56 + .cfi_offset 14, -48 + .cfi_offset 15, -40 + larl %r13,.L78 + aghi %r15,-176 + .cfi_def_cfa_offset 336 + lgr %r11,%r15 + .cfi_def_cfa_register 11 + aghi %r15,-2056 + lg %r9,48(%r2) + lg %r1,40(%r2) + sgr %r1,%r9 + srag %r1,%r1,3 + stg %r2,168(%r11) + stg %r6,160(%r11) + ltr %r1,%r1 + la %r8,160(%r15) + l %r0,64(%r2) + l %r7,112(%r2) + jle .L6 + ahi %r1,-1 + llgfr %r1,%r1 + aghi %r1,1 + lghi %r14,0 +.L5: + lg %r10,0(%r14,%r9) + stg %r10,0(%r14,%r8) + aghi %r14,8 + brctg %r1,.L5 +.L6: + ltr %r0,%r0 + je .L7 + lg %r1,168(%r11) + cl %r0,.L79-.L78(%r13) + lg %r2,72(%r1) + jle .L7 + chi %r0,2 + lg %r3,80(%r1) + je .L7 + chi %r0,3 + lg %r4,88(%r1) + je .L7 + chi %r0,4 + lg %r5,96(%r1) + jne .L73 +.L7: + ltr %r7,%r7 + je .L9 + lg %r10,168(%r11) + l %r1,120(%r10) + tmll %r1,1 + je .L10 + ld %f0,144(%r10) +.L11: + cl %r7,.L79-.L78(%r13) + jle .L9 + tmll %r1,2 + lg %r10,168(%r11) + jne .L74 + tm 119(%r10),2 + je .L14 + le %f2,128(%r10) +.L14: + chi %r7,2 + je .L9 + tmll %r1,4 + lg %r10,168(%r11) + je .L15 + ld %f4,160(%r10) +.L16: + chi %r7,3 + je .L9 + tmll %r1,8 + lg %r1,168(%r11) + jne .L75 + tm 119(%r1),8 + je .L9 + le %f6,136(%r1) +.L9: + lg %r1,168(%r11) + l %r1,24(%r1) + chi %r1,13 + je .L76 + chi %r1,14 + je .L77 + lg %r10,168(%r11) + lg %r1,8(%r10) + basr %r14,%r1 + l %r1,24(%r10) + chi %r1,1 + lgr %r0,%r2 + je .L19 + ltr %r1,%r1 + je .L67 + chi %r1,2 + je .L69 + chi %r1,3 + je .L69 + chi %r1,4 + je .L69 + chi %r1,5 + je .L71 + chi %r1,6 + je .L71 + chi %r1,7 + je .L70 + chi %r1,8 + je .L70 + lr %r9,%r1 + nill %r9,65533 + chi %r9,9 + je .L67 + chi %r1,10 + je .L67 + chi %r1,12 + je .L67 + chi %r1,15 + je .L67 +.L19: + lg %r4,288(%r11) + lg %r6,160(%r11) + lghi %r2,0 + lmg %r7,%r15,232(%r11) + .cfi_remember_state + .cfi_restore 15 + .cfi_restore 14 + .cfi_restore 13 + .cfi_restore 12 + .cfi_restore 11 + .cfi_restore 10 + .cfi_restore 9 + .cfi_restore 8 + .cfi_restore 7 + .cfi_def_cfa 15, 160 + br %r4 +.L10: + .cfi_restore_state + lg %r10,168(%r11) + tm 119(%r10),1 + je .L11 + le %f0,124(%r10) + j .L11 +.L67: + lg %r1,168(%r11) + lghi %r2,0 + lg %r1,16(%r1) + stg %r0,0(%r1) + lg %r4,288(%r11) + lg %r6,160(%r11) + lmg %r7,%r15,232(%r11) + .cfi_remember_state + .cfi_restore 7 + .cfi_restore 8 + .cfi_restore 9 + .cfi_restore 10 + .cfi_restore 11 + .cfi_restore 12 + .cfi_restore 13 + .cfi_restore 14 + .cfi_restore 15 + .cfi_def_cfa 15, 160 + br %r4 +.L74: + .cfi_restore_state + ld %f2,152(%r10) + j .L14 +.L69: + lg %r1,168(%r11) + lghi %r2,0 + lg %r1,16(%r1) + stc %r0,0(%r1) + lg %r4,288(%r11) + lg %r6,160(%r11) + lmg %r7,%r15,232(%r11) + .cfi_remember_state + .cfi_restore 7 + .cfi_restore 8 + .cfi_restore 9 + .cfi_restore 10 + .cfi_restore 11 + .cfi_restore 12 + .cfi_restore 13 + .cfi_restore 14 + .cfi_restore 15 + .cfi_def_cfa 15, 160 + br %r4 +.L77: + .cfi_restore_state + lg %r0,168(%r11) + lgr %r1,%r0 + lgr %r10,%r0 + lg %r1,8(%r1) + lg %r10,16(%r10) + basr %r14,%r1 + lg %r4,288(%r11) + std %f0,0(%r10) + lg %r6,160(%r11) + lghi %r2,0 + lmg %r7,%r15,232(%r11) + .cfi_remember_state + .cfi_restore 7 + .cfi_restore 8 + .cfi_restore 9 + .cfi_restore 10 + .cfi_restore 11 + .cfi_restore 12 + .cfi_restore 13 + .cfi_restore 14 + .cfi_restore 15 + .cfi_def_cfa 15, 160 + br %r4 +.L76: + .cfi_restore_state + lg %r0,168(%r11) + lgr %r1,%r0 + lgr %r10,%r0 + lg %r1,8(%r1) + lg %r10,16(%r10) + basr %r14,%r1 + ste %f0,0(%r10) + j .L19 +.L15: + tm 119(%r10),4 + je .L16 + le %f4,132(%r10) + j .L16 +.L71: + lg %r1,168(%r11) + lg %r1,16(%r1) + sth %r0,0(%r1) + j .L19 +.L73: + lg %r6,104(%r1) + j .L7 +.L75: + ld %f6,168(%r1) + j .L9 +.L70: + lg %r1,168(%r11) + lg %r1,16(%r1) + st %r0,0(%r1) + j .L19 + .section .rodata + .align 8 +.L78: +.L79: + .long 1 + .align 2 + .previous + .cfi_endproc +.LFE0: + .size avcall_call, .-avcall_call +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/avcall/avcall-s390x.c b/avcall/avcall-s390x.c new file mode 100644 index 0000000..06f488a --- /dev/null +++ b/avcall/avcall-s390x.c @@ -0,0 +1,193 @@ +/** + Copyright 1993 Bill Triggs + Copyright 1995-2018 Bruno Haible + + 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, see . +**/ +/*---------------------------------------------------------------------- + !!! THIS ROUTINE MUST BE COMPILED gcc -O -fno-omit-frame-pointer !!! + + Foreign function interface for an s390x 64-bit CPU. + + This calls a C function with an argument list built up using macros + defined in avcall.h. + + s390x 64-bit Argument Passing Conventions + + * Arguments: + - The first 5 integer or pointer arguments get passed in + r2, r3, r4, r5, r6; the remaining ones (as an entire word each) + on the stack. + - The first 4 float or double arguments get passed in + f0, f2, f4, f6; the remaining ones on the stack (as an entire + word each, floats in the upper half of a word). + - Structures of sizes 1, 2, 4, 8 are passed as follows: + - Structures consisting only of a float or double are passed + like an immediate float or double, that is, in f0, f2, f4, f6 + and on the stack (floats in the upper half of their respective + word). But we don't support this kind of structure. + - Other structures get passed as an entire word, like integers + and pointers. + When in r2, ..., r6: as the 8*sizeof(S) low bits of the register + (a.k.a. "right-adjusted"). + When on the stack: they occupy an entire word and are adjusted + on the high end of the word: + - sizeof(S) == 1: at an address == 7 mod 8, + - sizeof(S) == 2: at an address == 6 mod 8, + - sizeof(S) == 4: at an address == 4 mod 8, + - Structures of other sizes are passed as references. + * Return value: + - An integer or pointer is returned in r2. + - A float or double is returned in f0. + - Structure return convention: The caller passes a pointer to the + destination area (quasi as an additional first pointer argument) + in r2. The callee fills it and returns the same pointer in r2. + + ----------------------------------------------------------------------*/ +#include "avcall-internal.h" + +#define RETURN(TYPE,VAL) (*(TYPE*)l->raddr = (TYPE)(VAL)) + +register __avword iarg1 __asm__("r2"); +register __avword iarg2 __asm__("r3"); +register __avword iarg3 __asm__("r4"); +register __avword iarg4 __asm__("r5"); +register __avword iarg5 __asm__("r6"); + +register float farg1 __asm__("f0"); +register float farg2 __asm__("f2"); +register float farg3 __asm__("f4"); +register float farg4 __asm__("f6"); + +register double darg1 __asm__("f0"); +register double darg2 __asm__("f2"); +register double darg3 __asm__("f4"); +register double darg4 __asm__("f6"); + +int +avcall_call(av_alist* list) +{ + register __avword* sp __asm__("r15"); /* C names for registers */ + register __avword iretreg __asm__("r2"); + register double dret __asm__("f0"); + + /* We need to put a value in r6, but it's a call-saved register. */ + __avword saved_iarg5 = iarg5; + + __av_alist* l = &AV_LIST_INNER(list); + + __avword* argframe = __builtin_alloca(__AV_ALIST_WORDS * sizeof(__avword)); /* make room for argument list */ + int arglen = l->aptr - l->args; + unsigned int ianum = l->ianum; + unsigned int fanum = l->fanum; + + { + int i; + for (i = 0; i < arglen; i++) /* push function args onto stack */ + argframe[i] = l->args[i]; + } + + /* Put up to 5 integer args into registers. */ + if (ianum >= 1) { + iarg1 = l->iargs[0]; + if (ianum >= 2) { + iarg2 = l->iargs[1]; + if (ianum >= 3) { + iarg3 = l->iargs[2]; + if (ianum >= 4) { + iarg4 = l->iargs[3]; + if (ianum >= 5) { + iarg5 = l->iargs[4]; + } + } + } + } + } + + /* Put upto 4 floating-point args into registers. */ + if (fanum >= 1) { + if (l->darg_mask & (1 << 0)) darg1 = l->dargs[0]; + else if (l->farg_mask & (1 << 0)) farg1 = l->fargs[0]; + if (fanum >= 2) { + if (l->darg_mask & (1 << 1)) darg2 = l->dargs[1]; + else if (l->farg_mask & (1 << 1)) farg2 = l->fargs[1]; + if (fanum >= 3) { + if (l->darg_mask & (1 << 2)) darg3 = l->dargs[2]; + else if (l->farg_mask & (1 << 2)) farg3 = l->fargs[2]; + if (fanum >= 4) { + if (l->darg_mask & (1 << 3)) darg4 = l->dargs[3]; + else if (l->farg_mask & (1 << 3)) farg4 = l->fargs[3]; + } + } + } + } + + /* Call function. */ + if (l->rtype == __AVfloat) { + *(float*)l->raddr = (*(float(*)())l->func)(); + } else + if (l->rtype == __AVdouble) { + *(double*)l->raddr = (*(double(*)())l->func)(); + } else { + __avword iret = (*l->func)(); + + /* save return value */ + if (l->rtype == __AVvoid) { + } else + if (l->rtype == __AVword) { + RETURN(__avword, iret); + } else + if (l->rtype == __AVchar) { + RETURN(char, iret); + } else + if (l->rtype == __AVschar) { + RETURN(signed char, iret); + } else + if (l->rtype == __AVuchar) { + RETURN(unsigned char, iret); + } else + if (l->rtype == __AVshort) { + RETURN(short, iret); + } else + if (l->rtype == __AVushort) { + RETURN(unsigned short, iret); + } else + if (l->rtype == __AVint) { + RETURN(int, iret); + } else + if (l->rtype == __AVuint) { + RETURN(unsigned int, iret); + } else + if (l->rtype == __AVlong || l->rtype == __AVlonglong) { + RETURN(long, iret); + } else + if (l->rtype == __AVulong || l->rtype == __AVulonglong) { + RETURN(unsigned long, iret); + } else + /* see above + if (l->rtype == __AVfloat) { + } else + if (l->rtype == __AVdouble) { + } else + */ + if (l->rtype == __AVvoidp) { + RETURN(void*, iret); + } else + if (l->rtype == __AVstruct) { + /* normal struct return convention */ + } + } + iarg5 = saved_iarg5; + return 0; +} diff --git a/avcall/avcall-sparc-linux.s b/avcall/avcall-sparc-linux.s new file mode 100644 index 0000000..68946c2 --- /dev/null +++ b/avcall/avcall-sparc-linux.s @@ -0,0 +1,170 @@ + .file "avcall-sparc.c" + .section ".text" + .align 4 + .global avcall_call + .type avcall_call,#function + .proc 04 +avcall_call: + !#PROLOGUE# 0 + save %sp, -1152, %sp + ld [%i0+20], %g3 + add %sp, 68, %l1 + ld [%i0+24], %o7 + ld [%i0+12], %l0 + sub %g3, %o7, %g3 + cmp %l0, 16 + be .LL54 + sra %g3, 2, %g4 +.LL2: + mov 6, %l0 + cmp %l0, %g4 + bge .LL49 + ld [%i0+24], %g1 +.LL7: + sll %l0, 2, %g3 + ld [%g1+%g3], %o7 + add %l0, 1, %l0 + cmp %l0, %g4 + bl .LL7 + st %o7, [%l1+%g3] +.LL49: + ld [%i0+12], %g3 + cmp %g3, 16 + be,a .LL55 + ld [%i0], %g3 + ld [%g1+20], %o5 +.LL60: + ld [%i0+4], %g3 + ld [%g1], %o0 + ld [%g1+4], %o1 + ld [%g1+8], %o2 + ld [%g1+12], %o3 + call %g3, 0 + ld [%g1+16], %o4 + nop + ld [%i0+12], %o7 + cmp %o7, 1 + be .LL10 + mov %o0, %l0 + cmp %o7, 0 + be,a .LL59 + ld [%i0+8], %g3 + cmp %o7, 2 + be .LL53 + cmp %o7, 3 + be .LL53 + cmp %o7, 4 + be .LL53 + cmp %o7, 5 + be .LL52 + cmp %o7, 6 + be .LL52 + cmp %o7, 7 + be .LL51 + cmp %o7, 8 + be .LL51 + cmp %o7, 9 + be .LL51 + cmp %o7, 10 + be .LL51 + add %o7, -11, %g3 + cmp %g3, 1 + bgu .LL31 + cmp %o7, 13 + ld [%i0+8], %g3 + st %o0, [%g3] + b .LL10 + st %o1, [%g3+4] +.LL31: + be .LL56 + cmp %o7, 14 + be .LL57 + cmp %o7, 15 + be .LL51 + cmp %o7, 16 + bne .LL10 + nop + ld [%i0], %g3 + andcc %g3, 2, %g0 + be .LL10 + nop + ld [%i0+16], %g3 + cmp %g3, 1 + be .LL53 + cmp %g3, 2 + be .LL52 + cmp %g3, 4 + bne .LL10 + nop +.LL51: + ld [%i0+8], %g3 +.LL59: + b .LL10 + st %l0, [%g3] +.LL52: + ld [%i0+8], %g3 + b .LL10 + sth %l0, [%g3] +.LL53: + ld [%i0+8], %g3 + b .LL10 + stb %l0, [%g3] +.LL57: + ld [%i0+8], %g3 + b .LL10 + std %f0, [%g3] +.LL56: + ld [%i0], %g3 + andcc %g3, 32, %g0 + bne,a .LL34 + fdtos %f0, %f0 +.LL34: + ld [%i0+8], %g3 + b .LL10 + st %f0, [%g3] +.LL55: + andcc %g3, 16, %g0 + be,a .LL60 + ld [%g1+20], %o5 + b .LL58 + ld [%i0+16], %l0 +.LL54: + ld [%i0+8], %g3 + b .LL2 + st %g3, [%sp+64] +.LL58: + sethi %hi(-1614774272), %g3 + sethi %hi(16777216), %o7 + st %g3, [%fp-32] + st %o7, [%fp-28] + sethi %hi(-1341120512), %o7 + sethi %hi(-2117607424), %g3 + st %o7, [%fp-20] + or %g3, 8, %g3 + and %l0, 4095, %l0 + st %g3, [%fp-16] + sethi %hi(-2115502080), %o7 + st %l0, [%fp-24] + st %o7, [%fp-12] + add %fp, -32, %g3 + iflush %g3 + add %fp, -24, %o7 + iflush %o7 + add %fp, -16, %g3 + iflush %g3 + add %fp, -12, %o7 + iflush %o7 + ld [%g1+20], %o5 + ld [%i0+4], %g2 + ld [%g1], %o0 + ld [%g1+4], %o1 + ld [%g1+8], %o2 + ld [%g1+12], %o3 + jmp %fp-32 + ld [%g1+16], %o4 +.LL10: + ret + restore %g0, 0, %o0 +.LLfe1: + .size avcall_call,.LLfe1-avcall_call + .ident "GCC: (GNU) 3.1" diff --git a/avcall/avcall-sparc-macro.S b/avcall/avcall-sparc-macro.S new file mode 100644 index 0000000..7d4da98 --- /dev/null +++ b/avcall/avcall-sparc-macro.S @@ -0,0 +1,172 @@ +#include "asm-sparc.h" + .section ".text" + .align 4 + .global C(avcall_call) + DECLARE_FUNCTION(avcall_call) + .proc 04 +FUNBEGIN(avcall_call) + !$PROLOGUE$ 0 + save %sp, -1152, %sp + ld [%i0+20], %g3 + add %sp, 68, %l1 + ld [%i0+24], %o7 + ld [%i0+12], %l0 + sub %g3, %o7, %g3 + cmp %l0, 16 + be L(L54) + sra %g3, 2, %g4 +L(L2): + mov 6, %l0 + cmp %l0, %g4 + bge L(L49) + ld [%i0+24], %g1 +L(L7): + sll %l0, 2, %g3 + ld [%g1+%g3], %o7 + add %l0, 1, %l0 + cmp %l0, %g4 + bl L(L7) + st %o7, [%l1+%g3] +L(L49): + ld [%i0+12], %g3 + cmp %g3, 16 + be,a L(L55) + ld [%i0], %g3 + ld [%g1+20], %o5 +L(L60): + ld [%i0+4], %g3 + ld [%g1], %o0 + ld [%g1+4], %o1 + ld [%g1+8], %o2 + ld [%g1+12], %o3 + call %g3, 0 + ld [%g1+16], %o4 + nop + ld [%i0+12], %o7 + cmp %o7, 1 + be L(L10) + mov %o0, %l0 + cmp %o7, 0 + be,a L(L59) + ld [%i0+8], %g3 + cmp %o7, 2 + be L(L53) + cmp %o7, 3 + be L(L53) + cmp %o7, 4 + be L(L53) + cmp %o7, 5 + be L(L52) + cmp %o7, 6 + be L(L52) + cmp %o7, 7 + be L(L51) + cmp %o7, 8 + be L(L51) + cmp %o7, 9 + be L(L51) + cmp %o7, 10 + be L(L51) + add %o7, -11, %g3 + cmp %g3, 1 + bgu L(L31) + cmp %o7, 13 + ld [%i0+8], %g3 + st %o0, [%g3] + b L(L10) + st %o1, [%g3+4] +L(L31): + be L(L56) + cmp %o7, 14 + be L(L57) + cmp %o7, 15 + be L(L51) + cmp %o7, 16 + bne L(L10) + nop + ld [%i0], %g3 + andcc %g3, 2, %g0 + be L(L10) + nop + ld [%i0+16], %g3 + cmp %g3, 1 + be L(L53) + cmp %g3, 2 + be L(L52) + cmp %g3, 4 + bne L(L10) + nop +L(L51): + ld [%i0+8], %g3 +L(L59): + b L(L10) + st %l0, [%g3] +L(L52): + ld [%i0+8], %g3 + b L(L10) + sth %l0, [%g3] +L(L53): + ld [%i0+8], %g3 + b L(L10) + stb %l0, [%g3] +L(L57): + ld [%i0+8], %g3 + b L(L10) + std %f0, [%g3] +L(L56): + ld [%i0], %g3 + andcc %g3, 32, %g0 + bne,a L(L34) + fdtos %f0, %f0 +L(L34): + ld [%i0+8], %g3 + b L(L10) + st %f0, [%g3] +L(L55): + andcc %g3, 16, %g0 + be,a L(L60) + ld [%g1+20], %o5 + b L(L58) + ld [%i0+16], %l0 +L(L54): + ld [%i0+8], %g3 + b L(L2) + st %g3, [%sp+64] +L(L58): + sethi %hi(-1614774272), %g3 + sethi %hi(16777216), %o7 + st %g3, [%fp-32] + st %o7, [%fp-28] + sethi %hi(-1341120512), %o7 + sethi %hi(-2117607424), %g3 + st %o7, [%fp-20] + or %g3, 8, %g3 + and %l0, 4095, %l0 + st %g3, [%fp-16] + sethi %hi(-2115502080), %o7 + st %l0, [%fp-24] + st %o7, [%fp-12] + add %fp, -32, %g3 + iflush %g3 + add %fp, -24, %o7 + iflush %o7 + add %fp, -16, %g3 + iflush %g3 + add %fp, -12, %o7 + iflush %o7 + ld [%g1+20], %o5 + ld [%i0+4], %g2 + ld [%g1], %o0 + ld [%g1+4], %o1 + ld [%g1+8], %o2 + ld [%g1+12], %o3 + jmp %fp-32 + ld [%g1+16], %o4 +L(L10): + ret + restore %g0, 0, %o0 +L(Lfe1): + FUNEND(avcall_call) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/avcall/avcall-sparc.c b/avcall/avcall-sparc.c new file mode 100644 index 0000000..64e649b --- /dev/null +++ b/avcall/avcall-sparc.c @@ -0,0 +1,192 @@ +/** + Copyright 1993 Bill Triggs + Copyright 1995-2017 Bruno Haible + + 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, see . +**/ +/*---------------------------------------------------------------------- + !!! THIS ROUTINE MUST BE COMPILED gcc -O !!! + + Foreign function interface for a Sun4 Sparc with gcc/sun-cc. + + This calls a C function with an argument list built up using macros + defined in avcall.h. + + Sparc Argument Passing Conventions + + The first 6 words of arguments are passed in integer registers o0-o5 + regardless of type or alignment. (Registers are windowed: o0-o5 become + i0-i5 if the called function executes a ‘save’ instruction.) Remaining + arguments are pushed onto the stack starting at a fixed offset + ("argframe"). Space is left on the stack frame for temporary storage of + the register arguments as well. + + Doubles may be cut in half and misaligned. Shorter integers are + always promoted to word-length. Functions with K&R-style declarations + and float args pass them as doubles and truncate them on function entry. + Structures are passed as pointers to a local copy of the structure made + by the caller. + + Integers and pointers are returned in o0, floats in f0, doubles in + f0/f1. If the function returns a structure a pointer to space + allocated by the caller is pushed onto the stack immediately + before the function arguments. Gcc without -fpcc-struct-return returns + <= 4 byte structures as integers. + + Sun cc allocates temporary space for a returned structure just below + the current frame pointer $fp (the $sp of the caller), and the caller + must copy them from there. It also returns the temp address in $o0, but + that gets nuked in the return in the code below so we can't use it. + **The Sun cc struct return stuff below is a kludge**, but seems to work + on the test cases... + + Compile this routine with gcc for the __asm__ extensions and with + optimisation on (-O or -O2 or -g -O) so that argframe is set to the + correct offset. (%sp is used differently in non-optimized code). + For Sun cc, use the pre-compiled assembler version of this routine. + ----------------------------------------------------------------------*/ +#include "avcall-internal.h" + +#define RETURN(TYPE,VAL) (*(TYPE*)l->raddr = (TYPE)(VAL)) + +register void* callee __asm__("%g2"); /* any global or local register */ +register __avword o0 __asm__("%o0"); +register __avword o1 __asm__("%o1"); +register __avword o2 __asm__("%o2"); +register __avword o3 __asm__("%o3"); +register __avword o4 __asm__("%o4"); +register __avword o5 __asm__("%o5"); + +int +avcall_call(av_alist* list) +{ + /*?? We probably need to make space for Sun cc + struct return somewhere here. */ + register __avword* sp __asm__("%sp"); /* C names for registers */ + register float fret __asm__("%f0"); /* %f0 */ + register double dret __asm__("%f0"); /* %f0,%f1 */ + + __av_alist* l = &AV_LIST_INNER(list); + + __avword trampoline[6]; /* room for a trampoline */ + __avword space[__AV_ALIST_WORDS]; /* space for callee's stack frame */ + __avword *argframe = sp + 17; /* stack offset for argument list */ + int arglen = l->aptr - l->args; + __avword i; + + if (l->rtype == __AVstruct) + argframe[-1] = (__avword)l->raddr; /* push struct return address */ + + { + int i; + for (i = 6; i < arglen; i++) /* push excess function args */ + argframe[i] = l->args[i]; + } + + if ((l->rtype == __AVstruct) && (l->flags & __AV_SUNPROCC_STRUCT_RETURN)) + /* SUNWspro cc compiled functions don't copy the structure to the area + * pointed to by argframe[-1] unless the caller has a proper "unimp n" + * instruction. We generate the calling instructions on the stack. */ + { + trampoline[0] = 0x9FC08000; /* call %g2 */ + trampoline[1] = 0x01000000; /* nop */ + trampoline[2] = l->rsize & 0xFFF; /* unimp n */ + trampoline[3] = 0xB0102000; /* mov 0,%i0 */ + trampoline[4] = 0x81C7E008; /* ret */ + trampoline[5] = 0x81E80000; /* restore */ + __asm__ __volatile__ ("iflush %0" : : "r" (&trampoline[0])); + __asm__ __volatile__ ("iflush %0" : : "r" (&trampoline[2])); + __asm__ __volatile__ ("iflush %0" : : "r" (&trampoline[4])); + __asm__ __volatile__ ("iflush %0" : : "r" (&trampoline[5])); + o0 = l->args[0]; o1 = l->args[1]; o2 = l->args[2]; + o3 = l->args[3]; o4 = l->args[4]; o5 = l->args[5]; + callee = l->func; + goto *(void*)trampoline; + } + + /* call function with 1st 6 args */ + i = ({ register __avword iret __asm__("%o0"); + iret = (*l->func)(l->args[0], l->args[1], l->args[2], + l->args[3], l->args[4], l->args[5]); + asm ("nop"); /* struct returning functions skip this instruction */ + iret; + }); + + /* save return value */ + if (l->rtype == __AVvoid) { + } else + if (l->rtype == __AVword) { + RETURN(__avword, i); + } else + if (l->rtype == __AVchar) { + RETURN(char, i); + } else + if (l->rtype == __AVschar) { + RETURN(signed char, i); + } else + if (l->rtype == __AVuchar) { + RETURN(unsigned char, i); + } else + if (l->rtype == __AVshort) { + RETURN(short, i); + } else + if (l->rtype == __AVushort) { + RETURN(unsigned short, i); + } else + if (l->rtype == __AVint) { + RETURN(int, i); + } else + if (l->rtype == __AVuint) { + RETURN(unsigned int, i); + } else + if (l->rtype == __AVlong) { + RETURN(long, i); + } else + if (l->rtype == __AVulong) { + RETURN(unsigned long, i); + } else + if (l->rtype == __AVlonglong || l->rtype == __AVulonglong) { + void* raddr = l->raddr; + ((__avword*)raddr)[0] = i; + ((__avword*)raddr)[1] = o1; + } else + if (l->rtype == __AVfloat) { + /* old Sun cc returns floats as doubles */ + if (l->flags & __AV_SUNCC_FLOAT_RETURN) { + RETURN(float, (float)dret); + } else { + RETURN(float, fret); + } + } else + if (l->rtype == __AVdouble) { + RETURN(double, dret); + } else + if (l->rtype == __AVvoidp) { + RETURN(void*, i); + } else + if (l->rtype == __AVstruct) { + if (l->flags & __AV_SMALL_STRUCT_RETURN) { + if (l->rsize == sizeof(char)) { + RETURN(char, i); + } else + if (l->rsize == sizeof(short)) { + RETURN(short, i); + } else + if (l->rsize == sizeof(int)) { + RETURN(int, i); + } + } + } + return 0; +} diff --git a/avcall/avcall-sparc64-linux.s b/avcall/avcall-sparc64-linux.s new file mode 100644 index 0000000..1f9781e --- /dev/null +++ b/avcall/avcall-sparc64-linux.s @@ -0,0 +1,525 @@ + .file "avcall-sparc64.c" + .section ".text" + .align 4 + .global avcall_call + .type avcall_call, #function + .proc 04 +avcall_call: + .register %g2, #scratch + .register %g3, #scratch + save %sp, -192, %sp + ldx [%i0+48], %g2 + ldx [%i0+40], %g1 + lduw [%i0+68], %g3 + sub %g1, %g2, %g1 + cmp %g3, 0 + be,pt %icc, .LL2 + srlx %g1, 3, %o7 + andcc %g3, 1, %g0 + bne,pt %xcc, .LL100 + andcc %g3, 2, %g0 + bne,pt %xcc, .LL101 + andcc %g3, 4, %g0 +.LL130: + bne,pt %xcc, .LL102 + andcc %g3, 8, %g0 +.LL129: + bne,pt %xcc, .LL103 + andcc %g3, 16, %g0 +.LL128: + bne,pt %xcc, .LL104 + andcc %g3, 32, %g0 +.LL127: + bne,pt %xcc, .LL105 + andcc %g3, 64, %g0 +.LL126: + bne,pt %xcc, .LL106 + andcc %g3, 128, %g0 +.LL125: + bne,pt %xcc, .LL107 + andcc %g3, 256, %g0 +.LL124: + bne,pt %xcc, .LL108 + andcc %g3, 512, %g0 +.LL123: + bne,pt %xcc, .LL109 + andcc %g3, 1024, %g0 +.LL134: + bne,pt %xcc, .LL110 + andcc %g3, 2048, %g0 +.LL133: + bne,pt %xcc, .LL111 + sethi %hi(4096), %g1 +.LL132: + andcc %g3, %g1, %g0 + bne,pt %icc, .LL112 + sethi %hi(8192), %g1 +.LL131: + andcc %g3, %g1, %g0 + bne,pt %icc, .LL113 + sethi %hi(16384), %g1 +.LL136: + andcc %g3, %g1, %g0 + bne,pt %icc, .LL114 + sethi %hi(32768), %g1 +.LL135: + andcc %g3, %g1, %g0 + bne,pt %icc, .LL115 + nop +.LL2: + cmp %o7, 6 +.LL137: + bg,pn %icc, .LL120 + add %o7, -6, %g1 + ldx [%i0+48], %g3 +.LL122: + ldx [%g3+40], %o5 +.LL119: + ldx [%i0+8], %g1 + ldx [%g3], %o0 + ldx [%g3+8], %o1 + ldx [%g3+16], %o2 + ldx [%g3+24], %o3 + call %g1, 0 + ldx [%g3+32], %o4 + mov %o0, %l3 + nop + lduw [%i0+24], %g1 + cmp %g1, 1 + be,pn %icc, .LL38 + cmp %g1, 0 + be,a,pt %icc, .LL121 + ldx [%i0+16], %g1 + cmp %g1, 2 + be,pn %icc, .LL92 + cmp %g1, 3 + be,pn %icc, .LL92 + cmp %g1, 4 + be,pn %icc, .LL92 + cmp %g1, 5 + be,pn %icc, .LL93 + cmp %g1, 6 + be,pn %icc, .LL93 + cmp %g1, 7 + be,pn %icc, .LL94 + cmp %g1, 8 + be,pn %icc, .LL94 + cmp %g1, 9 + be,pn %icc, .LL98 + cmp %g1, 10 + be,pn %icc, .LL98 + cmp %g1, 11 + be,pn %icc, .LL98 + cmp %g1, 12 + be,pn %icc, .LL98 + cmp %g1, 13 + be,pn %icc, .LL117 + cmp %g1, 14 + be,pn %icc, .LL118 + cmp %g1, 15 + be,pn %icc, .LL98 + cmp %g1, 16 + bne,pt %icc, .LL38 + nop + lduw [%i0], %g1 + andcc %g1, 512, %g0 + be,pn %xcc, .LL38 + nop + ldx [%i0+32], %g2 + add %g2, -1, %g1 + cmp %g1, 31 + bgu,pn %xcc, .LL38 + cmp %g2, 8 + ldx [%i0+16], %g1 + and %g1, 7, %g5 + and %g1, -8, %i0 + bgu,pt %xcc, .LL73 + add %g2, %g5, %g4 + cmp %g4, 8 + bgu,pt %xcc, .LL75 + sllx %g5, 3, %g2 + sllx %g5, 3, %g3 + sllx %g4, 3, %g4 + ldx [%i0], %g5 + srax %o0, %g3, %o7 + sub %g0, %g4, %g4 + xor %g5, %o7, %o7 + xnor %g0, %g3, %g3 + mov 2, %g1 + mov 1, %g2 + sllx %g1, %g3, %g1 + sllx %g2, %g4, %g2 + sub %g1, %g2, %g1 + and %g1, %o7, %g1 + xor %g5, %g1, %g5 + stx %g5, [%i0] +.LL38: + return %i7+8 + mov 0, %o0 +.LL98: + ldx [%i0+16], %g1 +.LL121: + stx %l3, [%g1] + return %i7+8 + mov 0, %o0 +.LL115: + ldd [%g2+120],%f30 + cmp %o7, 6 + ble,a,pt %icc, .LL122 + ldx [%i0+48], %g3 + add %o7, -6, %g1 +.LL120: + sra %g1, 0, %g1 + sllx %g1, 3, %g1 + add %g1, 15, %g1 + and %g1, -16, %g1 + mov 6, %g4 + sub %sp, %g1, %sp + ldx [%i0+48], %g3 + add %sp, 2238, %g1 + and %g1, -16, %g1 + add %g1, -48, %g5 +.LL37: + sra %g4, 0, %g1 + add %g4, 1, %g4 + sllx %g1, 3, %g1 + cmp %o7, %g4 + ldx [%g1+%g3], %g2 + bne,pt %icc, .LL37 + stx %g2, [%g5+%g1] + ba,pt %xcc, .LL119 + ldx [%g3+40], %o5 +.LL107: + ldd [%g2+56],%f14 + andcc %g3, 256, %g0 + be,pt %xcc, .LL123 + andcc %g3, 512, %g0 + ba,pt %xcc, .LL108 + nop +.LL106: + ldd [%g2+48],%f12 + andcc %g3, 128, %g0 + be,pt %xcc, .LL124 + andcc %g3, 256, %g0 + ba,pt %xcc, .LL107 + nop +.LL105: + ldd [%g2+40],%f10 + andcc %g3, 64, %g0 + be,pt %xcc, .LL125 + andcc %g3, 128, %g0 + ba,pt %xcc, .LL106 + nop +.LL104: + ldd [%g2+32],%f8 + andcc %g3, 32, %g0 + be,pt %xcc, .LL126 + andcc %g3, 64, %g0 + ba,pt %xcc, .LL105 + nop +.LL103: + ldd [%g2+24],%f6 + andcc %g3, 16, %g0 + be,pt %xcc, .LL127 + andcc %g3, 32, %g0 + ba,pt %xcc, .LL104 + nop +.LL102: + ldd [%g2+16],%f4 + andcc %g3, 8, %g0 + be,pt %xcc, .LL128 + andcc %g3, 16, %g0 + ba,pt %xcc, .LL103 + nop +.LL101: + ldd [%g2+8],%f2 + andcc %g3, 4, %g0 + be,pt %xcc, .LL129 + andcc %g3, 8, %g0 + ba,pt %xcc, .LL102 + nop +.LL100: + ldd [%g2+0],%f0 + andcc %g3, 2, %g0 + be,pt %xcc, .LL130 + andcc %g3, 4, %g0 + ba,pt %xcc, .LL101 + nop +.LL111: + ldd [%g2+88],%f22 + sethi %hi(4096), %g1 + andcc %g3, %g1, %g0 + be,pt %icc, .LL131 + sethi %hi(8192), %g1 + ba,pt %xcc, .LL112 + nop +.LL110: + ldd [%g2+80],%f20 + andcc %g3, 2048, %g0 + be,pt %xcc, .LL132 + sethi %hi(4096), %g1 + ba,pt %xcc, .LL111 + nop +.LL109: + ldd [%g2+72],%f18 + andcc %g3, 1024, %g0 + be,pt %xcc, .LL133 + andcc %g3, 2048, %g0 + ba,pt %xcc, .LL110 + nop +.LL108: + ldd [%g2+64],%f16 + andcc %g3, 512, %g0 + be,pt %xcc, .LL134 + andcc %g3, 1024, %g0 + ba,pt %xcc, .LL109 + nop +.LL113: + ldd [%g2+104],%f26 + sethi %hi(16384), %g1 + andcc %g3, %g1, %g0 + be,pt %icc, .LL135 + sethi %hi(32768), %g1 + ba,pt %xcc, .LL114 + nop +.LL112: + ldd [%g2+96],%f24 + sethi %hi(8192), %g1 + andcc %g3, %g1, %g0 + be,pt %icc, .LL136 + sethi %hi(16384), %g1 + ba,pt %xcc, .LL113 + nop +.LL114: + ldd [%g2+112],%f28 + sethi %hi(32768), %g1 + andcc %g3, %g1, %g0 + be,pt %icc, .LL137 + cmp %o7, 6 + ba,pt %xcc, .LL115 + nop +.LL92: + ldx [%i0+16], %g1 + stb %l3, [%g1] + return %i7+8 + mov 0, %o0 +.LL93: + ldx [%i0+16], %g1 + ba,pt %xcc, .LL38 + sth %l3, [%g1] +.LL94: + ldx [%i0+16], %g1 + ba,pt %xcc, .LL38 + st %l3, [%g1] +.LL117: + ldx [%i0+16], %g1 + ba,pt %xcc, .LL38 + st %f0, [%g1] +.LL118: + ldx [%i0+16], %g1 + ba,pt %xcc, .LL38 + std %f0, [%g1] +.LL75: + sllx %g4, 3, %l0 + ldx [%i0], %g5 + srax %o0, %g2, %g4 + sub %g0, %g2, %g3 + xor %g5, %g4, %g4 + xnor %g0, %g2, %g2 + mov 2, %g1 + sllx %g1, %g2, %g1 + add %g1, -1, %g1 + and %g1, %g4, %g1 + ldx [%i0+8], %o7 + xor %g5, %g1, %g5 + sub %g0, %l0, %l0 + sllx %o0, %g3, %g3 + mov -1, %g1 + xor %o7, %g3, %g3 + sllx %g1, %l0, %g1 + stx %g5, [%i0] + and %g1, %g3, %g1 + xor %o7, %g1, %o7 + ba,pt %xcc, .LL38 + stx %o7, [%i0+8] +.LL73: + cmp %g2, 16 + bgu,pt %xcc, .LL77 + cmp %g2, 24 + sll %g5, 3, %l2 + xnor %g0, %l2, %g2 + ldx [%i0], %g3 + mov 2, %g1 + cmp %g4, 16 + sllx %g1, %g2, %g1 + srax %o0, %l2, %g2 + add %g1, -1, %g1 + xor %g3, %g2, %g2 + and %g1, %g2, %g1 + xor %g3, %g1, %g3 + bgu,pt %xcc, .LL79 + stx %g3, [%i0] + sllx %g5, 2, %g5 + mov 32, %g2 + sub %g2, %g5, %g2 + ldx [%i0+8], %g3 + sllx %o0, %g2, %g1 + sllx %g4, 3, %g4 + sllx %g1, %g2, %g1 + srax %o1, %l2, %o7 + sub %g0, %g4, %g4 + or %g1, %o7, %g1 + mov -1, %g2 + xor %g3, %g1, %g1 + sllx %g2, %g4, %g2 + and %g2, %g1, %g2 + xor %g3, %g2, %g3 + ba,pt %xcc, .LL38 + stx %g3, [%i0+8] +.LL77: + bgu,pt %xcc, .LL81 + sll %g5, 3, %l4 + sll %g5, 3, %l2 + xnor %g0, %l2, %g2 + ldx [%i0], %g3 + mov 2, %g1 + cmp %g4, 24 + sllx %g1, %g2, %g1 + srax %o0, %l2, %g2 + add %g1, -1, %g1 + xor %g3, %g2, %g2 + and %g1, %g2, %g1 + xor %g3, %g1, %g3 + bgu,pt %xcc, .LL83 + stx %g3, [%i0] + sllx %g5, 2, %g2 + mov 32, %g1 + sub %g1, %g2, %g1 + ldx [%i0+16], %o7 + sllx %g4, 3, %g5 + sllx %o0, %g1, %g3 + sllx %o1, %g1, %g2 + sllx %g3, %g1, %g3 + sllx %g2, %g1, %g2 + srax %o2, %l2, %l0 + sub %g0, %g5, %g5 + or %g2, %l0, %g2 + srax %o1, %l2, %g4 + xor %o7, %g2, %g2 + or %g3, %g4, %g3 + mov -1, %g1 + stx %g3, [%i0+8] + sllx %g1, %g5, %g1 + and %g1, %g2, %g1 + xor %o7, %g1, %o7 + ba,pt %xcc, .LL38 + stx %o7, [%i0+16] +.LL79: + srax %o1, %l2, %g5 + mov 64, %g1 + sub %g1, %l2, %g1 + sllx %o1, %g1, %g2 + sllx %o0, %g1, %g1 + or %g1, %g5, %g1 + sllx %g4, 3, %g3 + stx %g1, [%i0+8] + ldx [%i0+16], %g4 + sub %g0, %g3, %g3 + xor %g4, %g2, %g2 + mov -1, %g1 + sllx %g1, %g3, %g1 + and %g1, %g2, %g1 + xor %g4, %g1, %g4 + ba,pt %xcc, .LL38 + stx %g4, [%i0+16] +.LL83: + sllx %g4, 3, %g5 + srax %o2, %l2, %l0 + mov 64, %g1 + sub %g1, %l2, %g1 + sllx %o2, %g1, %g4 + sllx %o0, %g1, %g2 + sllx %o1, %g1, %g1 + or %g1, %l0, %g1 + ldx [%i0+24], %o7 + sub %g0, %g5, %g5 + xor %o7, %g4, %g4 + stx %g1, [%i0+16] + srax %o1, %l2, %g3 + mov -1, %g1 + or %g2, %g3, %g2 + sllx %g1, %g5, %g1 + stx %g2, [%i0+8] + and %g1, %g4, %g1 + xor %o7, %g1, %o7 + ba,pt %xcc, .LL38 + stx %o7, [%i0+24] +.LL81: + xnor %g0, %l4, %g2 + ldx [%i0], %g3 + mov 2, %g1 + cmp %g4, 32 + sllx %g1, %g2, %g1 + srax %o0, %l4, %g2 + add %g1, -1, %g1 + xor %g3, %g2, %g2 + and %g1, %g2, %g1 + xor %g3, %g1, %g3 + bgu,pt %xcc, .LL85 + stx %g3, [%i0] + sllx %g5, 2, %g2 + mov 32, %g1 + sub %g1, %g2, %g1 + ldx [%i0+24], %l0 + sllx %g4, 3, %l1 + sllx %o0, %g1, %g3 + sllx %o1, %g1, %g4 + sllx %g3, %g1, %g3 + sllx %g4, %g1, %g4 + sllx %o2, %g1, %g2 + srax %o3, %l4, %l2 + sllx %g2, %g1, %g2 + sub %g0, %l1, %l1 + or %g2, %l2, %g2 + srax %o1, %l4, %g5 + xor %l0, %g2, %g2 + or %g3, %g5, %g3 + srax %o2, %l4, %o7 + mov -1, %g1 + or %g4, %o7, %g4 + sllx %g1, %l1, %g1 + stx %g3, [%i0+8] + and %g1, %g2, %g1 + stx %g4, [%i0+16] + xor %l0, %g1, %l0 + ba,pt %xcc, .LL38 + stx %l0, [%i0+24] +.LL85: + srax %o3, %l4, %l2 + mov 64, %g1 + sub %g1, %l4, %g1 + sllx %o3, %g1, %o7 + sllx %o0, %g1, %g2 + sllx %o1, %g1, %g3 + sllx %o2, %g1, %g1 + or %g1, %l2, %g1 + ldx [%i0+32], %l0 + sllx %g4, 3, %l1 + xor %l0, %o7, %o7 + sub %g0, %l1, %l1 + stx %g1, [%i0+24] + srax %o1, %l4, %g4 + srax %o2, %l4, %g5 + or %g2, %g4, %g2 + or %g3, %g5, %g3 + mov -1, %g1 + stx %g2, [%i0+8] + sllx %g1, %l1, %g1 + stx %g3, [%i0+16] + and %g1, %o7, %g1 + xor %l0, %g1, %l0 + ba,pt %xcc, .LL38 + stx %l0, [%i0+32] + .size avcall_call, .-avcall_call + .ident "GCC: (GNU) 4.0.2" + .section ".note.GNU-stack" diff --git a/avcall/avcall-sparc64-macro.S b/avcall/avcall-sparc64-macro.S new file mode 100644 index 0000000..e538a4e --- /dev/null +++ b/avcall/avcall-sparc64-macro.S @@ -0,0 +1,526 @@ +#include "asm-sparc.h" + .section ".text" + .align 4 + .global C(avcall_call) + DECLARE_FUNCTION(avcall_call) + .proc 04 +FUNBEGIN(avcall_call) + .register %g2, $scratch + .register %g3, $scratch + save %sp, -192, %sp + ldx [%i0+48], %g2 + ldx [%i0+40], %g1 + lduw [%i0+68], %g3 + sub %g1, %g2, %g1 + cmp %g3, 0 + be,pt %icc, L(L2) + srlx %g1, 3, %o7 + andcc %g3, 1, %g0 + bne,pt %xcc, L(L100) + andcc %g3, 2, %g0 + bne,pt %xcc, L(L101) + andcc %g3, 4, %g0 +L(L130): + bne,pt %xcc, L(L102) + andcc %g3, 8, %g0 +L(L129): + bne,pt %xcc, L(L103) + andcc %g3, 16, %g0 +L(L128): + bne,pt %xcc, L(L104) + andcc %g3, 32, %g0 +L(L127): + bne,pt %xcc, L(L105) + andcc %g3, 64, %g0 +L(L126): + bne,pt %xcc, L(L106) + andcc %g3, 128, %g0 +L(L125): + bne,pt %xcc, L(L107) + andcc %g3, 256, %g0 +L(L124): + bne,pt %xcc, L(L108) + andcc %g3, 512, %g0 +L(L123): + bne,pt %xcc, L(L109) + andcc %g3, 1024, %g0 +L(L134): + bne,pt %xcc, L(L110) + andcc %g3, 2048, %g0 +L(L133): + bne,pt %xcc, L(L111) + sethi %hi(4096), %g1 +L(L132): + andcc %g3, %g1, %g0 + bne,pt %icc, L(L112) + sethi %hi(8192), %g1 +L(L131): + andcc %g3, %g1, %g0 + bne,pt %icc, L(L113) + sethi %hi(16384), %g1 +L(L136): + andcc %g3, %g1, %g0 + bne,pt %icc, L(L114) + sethi %hi(32768), %g1 +L(L135): + andcc %g3, %g1, %g0 + bne,pt %icc, L(L115) + nop +L(L2): + cmp %o7, 6 +L(L137): + bg,pn %icc, L(L120) + add %o7, -6, %g1 + ldx [%i0+48], %g3 +L(L122): + ldx [%g3+40], %o5 +L(L119): + ldx [%i0+8], %g1 + ldx [%g3], %o0 + ldx [%g3+8], %o1 + ldx [%g3+16], %o2 + ldx [%g3+24], %o3 + call %g1, 0 + ldx [%g3+32], %o4 + mov %o0, %l3 + nop + lduw [%i0+24], %g1 + cmp %g1, 1 + be,pn %icc, L(L38) + cmp %g1, 0 + be,a,pt %icc, L(L121) + ldx [%i0+16], %g1 + cmp %g1, 2 + be,pn %icc, L(L92) + cmp %g1, 3 + be,pn %icc, L(L92) + cmp %g1, 4 + be,pn %icc, L(L92) + cmp %g1, 5 + be,pn %icc, L(L93) + cmp %g1, 6 + be,pn %icc, L(L93) + cmp %g1, 7 + be,pn %icc, L(L94) + cmp %g1, 8 + be,pn %icc, L(L94) + cmp %g1, 9 + be,pn %icc, L(L98) + cmp %g1, 10 + be,pn %icc, L(L98) + cmp %g1, 11 + be,pn %icc, L(L98) + cmp %g1, 12 + be,pn %icc, L(L98) + cmp %g1, 13 + be,pn %icc, L(L117) + cmp %g1, 14 + be,pn %icc, L(L118) + cmp %g1, 15 + be,pn %icc, L(L98) + cmp %g1, 16 + bne,pt %icc, L(L38) + nop + lduw [%i0], %g1 + andcc %g1, 512, %g0 + be,pn %xcc, L(L38) + nop + ldx [%i0+32], %g2 + add %g2, -1, %g1 + cmp %g1, 31 + bgu,pn %xcc, L(L38) + cmp %g2, 8 + ldx [%i0+16], %g1 + and %g1, 7, %g5 + and %g1, -8, %i0 + bgu,pt %xcc, L(L73) + add %g2, %g5, %g4 + cmp %g4, 8 + bgu,pt %xcc, L(L75) + sllx %g5, 3, %g2 + sllx %g5, 3, %g3 + sllx %g4, 3, %g4 + ldx [%i0], %g5 + srax %o0, %g3, %o7 + sub %g0, %g4, %g4 + xor %g5, %o7, %o7 + xnor %g0, %g3, %g3 + mov 2, %g1 + mov 1, %g2 + sllx %g1, %g3, %g1 + sllx %g2, %g4, %g2 + sub %g1, %g2, %g1 + and %g1, %o7, %g1 + xor %g5, %g1, %g5 + stx %g5, [%i0] +L(L38): + return %i7+8 + mov 0, %o0 +L(L98): + ldx [%i0+16], %g1 +L(L121): + stx %l3, [%g1] + return %i7+8 + mov 0, %o0 +L(L115): + ldd [%g2+120],%f30 + cmp %o7, 6 + ble,a,pt %icc, L(L122) + ldx [%i0+48], %g3 + add %o7, -6, %g1 +L(L120): + sra %g1, 0, %g1 + sllx %g1, 3, %g1 + add %g1, 15, %g1 + and %g1, -16, %g1 + mov 6, %g4 + sub %sp, %g1, %sp + ldx [%i0+48], %g3 + add %sp, 2238, %g1 + and %g1, -16, %g1 + add %g1, -48, %g5 +L(L37): + sra %g4, 0, %g1 + add %g4, 1, %g4 + sllx %g1, 3, %g1 + cmp %o7, %g4 + ldx [%g1+%g3], %g2 + bne,pt %icc, L(L37) + stx %g2, [%g5+%g1] + ba,pt %xcc, L(L119) + ldx [%g3+40], %o5 +L(L107): + ldd [%g2+56],%f14 + andcc %g3, 256, %g0 + be,pt %xcc, L(L123) + andcc %g3, 512, %g0 + ba,pt %xcc, L(L108) + nop +L(L106): + ldd [%g2+48],%f12 + andcc %g3, 128, %g0 + be,pt %xcc, L(L124) + andcc %g3, 256, %g0 + ba,pt %xcc, L(L107) + nop +L(L105): + ldd [%g2+40],%f10 + andcc %g3, 64, %g0 + be,pt %xcc, L(L125) + andcc %g3, 128, %g0 + ba,pt %xcc, L(L106) + nop +L(L104): + ldd [%g2+32],%f8 + andcc %g3, 32, %g0 + be,pt %xcc, L(L126) + andcc %g3, 64, %g0 + ba,pt %xcc, L(L105) + nop +L(L103): + ldd [%g2+24],%f6 + andcc %g3, 16, %g0 + be,pt %xcc, L(L127) + andcc %g3, 32, %g0 + ba,pt %xcc, L(L104) + nop +L(L102): + ldd [%g2+16],%f4 + andcc %g3, 8, %g0 + be,pt %xcc, L(L128) + andcc %g3, 16, %g0 + ba,pt %xcc, L(L103) + nop +L(L101): + ldd [%g2+8],%f2 + andcc %g3, 4, %g0 + be,pt %xcc, L(L129) + andcc %g3, 8, %g0 + ba,pt %xcc, L(L102) + nop +L(L100): + ldd [%g2+0],%f0 + andcc %g3, 2, %g0 + be,pt %xcc, L(L130) + andcc %g3, 4, %g0 + ba,pt %xcc, L(L101) + nop +L(L111): + ldd [%g2+88],%f22 + sethi %hi(4096), %g1 + andcc %g3, %g1, %g0 + be,pt %icc, L(L131) + sethi %hi(8192), %g1 + ba,pt %xcc, L(L112) + nop +L(L110): + ldd [%g2+80],%f20 + andcc %g3, 2048, %g0 + be,pt %xcc, L(L132) + sethi %hi(4096), %g1 + ba,pt %xcc, L(L111) + nop +L(L109): + ldd [%g2+72],%f18 + andcc %g3, 1024, %g0 + be,pt %xcc, L(L133) + andcc %g3, 2048, %g0 + ba,pt %xcc, L(L110) + nop +L(L108): + ldd [%g2+64],%f16 + andcc %g3, 512, %g0 + be,pt %xcc, L(L134) + andcc %g3, 1024, %g0 + ba,pt %xcc, L(L109) + nop +L(L113): + ldd [%g2+104],%f26 + sethi %hi(16384), %g1 + andcc %g3, %g1, %g0 + be,pt %icc, L(L135) + sethi %hi(32768), %g1 + ba,pt %xcc, L(L114) + nop +L(L112): + ldd [%g2+96],%f24 + sethi %hi(8192), %g1 + andcc %g3, %g1, %g0 + be,pt %icc, L(L136) + sethi %hi(16384), %g1 + ba,pt %xcc, L(L113) + nop +L(L114): + ldd [%g2+112],%f28 + sethi %hi(32768), %g1 + andcc %g3, %g1, %g0 + be,pt %icc, L(L137) + cmp %o7, 6 + ba,pt %xcc, L(L115) + nop +L(L92): + ldx [%i0+16], %g1 + stb %l3, [%g1] + return %i7+8 + mov 0, %o0 +L(L93): + ldx [%i0+16], %g1 + ba,pt %xcc, L(L38) + sth %l3, [%g1] +L(L94): + ldx [%i0+16], %g1 + ba,pt %xcc, L(L38) + st %l3, [%g1] +L(L117): + ldx [%i0+16], %g1 + ba,pt %xcc, L(L38) + st %f0, [%g1] +L(L118): + ldx [%i0+16], %g1 + ba,pt %xcc, L(L38) + std %f0, [%g1] +L(L75): + sllx %g4, 3, %l0 + ldx [%i0], %g5 + srax %o0, %g2, %g4 + sub %g0, %g2, %g3 + xor %g5, %g4, %g4 + xnor %g0, %g2, %g2 + mov 2, %g1 + sllx %g1, %g2, %g1 + add %g1, -1, %g1 + and %g1, %g4, %g1 + ldx [%i0+8], %o7 + xor %g5, %g1, %g5 + sub %g0, %l0, %l0 + sllx %o0, %g3, %g3 + mov -1, %g1 + xor %o7, %g3, %g3 + sllx %g1, %l0, %g1 + stx %g5, [%i0] + and %g1, %g3, %g1 + xor %o7, %g1, %o7 + ba,pt %xcc, L(L38) + stx %o7, [%i0+8] +L(L73): + cmp %g2, 16 + bgu,pt %xcc, L(L77) + cmp %g2, 24 + sll %g5, 3, %l2 + xnor %g0, %l2, %g2 + ldx [%i0], %g3 + mov 2, %g1 + cmp %g4, 16 + sllx %g1, %g2, %g1 + srax %o0, %l2, %g2 + add %g1, -1, %g1 + xor %g3, %g2, %g2 + and %g1, %g2, %g1 + xor %g3, %g1, %g3 + bgu,pt %xcc, L(L79) + stx %g3, [%i0] + sllx %g5, 2, %g5 + mov 32, %g2 + sub %g2, %g5, %g2 + ldx [%i0+8], %g3 + sllx %o0, %g2, %g1 + sllx %g4, 3, %g4 + sllx %g1, %g2, %g1 + srax %o1, %l2, %o7 + sub %g0, %g4, %g4 + or %g1, %o7, %g1 + mov -1, %g2 + xor %g3, %g1, %g1 + sllx %g2, %g4, %g2 + and %g2, %g1, %g2 + xor %g3, %g2, %g3 + ba,pt %xcc, L(L38) + stx %g3, [%i0+8] +L(L77): + bgu,pt %xcc, L(L81) + sll %g5, 3, %l4 + sll %g5, 3, %l2 + xnor %g0, %l2, %g2 + ldx [%i0], %g3 + mov 2, %g1 + cmp %g4, 24 + sllx %g1, %g2, %g1 + srax %o0, %l2, %g2 + add %g1, -1, %g1 + xor %g3, %g2, %g2 + and %g1, %g2, %g1 + xor %g3, %g1, %g3 + bgu,pt %xcc, L(L83) + stx %g3, [%i0] + sllx %g5, 2, %g2 + mov 32, %g1 + sub %g1, %g2, %g1 + ldx [%i0+16], %o7 + sllx %g4, 3, %g5 + sllx %o0, %g1, %g3 + sllx %o1, %g1, %g2 + sllx %g3, %g1, %g3 + sllx %g2, %g1, %g2 + srax %o2, %l2, %l0 + sub %g0, %g5, %g5 + or %g2, %l0, %g2 + srax %o1, %l2, %g4 + xor %o7, %g2, %g2 + or %g3, %g4, %g3 + mov -1, %g1 + stx %g3, [%i0+8] + sllx %g1, %g5, %g1 + and %g1, %g2, %g1 + xor %o7, %g1, %o7 + ba,pt %xcc, L(L38) + stx %o7, [%i0+16] +L(L79): + srax %o1, %l2, %g5 + mov 64, %g1 + sub %g1, %l2, %g1 + sllx %o1, %g1, %g2 + sllx %o0, %g1, %g1 + or %g1, %g5, %g1 + sllx %g4, 3, %g3 + stx %g1, [%i0+8] + ldx [%i0+16], %g4 + sub %g0, %g3, %g3 + xor %g4, %g2, %g2 + mov -1, %g1 + sllx %g1, %g3, %g1 + and %g1, %g2, %g1 + xor %g4, %g1, %g4 + ba,pt %xcc, L(L38) + stx %g4, [%i0+16] +L(L83): + sllx %g4, 3, %g5 + srax %o2, %l2, %l0 + mov 64, %g1 + sub %g1, %l2, %g1 + sllx %o2, %g1, %g4 + sllx %o0, %g1, %g2 + sllx %o1, %g1, %g1 + or %g1, %l0, %g1 + ldx [%i0+24], %o7 + sub %g0, %g5, %g5 + xor %o7, %g4, %g4 + stx %g1, [%i0+16] + srax %o1, %l2, %g3 + mov -1, %g1 + or %g2, %g3, %g2 + sllx %g1, %g5, %g1 + stx %g2, [%i0+8] + and %g1, %g4, %g1 + xor %o7, %g1, %o7 + ba,pt %xcc, L(L38) + stx %o7, [%i0+24] +L(L81): + xnor %g0, %l4, %g2 + ldx [%i0], %g3 + mov 2, %g1 + cmp %g4, 32 + sllx %g1, %g2, %g1 + srax %o0, %l4, %g2 + add %g1, -1, %g1 + xor %g3, %g2, %g2 + and %g1, %g2, %g1 + xor %g3, %g1, %g3 + bgu,pt %xcc, L(L85) + stx %g3, [%i0] + sllx %g5, 2, %g2 + mov 32, %g1 + sub %g1, %g2, %g1 + ldx [%i0+24], %l0 + sllx %g4, 3, %l1 + sllx %o0, %g1, %g3 + sllx %o1, %g1, %g4 + sllx %g3, %g1, %g3 + sllx %g4, %g1, %g4 + sllx %o2, %g1, %g2 + srax %o3, %l4, %l2 + sllx %g2, %g1, %g2 + sub %g0, %l1, %l1 + or %g2, %l2, %g2 + srax %o1, %l4, %g5 + xor %l0, %g2, %g2 + or %g3, %g5, %g3 + srax %o2, %l4, %o7 + mov -1, %g1 + or %g4, %o7, %g4 + sllx %g1, %l1, %g1 + stx %g3, [%i0+8] + and %g1, %g2, %g1 + stx %g4, [%i0+16] + xor %l0, %g1, %l0 + ba,pt %xcc, L(L38) + stx %l0, [%i0+24] +L(L85): + srax %o3, %l4, %l2 + mov 64, %g1 + sub %g1, %l4, %g1 + sllx %o3, %g1, %o7 + sllx %o0, %g1, %g2 + sllx %o1, %g1, %g3 + sllx %o2, %g1, %g1 + or %g1, %l2, %g1 + ldx [%i0+32], %l0 + sllx %g4, 3, %l1 + xor %l0, %o7, %o7 + sub %g0, %l1, %l1 + stx %g1, [%i0+24] + srax %o1, %l4, %g4 + srax %o2, %l4, %g5 + or %g2, %g4, %g2 + or %g3, %g5, %g3 + mov -1, %g1 + stx %g2, [%i0+8] + sllx %g1, %l1, %g1 + stx %g3, [%i0+16] + and %g1, %o7, %g1 + xor %l0, %g1, %l0 + ba,pt %xcc, L(L38) + stx %l0, [%i0+32] + FUNEND(avcall_call) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/avcall/avcall-sparc64.c b/avcall/avcall-sparc64.c new file mode 100644 index 0000000..6a911da --- /dev/null +++ b/avcall/avcall-sparc64.c @@ -0,0 +1,521 @@ +/** + Copyright 1993 Bill Triggs + Copyright 1995-2017 Bruno Haible + + 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, see . +**/ +/*---------------------------------------------------------------------- + !!! THIS ROUTINE MUST BE COMPILED gcc -O !!! + + Foreign function interface for a Sparc v9 in 64-bit mode with gcc. + + This calls a C function with an argument list built up using macros + defined in avcall.h. + + Sparc 64-bit Argument Passing Conventions + + The argument registers are laid out as an array of 16 elements + and arguments are added sequentially. The first 6 int args and up to the + first 16 fp args (depending on size) are passed in regs. + + Slot Stack Integral Float Float in structure Double Long Double + ---- ----- -------- ----- ------------------ ------ ----------- + 15 [SP+248] %f31 %f30,%f31 %d30 + 14 [SP+240] %f29 %f28,%f29 %d28 %q28 + 13 [SP+232] %f27 %f26,%f27 %d26 + 12 [SP+224] %f25 %f24,%f25 %d24 %q24 + 11 [SP+216] %f23 %f22,%f23 %d22 + 10 [SP+208] %f21 %f20,%f21 %d20 %q20 + 9 [SP+200] %f19 %f18,%f19 %d18 + 8 [SP+192] %f17 %f16,%f17 %d16 %q16 + 7 [SP+184] %f15 %f14,%f15 %d14 + 6 [SP+176] %f13 %f12,%f13 %d12 %q12 + 5 [SP+168] %o5 %f11 %f10,%f11 %d10 + 4 [SP+160] %o4 %f9 %f8,%f9 %d8 %q8 + 3 [SP+152] %o3 %f7 %f6,%f7 %d6 + 2 [SP+144] %o2 %f5 %f4,%f5 %d4 %q4 + 1 [SP+136] %o1 %f3 %f2,%f3 %d2 + 0 [SP+128] %o0 %f1 %f0,%f1 %d0 %q0 + + Here SP = %sp if -mno-stack-bias or %sp+stack_bias otherwise. + + Integral arguments are always passed as 64 bit quantities appropriately + extended. + + Passing of floating point values is handled as follows. + If a prototype is in scope: + If the value is in a named argument (i.e. not a stdarg function or a + value not part of the ‘...’) then the value is passed in the appropriate + fp reg. + If the value is part of the ‘...’ and is passed in one of the first 6 + slots then the value is passed in the appropriate int reg. + If the value is part of the ‘...’ and is not passed in one of the first 6 + slots then the value is passed in memory. + If a prototype is not in scope: + If the value is one of the first 6 arguments the value is passed in the + appropriate integer reg and the appropriate fp reg. + If the value is not one of the first 6 arguments the value is passed in + the appropriate fp reg and in memory. + + Remaining arguments are pushed onto the stack starting at a fixed offset + Space is left on the stack frame for temporary storage of the register + arguments as well. + + Integers shorter than ‘long’ are always promoted to word-length + (zero-extended or sign-extended, according to their type). Structures + <= 16 bytes are passed embedded in the argument sequence; bigger structures + are passed by reference. + + Integers and pointers are returned in o0, floats in f0, doubles in + f0/f1. If the function returns a structure a pointer to space + allocated by the caller is pushed onto the stack immediately + before the function arguments. Structures <= 32 bytes are returned in + registers (integer/float/double registers, as appropriate). + + Long doubles are 16-byte aligned, but we don't deal with this here, so + we assume 8-byte alignment for everything. + + ----------------------------------------------------------------------*/ +#include "avcall-internal.h" + +#define RETURN(TYPE,VAL) (*(TYPE*)l->raddr = (TYPE)(VAL)) +#define OFFSETOF(struct,member) ((int)&(((struct*)0)->member)) + +register __avword o0 __asm__("%o0"); +register __avword o1 __asm__("%o1"); +register __avword o2 __asm__("%o2"); +register __avword o3 __asm__("%o3"); +register __avword o4 __asm__("%o4"); +register __avword o5 __asm__("%o5"); + +int +avcall_call(av_alist* list) +{ + register __avword* sp __asm__("%sp"); /* C names for registers */ + register float fret __asm__("%f0"); /* %f0 */ + register double dret __asm__("%f0"); /* %f0,%f1 */ + + __av_alist* l = &AV_LIST_INNER(list); + + __avword trampoline[6]; /* room for a trampoline */ + int arglen = l->aptr - l->args; + __avword iret; + + if (l->darg_mask) { + /* push leading float/double args */ + __avword* a = l->args; + if (l->darg_mask & (1<<0)) + __asm__("ldd [%0+%1],%%f0" : : "p" (a), "i" (0 * sizeof (__avword))); + if (l->darg_mask & (1<<1)) + __asm__("ldd [%0+%1],%%f2" : : "p" (a), "i" (1 * sizeof (__avword))); + if (l->darg_mask & (1<<2)) + __asm__("ldd [%0+%1],%%f4" : : "p" (a), "i" (2 * sizeof (__avword))); + if (l->darg_mask & (1<<3)) + __asm__("ldd [%0+%1],%%f6" : : "p" (a), "i" (3 * sizeof (__avword))); + if (l->darg_mask & (1<<4)) + __asm__("ldd [%0+%1],%%f8" : : "p" (a), "i" (4 * sizeof (__avword))); + if (l->darg_mask & (1<<5)) + __asm__("ldd [%0+%1],%%f10" : : "p" (a), "i" (5 * sizeof (__avword))); + if (l->darg_mask & (1<<6)) + __asm__("ldd [%0+%1],%%f12" : : "p" (a), "i" (6 * sizeof (__avword))); + if (l->darg_mask & (1<<7)) + __asm__("ldd [%0+%1],%%f14" : : "p" (a), "i" (7 * sizeof (__avword))); + if (l->darg_mask & (1<<8)) + __asm__("ldd [%0+%1],%%f16" : : "p" (a), "i" (8 * sizeof (__avword))); + if (l->darg_mask & (1<<9)) + __asm__("ldd [%0+%1],%%f18" : : "p" (a), "i" (9 * sizeof (__avword))); + if (l->darg_mask & (1<<10)) + __asm__("ldd [%0+%1],%%f20" : : "p" (a), "i" (10 * sizeof (__avword))); + if (l->darg_mask & (1<<11)) + __asm__("ldd [%0+%1],%%f22" : : "p" (a), "i" (11 * sizeof (__avword))); + if (l->darg_mask & (1<<12)) + __asm__("ldd [%0+%1],%%f24" : : "p" (a), "i" (12 * sizeof (__avword))); + if (l->darg_mask & (1<<13)) + __asm__("ldd [%0+%1],%%f26" : : "p" (a), "i" (13 * sizeof (__avword))); + if (l->darg_mask & (1<<14)) + __asm__("ldd [%0+%1],%%f28" : : "p" (a), "i" (14 * sizeof (__avword))); + if (l->darg_mask & (1<<15)) + __asm__("ldd [%0+%1],%%f30" : : "p" (a), "i" (15 * sizeof (__avword))); + } + + if (arglen > 6) { + /* alloca space is separated from the extra outgoing args area by + * the area for compiler temps (addressable with postive offsets from sp) + * but they shouldn't be needed for this function, so, effectively, + * space returned by alloca is safe to use as the area for extra args. + */ + void *extra_args_area = __builtin_alloca(sizeof(__avword) * (arglen - 6)); + __avword *argframe = (__avword *)extra_args_area - 6; +#if 0 + /* "by construction" */ + assert(argframe == (void *)((unsigned long)(sp + 16)+2047)); +#endif + + int i; + for (i = 6; i < arglen; i++) /* push excess function args */ + argframe[i] = l->args[i]; + } + + /* call function with 1st 6 args */ + iret = ({ register __avword iretreg __asm__ ("%o0"); + iretreg = (*l->func)(l->args[0], l->args[1], l->args[2], + l->args[3], l->args[4], l->args[5]); + asm __volatile__("nop"); /* struct returning functions skip this instruction */ + iretreg; + }); + + /* save return value */ + if (l->rtype == __AVvoid) { + } else + if (l->rtype == __AVword) { + RETURN(__avword, iret); + } else + if (l->rtype == __AVchar) { + RETURN(char, iret); + } else + if (l->rtype == __AVschar) { + RETURN(signed char, iret); + } else + if (l->rtype == __AVuchar) { + RETURN(unsigned char, iret); + } else + if (l->rtype == __AVshort) { + RETURN(short, iret); + } else + if (l->rtype == __AVushort) { + RETURN(unsigned short, iret); + } else + if (l->rtype == __AVint) { + RETURN(int, iret); + } else + if (l->rtype == __AVuint) { + RETURN(unsigned int, iret); + } else + if (l->rtype == __AVlong) { + RETURN(long, iret); + } else + if (l->rtype == __AVulong) { + RETURN(unsigned long, iret); + } else + if (l->rtype == __AVlonglong) { + RETURN(long long, iret); + } else + if (l->rtype == __AVulonglong) { + RETURN(unsigned long long, iret); + } else + if (l->rtype == __AVfloat) { + RETURN(float, fret); + } else + if (l->rtype == __AVdouble) { + RETURN(double, dret); + } else + if (l->rtype == __AVvoidp) { + RETURN(void*, iret); + } else + if (l->rtype == __AVstruct) { + if (l->flags & __AV_REGISTER_STRUCT_RETURN) { + /* Return structs of size <= 32 in registers. */ + #define iret2 o1 + #define iret3 o2 + #define iret4 o3 + if (l->rsize > 0 && l->rsize <= 32) { + void* raddr = l->raddr; + #if 0 /* Unoptimized */ + if (l->rsize == 1) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + } else + if (l->rsize == 2) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>48); + } else + if (l->rsize == 3) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>40); + } else + if (l->rsize == 4) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>32); + } else + if (l->rsize == 5) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>24); + } else + if (l->rsize == 6) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>16); + } else + if (l->rsize == 7) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[6] = (unsigned char)(iret>>8); + } else + if (l->rsize >= 8 && l->rsize <= 32) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret>>56); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[6] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[7] = (unsigned char)(iret); + if (l->rsize == 8) { + } else + if (l->rsize == 9) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + } else + if (l->rsize == 10) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>48); + } else + if (l->rsize == 11) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>40); + } else + if (l->rsize == 12) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>32); + } else + if (l->rsize == 13) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>24); + } else + if (l->rsize == 14) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>16); + } else + if (l->rsize == 15) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+6] = (unsigned char)(iret2>>8); + } else + if (l->rsize >= 16 && l->rsize <= 32) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2>>56); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+6] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+7] = (unsigned char)(iret2); + if (l->rsize == 16) { + } else + if (l->rsize == 17) { + ((unsigned char *)raddr)[16+0] = (unsigned char)(iret3>>56); + } else + if (l->rsize == 18) { + ((unsigned char *)raddr)[16+0] = (unsigned char)(iret3>>56); + ((unsigned char *)raddr)[16+1] = (unsigned char)(iret3>>48); + } else + if (l->rsize == 19) { + ((unsigned char *)raddr)[16+0] = (unsigned char)(iret3>>56); + ((unsigned char *)raddr)[16+1] = (unsigned char)(iret3>>48); + ((unsigned char *)raddr)[16+2] = (unsigned char)(iret3>>40); + } else + if (l->rsize == 20) { + ((unsigned char *)raddr)[16+0] = (unsigned char)(iret3>>56); + ((unsigned char *)raddr)[16+1] = (unsigned char)(iret3>>48); + ((unsigned char *)raddr)[16+2] = (unsigned char)(iret3>>40); + ((unsigned char *)raddr)[16+3] = (unsigned char)(iret3>>32); + } else + if (l->rsize == 21) { + ((unsigned char *)raddr)[16+0] = (unsigned char)(iret3>>56); + ((unsigned char *)raddr)[16+1] = (unsigned char)(iret3>>48); + ((unsigned char *)raddr)[16+2] = (unsigned char)(iret3>>40); + ((unsigned char *)raddr)[16+3] = (unsigned char)(iret3>>32); + ((unsigned char *)raddr)[16+4] = (unsigned char)(iret3>>24); + } else + if (l->rsize == 22) { + ((unsigned char *)raddr)[16+0] = (unsigned char)(iret3>>56); + ((unsigned char *)raddr)[16+1] = (unsigned char)(iret3>>48); + ((unsigned char *)raddr)[16+2] = (unsigned char)(iret3>>40); + ((unsigned char *)raddr)[16+3] = (unsigned char)(iret3>>32); + ((unsigned char *)raddr)[16+4] = (unsigned char)(iret3>>24); + ((unsigned char *)raddr)[16+5] = (unsigned char)(iret3>>16); + } else + if (l->rsize == 23) { + ((unsigned char *)raddr)[16+0] = (unsigned char)(iret3>>56); + ((unsigned char *)raddr)[16+1] = (unsigned char)(iret3>>48); + ((unsigned char *)raddr)[16+2] = (unsigned char)(iret3>>40); + ((unsigned char *)raddr)[16+3] = (unsigned char)(iret3>>32); + ((unsigned char *)raddr)[16+4] = (unsigned char)(iret3>>24); + ((unsigned char *)raddr)[16+5] = (unsigned char)(iret3>>16); + ((unsigned char *)raddr)[16+6] = (unsigned char)(iret3>>8); + } else + if (l->rsize >= 24 && l->rsize <= 32) { + ((unsigned char *)raddr)[16+0] = (unsigned char)(iret3>>56); + ((unsigned char *)raddr)[16+1] = (unsigned char)(iret3>>48); + ((unsigned char *)raddr)[16+2] = (unsigned char)(iret3>>40); + ((unsigned char *)raddr)[16+3] = (unsigned char)(iret3>>32); + ((unsigned char *)raddr)[16+4] = (unsigned char)(iret3>>24); + ((unsigned char *)raddr)[16+5] = (unsigned char)(iret3>>16); + ((unsigned char *)raddr)[16+6] = (unsigned char)(iret3>>8); + ((unsigned char *)raddr)[16+7] = (unsigned char)(iret3); + if (l->rsize == 24) { + } else + if (l->rsize == 25) { + ((unsigned char *)raddr)[24+0] = (unsigned char)(iret4>>56); + } else + if (l->rsize == 26) { + ((unsigned char *)raddr)[24+0] = (unsigned char)(iret4>>56); + ((unsigned char *)raddr)[24+1] = (unsigned char)(iret4>>48); + } else + if (l->rsize == 27) { + ((unsigned char *)raddr)[24+0] = (unsigned char)(iret4>>56); + ((unsigned char *)raddr)[24+1] = (unsigned char)(iret4>>48); + ((unsigned char *)raddr)[24+2] = (unsigned char)(iret4>>40); + } else + if (l->rsize == 28) { + ((unsigned char *)raddr)[24+0] = (unsigned char)(iret4>>56); + ((unsigned char *)raddr)[24+1] = (unsigned char)(iret4>>48); + ((unsigned char *)raddr)[24+2] = (unsigned char)(iret4>>40); + ((unsigned char *)raddr)[24+3] = (unsigned char)(iret4>>32); + } else + if (l->rsize == 29) { + ((unsigned char *)raddr)[24+0] = (unsigned char)(iret4>>56); + ((unsigned char *)raddr)[24+1] = (unsigned char)(iret4>>48); + ((unsigned char *)raddr)[24+2] = (unsigned char)(iret4>>40); + ((unsigned char *)raddr)[24+3] = (unsigned char)(iret4>>32); + ((unsigned char *)raddr)[24+4] = (unsigned char)(iret4>>24); + } else + if (l->rsize == 30) { + ((unsigned char *)raddr)[24+0] = (unsigned char)(iret4>>56); + ((unsigned char *)raddr)[24+1] = (unsigned char)(iret4>>48); + ((unsigned char *)raddr)[24+2] = (unsigned char)(iret4>>40); + ((unsigned char *)raddr)[24+3] = (unsigned char)(iret4>>32); + ((unsigned char *)raddr)[24+4] = (unsigned char)(iret4>>24); + ((unsigned char *)raddr)[24+5] = (unsigned char)(iret4>>16); + } else + if (l->rsize == 31) { + ((unsigned char *)raddr)[24+0] = (unsigned char)(iret4>>56); + ((unsigned char *)raddr)[24+1] = (unsigned char)(iret4>>48); + ((unsigned char *)raddr)[24+2] = (unsigned char)(iret4>>40); + ((unsigned char *)raddr)[24+3] = (unsigned char)(iret4>>32); + ((unsigned char *)raddr)[24+4] = (unsigned char)(iret4>>24); + ((unsigned char *)raddr)[24+5] = (unsigned char)(iret4>>16); + ((unsigned char *)raddr)[24+6] = (unsigned char)(iret4>>8); + } else + if (l->rsize == 32) { + ((unsigned char *)raddr)[24+0] = (unsigned char)(iret4>>56); + ((unsigned char *)raddr)[24+1] = (unsigned char)(iret4>>48); + ((unsigned char *)raddr)[24+2] = (unsigned char)(iret4>>40); + ((unsigned char *)raddr)[24+3] = (unsigned char)(iret4>>32); + ((unsigned char *)raddr)[24+4] = (unsigned char)(iret4>>24); + ((unsigned char *)raddr)[24+5] = (unsigned char)(iret4>>16); + ((unsigned char *)raddr)[24+6] = (unsigned char)(iret4>>8); + ((unsigned char *)raddr)[24+7] = (unsigned char)(iret4); + } + } + } + } + #else /* Optimized: fewer conditional jumps, fewer memory accesses */ + uintptr_t count = l->rsize; /* > 0, ≤ 4*sizeof(__avword) */ + __avword* wordaddr = (__avword*)((uintptr_t)raddr & ~(uintptr_t)(sizeof(__avword)-1)); + uintptr_t start_offset = (uintptr_t)raddr & (uintptr_t)(sizeof(__avword)-1); /* ≥ 0, < sizeof(__avword) */ + uintptr_t end_offset = start_offset + count; /* > 0, < 5*sizeof(__avword) */ + if (count <= sizeof(__avword)) { + /* Use iret. */ + if (end_offset <= sizeof(__avword)) { + /* 0 < end_offset ≤ sizeof(__avword) */ + __avword mask0 = ((__avword)2 << (sizeof(__avword)*8-start_offset*8-1)) - ((__avword)1 << (sizeof(__avword)*8-end_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret >> (start_offset*8))) & mask0; + } else { + /* sizeof(__avword) < end_offset < 2*sizeof(__avword), start_offset > 0 */ + __avword mask0 = ((__avword)2 << (sizeof(__avword)*8-start_offset*8-1)) - 1; + __avword mask1 = - ((__avword)1 << (2*sizeof(__avword)*8-end_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret >> (start_offset*8))) & mask0; + wordaddr[1] ^= (wordaddr[1] ^ (iret << (sizeof(__avword)*8-start_offset*8))) & mask1; + } + } else if (count <= 2*sizeof(__avword)) { + /* Use iret, iret2. */ + __avword mask0 = ((__avword)2 << (sizeof(__avword)*8-start_offset*8-1)) - 1; + wordaddr[0] ^= (wordaddr[0] ^ (iret >> (start_offset*8))) & mask0; + if (end_offset <= 2*sizeof(__avword)) { + /* sizeof(__avword) < end_offset ≤ 2*sizeof(__avword) */ + __avword mask1 = - ((__avword)1 << (2*sizeof(__avword)*8-end_offset*8)); + wordaddr[1] ^= (wordaddr[1] ^ ((iret << (sizeof(__avword)*4-start_offset*4) << (sizeof(__avword)*4-start_offset*4)) | (iret2 >> (start_offset*8)))) & mask1; + } else { + /* 2*sizeof(__avword) < end_offset < 3*sizeof(__avword), start_offset > 0 */ + __avword mask2 = - ((__avword)1 << (3*sizeof(__avword)*8-end_offset*8)); + wordaddr[1] = (iret << (sizeof(__avword)*8-start_offset*8)) | (iret2 >> (start_offset*8)); + wordaddr[2] ^= (wordaddr[2] ^ (iret2 << (sizeof(__avword)*8-start_offset*8))) & mask2; + } + } else if (count <= 3*sizeof(__avword)) { + /* Use iret, iret2, iret3. */ + __avword mask0 = ((__avword)2 << (sizeof(__avword)*8-start_offset*8-1)) - 1; + wordaddr[0] ^= (wordaddr[0] ^ (iret >> (start_offset*8))) & mask0; + if (end_offset <= 3*sizeof(__avword)) { + /* 2*sizeof(__avword) < end_offset ≤ 3*sizeof(__avword) */ + __avword mask2 = - ((__avword)1 << (3*sizeof(__avword)*8-end_offset*8)); + wordaddr[1] = (iret << (sizeof(__avword)*4-start_offset*4) << (sizeof(__avword)*4-start_offset*4)) | (iret2 >> (start_offset*8)); + wordaddr[2] ^= (wordaddr[2] ^ ((iret2 << (sizeof(__avword)*4-start_offset*4) << (sizeof(__avword)*4-start_offset*4)) | (iret3 >> (start_offset*8)))) & mask2; + } else { + /* 3*sizeof(__avword) < end_offset < 4*sizeof(__avword), start_offset > 0 */ + __avword mask3 = - ((__avword)1 << (4*sizeof(__avword)*8-end_offset*8)); + wordaddr[1] = (iret << (sizeof(__avword)*8-start_offset*8)) | (iret2 >> (start_offset*8)); + wordaddr[2] = (iret2 << (sizeof(__avword)*8-start_offset*8)) | (iret3 >> (start_offset*8)); + wordaddr[3] ^= (wordaddr[3] ^ (iret3 << (sizeof(__avword)*8-start_offset*8))) & mask3; + } + } else { + /* Use iret, iret2, iret3, iret4. */ + __avword mask0 = ((__avword)2 << (sizeof(__avword)*8-start_offset*8-1)) - 1; + wordaddr[0] ^= (wordaddr[0] ^ (iret >> (start_offset*8))) & mask0; + if (end_offset <= 4*sizeof(__avword)) { + /* 3*sizeof(__avword) < end_offset ≤ 4*sizeof(__avword) */ + __avword mask3 = - ((__avword)1 << (4*sizeof(__avword)*8-end_offset*8)); + wordaddr[1] = (iret << (sizeof(__avword)*4-start_offset*4) << (sizeof(__avword)*4-start_offset*4)) | (iret2 >> (start_offset*8)); + wordaddr[2] = (iret2 << (sizeof(__avword)*4-start_offset*4) << (sizeof(__avword)*4-start_offset*4)) | (iret3 >> (start_offset*8)); + wordaddr[3] ^= (wordaddr[3] ^ ((iret3 << (sizeof(__avword)*4-start_offset*4) << (sizeof(__avword)*4-start_offset*4)) | (iret4 >> (start_offset*8)))) & mask3; + } else { + /* 4*sizeof(__avword) < end_offset < 5*sizeof(__avword), start_offset > 0 */ + __avword mask4 = - ((__avword)1 << (5*sizeof(__avword)*8-end_offset*8)); + wordaddr[1] = (iret << (sizeof(__avword)*8-start_offset*8)) | (iret2 >> (start_offset*8)); + wordaddr[2] = (iret2 << (sizeof(__avword)*8-start_offset*8)) | (iret3 >> (start_offset*8)); + wordaddr[3] = (iret3 << (sizeof(__avword)*8-start_offset*8)) | (iret4 >> (start_offset*8)); + wordaddr[4] ^= (wordaddr[4] ^ (iret4 << (sizeof(__avword)*8-start_offset*8))) & mask4; + } + } + #endif + } + } + } + return 0; +} diff --git a/avcall/avcall-structcpy.c b/avcall/avcall-structcpy.c new file mode 100644 index 0000000..4b41bb5 --- /dev/null +++ b/avcall/avcall-structcpy.c @@ -0,0 +1,22 @@ +/* copy structs */ + +/* + * Copyright 2016 Bruno Haible + * + * 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, see . + */ + +#define __structcpy avcall_structcpy + +#include "structcpy.c" diff --git a/avcall/avcall-x86_64-linux.s b/avcall/avcall-x86_64-linux.s new file mode 100644 index 0000000..5111dbd --- /dev/null +++ b/avcall/avcall-x86_64-linux.s @@ -0,0 +1,647 @@ + .file "avcall-x86_64.c" + .text + .p2align 4,,15 +.globl avcall_call + .type avcall_call, @function +avcall_call: +.LFB2: + pushq %rbp +.LCFI0: + movq %rsp, %rbp +.LCFI1: + pushq %r13 +.LCFI2: + pushq %r12 +.LCFI3: + pushq %rbx +.LCFI4: + movq %rdi, %rbx + leaq 128(%rbx), %rdx + subq $2072, %rsp +.LCFI5: + movq 40(%rdi), %rax + movq 48(%rdi), %r8 + leaq 15(%rsp), %rsi + subq %r8, %rax + andq $-16, %rsi + movq %rax, %rdi + movq 120(%rbx), %rax + shrq $3, %rdi + subq %rdx, %rax + movq %rax, %r9 + shrq $3, %r9 + testl %edi, %edi + jle .L2 + xorl %ecx, %ecx + xorl %edx, %edx + .p2align 4,,7 +.L4: + movq (%rdx,%r8), %rax + incl %ecx + movq %rax, (%rsi,%rdx) + addq $8, %rdx + cmpl %ecx, %edi + jne .L4 +.L2: + movl 24(%rbx), %eax + cmpl $13, %eax + je .L127 + cmpl $14, %eax + je .L128 + cmpl $7, %r9d + movq 8(%rbx), %r12 + jle .L58 + movlpd 184(%rbx), %xmm10 +.L60: + movq 176(%rbx), %r9 +.L63: + movq 168(%rbx), %r11 +.L66: + movq 160(%rbx), %r10 +.L69: + movlpd 152(%rbx), %xmm8 +.L72: + movq 144(%rbx), %rax +.L75: + movq 136(%rbx), %r8 +.L78: + movlpd 128(%rbx), %xmm9 +.L81: + movq 88(%rbx), %rdx + movq 96(%rbx), %rcx + movsd %xmm10, %xmm7 + movq 80(%rbx), %rsi + movq 72(%rbx), %rdi + movsd %xmm8, %xmm3 + movq %r9, -32(%rbp) + movsd %xmm9, %xmm0 + movlpd -32(%rbp), %xmm6 + movq %r11, -32(%rbp) + movlpd -32(%rbp), %xmm5 + movq %r10, -32(%rbp) + movlpd -32(%rbp), %xmm4 + movq %rax, -32(%rbp) + movl $8, %eax + movlpd -32(%rbp), %xmm2 + movq %r8, -32(%rbp) + movlpd -32(%rbp), %xmm1 + movq 112(%rbx), %r9 + movq 104(%rbx), %r8 + call *%r12 + movq %rax, %r8 + movl 24(%rbx), %eax + movq %rdx, %r9 + cmpl $1, %eax + je .L31 + testl %eax, %eax + je .L125 + cmpl $2, %eax + je .L122 + cmpl $3, %eax + .p2align 4,,5 + je .L122 + cmpl $4, %eax + .p2align 4,,5 + je .L122 + cmpl $5, %eax + .p2align 4,,5 + je .L123 + cmpl $6, %eax + .p2align 4,,5 + je .L123 + cmpl $7, %eax + .p2align 4,,5 + je .L124 + cmpl $8, %eax + .p2align 4,,5 + je .L124 + cmpl $9, %eax + .p2align 4,,5 + je .L125 + cmpl $10, %eax + .p2align 4,,5 + je .L125 + cmpl $11, %eax + .p2align 4,,5 + je .L125 + cmpl $12, %eax + .p2align 4,,5 + je .L125 + cmpl $15, %eax + .p2align 4,,5 + je .L125 + cmpl $16, %eax + .p2align 4,,5 + jne .L31 + testb $2, 1(%rbx) + .p2align 4,,5 + je .L31 + movq 32(%rbx), %rdx + leaq -1(%rdx), %rax + cmpq $15, %rax + ja .L31 + movq 16(%rbx), %rax + movq %rax, %r10 + movq %rax, %rdi + andl $7, %edi + andq $-8, %r10 + cmpq $8, %rdx + leaq (%rdx,%rdi), %r11 + ja .L112 + cmpq $8, %r11 + ja .L114 + leal -1(,%r11,8), %ecx + movq (%r10), %rsi + sall $3, %edi + movl $2, %edx + movl $1, %eax + salq %cl, %rdx + movl %edi, %ecx + salq %cl, %rax + salq %cl, %r8 + xorq %rsi, %r8 + subq %rax, %rdx + andq %r8, %rdx + xorq %rdx, %rsi + movq %rsi, (%r10) +.L31: + leaq -24(%rbp), %rsp + xorl %eax, %eax + popq %rbx + popq %r12 + popq %r13 + leave + ret +.L58: + je .L129 + cmpl $5, %r9d + jle .L64 + xorl %r9d, %r9d + movq %r9, -32(%rbp) + movlpd -32(%rbp), %xmm10 + .p2align 4,,3 + jmp .L63 +.L127: + cmpl $7, %r9d + movq 16(%rbx), %r13 + movq 8(%rbx), %r12 + jle .L7 + movlpd 184(%rbx), %xmm10 +.L9: + movq 176(%rbx), %r9 +.L12: + movq 168(%rbx), %r11 +.L15: + movq 160(%rbx), %r10 +.L18: + movlpd 152(%rbx), %xmm8 +.L21: + movq 144(%rbx), %rax +.L24: + movq 136(%rbx), %r8 +.L27: + movlpd 128(%rbx), %xmm9 +.L30: + movq 96(%rbx), %rcx + movq 88(%rbx), %rdx + movsd %xmm10, %xmm7 + movq 80(%rbx), %rsi + movq 72(%rbx), %rdi + movsd %xmm8, %xmm3 + movq %r9, -32(%rbp) + movsd %xmm9, %xmm0 + movlpd -32(%rbp), %xmm6 + movq %r11, -32(%rbp) + movlpd -32(%rbp), %xmm5 + movq %r10, -32(%rbp) + movlpd -32(%rbp), %xmm4 + movq %rax, -32(%rbp) + movl $8, %eax + movlpd -32(%rbp), %xmm2 + movq %r8, -32(%rbp) + movlpd -32(%rbp), %xmm1 + movq 112(%rbx), %r9 + movq 104(%rbx), %r8 + call *%r12 + movss %xmm0, (%r13) + leaq -24(%rbp), %rsp + xorl %eax, %eax + popq %rbx + popq %r12 + popq %r13 + leave + ret +.L125: + movq 16(%rbx), %rax + movq %r8, (%rax) + leaq -24(%rbp), %rsp + xorl %eax, %eax + popq %rbx + popq %r12 + popq %r13 + leave + ret +.L128: + cmpl $7, %r9d + movq 16(%rbx), %r13 + movq 8(%rbx), %r12 + jle .L34 + movlpd 184(%rbx), %xmm10 +.L36: + movq 176(%rbx), %r10 +.L39: + movq 168(%rbx), %r11 +.L42: + movq 160(%rbx), %r9 +.L45: + movlpd 152(%rbx), %xmm8 +.L48: + movq 144(%rbx), %rax +.L51: + movq 136(%rbx), %r8 +.L54: + movlpd 128(%rbx), %xmm9 +.L57: + movq 96(%rbx), %rcx + movq 88(%rbx), %rdx + movsd %xmm10, %xmm7 + movq 80(%rbx), %rsi + movq 72(%rbx), %rdi + movsd %xmm8, %xmm3 + movq %r10, -32(%rbp) + movsd %xmm9, %xmm0 + movlpd -32(%rbp), %xmm6 + movq %r11, -32(%rbp) + movlpd -32(%rbp), %xmm5 + movq %r9, -32(%rbp) + movlpd -32(%rbp), %xmm4 + movq %rax, -32(%rbp) + movl $8, %eax + movlpd -32(%rbp), %xmm2 + movq %r8, -32(%rbp) + movlpd -32(%rbp), %xmm1 + movq 112(%rbx), %r9 + movq 104(%rbx), %r8 + call *%r12 + movsd %xmm0, (%r13) + leaq -24(%rbp), %rsp + xorl %eax, %eax + popq %rbx + popq %r12 + popq %r13 + leave + ret +.L7: + jne .L10 + xorpd %xmm10, %xmm10 + jmp .L9 +.L129: + xorpd %xmm10, %xmm10 + .p2align 4,,7 + jmp .L60 +.L34: + .p2align 4,,7 + jne .L37 + xorpd %xmm10, %xmm10 + .p2align 4,,7 + jmp .L36 +.L122: + movq 16(%rbx), %rax + movb %r8b, (%rax) + leaq -24(%rbp), %rsp + xorl %eax, %eax + popq %rbx + popq %r12 + popq %r13 + leave + ret +.L10: + cmpl $5, %r9d + jg .L130 + jne .L16 + xorl %r9d, %r9d + movq %r9, -32(%rbp) + movq %r9, %r11 + movlpd -32(%rbp), %xmm10 + jmp .L15 +.L64: + .p2align 4,,3 + je .L131 + cmpl $3, %r9d + jle .L70 + xorl %r9d, %r9d + movq %r9, -32(%rbp) + movq %r9, %r10 + movq %r9, %r11 + movlpd -32(%rbp), %xmm10 + jmp .L69 +.L37: + cmpl $5, %r9d + jg .L132 + jne .L43 + xorl %r10d, %r10d + movq %r10, -32(%rbp) + movq %r10, %r11 + movlpd -32(%rbp), %xmm10 + jmp .L42 +.L130: + xorl %r9d, %r9d + movq %r9, -32(%rbp) + movlpd -32(%rbp), %xmm10 + jmp .L12 +.L131: + xorl %r9d, %r9d + movq %r9, -32(%rbp) + movq %r9, %r11 + movlpd -32(%rbp), %xmm10 + jmp .L66 +.L132: + xorl %r10d, %r10d + movq %r10, -32(%rbp) + movlpd -32(%rbp), %xmm10 + jmp .L39 +.L123: + movq 16(%rbx), %rax + movw %r8w, (%rax) + jmp .L31 +.L124: + movq 16(%rbx), %rax + movl %r8d, (%rax) + jmp .L31 +.L16: + cmpl $3, %r9d + jle .L19 + xorl %r9d, %r9d + movq %r9, -32(%rbp) + movq %r9, %r10 + movq %r9, %r11 + movlpd -32(%rbp), %xmm10 + jmp .L18 +.L70: + jne .L73 + xorl %r9d, %r9d + movq %r9, -32(%rbp) + movq %r9, %r10 + movq %r9, %r11 + movlpd -32(%rbp), %xmm10 + movsd %xmm10, %xmm8 + jmp .L72 +.L43: + cmpl $3, %r9d + jle .L46 + xorl %r10d, %r10d + movq %r10, -32(%rbp) + movq %r10, %r9 + movq %r10, %r11 + movlpd -32(%rbp), %xmm10 + jmp .L45 +.L19: + jne .L22 + xorl %r9d, %r9d + movq %r9, -32(%rbp) + movq %r9, %r10 + movq %r9, %r11 + movlpd -32(%rbp), %xmm10 + movsd %xmm10, %xmm8 + jmp .L21 +.L73: + cmpl $1, %r9d + jle .L76 + xorl %r9d, %r9d + movq %r9, -32(%rbp) + movq %r9, %r10 + movq %r9, %r11 + movlpd -32(%rbp), %xmm10 + movq %r9, %rax + movsd %xmm10, %xmm8 + jmp .L75 +.L46: + jne .L49 + xorl %r10d, %r10d + movq %r10, -32(%rbp) + movq %r10, %r9 + movq %r10, %r11 + movlpd -32(%rbp), %xmm10 + movsd %xmm10, %xmm8 + jmp .L48 +.L22: + cmpl $1, %r9d + jle .L25 + xorl %r9d, %r9d + movq %r9, -32(%rbp) + movq %r9, %r10 + movq %r9, %r11 + movlpd -32(%rbp), %xmm10 + movq %r9, %rax + movsd %xmm10, %xmm8 + jmp .L24 +.L49: + cmpl $1, %r9d + jle .L52 + xorl %r10d, %r10d + movq %r10, -32(%rbp) + movq %r10, %r9 + movq %r10, %r11 + movlpd -32(%rbp), %xmm10 + movq %r10, %rax + movsd %xmm10, %xmm8 + jmp .L51 +.L76: + jne .L133 + xorl %r9d, %r9d + movq %r9, -32(%rbp) + movq %r9, %r10 + movq %r9, %r11 + movlpd -32(%rbp), %xmm10 + movq %r9, %rax + movq %r9, %r8 + movsd %xmm10, %xmm8 + jmp .L78 +.L25: + jne .L134 + xorl %r9d, %r9d + movq %r9, -32(%rbp) + movq %r9, %r10 + movq %r9, %r11 + movlpd -32(%rbp), %xmm10 + movq %r9, %rax + movq %r9, %r8 + movsd %xmm10, %xmm8 + jmp .L27 +.L112: + leaq 0(,%rdi,8), %r12 + movq (%r10), %rsi + movq %r8, %rax + movq $-1, %rdx + movl %r12d, %ecx + salq %cl, %rax + salq %cl, %rdx + xorq %rsi, %rax + andq %rax, %rdx + xorq %rdx, %rsi + cmpq $16, %r11 + movq %rsi, (%r10) + ja .L116 + leaq 0(,%rdi,4), %rax + leal -65(,%r11,8), %edx + movl $32, %edi + movq 8(%r10), %rsi + subl %eax, %edi + movl %edx, %ecx + movl $2, %eax + salq %cl, %rax + movl %edi, %ecx + sarq %cl, %r8 + decq %rax + sarq %cl, %r8 + movl %r12d, %ecx + salq %cl, %r9 + orq %r9, %r8 + xorq %rsi, %r8 + andq %r8, %rax + xorq %rax, %rsi + movq %rsi, 8(%r10) + jmp .L31 + .p2align 4,,7 +.L133: + xorpd %xmm9, %xmm9 + movsd %xmm9, -32(%rbp) + movq -32(%rbp), %r9 + movsd %xmm9, %xmm10 + movsd %xmm9, %xmm8 + movq %r9, %r11 + movq %r9, %r10 + movq %r9, %rax + movq %r9, %r8 + jmp .L81 +.L52: + jne .L135 + xorl %r10d, %r10d + movq %r10, -32(%rbp) + movq %r10, %r9 + movq %r10, %r11 + movlpd -32(%rbp), %xmm10 + movq %r10, %rax + movq %r10, %r8 + movsd %xmm10, %xmm8 + jmp .L54 +.L134: + xorpd %xmm9, %xmm9 + movsd %xmm9, -32(%rbp) + movq -32(%rbp), %r9 + movsd %xmm9, %xmm10 + movsd %xmm9, %xmm8 + movq %r9, %r11 + movq %r9, %r10 + movq %r9, %rax + movq %r9, %r8 + jmp .L30 +.L135: + xorpd %xmm9, %xmm9 + movsd %xmm9, -32(%rbp) + movq -32(%rbp), %r10 + movsd %xmm9, %xmm10 + movsd %xmm9, %xmm8 + movq %r10, %r11 + movq %r10, %r9 + movq %r10, %rax + movq %r10, %r8 + jmp .L57 +.L114: + leaq 0(,%rdi,8), %rsi + movq (%r10), %rdx + movq %r8, %rbx + movq $-1, %rax + movl %esi, %ecx + salq %cl, %rbx + salq %cl, %rax + movq %rbx, %rcx + xorq %rdx, %rcx + andq %rcx, %rax + leal -65(,%r11,8), %ecx + xorq %rax, %rdx + movl $2, %eax + salq %cl, %rax + movq %rdx, (%r10) + movl $64, %ecx + movq 8(%r10), %rdx + subl %esi, %ecx + decq %rax + sarq %cl, %r8 + xorq %rdx, %r8 + andq %r8, %rax + xorq %rax, %rdx + movq %rdx, 8(%r10) + jmp .L31 +.L116: + movl $64, %esi + movq %r9, %rax + movq 16(%r10), %rdx + subl %r12d, %esi + movl %esi, %ecx + sarq %cl, %r8 + movl %r12d, %ecx + salq %cl, %rax + leal -129(,%r11,8), %ecx + orq %r8, %rax + movq %rax, 8(%r10) + movl $2, %eax + salq %cl, %rax + movl %esi, %ecx + sarq %cl, %r9 + decq %rax + xorq %rdx, %r9 + andq %r9, %rax + xorq %rax, %rdx + movq %rdx, 16(%r10) + jmp .L31 +.LFE2: + .size avcall_call, .-avcall_call + .section .eh_frame,"a",@progbits +.Lframe1: + .long .LECIE1-.LSCIE1 +.LSCIE1: + .long 0x0 + .byte 0x1 + .string "zR" + .uleb128 0x1 + .sleb128 -8 + .byte 0x10 + .uleb128 0x1 + .byte 0x1b + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x90 + .uleb128 0x1 + .align 8 +.LECIE1: +.LSFDE1: + .long .LEFDE1-.LASFDE1 +.LASFDE1: + .long .LASFDE1-.Lframe1 + .long .LFB2-. + .long .LFE2-.LFB2 + .uleb128 0x0 + .byte 0x4 + .long .LCFI0-.LFB2 + .byte 0xe + .uleb128 0x10 + .byte 0x86 + .uleb128 0x2 + .byte 0x4 + .long .LCFI1-.LCFI0 + .byte 0xd + .uleb128 0x6 + .byte 0x4 + .long .LCFI4-.LCFI1 + .byte 0x83 + .uleb128 0x5 + .byte 0x8c + .uleb128 0x4 + .byte 0x8d + .uleb128 0x3 + .align 8 +.LEFDE1: + .ident "GCC: (GNU) 4.0.2" + .section .note.GNU-stack,"",@progbits diff --git a/avcall/avcall-x86_64-macro.S b/avcall/avcall-x86_64-macro.S new file mode 100644 index 0000000..f7c6688 --- /dev/null +++ b/avcall/avcall-x86_64-macro.S @@ -0,0 +1,650 @@ +#include "asm-x86_64.h" + TEXT() + P2ALIGN(4,15) +GLOBL(C(avcall_call)) + DECLARE_FUNCTION(avcall_call) +FUNBEGIN(avcall_call) +L(FB2): + INSN1(push,q ,R(rbp)) +L(CFI0): + INSN2(mov,q ,R(rsp), R(rbp)) +L(CFI1): + INSN1(push,q ,R(r13)) +L(CFI2): + INSN1(push,q ,R(r12)) +L(CFI3): + INSN1(push,q ,R(rbx)) +L(CFI4): + INSN2(mov,q ,R(rdi), R(rbx)) + INSN2(lea,q ,X8 MEM_DISP(rbx,128), R(rdx)) + INSN2(sub,q ,NUM(2072), R(rsp)) +L(CFI5): + INSN2(mov,q ,X8 MEM_DISP(rdi,40), R(rax)) + INSN2(mov,q ,X8 MEM_DISP(rdi,48), R(r8)) + INSN2(lea,q ,X8 MEM_DISP(rsp,15), R(rsi)) + INSN2(sub,q ,R(r8), R(rax)) + INSN2(and,q ,NUM(-16), R(rsi)) + INSN2(mov,q ,R(rax), R(rdi)) + INSN2(mov,q ,X8 MEM_DISP(rbx,120), R(rax)) + INSN2(shr,q ,NUM(3), R(rdi)) + INSN2(sub,q ,R(rdx), R(rax)) + INSN2(mov,q ,R(rax), R(r9)) + INSN2(shr,q ,NUM(3), R(r9)) + INSN2(test,l ,R(edi), R(edi)) + INSN1(jle,_ ,L(2)) + INSN2(xor,l ,R(ecx), R(ecx)) + INSN2(xor,l ,R(edx), R(edx)) + P2ALIGN(4,7) +L(4): + INSN2(mov,q ,X8 MEM_INDEX(rdx,r8), R(rax)) + INSN1(inc,l ,R(ecx)) + INSN2(mov,q ,R(rax),X8 MEM_INDEX(rsi,rdx)) + INSN2(add,q ,NUM(8), R(rdx)) + INSN2(cmp,l ,R(ecx), R(edi)) + INSN1(jne,_ ,L(4)) +L(2): + INSN2(mov,l ,X4 MEM_DISP(rbx,24), R(eax)) + INSN2(cmp,l ,NUM(13), R(eax)) + INSN1(je,_ ,L(127)) + INSN2(cmp,l ,NUM(14), R(eax)) + INSN1(je,_ ,L(128)) + INSN2(cmp,l ,NUM(7), R(r9d)) + INSN2(mov,q ,X8 MEM_DISP(rbx,8), R(r12)) + INSN1(jle,_ ,L(58)) + INSN2(movlp,d ,X8 MEM_DISP(rbx,184), R(xmm10)) +L(60): + INSN2(mov,q ,X8 MEM_DISP(rbx,176), R(r9)) +L(63): + INSN2(mov,q ,X8 MEM_DISP(rbx,168), R(r11)) +L(66): + INSN2(mov,q ,X8 MEM_DISP(rbx,160), R(r10)) +L(69): + INSN2(movlp,d ,X8 MEM_DISP(rbx,152), R(xmm8)) +L(72): + INSN2(mov,q ,X8 MEM_DISP(rbx,144), R(rax)) +L(75): + INSN2(mov,q ,X8 MEM_DISP(rbx,136), R(r8)) +L(78): + INSN2(movlp,d ,X8 MEM_DISP(rbx,128), R(xmm9)) +L(81): + INSN2(mov,q ,X8 MEM_DISP(rbx,88), R(rdx)) + INSN2(mov,q ,X8 MEM_DISP(rbx,96), R(rcx)) + INSN2S(movs,d ,R(xmm10), R(xmm7)) + INSN2(mov,q ,X8 MEM_DISP(rbx,80), R(rsi)) + INSN2(mov,q ,X8 MEM_DISP(rbx,72), R(rdi)) + INSN2S(movs,d ,R(xmm8), R(xmm3)) + INSN2(mov,q ,R(r9),X8 MEM_DISP(rbp,-32)) + INSN2S(movs,d ,R(xmm9), R(xmm0)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm6)) + INSN2(mov,q ,R(r11),X8 MEM_DISP(rbp,-32)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm5)) + INSN2(mov,q ,R(r10),X8 MEM_DISP(rbp,-32)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm4)) + INSN2(mov,q ,R(rax),X8 MEM_DISP(rbp,-32)) + INSN2(mov,l ,NUM(8), R(eax)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm2)) + INSN2(mov,q ,R(r8),X8 MEM_DISP(rbp,-32)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm1)) + INSN2(mov,q ,X8 MEM_DISP(rbx,112), R(r9)) + INSN2(mov,q ,X8 MEM_DISP(rbx,104), R(r8)) + INSN1(call,_ ,INDIR(R(r12))) + INSN2(mov,q ,R(rax), R(r8)) + INSN2(mov,l ,X4 MEM_DISP(rbx,24), R(eax)) + INSN2(mov,q ,R(rdx), R(r9)) + INSN2(cmp,l ,NUM(1), R(eax)) + INSN1(je,_ ,L(31)) + INSN2(test,l ,R(eax), R(eax)) + INSN1(je,_ ,L(125)) + INSN2(cmp,l ,NUM(2), R(eax)) + INSN1(je,_ ,L(122)) + INSN2(cmp,l ,NUM(3), R(eax)) + P2ALIGN(4,5) + INSN1(je,_ ,L(122)) + INSN2(cmp,l ,NUM(4), R(eax)) + P2ALIGN(4,5) + INSN1(je,_ ,L(122)) + INSN2(cmp,l ,NUM(5), R(eax)) + P2ALIGN(4,5) + INSN1(je,_ ,L(123)) + INSN2(cmp,l ,NUM(6), R(eax)) + P2ALIGN(4,5) + INSN1(je,_ ,L(123)) + INSN2(cmp,l ,NUM(7), R(eax)) + P2ALIGN(4,5) + INSN1(je,_ ,L(124)) + INSN2(cmp,l ,NUM(8), R(eax)) + P2ALIGN(4,5) + INSN1(je,_ ,L(124)) + INSN2(cmp,l ,NUM(9), R(eax)) + P2ALIGN(4,5) + INSN1(je,_ ,L(125)) + INSN2(cmp,l ,NUM(10), R(eax)) + P2ALIGN(4,5) + INSN1(je,_ ,L(125)) + INSN2(cmp,l ,NUM(11), R(eax)) + P2ALIGN(4,5) + INSN1(je,_ ,L(125)) + INSN2(cmp,l ,NUM(12), R(eax)) + P2ALIGN(4,5) + INSN1(je,_ ,L(125)) + INSN2(cmp,l ,NUM(15), R(eax)) + P2ALIGN(4,5) + INSN1(je,_ ,L(125)) + INSN2(cmp,l ,NUM(16), R(eax)) + P2ALIGN(4,5) + INSN1(jne,_ ,L(31)) + INSN2(test,b ,NUM(2),X1 MEM_DISP(rbx,1)) + P2ALIGN(4,5) + INSN1(je,_ ,L(31)) + INSN2(mov,q ,X8 MEM_DISP(rbx,32), R(rdx)) + INSN2(lea,q ,X8 MEM_DISP(rdx,-1), R(rax)) + INSN2(cmp,q ,NUM(15), R(rax)) + INSN1(ja,_ ,L(31)) + INSN2(mov,q ,X8 MEM_DISP(rbx,16), R(rax)) + INSN2(mov,q ,R(rax), R(r10)) + INSN2(mov,q ,R(rax), R(rdi)) + INSN2(and,l ,NUM(7), R(edi)) + INSN2(and,q ,NUM(-8), R(r10)) + INSN2(cmp,q ,NUM(8), R(rdx)) + INSN2(lea,q ,X8 MEM_INDEX(rdx,rdi), R(r11)) + INSN1(ja,_ ,L(112)) + INSN2(cmp,q ,NUM(8), R(r11)) + INSN1(ja,_ ,L(114)) + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(-1,r11,8), R(ecx)) + INSN2(mov,q ,X8 MEM(r10), R(rsi)) + INSN2(sal,l ,NUM(3), R(edi)) + INSN2(mov,l ,NUM(2), R(edx)) + INSN2(mov,l ,NUM(1), R(eax)) + INSN2(sal,q ,R(cl), R(rdx)) + INSN2(mov,l ,R(edi), R(ecx)) + INSN2(sal,q ,R(cl), R(rax)) + INSN2(sal,q ,R(cl), R(r8)) + INSN2(xor,q ,R(rsi), R(r8)) + INSN2(sub,q ,R(rax), R(rdx)) + INSN2(and,q ,R(r8), R(rdx)) + INSN2(xor,q ,R(rdx), R(rsi)) + INSN2(mov,q ,R(rsi),X8 MEM(r10)) +L(31): + INSN2(lea,q ,X8 MEM_DISP(rbp,-24), R(rsp)) + INSN2(xor,l ,R(eax), R(eax)) + INSN1(pop,q ,R(rbx)) + INSN1(pop,q ,R(r12)) + INSN1(pop,q ,R(r13)) + leave + ret +L(58): + INSN1(je,_ ,L(129)) + INSN2(cmp,l ,NUM(5), R(r9d)) + INSN1(jle,_ ,L(64)) + INSN2(xor,l ,R(r9d), R(r9d)) + INSN2(mov,q ,R(r9),X8 MEM_DISP(rbp,-32)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm10)) + P2ALIGN(4,3) + INSN1(jmp,_ ,L(63)) +L(127): + INSN2(cmp,l ,NUM(7), R(r9d)) + INSN2(mov,q ,X8 MEM_DISP(rbx,16), R(r13)) + INSN2(mov,q ,X8 MEM_DISP(rbx,8), R(r12)) + INSN1(jle,_ ,L(7)) + INSN2(movlp,d ,X8 MEM_DISP(rbx,184), R(xmm10)) +L(9): + INSN2(mov,q ,X8 MEM_DISP(rbx,176), R(r9)) +L(12): + INSN2(mov,q ,X8 MEM_DISP(rbx,168), R(r11)) +L(15): + INSN2(mov,q ,X8 MEM_DISP(rbx,160), R(r10)) +L(18): + INSN2(movlp,d ,X8 MEM_DISP(rbx,152), R(xmm8)) +L(21): + INSN2(mov,q ,X8 MEM_DISP(rbx,144), R(rax)) +L(24): + INSN2(mov,q ,X8 MEM_DISP(rbx,136), R(r8)) +L(27): + INSN2(movlp,d ,X8 MEM_DISP(rbx,128), R(xmm9)) +L(30): + INSN2(mov,q ,X8 MEM_DISP(rbx,96), R(rcx)) + INSN2(mov,q ,X8 MEM_DISP(rbx,88), R(rdx)) + INSN2S(movs,d ,R(xmm10), R(xmm7)) + INSN2(mov,q ,X8 MEM_DISP(rbx,80), R(rsi)) + INSN2(mov,q ,X8 MEM_DISP(rbx,72), R(rdi)) + INSN2S(movs,d ,R(xmm8), R(xmm3)) + INSN2(mov,q ,R(r9),X8 MEM_DISP(rbp,-32)) + INSN2S(movs,d ,R(xmm9), R(xmm0)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm6)) + INSN2(mov,q ,R(r11),X8 MEM_DISP(rbp,-32)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm5)) + INSN2(mov,q ,R(r10),X8 MEM_DISP(rbp,-32)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm4)) + INSN2(mov,q ,R(rax),X8 MEM_DISP(rbp,-32)) + INSN2(mov,l ,NUM(8), R(eax)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm2)) + INSN2(mov,q ,R(r8),X8 MEM_DISP(rbp,-32)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm1)) + INSN2(mov,q ,X8 MEM_DISP(rbx,112), R(r9)) + INSN2(mov,q ,X8 MEM_DISP(rbx,104), R(r8)) + INSN1(call,_ ,INDIR(R(r12))) + INSN2S(movs,s ,R(xmm0),X4 MEM(r13)) + INSN2(lea,q ,X8 MEM_DISP(rbp,-24), R(rsp)) + INSN2(xor,l ,R(eax), R(eax)) + INSN1(pop,q ,R(rbx)) + INSN1(pop,q ,R(r12)) + INSN1(pop,q ,R(r13)) + leave + ret +L(125): + INSN2(mov,q ,X8 MEM_DISP(rbx,16), R(rax)) + INSN2(mov,q ,R(r8),X8 MEM(rax)) + INSN2(lea,q ,X8 MEM_DISP(rbp,-24), R(rsp)) + INSN2(xor,l ,R(eax), R(eax)) + INSN1(pop,q ,R(rbx)) + INSN1(pop,q ,R(r12)) + INSN1(pop,q ,R(r13)) + leave + ret +L(128): + INSN2(cmp,l ,NUM(7), R(r9d)) + INSN2(mov,q ,X8 MEM_DISP(rbx,16), R(r13)) + INSN2(mov,q ,X8 MEM_DISP(rbx,8), R(r12)) + INSN1(jle,_ ,L(34)) + INSN2(movlp,d ,X8 MEM_DISP(rbx,184), R(xmm10)) +L(36): + INSN2(mov,q ,X8 MEM_DISP(rbx,176), R(r10)) +L(39): + INSN2(mov,q ,X8 MEM_DISP(rbx,168), R(r11)) +L(42): + INSN2(mov,q ,X8 MEM_DISP(rbx,160), R(r9)) +L(45): + INSN2(movlp,d ,X8 MEM_DISP(rbx,152), R(xmm8)) +L(48): + INSN2(mov,q ,X8 MEM_DISP(rbx,144), R(rax)) +L(51): + INSN2(mov,q ,X8 MEM_DISP(rbx,136), R(r8)) +L(54): + INSN2(movlp,d ,X8 MEM_DISP(rbx,128), R(xmm9)) +L(57): + INSN2(mov,q ,X8 MEM_DISP(rbx,96), R(rcx)) + INSN2(mov,q ,X8 MEM_DISP(rbx,88), R(rdx)) + INSN2S(movs,d ,R(xmm10), R(xmm7)) + INSN2(mov,q ,X8 MEM_DISP(rbx,80), R(rsi)) + INSN2(mov,q ,X8 MEM_DISP(rbx,72), R(rdi)) + INSN2S(movs,d ,R(xmm8), R(xmm3)) + INSN2(mov,q ,R(r10),X8 MEM_DISP(rbp,-32)) + INSN2S(movs,d ,R(xmm9), R(xmm0)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm6)) + INSN2(mov,q ,R(r11),X8 MEM_DISP(rbp,-32)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm5)) + INSN2(mov,q ,R(r9),X8 MEM_DISP(rbp,-32)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm4)) + INSN2(mov,q ,R(rax),X8 MEM_DISP(rbp,-32)) + INSN2(mov,l ,NUM(8), R(eax)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm2)) + INSN2(mov,q ,R(r8),X8 MEM_DISP(rbp,-32)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm1)) + INSN2(mov,q ,X8 MEM_DISP(rbx,112), R(r9)) + INSN2(mov,q ,X8 MEM_DISP(rbx,104), R(r8)) + INSN1(call,_ ,INDIR(R(r12))) + INSN2S(movs,d ,R(xmm0),X8 MEM(r13)) + INSN2(lea,q ,X8 MEM_DISP(rbp,-24), R(rsp)) + INSN2(xor,l ,R(eax), R(eax)) + INSN1(pop,q ,R(rbx)) + INSN1(pop,q ,R(r12)) + INSN1(pop,q ,R(r13)) + leave + ret +L(7): + INSN1(jne,_ ,L(10)) + INSN2(xorp,d ,R(xmm10), R(xmm10)) + INSN1(jmp,_ ,L(9)) +L(129): + INSN2(xorp,d ,R(xmm10), R(xmm10)) + P2ALIGN(4,7) + INSN1(jmp,_ ,L(60)) +L(34): + P2ALIGN(4,7) + INSN1(jne,_ ,L(37)) + INSN2(xorp,d ,R(xmm10), R(xmm10)) + P2ALIGN(4,7) + INSN1(jmp,_ ,L(36)) +L(122): + INSN2(mov,q ,X8 MEM_DISP(rbx,16), R(rax)) + INSN2(mov,b ,R(r8b),X1 MEM(rax)) + INSN2(lea,q ,X8 MEM_DISP(rbp,-24), R(rsp)) + INSN2(xor,l ,R(eax), R(eax)) + INSN1(pop,q ,R(rbx)) + INSN1(pop,q ,R(r12)) + INSN1(pop,q ,R(r13)) + leave + ret +L(10): + INSN2(cmp,l ,NUM(5), R(r9d)) + INSN1(jg,_ ,L(130)) + INSN1(jne,_ ,L(16)) + INSN2(xor,l ,R(r9d), R(r9d)) + INSN2(mov,q ,R(r9),X8 MEM_DISP(rbp,-32)) + INSN2(mov,q ,R(r9), R(r11)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm10)) + INSN1(jmp,_ ,L(15)) +L(64): + P2ALIGN(4,3) + INSN1(je,_ ,L(131)) + INSN2(cmp,l ,NUM(3), R(r9d)) + INSN1(jle,_ ,L(70)) + INSN2(xor,l ,R(r9d), R(r9d)) + INSN2(mov,q ,R(r9),X8 MEM_DISP(rbp,-32)) + INSN2(mov,q ,R(r9), R(r10)) + INSN2(mov,q ,R(r9), R(r11)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm10)) + INSN1(jmp,_ ,L(69)) +L(37): + INSN2(cmp,l ,NUM(5), R(r9d)) + INSN1(jg,_ ,L(132)) + INSN1(jne,_ ,L(43)) + INSN2(xor,l ,R(r10d), R(r10d)) + INSN2(mov,q ,R(r10),X8 MEM_DISP(rbp,-32)) + INSN2(mov,q ,R(r10), R(r11)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm10)) + INSN1(jmp,_ ,L(42)) +L(130): + INSN2(xor,l ,R(r9d), R(r9d)) + INSN2(mov,q ,R(r9),X8 MEM_DISP(rbp,-32)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm10)) + INSN1(jmp,_ ,L(12)) +L(131): + INSN2(xor,l ,R(r9d), R(r9d)) + INSN2(mov,q ,R(r9),X8 MEM_DISP(rbp,-32)) + INSN2(mov,q ,R(r9), R(r11)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm10)) + INSN1(jmp,_ ,L(66)) +L(132): + INSN2(xor,l ,R(r10d), R(r10d)) + INSN2(mov,q ,R(r10),X8 MEM_DISP(rbp,-32)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm10)) + INSN1(jmp,_ ,L(39)) +L(123): + INSN2(mov,q ,X8 MEM_DISP(rbx,16), R(rax)) + INSN2(mov,w ,R(r8w),X2 MEM(rax)) + INSN1(jmp,_ ,L(31)) +L(124): + INSN2(mov,q ,X8 MEM_DISP(rbx,16), R(rax)) + INSN2(mov,l ,R(r8d),X4 MEM(rax)) + INSN1(jmp,_ ,L(31)) +L(16): + INSN2(cmp,l ,NUM(3), R(r9d)) + INSN1(jle,_ ,L(19)) + INSN2(xor,l ,R(r9d), R(r9d)) + INSN2(mov,q ,R(r9),X8 MEM_DISP(rbp,-32)) + INSN2(mov,q ,R(r9), R(r10)) + INSN2(mov,q ,R(r9), R(r11)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm10)) + INSN1(jmp,_ ,L(18)) +L(70): + INSN1(jne,_ ,L(73)) + INSN2(xor,l ,R(r9d), R(r9d)) + INSN2(mov,q ,R(r9),X8 MEM_DISP(rbp,-32)) + INSN2(mov,q ,R(r9), R(r10)) + INSN2(mov,q ,R(r9), R(r11)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm10)) + INSN2S(movs,d ,R(xmm10), R(xmm8)) + INSN1(jmp,_ ,L(72)) +L(43): + INSN2(cmp,l ,NUM(3), R(r9d)) + INSN1(jle,_ ,L(46)) + INSN2(xor,l ,R(r10d), R(r10d)) + INSN2(mov,q ,R(r10),X8 MEM_DISP(rbp,-32)) + INSN2(mov,q ,R(r10), R(r9)) + INSN2(mov,q ,R(r10), R(r11)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm10)) + INSN1(jmp,_ ,L(45)) +L(19): + INSN1(jne,_ ,L(22)) + INSN2(xor,l ,R(r9d), R(r9d)) + INSN2(mov,q ,R(r9),X8 MEM_DISP(rbp,-32)) + INSN2(mov,q ,R(r9), R(r10)) + INSN2(mov,q ,R(r9), R(r11)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm10)) + INSN2S(movs,d ,R(xmm10), R(xmm8)) + INSN1(jmp,_ ,L(21)) +L(73): + INSN2(cmp,l ,NUM(1), R(r9d)) + INSN1(jle,_ ,L(76)) + INSN2(xor,l ,R(r9d), R(r9d)) + INSN2(mov,q ,R(r9),X8 MEM_DISP(rbp,-32)) + INSN2(mov,q ,R(r9), R(r10)) + INSN2(mov,q ,R(r9), R(r11)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm10)) + INSN2(mov,q ,R(r9), R(rax)) + INSN2S(movs,d ,R(xmm10), R(xmm8)) + INSN1(jmp,_ ,L(75)) +L(46): + INSN1(jne,_ ,L(49)) + INSN2(xor,l ,R(r10d), R(r10d)) + INSN2(mov,q ,R(r10),X8 MEM_DISP(rbp,-32)) + INSN2(mov,q ,R(r10), R(r9)) + INSN2(mov,q ,R(r10), R(r11)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm10)) + INSN2S(movs,d ,R(xmm10), R(xmm8)) + INSN1(jmp,_ ,L(48)) +L(22): + INSN2(cmp,l ,NUM(1), R(r9d)) + INSN1(jle,_ ,L(25)) + INSN2(xor,l ,R(r9d), R(r9d)) + INSN2(mov,q ,R(r9),X8 MEM_DISP(rbp,-32)) + INSN2(mov,q ,R(r9), R(r10)) + INSN2(mov,q ,R(r9), R(r11)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm10)) + INSN2(mov,q ,R(r9), R(rax)) + INSN2S(movs,d ,R(xmm10), R(xmm8)) + INSN1(jmp,_ ,L(24)) +L(49): + INSN2(cmp,l ,NUM(1), R(r9d)) + INSN1(jle,_ ,L(52)) + INSN2(xor,l ,R(r10d), R(r10d)) + INSN2(mov,q ,R(r10),X8 MEM_DISP(rbp,-32)) + INSN2(mov,q ,R(r10), R(r9)) + INSN2(mov,q ,R(r10), R(r11)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm10)) + INSN2(mov,q ,R(r10), R(rax)) + INSN2S(movs,d ,R(xmm10), R(xmm8)) + INSN1(jmp,_ ,L(51)) +L(76): + INSN1(jne,_ ,L(133)) + INSN2(xor,l ,R(r9d), R(r9d)) + INSN2(mov,q ,R(r9),X8 MEM_DISP(rbp,-32)) + INSN2(mov,q ,R(r9), R(r10)) + INSN2(mov,q ,R(r9), R(r11)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm10)) + INSN2(mov,q ,R(r9), R(rax)) + INSN2(mov,q ,R(r9), R(r8)) + INSN2S(movs,d ,R(xmm10), R(xmm8)) + INSN1(jmp,_ ,L(78)) +L(25): + INSN1(jne,_ ,L(134)) + INSN2(xor,l ,R(r9d), R(r9d)) + INSN2(mov,q ,R(r9),X8 MEM_DISP(rbp,-32)) + INSN2(mov,q ,R(r9), R(r10)) + INSN2(mov,q ,R(r9), R(r11)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm10)) + INSN2(mov,q ,R(r9), R(rax)) + INSN2(mov,q ,R(r9), R(r8)) + INSN2S(movs,d ,R(xmm10), R(xmm8)) + INSN1(jmp,_ ,L(27)) +L(112): + INSN2(lea,q ,X8 MEM_DISP_SHINDEX0(0,rdi,8), R(r12)) + INSN2(mov,q ,X8 MEM(r10), R(rsi)) + INSN2(mov,q ,R(r8), R(rax)) + INSN2(mov,q ,NUM(-1), R(rdx)) + INSN2(mov,l ,R(r12d), R(ecx)) + INSN2(sal,q ,R(cl), R(rax)) + INSN2(sal,q ,R(cl), R(rdx)) + INSN2(xor,q ,R(rsi), R(rax)) + INSN2(and,q ,R(rax), R(rdx)) + INSN2(xor,q ,R(rdx), R(rsi)) + INSN2(cmp,q ,NUM(16), R(r11)) + INSN2(mov,q ,R(rsi),X8 MEM(r10)) + INSN1(ja,_ ,L(116)) + INSN2(lea,q ,X8 MEM_DISP_SHINDEX0(0,rdi,4), R(rax)) + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(-65,r11,8), R(edx)) + INSN2(mov,l ,NUM(32), R(edi)) + INSN2(mov,q ,X8 MEM_DISP(r10,8), R(rsi)) + INSN2(sub,l ,R(eax), R(edi)) + INSN2(mov,l ,R(edx), R(ecx)) + INSN2(mov,l ,NUM(2), R(eax)) + INSN2(sal,q ,R(cl), R(rax)) + INSN2(mov,l ,R(edi), R(ecx)) + INSN2(sar,q ,R(cl), R(r8)) + INSN1(dec,q ,R(rax)) + INSN2(sar,q ,R(cl), R(r8)) + INSN2(mov,l ,R(r12d), R(ecx)) + INSN2(sal,q ,R(cl), R(r9)) + INSN2(or,q ,R(r9), R(r8)) + INSN2(xor,q ,R(rsi), R(r8)) + INSN2(and,q ,R(r8), R(rax)) + INSN2(xor,q ,R(rax), R(rsi)) + INSN2(mov,q ,R(rsi),X8 MEM_DISP(r10,8)) + INSN1(jmp,_ ,L(31)) + P2ALIGN(4,7) +L(133): + INSN2(xorp,d ,R(xmm9), R(xmm9)) + INSN2S(movs,d ,R(xmm9),X8 MEM_DISP(rbp,-32)) + INSN2(mov,q ,X8 MEM_DISP(rbp,-32), R(r9)) + INSN2S(movs,d ,R(xmm9), R(xmm10)) + INSN2S(movs,d ,R(xmm9), R(xmm8)) + INSN2(mov,q ,R(r9), R(r11)) + INSN2(mov,q ,R(r9), R(r10)) + INSN2(mov,q ,R(r9), R(rax)) + INSN2(mov,q ,R(r9), R(r8)) + INSN1(jmp,_ ,L(81)) +L(52): + INSN1(jne,_ ,L(135)) + INSN2(xor,l ,R(r10d), R(r10d)) + INSN2(mov,q ,R(r10),X8 MEM_DISP(rbp,-32)) + INSN2(mov,q ,R(r10), R(r9)) + INSN2(mov,q ,R(r10), R(r11)) + INSN2(movlp,d ,X8 MEM_DISP(rbp,-32), R(xmm10)) + INSN2(mov,q ,R(r10), R(rax)) + INSN2(mov,q ,R(r10), R(r8)) + INSN2S(movs,d ,R(xmm10), R(xmm8)) + INSN1(jmp,_ ,L(54)) +L(134): + INSN2(xorp,d ,R(xmm9), R(xmm9)) + INSN2S(movs,d ,R(xmm9),X8 MEM_DISP(rbp,-32)) + INSN2(mov,q ,X8 MEM_DISP(rbp,-32), R(r9)) + INSN2S(movs,d ,R(xmm9), R(xmm10)) + INSN2S(movs,d ,R(xmm9), R(xmm8)) + INSN2(mov,q ,R(r9), R(r11)) + INSN2(mov,q ,R(r9), R(r10)) + INSN2(mov,q ,R(r9), R(rax)) + INSN2(mov,q ,R(r9), R(r8)) + INSN1(jmp,_ ,L(30)) +L(135): + INSN2(xorp,d ,R(xmm9), R(xmm9)) + INSN2S(movs,d ,R(xmm9),X8 MEM_DISP(rbp,-32)) + INSN2(mov,q ,X8 MEM_DISP(rbp,-32), R(r10)) + INSN2S(movs,d ,R(xmm9), R(xmm10)) + INSN2S(movs,d ,R(xmm9), R(xmm8)) + INSN2(mov,q ,R(r10), R(r11)) + INSN2(mov,q ,R(r10), R(r9)) + INSN2(mov,q ,R(r10), R(rax)) + INSN2(mov,q ,R(r10), R(r8)) + INSN1(jmp,_ ,L(57)) +L(114): + INSN2(lea,q ,X8 MEM_DISP_SHINDEX0(0,rdi,8), R(rsi)) + INSN2(mov,q ,X8 MEM(r10), R(rdx)) + INSN2(mov,q ,R(r8), R(rbx)) + INSN2(mov,q ,NUM(-1), R(rax)) + INSN2(mov,l ,R(esi), R(ecx)) + INSN2(sal,q ,R(cl), R(rbx)) + INSN2(sal,q ,R(cl), R(rax)) + INSN2(mov,q ,R(rbx), R(rcx)) + INSN2(xor,q ,R(rdx), R(rcx)) + INSN2(and,q ,R(rcx), R(rax)) + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(-65,r11,8), R(ecx)) + INSN2(xor,q ,R(rax), R(rdx)) + INSN2(mov,l ,NUM(2), R(eax)) + INSN2(sal,q ,R(cl), R(rax)) + INSN2(mov,q ,R(rdx),X8 MEM(r10)) + INSN2(mov,l ,NUM(64), R(ecx)) + INSN2(mov,q ,X8 MEM_DISP(r10,8), R(rdx)) + INSN2(sub,l ,R(esi), R(ecx)) + INSN1(dec,q ,R(rax)) + INSN2(sar,q ,R(cl), R(r8)) + INSN2(xor,q ,R(rdx), R(r8)) + INSN2(and,q ,R(r8), R(rax)) + INSN2(xor,q ,R(rax), R(rdx)) + INSN2(mov,q ,R(rdx),X8 MEM_DISP(r10,8)) + INSN1(jmp,_ ,L(31)) +L(116): + INSN2(mov,l ,NUM(64), R(esi)) + INSN2(mov,q ,R(r9), R(rax)) + INSN2(mov,q ,X8 MEM_DISP(r10,16), R(rdx)) + INSN2(sub,l ,R(r12d), R(esi)) + INSN2(mov,l ,R(esi), R(ecx)) + INSN2(sar,q ,R(cl), R(r8)) + INSN2(mov,l ,R(r12d), R(ecx)) + INSN2(sal,q ,R(cl), R(rax)) + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(-129,r11,8), R(ecx)) + INSN2(or,q ,R(r8), R(rax)) + INSN2(mov,q ,R(rax),X8 MEM_DISP(r10,8)) + INSN2(mov,l ,NUM(2), R(eax)) + INSN2(sal,q ,R(cl), R(rax)) + INSN2(mov,l ,R(esi), R(ecx)) + INSN2(sar,q ,R(cl), R(r9)) + INSN1(dec,q ,R(rax)) + INSN2(xor,q ,R(rdx), R(r9)) + INSN2(and,q ,R(r9), R(rax)) + INSN2(xor,q ,R(rax), R(rdx)) + INSN2(mov,q ,R(rdx),X8 MEM_DISP(r10,16)) + INSN1(jmp,_ ,L(31)) +L(FE2): + FUNEND(avcall_call, .-avcall_call) +#if !(defined __sun || (defined __APPLE__ && defined __MACH__) || (defined _WIN32 || defined __CYGWIN__)) + .section EH_FRAME_SECTION +L(frame1): + .long L(ECIE1)-.LSCIE1 +L(SCIE1): + .long 0x0 + .byte 0x1 + .string "zR" + .uleb128 0x1 + .sleb128 -8 + .byte 0x10 + .uleb128 0x1 + .byte 0x1b + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x90 + .uleb128 0x1 + .align 8 +L(ECIE1): +L(SFDE1): + .long L(EFDE1)-.LASFDE1 +L(ASFDE1): + .long L(ASFDE1)-.Lframe1 + .long L(FB2)-. + .long L(FE2)-.LFB2 + .uleb128 0x0 + .byte 0x4 + .long L(CFI0)-.LFB2 + .byte 0xe + .uleb128 0x10 + .byte 0x86 + .uleb128 0x2 + .byte 0x4 + .long L(CFI1)-.LCFI0 + .byte 0xd + .uleb128 0x6 + .byte 0x4 + .long L(CFI4)-.LCFI1 + .byte 0x83 + .uleb128 0x5 + .byte 0x8c + .uleb128 0x4 + .byte 0x8d + .uleb128 0x3 + .align 8 +L(EFDE1): +#endif +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/avcall/avcall-x86_64-windows-macro.S b/avcall/avcall-x86_64-windows-macro.S new file mode 100644 index 0000000..fe824f2 --- /dev/null +++ b/avcall/avcall-x86_64-windows-macro.S @@ -0,0 +1,372 @@ +#include "asm-x86_64.h" + TEXT() + P2ALIGN(4,15) + GLOBL(C(avcall_call)) + DECLARE_FUNCTION(avcall_call) +FUNBEGIN(avcall_call) +L(FB0): + INSN1(push,q ,R(rbp)) +L(CFI0): + INSN2(mov,q ,R(rsp), R(rbp)) +L(CFI1): + INSN1(push,q ,R(rsi)) + INSN1(push,q ,R(rbx)) +L(CFI2): + INSN2(mov,q ,R(rcx), R(rbx)) + INSN2(sub,q ,NUM(32), R(rsp)) + INSN2(mov,q ,X8 MEM_DISP(rcx,48), R(rcx)) + INSN2(mov,q ,X8 MEM_DISP(rbx,40), R(rax)) + INSN2(sub,q ,NUM(2064), R(rsp)) + INSN2(sub,q ,R(rcx), R(rax)) + INSN2(sar,q ,NUM(3), R(rax)) + INSN2(cmp,l ,NUM(4), R(eax)) + INSN1(jle,_ ,L(6)) + INSN2(lea,l ,X4 MEM_DISP(rax,-5), R(r8d)) + INSN2(lea,q ,X8 MEM_DISP(rsp,32), R(r9)) + INSN2(xor,l ,R(eax), R(eax)) + INSN2(add,q ,NUM(1), R(r8)) + P2ALIGN(4,10) + P2ALIGN(3,7) +L(5): + INSN2(mov,q ,X8 MEM_DISP_SHINDEX(rcx,32,rax,8), R(rdx)) + INSN2(mov,q ,R(rdx),X8 MEM_SHINDEX(r9,rax,8)) + INSN2(add,q ,NUM(1), R(rax)) + INSN2(cmp,q ,R(r8), R(rax)) + INSN1(jne,_ ,L(5)) +L(6): + INSN2(mov,l ,X4 MEM_DISP(rbx,68), R(eax)) + INSN2(test,l ,R(eax), R(eax)) + INSN1(je,_ ,L(7)) + INSN2(test,b ,NUM(1), R(al)) + INSN1(je,_ ,L(8)) + INSN2S(movs,s ,X4 MEM_DISP(rbx,76), R(xmm0)) +L(8): + INSN2(test,b ,NUM(2), R(al)) + INSN1(je,_ ,L(9)) + INSN2S(movs,s ,X4 MEM_DISP(rbx,80), R(xmm1)) +L(9): + INSN2(test,b ,NUM(4), R(al)) + INSN1(je,_ ,L(10)) + INSN2S(movs,s ,X4 MEM_DISP(rbx,84), R(xmm2)) +L(10): + INSN2(test,b ,NUM(8), R(al)) + INSN1(jne,_ ,L(78)) +L(7): + INSN2(mov,l ,X4 MEM_DISP(rbx,72), R(eax)) + INSN2(test,l ,R(eax), R(eax)) + INSN1(je,_ ,L(12)) + INSN2(test,b ,NUM(1), R(al)) + INSN1(je,_ ,L(13)) + INSN2S(movs,d ,X8 MEM_DISP(rbx,96), R(xmm0)) +L(13): + INSN2(test,b ,NUM(2), R(al)) + INSN1(je,_ ,L(14)) + INSN2S(movs,d ,X8 MEM_DISP(rbx,104), R(xmm1)) +L(14): + INSN2(test,b ,NUM(4), R(al)) + INSN1(je,_ ,L(15)) + INSN2S(movs,d ,X8 MEM_DISP(rbx,112), R(xmm2)) +L(15): + INSN2(test,b ,NUM(8), R(al)) + INSN1(jne,_ ,L(79)) +L(12): + INSN2(mov,l ,X4 MEM_DISP(rbx,24), R(eax)) + INSN2(cmp,l ,NUM(13), R(eax)) + INSN1(je,_ ,L(80)) + INSN2(cmp,l ,NUM(14), R(eax)) + INSN1(je,_ ,L(81)) + INSN2(mov,q ,X8 MEM_DISP(rcx,8), R(rdx)) + INSN2(mov,q ,X8 MEM_DISP(rcx,24), R(r9)) + INSN2(mov,q ,X8 MEM_DISP(rcx,16), R(r8)) + INSN2(mov,q ,X8 MEM(rcx), R(rcx)) + INSN1(call,_ ,INDIR(X8 MEM_DISP(rbx,8))) + INSN2(mov,l ,X4 MEM_DISP(rbx,24), R(edx)) + INSN2(cmp,l ,NUM(1), R(edx)) + INSN1(je,_ ,L(18)) + INSN2(test,l ,R(edx), R(edx)) + INSN1(je,_ ,L(76)) + INSN2(cmp,l ,NUM(2), R(edx)) + INSN1(je,_ ,L(73)) + INSN2(cmp,l ,NUM(3), R(edx)) + INSN1(je,_ ,L(73)) + INSN2(cmp,l ,NUM(4), R(edx)) + INSN1(je,_ ,L(73)) + INSN2(cmp,l ,NUM(5), R(edx)) + INSN1(je,_ ,L(74)) + INSN2(cmp,l ,NUM(6), R(edx)) + INSN1(je,_ ,L(74)) + INSN2(cmp,l ,NUM(7), R(edx)) + INSN1(je,_ ,L(75)) + INSN2(cmp,l ,NUM(8), R(edx)) + INSN1(je,_ ,L(75)) + INSN2(cmp,l ,NUM(9), R(edx)) + INSN1(je,_ ,L(76)) + INSN2(cmp,l ,NUM(10), R(edx)) + INSN1(je,_ ,L(76)) + INSN2(cmp,l ,NUM(11), R(edx)) + INSN1(je,_ ,L(76)) + INSN2(cmp,l ,NUM(12), R(edx)) + INSN1(je,_ ,L(76)) + INSN2(cmp,l ,NUM(15), R(edx)) + INSN1(je,_ ,L(76)) + INSN2(cmp,l ,NUM(16), R(edx)) + INSN1(jne,_ ,L(18)) + INSN2(test,l ,NUM(512),X4 MEM(rbx)) + INSN1(je,_ ,L(18)) + INSN2(mov,q ,X8 MEM_DISP(rbx,32), R(r8)) + INSN2(lea,q ,X8 MEM_DISP(r8,-4), R(rdx)) + INSN2(test,q ,NUM(-5), R(rdx)) + INSN1(je,_ ,L(35)) + INSN2(lea,q ,X8 MEM_DISP(r8,-1), R(rdx)) + INSN2(cmp,q ,NUM(1), R(rdx)) + INSN1(ja,_ ,L(18)) +L(35): + INSN2(mov,q ,X8 MEM_DISP(rbx,16), R(rdx)) + INSN2(mov,q ,R(rdx), R(r9)) + INSN2(and,l ,NUM(7), R(edx)) + INSN2(add,q ,R(rdx), R(r8)) + INSN2(and,q ,NUM(-8), R(r9)) + INSN2(cmp,q ,NUM(8), R(r8)) + INSN1(jbe,_ ,L(82)) + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(0,rdx,8), R(ecx)) + INSN2(mov,q ,X8 MEM(r9), R(r10)) + INSN2(mov,q ,R(rax), R(rsi)) + INSN2(mov,q ,NUM(-1), R(r11)) + INSN1(neg,l ,R(edx)) + INSN2(sal,q ,R(cl), R(rsi)) + INSN2(sal,q ,R(cl), R(r11)) + INSN2(mov,q ,R(rsi), R(rcx)) + INSN2(xor,q ,R(r10), R(rcx)) + INSN2(and,q ,R(r11), R(rcx)) + INSN2(xor,q ,R(r10), R(rcx)) + INSN2(mov,q ,X8 MEM_DISP(r9,8), R(r10)) + INSN2(mov,q ,R(rcx),X8 MEM(r9)) + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(-65,r8,8), R(ecx)) + INSN2(mov,l ,NUM(2), R(r8d)) + INSN2(sal,q ,R(cl), R(r8)) + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(64,rdx,8), R(ecx)) + INSN2(sub,q ,NUM(1), R(r8)) + INSN2(sar,q ,R(cl), R(rax)) + INSN2(xor,q ,R(r10), R(rax)) + INSN2(and,q ,R(r8), R(rax)) + INSN2(xor,q ,R(r10), R(rax)) + INSN2(mov,q ,R(rax),X8 MEM_DISP(r9,8)) +L(18): + INSN2(lea,q ,X8 MEM_DISP(rbp,-16), R(rsp)) + INSN2(xor,l ,R(eax), R(eax)) + INSN1(pop,q ,R(rbx)) +L(CFI3): + INSN1(pop,q ,R(rsi)) +L(CFI4): + INSN1(pop,q ,R(rbp)) +L(CFI5): + ret + P2ALIGN(4,10) + P2ALIGN(3,7) +L(79): +L(CFI6): + INSN2S(movs,d ,X8 MEM_DISP(rbx,120), R(xmm3)) + INSN1(jmp,_ ,L(12)) + P2ALIGN(4,10) + P2ALIGN(3,7) +L(78): + INSN2S(movs,s ,X4 MEM_DISP(rbx,88), R(xmm3)) + INSN1(jmp,_ ,L(7)) + P2ALIGN(4,10) + P2ALIGN(3,7) +L(76): + INSN2(mov,q ,X8 MEM_DISP(rbx,16), R(rdx)) + INSN2(mov,q ,R(rax),X8 MEM(rdx)) + INSN2(lea,q ,X8 MEM_DISP(rbp,-16), R(rsp)) + INSN2(xor,l ,R(eax), R(eax)) + INSN1(pop,q ,R(rbx)) +L(CFI7): + INSN1(pop,q ,R(rsi)) +L(CFI8): + INSN1(pop,q ,R(rbp)) +L(CFI9): + ret + P2ALIGN(4,10) + P2ALIGN(3,7) +L(73): +L(CFI10): + INSN2(mov,q ,X8 MEM_DISP(rbx,16), R(rdx)) + INSN2(mov,b ,R(al),X1 MEM(rdx)) + INSN2(lea,q ,X8 MEM_DISP(rbp,-16), R(rsp)) + INSN2(xor,l ,R(eax), R(eax)) + INSN1(pop,q ,R(rbx)) +L(CFI11): + INSN1(pop,q ,R(rsi)) +L(CFI12): + INSN1(pop,q ,R(rbp)) +L(CFI13): + ret + P2ALIGN(4,10) + P2ALIGN(3,7) +L(81): +L(CFI14): + INSN2(mov,q ,X8 MEM_DISP(rbx,16), R(rsi)) + INSN2(mov,q ,X8 MEM_DISP(rcx,8), R(rdx)) + INSN2(mov,q ,X8 MEM_DISP(rcx,24), R(r9)) + INSN2(mov,q ,X8 MEM_DISP(rcx,16), R(r8)) + INSN2(mov,q ,X8 MEM(rcx), R(rcx)) + INSN1(call,_ ,INDIR(X8 MEM_DISP(rbx,8))) + INSN2S(movs,d ,R(xmm0),X8 MEM(rsi)) + INSN2(lea,q ,X8 MEM_DISP(rbp,-16), R(rsp)) + INSN2(xor,l ,R(eax), R(eax)) + INSN1(pop,q ,R(rbx)) +L(CFI15): + INSN1(pop,q ,R(rsi)) +L(CFI16): + INSN1(pop,q ,R(rbp)) +L(CFI17): + ret +L(80): +L(CFI18): + INSN2(mov,q ,X8 MEM_DISP(rbx,16), R(rsi)) + INSN2(mov,q ,X8 MEM_DISP(rcx,8), R(rdx)) + INSN2(mov,q ,X8 MEM_DISP(rcx,24), R(r9)) + INSN2(mov,q ,X8 MEM_DISP(rcx,16), R(r8)) + INSN2(mov,q ,X8 MEM(rcx), R(rcx)) + INSN1(call,_ ,INDIR(X8 MEM_DISP(rbx,8))) + INSN2S(movs,s ,R(xmm0),X4 MEM(rsi)) + INSN1(jmp,_ ,L(18)) +L(74): + INSN2(mov,q ,X8 MEM_DISP(rbx,16), R(rdx)) + INSN2(mov,w ,R(ax),X2 MEM(rdx)) + INSN1(jmp,_ ,L(18)) +L(75): + INSN2(mov,q ,X8 MEM_DISP(rbx,16), R(rdx)) + INSN2(mov,l ,R(eax),X4 MEM(rdx)) + INSN1(jmp,_ ,L(18)) +L(82): + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(-1,r8,8), R(ecx)) + INSN2(mov,q ,X8 MEM(r9), R(r10)) + INSN2(sal,l ,NUM(3), R(edx)) + INSN2(mov,l ,NUM(2), R(r8d)) + INSN2(mov,l ,NUM(1), R(r11d)) + INSN2(sal,q ,R(cl), R(r8)) + INSN2(mov,l ,R(edx), R(ecx)) + INSN2(sal,q ,R(cl), R(r11)) + INSN2(sal,q ,R(cl), R(rax)) + INSN2(sub,q ,R(r11), R(r8)) + INSN2(xor,q ,R(r10), R(rax)) + INSN2(and,q ,R(r8), R(rax)) + INSN2(xor,q ,R(r10), R(rax)) + INSN2(mov,q ,R(rax),X8 MEM(r9)) + INSN1(jmp,_ ,L(18)) +L(FE0): + FUNEND(avcall_call, .-avcall_call) +#if !(defined __sun || (defined __APPLE__ && defined __MACH__) || (defined _WIN32 || defined __CYGWIN__)) + .section EH_FRAME_SECTION +L(frame1): + .long L(ECIE1)-.LSCIE1 +L(SCIE1): + .long 0 + .byte 0x3 + .string "zR" + .uleb128 0x1 + .sleb128 -8 + .uleb128 0x10 + .uleb128 0x1 + .byte 0x1b + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x90 + .uleb128 0x1 + .align 8 +L(ECIE1): +L(SFDE1): + .long L(EFDE1)-.LASFDE1 +L(ASFDE1): + .long L(ASFDE1)-.Lframe1 + .long L(FB0)-. + .long L(FE0)-.LFB0 + .uleb128 0 + .byte 0x4 + .long L(CFI0)-.LFB0 + .byte 0xe + .uleb128 0x10 + .byte 0x86 + .uleb128 0x2 + .byte 0x4 + .long L(CFI1)-.LCFI0 + .byte 0xd + .uleb128 0x6 + .byte 0x4 + .long L(CFI2)-.LCFI1 + .byte 0x84 + .uleb128 0x3 + .byte 0x83 + .uleb128 0x4 + .byte 0x4 + .long L(CFI3)-.LCFI2 + .byte 0xa + .byte 0xc3 + .byte 0x4 + .long L(CFI4)-.LCFI3 + .byte 0xc4 + .byte 0x4 + .long L(CFI5)-.LCFI4 + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long L(CFI6)-.LCFI5 + .byte 0xb + .byte 0x4 + .long L(CFI7)-.LCFI6 + .byte 0xa + .byte 0xc3 + .byte 0x4 + .long L(CFI8)-.LCFI7 + .byte 0xc4 + .byte 0x4 + .long L(CFI9)-.LCFI8 + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long L(CFI10)-.LCFI9 + .byte 0xb + .byte 0x4 + .long L(CFI11)-.LCFI10 + .byte 0xa + .byte 0xc3 + .byte 0x4 + .long L(CFI12)-.LCFI11 + .byte 0xc4 + .byte 0x4 + .long L(CFI13)-.LCFI12 + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long L(CFI14)-.LCFI13 + .byte 0xb + .byte 0x4 + .long L(CFI15)-.LCFI14 + .byte 0xa + .byte 0xc3 + .byte 0x4 + .long L(CFI16)-.LCFI15 + .byte 0xc4 + .byte 0x4 + .long L(CFI17)-.LCFI16 + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long L(CFI18)-.LCFI17 + .byte 0xb + .align 8 +L(EFDE1): +#endif +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/avcall/avcall-x86_64-windows.c b/avcall/avcall-x86_64-windows.c new file mode 100644 index 0000000..5d5d43c --- /dev/null +++ b/avcall/avcall-x86_64-windows.c @@ -0,0 +1,228 @@ +/** + Copyright 1993 Bill Triggs + Copyright 1995-2017 Bruno Haible + + 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, see . +**/ +/*---------------------------------------------------------------------- + Foreign function interface for an x86_64 (a.k.a. amd64) with gcc + using the Windows ABI ('gcc -mabi=ms'). + + This calls a C function with an argument list built up using macros + defined in avcall.h. + + x86_64 Argument Passing Conventions on Windows: + + Documentation is at https://docs.microsoft.com/en-us/cpp/build/calling-convention + A summary is at https://en.wikipedia.org/wiki/X86_calling_conventions#x86-64_calling_conventions + + * Arguments: + - Up to 4 words are passed in registers: + integer/pointer float/double + 1. %rcx %xmm0 + 2. %rdx %xmm1 + 3. %r8 %xmm2 + 4. %r9 %xmm3 + - Integer or pointer arguments: + The first 4 integer or pointer arguments get passed in integer + registers (%rcx, %rdx, %r8, %r9). + The remaining ones (as an entire word each) on the stack. + - Floating-point arguments: + The float/double arguments among the first 4 words are passed in + SSE registers (%xmm0..%xmm3), as shown above. + The remaining ones (as an entire word each) on the stack. + - Structure arguments: + Structure args of size 1, 2, 4, 8 bytes are passed like integers. + Structure args of other sizes are passed as pointers to caller-allocated + temporary locations. + * Return value: + Types of size 1, 2, 4, 8 bytes are returned in %rax or (for float/double + values) in %xmm0. + To return a structure of another size, the called function copies the + value to space pointed to by its first argument, and all other arguments + are shifted down by one. The function also returns the pointer. + * Call-used registers: rax,rdx,rcx,r8-r11 + + ----------------------------------------------------------------------*/ +#include "avcall-internal.h" + +#define RETURN(TYPE,VAL) (*(TYPE*)l->raddr = (TYPE)(VAL)) + +/*register __avword iarg1 __asm__("rcx");*/ +/*register __avword iarg2 __asm__("rdx");*/ +/*register __avword iarg3 __asm__("r8");*/ +/*register __avword iarg4 __asm__("r9");*/ + +register float farg1 __asm__("xmm0"); +register float farg2 __asm__("xmm1"); +register float farg3 __asm__("xmm2"); +register float farg4 __asm__("xmm3"); + +register double darg1 __asm__("xmm0"); +register double darg2 __asm__("xmm1"); +register double darg3 __asm__("xmm2"); +register double darg4 __asm__("xmm3"); + +int +avcall_call(av_alist* list) +{ + register __avword* sp __asm__("rsp"); /* C names for registers */ + register __avword iret __asm__("rax"); + register float fret __asm__("xmm0"); + register double dret __asm__("xmm0"); + + __av_alist* l = &AV_LIST_INNER(list); + + __avword* argframe = __builtin_alloca(__AV_ALIST_WORDS * sizeof(__avword)); /* make room for argument list */ + int arglen = l->aptr - l->args; + int i; + + for (i = 4; i < arglen; i++) /* push function args onto stack */ + argframe[i-4] = l->args[i]; + + /* put up to 4 float args into registers */ + if (l->farg_mask) { + if (l->farg_mask & (1<<0)) + farg1 = l->fargs[0]; + if (l->farg_mask & (1<<1)) + farg2 = l->fargs[1]; + if (l->farg_mask & (1<<2)) + farg3 = l->fargs[2]; + if (l->farg_mask & (1<<3)) + farg4 = l->fargs[3]; + } + + /* put up to 4 double args into registers */ + if (l->darg_mask) { + if (l->darg_mask & (1<<0)) + darg1 = l->dargs[0]; + if (l->darg_mask & (1<<1)) + darg2 = l->dargs[1]; + if (l->darg_mask & (1<<2)) + darg3 = l->dargs[2]; + if (l->darg_mask & (1<<3)) + darg4 = l->dargs[3]; + } + + /* Call function. */ + if (l->rtype == __AVfloat) { + *(float*)l->raddr = (*(float(*)())l->func)(l->args[0], l->args[1], l->args[2], l->args[3]); + } else + if (l->rtype == __AVdouble) { + *(double*)l->raddr = (*(double(*)())l->func)(l->args[0], l->args[1], l->args[2], l->args[3]); + } else { + __avword iret; + iret = (*l->func)(l->args[0], l->args[1], l->args[2], l->args[3]); + + /* save return value */ + if (l->rtype == __AVvoid) { + } else + if (l->rtype == __AVword) { + RETURN(__avword, iret); + } else + if (l->rtype == __AVchar) { + RETURN(char, iret); + } else + if (l->rtype == __AVschar) { + RETURN(signed char, iret); + } else + if (l->rtype == __AVuchar) { + RETURN(unsigned char, iret); + } else + if (l->rtype == __AVshort) { + RETURN(short, iret); + } else + if (l->rtype == __AVushort) { + RETURN(unsigned short, iret); + } else + if (l->rtype == __AVint) { + RETURN(int, iret); + } else + if (l->rtype == __AVuint) { + RETURN(unsigned int, iret); + } else + if (l->rtype == __AVlong) { + RETURN(long, iret); + } else + if (l->rtype == __AVulong) { + RETURN(unsigned long, iret); + } else + if (l->rtype == __AVlonglong) { + RETURN(long long, iret); + } else + if (l->rtype == __AVulonglong) { + RETURN(unsigned long long, iret); + } else + /* see above + if (l->rtype == __AVfloat) { + } else + if (l->rtype == __AVdouble) { + } else + */ + if (l->rtype == __AVvoidp) { + RETURN(void*, iret); + } else + if (l->rtype == __AVstruct) { + if (l->flags & __AV_REGISTER_STRUCT_RETURN) { + /* Return structs of size 1, 2, 4, 8 in registers. */ + void* raddr = l->raddr; + #if 0 /* Unoptimized */ + if (l->rsize == 1) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + } else + if (l->rsize == 2) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + } else + if (l->rsize == 4) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + } else + if (l->rsize == 8) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[6] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[7] = (unsigned char)(iret>>56); + } + #else /* Optimized: fewer conditional jumps, fewer memory accesses */ + uintptr_t count = l->rsize; + if (count == 1 || count == 2 || count == 4 || count == 8) { + /* 0 < count ≤ sizeof(__avword) */ + __avword* wordaddr = (__avword*)((uintptr_t)raddr & ~(uintptr_t)(sizeof(__avword)-1)); + uintptr_t start_offset = (uintptr_t)raddr & (uintptr_t)(sizeof(__avword)-1); /* ≥ 0, < sizeof(__avword) */ + uintptr_t end_offset = start_offset + count; /* > 0, < 2*sizeof(__avword) */ + if (end_offset <= sizeof(__avword)) { + /* 0 < end_offset ≤ sizeof(__avword) */ + __avword mask0 = ((__avword)2 << (end_offset*8-1)) - ((__avword)1 << (start_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret << (start_offset*8))) & mask0; + } else { + /* sizeof(__avword) < end_offset < 2*sizeof(__avword), start_offset > 0 */ + __avword mask0 = - ((__avword)1 << (start_offset*8)); + __avword mask1 = ((__avword)2 << (end_offset*8-sizeof(__avword)*8-1)) - 1; + wordaddr[0] ^= (wordaddr[0] ^ (iret << (start_offset*8))) & mask0; + wordaddr[1] ^= (wordaddr[1] ^ (iret >> (sizeof(__avword)*8-start_offset*8))) & mask1; + } + } + #endif + } + } + } + return 0; +} diff --git a/avcall/avcall-x86_64-windows.s b/avcall/avcall-x86_64-windows.s new file mode 100644 index 0000000..73b140d --- /dev/null +++ b/avcall/avcall-x86_64-windows.s @@ -0,0 +1,369 @@ + .file "avcall-x86_64-windows.c" + .text + .p2align 4,,15 + .globl avcall_call + .type avcall_call, @function +avcall_call: +.LFB0: + pushq %rbp +.LCFI0: + movq %rsp, %rbp +.LCFI1: + pushq %rsi + pushq %rbx +.LCFI2: + movq %rcx, %rbx + subq $32, %rsp + movq 48(%rcx), %rcx + movq 40(%rbx), %rax + subq $2064, %rsp + subq %rcx, %rax + sarq $3, %rax + cmpl $4, %eax + jle .L6 + leal -5(%rax), %r8d + leaq 32(%rsp), %r9 + xorl %eax, %eax + addq $1, %r8 + .p2align 4,,10 + .p2align 3 +.L5: + movq 32(%rcx,%rax,8), %rdx + movq %rdx, (%r9,%rax,8) + addq $1, %rax + cmpq %r8, %rax + jne .L5 +.L6: + movl 68(%rbx), %eax + testl %eax, %eax + je .L7 + testb $1, %al + je .L8 + movss 76(%rbx), %xmm0 +.L8: + testb $2, %al + je .L9 + movss 80(%rbx), %xmm1 +.L9: + testb $4, %al + je .L10 + movss 84(%rbx), %xmm2 +.L10: + testb $8, %al + jne .L78 +.L7: + movl 72(%rbx), %eax + testl %eax, %eax + je .L12 + testb $1, %al + je .L13 + movsd 96(%rbx), %xmm0 +.L13: + testb $2, %al + je .L14 + movsd 104(%rbx), %xmm1 +.L14: + testb $4, %al + je .L15 + movsd 112(%rbx), %xmm2 +.L15: + testb $8, %al + jne .L79 +.L12: + movl 24(%rbx), %eax + cmpl $13, %eax + je .L80 + cmpl $14, %eax + je .L81 + movq 8(%rcx), %rdx + movq 24(%rcx), %r9 + movq 16(%rcx), %r8 + movq (%rcx), %rcx + call *8(%rbx) + movl 24(%rbx), %edx + cmpl $1, %edx + je .L18 + testl %edx, %edx + je .L76 + cmpl $2, %edx + je .L73 + cmpl $3, %edx + je .L73 + cmpl $4, %edx + je .L73 + cmpl $5, %edx + je .L74 + cmpl $6, %edx + je .L74 + cmpl $7, %edx + je .L75 + cmpl $8, %edx + je .L75 + cmpl $9, %edx + je .L76 + cmpl $10, %edx + je .L76 + cmpl $11, %edx + je .L76 + cmpl $12, %edx + je .L76 + cmpl $15, %edx + je .L76 + cmpl $16, %edx + jne .L18 + testl $512, (%rbx) + je .L18 + movq 32(%rbx), %r8 + leaq -4(%r8), %rdx + testq $-5, %rdx + je .L35 + leaq -1(%r8), %rdx + cmpq $1, %rdx + ja .L18 +.L35: + movq 16(%rbx), %rdx + movq %rdx, %r9 + andl $7, %edx + addq %rdx, %r8 + andq $-8, %r9 + cmpq $8, %r8 + jbe .L82 + leal 0(,%rdx,8), %ecx + movq (%r9), %r10 + movq %rax, %rsi + movq $-1, %r11 + negl %edx + salq %cl, %rsi + salq %cl, %r11 + movq %rsi, %rcx + xorq %r10, %rcx + andq %r11, %rcx + xorq %r10, %rcx + movq 8(%r9), %r10 + movq %rcx, (%r9) + leal -65(,%r8,8), %ecx + movl $2, %r8d + salq %cl, %r8 + leal 64(,%rdx,8), %ecx + subq $1, %r8 + sarq %cl, %rax + xorq %r10, %rax + andq %r8, %rax + xorq %r10, %rax + movq %rax, 8(%r9) +.L18: + leaq -16(%rbp), %rsp + xorl %eax, %eax + popq %rbx +.LCFI3: + popq %rsi +.LCFI4: + popq %rbp +.LCFI5: + ret + .p2align 4,,10 + .p2align 3 +.L79: +.LCFI6: + movsd 120(%rbx), %xmm3 + jmp .L12 + .p2align 4,,10 + .p2align 3 +.L78: + movss 88(%rbx), %xmm3 + jmp .L7 + .p2align 4,,10 + .p2align 3 +.L76: + movq 16(%rbx), %rdx + movq %rax, (%rdx) + leaq -16(%rbp), %rsp + xorl %eax, %eax + popq %rbx +.LCFI7: + popq %rsi +.LCFI8: + popq %rbp +.LCFI9: + ret + .p2align 4,,10 + .p2align 3 +.L73: +.LCFI10: + movq 16(%rbx), %rdx + movb %al, (%rdx) + leaq -16(%rbp), %rsp + xorl %eax, %eax + popq %rbx +.LCFI11: + popq %rsi +.LCFI12: + popq %rbp +.LCFI13: + ret + .p2align 4,,10 + .p2align 3 +.L81: +.LCFI14: + movq 16(%rbx), %rsi + movq 8(%rcx), %rdx + movq 24(%rcx), %r9 + movq 16(%rcx), %r8 + movq (%rcx), %rcx + call *8(%rbx) + movsd %xmm0, (%rsi) + leaq -16(%rbp), %rsp + xorl %eax, %eax + popq %rbx +.LCFI15: + popq %rsi +.LCFI16: + popq %rbp +.LCFI17: + ret +.L80: +.LCFI18: + movq 16(%rbx), %rsi + movq 8(%rcx), %rdx + movq 24(%rcx), %r9 + movq 16(%rcx), %r8 + movq (%rcx), %rcx + call *8(%rbx) + movss %xmm0, (%rsi) + jmp .L18 +.L74: + movq 16(%rbx), %rdx + movw %ax, (%rdx) + jmp .L18 +.L75: + movq 16(%rbx), %rdx + movl %eax, (%rdx) + jmp .L18 +.L82: + leal -1(,%r8,8), %ecx + movq (%r9), %r10 + sall $3, %edx + movl $2, %r8d + movl $1, %r11d + salq %cl, %r8 + movl %edx, %ecx + salq %cl, %r11 + salq %cl, %rax + subq %r11, %r8 + xorq %r10, %rax + andq %r8, %rax + xorq %r10, %rax + movq %rax, (%r9) + jmp .L18 +.LFE0: + .size avcall_call, .-avcall_call + .section .eh_frame,"a",@progbits +.Lframe1: + .long .LECIE1-.LSCIE1 +.LSCIE1: + .long 0 + .byte 0x3 + .string "zR" + .uleb128 0x1 + .sleb128 -8 + .uleb128 0x10 + .uleb128 0x1 + .byte 0x1b + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x90 + .uleb128 0x1 + .align 8 +.LECIE1: +.LSFDE1: + .long .LEFDE1-.LASFDE1 +.LASFDE1: + .long .LASFDE1-.Lframe1 + .long .LFB0-. + .long .LFE0-.LFB0 + .uleb128 0 + .byte 0x4 + .long .LCFI0-.LFB0 + .byte 0xe + .uleb128 0x10 + .byte 0x86 + .uleb128 0x2 + .byte 0x4 + .long .LCFI1-.LCFI0 + .byte 0xd + .uleb128 0x6 + .byte 0x4 + .long .LCFI2-.LCFI1 + .byte 0x84 + .uleb128 0x3 + .byte 0x83 + .uleb128 0x4 + .byte 0x4 + .long .LCFI3-.LCFI2 + .byte 0xa + .byte 0xc3 + .byte 0x4 + .long .LCFI4-.LCFI3 + .byte 0xc4 + .byte 0x4 + .long .LCFI5-.LCFI4 + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI6-.LCFI5 + .byte 0xb + .byte 0x4 + .long .LCFI7-.LCFI6 + .byte 0xa + .byte 0xc3 + .byte 0x4 + .long .LCFI8-.LCFI7 + .byte 0xc4 + .byte 0x4 + .long .LCFI9-.LCFI8 + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI10-.LCFI9 + .byte 0xb + .byte 0x4 + .long .LCFI11-.LCFI10 + .byte 0xa + .byte 0xc3 + .byte 0x4 + .long .LCFI12-.LCFI11 + .byte 0xc4 + .byte 0x4 + .long .LCFI13-.LCFI12 + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI14-.LCFI13 + .byte 0xb + .byte 0x4 + .long .LCFI15-.LCFI14 + .byte 0xa + .byte 0xc3 + .byte 0x4 + .long .LCFI16-.LCFI15 + .byte 0xc4 + .byte 0x4 + .long .LCFI17-.LCFI16 + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI18-.LCFI17 + .byte 0xb + .align 8 +.LEFDE1: + .ident "GCC: (GNU) 5.4.0" + .section .note.GNU-stack,"",@progbits diff --git a/avcall/avcall-x86_64-x32-linux.s b/avcall/avcall-x86_64-x32-linux.s new file mode 100644 index 0000000..8f3931d --- /dev/null +++ b/avcall/avcall-x86_64-x32-linux.s @@ -0,0 +1,632 @@ + .file "avcall-x86_64.c" + .section .text.unlikely,"ax",@progbits +.LCOLDB1: + .text +.LHOTB1: + .p2align 4,,15 + .globl avcall_call + .type avcall_call, @function +avcall_call: +.LFB0: + pushq %rbp +.LCFI0: + movl %esp, %ebp +.LCFI1: + pushq %r12 + pushq %rbx +.LCFI2: + movq %rdi, %rbx + movl 24(%edi), %edi + movl 20(%ebx), %ecx + movl 88(%ebx), %r8d + subl $2064, %esp + leal 96(%rbx), %eax + leal 15(%rsp), %esi + subl %edi, %ecx + subl %eax, %r8d + andl $-16, %esi + sarl $3, %ecx + sarl $3, %r8d + xorl %eax, %eax + testl %ecx, %ecx + jle .L6 + .p2align 4,,10 + .p2align 3 +.L77: + movq (%edi,%eax,8), %rdx + movq %rdx, (%esi,%eax,8) + addl $1, %eax + cmpl %eax, %ecx + jne .L77 +.L6: + movl 12(%ebx), %eax + cmpl $13, %eax + je .L95 + cmpl $14, %eax + je .L96 + cmpl $7, %r8d + movl 4(%ebx), %r10d + jle .L39 + movsd 152(%ebx), %xmm14 +.L40: + movsd 144(%ebx), %xmm13 +.L42: + movsd 136(%ebx), %xmm12 +.L44: + movsd 128(%ebx), %xmm11 +.L46: + movsd 120(%ebx), %xmm10 +.L48: + movsd 112(%ebx), %xmm9 +.L50: + movsd 104(%ebx), %xmm8 +.L52: + movsd 96(%ebx), %xmm15 +.L53: + movq 64(%ebx), %rcx + movq 56(%ebx), %rdx + movl $8, %eax + movq 48(%ebx), %rsi + movq 40(%ebx), %rdi + movapd %xmm14, %xmm7 + movapd %xmm13, %xmm6 + movapd %xmm12, %xmm5 + movq 80(%ebx), %r9 + movapd %xmm11, %xmm4 + movq 72(%ebx), %r8 + movapd %xmm10, %xmm3 + movapd %xmm9, %xmm2 + movapd %xmm8, %xmm1 + movapd %xmm15, %xmm0 + call *%r10 + movl 12(%ebx), %ecx + cmpl $1, %ecx + je .L22 + testl %ecx, %ecx + je .L92 + cmpl $2, %ecx + je .L86 + cmpl $3, %ecx + je .L86 + cmpl $4, %ecx + je .L86 + cmpl $5, %ecx + je .L87 + cmpl $6, %ecx + je .L87 + cmpl $7, %ecx + je .L91 + cmpl $8, %ecx + je .L91 + cmpl $9, %ecx + je .L91 + cmpl $10, %ecx + je .L91 + cmpl $11, %ecx + je .L92 + cmpl $12, %ecx + je .L92 + cmpl $15, %ecx + je .L91 + cmpl $16, %ecx + jne .L22 + testl $512, (%ebx) + je .L22 + movl 16(%ebx), %ecx + leal -1(%rcx), %esi + cmpl $15, %esi + ja .L22 + movl 8(%ebx), %esi + movl %esi, %edi + andl $7, %esi + andl $-8, %edi + cmpl $8, %ecx + leal (%rcx,%rsi), %r8d + ja .L67 + cmpl $8, %r8d + ja .L68 + leal -1(,%r8,8), %ecx + movq (%edi), %r9 + sall $3, %esi + movl $2, %edx + movl $1, %r8d + salq %cl, %rdx + movl %esi, %ecx + salq %cl, %r8 + salq %cl, %rax + subq %r8, %rdx + xorq %r9, %rax + andq %rdx, %rax + xorq %r9, %rax + movq %rax, (%edi) +.L22: + leal -16(%rbp), %esp + xorl %eax, %eax + popq %rbx + popq %r12 + popq %rbp +.LCFI3: + ret + .p2align 4,,10 + .p2align 3 +.L39: +.LCFI4: + je .L97 + cmpl $6, %r8d + je .L98 + cmpl $5, %r8d + je .L99 + cmpl $4, %r8d + je .L100 + cmpl $3, %r8d + je .L101 + cmpl $2, %r8d + je .L102 + pxor %xmm8, %xmm8 + cmpl $1, %r8d + movapd %xmm8, %xmm9 + movapd %xmm8, %xmm10 + movapd %xmm8, %xmm11 + movapd %xmm8, %xmm12 + movapd %xmm8, %xmm13 + movapd %xmm8, %xmm14 + je .L52 + movapd %xmm8, %xmm15 + jmp .L53 + .p2align 4,,10 + .p2align 3 +.L95: + cmpl $7, %r8d + movl 8(%ebx), %r12d + movl 4(%ebx), %r10d + jle .L7 + movsd 152(%ebx), %xmm14 +.L8: + movsd 144(%ebx), %xmm13 +.L10: + movsd 136(%ebx), %xmm12 +.L12: + movsd 128(%ebx), %xmm11 +.L14: + movsd 120(%ebx), %xmm10 +.L16: + movsd 112(%ebx), %xmm9 +.L18: + movsd 104(%ebx), %xmm8 +.L20: + movsd 96(%ebx), %xmm15 + jmp .L21 + .p2align 4,,10 + .p2align 3 +.L96: + cmpl $7, %r8d + movl 8(%ebx), %r12d + movl 4(%ebx), %r10d + jle .L24 + movsd 152(%ebx), %xmm14 +.L25: + movsd 144(%ebx), %xmm13 +.L27: + movsd 136(%ebx), %xmm12 +.L29: + movsd 128(%ebx), %xmm11 +.L31: + movsd 120(%ebx), %xmm10 +.L33: + movsd 112(%ebx), %xmm9 +.L35: + movsd 104(%ebx), %xmm8 +.L37: + movsd 96(%ebx), %xmm15 +.L38: + movq 64(%ebx), %rcx + movq 56(%ebx), %rdx + movl $8, %eax + movq 48(%ebx), %rsi + movq 40(%ebx), %rdi + movq 80(%ebx), %r9 + movq 72(%ebx), %r8 + movapd %xmm14, %xmm7 + movapd %xmm13, %xmm6 + movapd %xmm12, %xmm5 + movapd %xmm11, %xmm4 + movapd %xmm10, %xmm3 + movapd %xmm9, %xmm2 + movapd %xmm8, %xmm1 + movapd %xmm15, %xmm0 + call *%r10 + movsd %xmm0, (%r12d) + leal -16(%rbp), %esp + xorl %eax, %eax + popq %rbx + popq %r12 + popq %rbp +.LCFI5: + ret + .p2align 4,,10 + .p2align 3 +.L7: +.LCFI6: + je .L103 + cmpl $6, %r8d + je .L104 + cmpl $5, %r8d + je .L105 + cmpl $4, %r8d + je .L106 + cmpl $3, %r8d + je .L107 + cmpl $2, %r8d + je .L108 + pxor %xmm8, %xmm8 + cmpl $1, %r8d + movapd %xmm8, %xmm9 + movapd %xmm8, %xmm10 + movapd %xmm8, %xmm11 + movapd %xmm8, %xmm12 + movapd %xmm8, %xmm13 + movapd %xmm8, %xmm14 + movapd %xmm8, %xmm15 + je .L20 +.L21: + movq 64(%ebx), %rcx + movq 56(%ebx), %rdx + movl $8, %eax + movq 48(%ebx), %rsi + movq 40(%ebx), %rdi + movq 80(%ebx), %r9 + movq 72(%ebx), %r8 + movapd %xmm14, %xmm7 + movapd %xmm13, %xmm6 + movapd %xmm12, %xmm5 + movapd %xmm11, %xmm4 + movapd %xmm10, %xmm3 + movapd %xmm9, %xmm2 + movapd %xmm8, %xmm1 + movapd %xmm15, %xmm0 + call *%r10 + movss %xmm0, (%r12d) + leal -16(%rbp), %esp + xorl %eax, %eax + popq %rbx + popq %r12 + popq %rbp +.LCFI7: + ret + .p2align 4,,10 + .p2align 3 +.L102: +.LCFI8: + pxor %xmm9, %xmm9 + movapd %xmm9, %xmm10 + movapd %xmm9, %xmm11 + movapd %xmm9, %xmm12 + movapd %xmm9, %xmm13 + movapd %xmm9, %xmm14 + jmp .L50 +.L24: + je .L109 + cmpl $6, %r8d + je .L110 + cmpl $5, %r8d + je .L111 + cmpl $4, %r8d + je .L112 + cmpl $3, %r8d + je .L113 + cmpl $2, %r8d + je .L114 + pxor %xmm8, %xmm8 + cmpl $1, %r8d + movapd %xmm8, %xmm9 + movapd %xmm8, %xmm10 + movapd %xmm8, %xmm11 + movapd %xmm8, %xmm12 + movapd %xmm8, %xmm13 + movapd %xmm8, %xmm14 + movapd %xmm8, %xmm15 + jne .L38 + jmp .L37 + .p2align 4,,10 + .p2align 3 +.L86: + movl 8(%ebx), %edx + movb %al, (%edx) + leal -16(%rbp), %esp + xorl %eax, %eax + popq %rbx + popq %r12 + popq %rbp +.LCFI9: + ret +.L91: +.LCFI10: + movl 8(%ebx), %edx + movl %eax, (%edx) + jmp .L22 + .p2align 4,,10 + .p2align 3 +.L92: + movl 8(%ebx), %edx + movq %rax, (%edx) + leal -16(%rbp), %esp + xorl %eax, %eax + popq %rbx + popq %r12 + popq %rbp +.LCFI11: + ret +.L108: +.LCFI12: + pxor %xmm9, %xmm9 + movapd %xmm9, %xmm10 + movapd %xmm9, %xmm11 + movapd %xmm9, %xmm12 + movapd %xmm9, %xmm13 + movapd %xmm9, %xmm14 + jmp .L18 +.L87: + movl 8(%ebx), %edx + movw %ax, (%edx) + jmp .L22 +.L114: + pxor %xmm9, %xmm9 + movapd %xmm9, %xmm10 + movapd %xmm9, %xmm11 + movapd %xmm9, %xmm12 + movapd %xmm9, %xmm13 + movapd %xmm9, %xmm14 + jmp .L35 +.L68: + leal 0(,%rsi,8), %ecx + movq $-1, %rdx + movq (%edi), %r9 + negl %esi + salq %cl, %rdx + movq %rdx, %r10 + movq %rax, %rdx + salq %cl, %rdx + leal -65(,%r8,8), %ecx + xorq %r9, %rdx + andq %r10, %rdx + xorq %r9, %rdx + movq 8(%edi), %r9 + movq %rdx, (%edi) + movl $2, %edx + salq %cl, %rdx + leal 64(,%rsi,8), %ecx + subq $1, %rdx + sarq %cl, %rax + xorq %r9, %rax + andq %rdx, %rax + xorq %r9, %rax + movq %rax, 8(%edi) + jmp .L22 +.L67: + leal 0(,%rsi,8), %r10d + movq (%edi), %r9 + movq %rax, %rbx + movq $-1, %r11 + movl %r10d, %ecx + salq %cl, %rbx + salq %cl, %r11 + movq %rbx, %rcx + xorq %r9, %rcx + andq %r11, %rcx + xorq %r9, %rcx + cmpl $16, %r8d + movq %rcx, (%edi) + jbe .L115 + negl %esi + movq 16(%edi), %r9 + leal 64(,%rsi,8), %r11d + movq %rdx, %rsi + movl %r11d, %ecx + sarq %cl, %rax + movl %r10d, %ecx + salq %cl, %rsi + leal -129(,%r8,8), %ecx + orq %rsi, %rax + movq %rax, 8(%edi) + movl $2, %eax + salq %cl, %rax + movl %r11d, %ecx + leaq -1(%rax), %rsi + movq %rdx, %rax + sarq %cl, %rax + xorq %r9, %rax + andq %rsi, %rax + xorq %r9, %rax + movq %rax, 16(%edi) + jmp .L22 +.L101: + pxor %xmm10, %xmm10 + movapd %xmm10, %xmm11 + movapd %xmm10, %xmm12 + movapd %xmm10, %xmm13 + movapd %xmm10, %xmm14 + jmp .L48 +.L115: + negl %esi + leal -65(,%r8,8), %ecx + movq 8(%edi), %r9 + leal 32(,%rsi,4), %r11d + movl $2, %esi + salq %cl, %rsi + movl %r11d, %ecx + subq $1, %rsi + sarq %cl, %rax + sarq %cl, %rax + movl %r10d, %ecx + salq %cl, %rdx + orq %rdx, %rax + xorq %r9, %rax + andq %rsi, %rax + xorq %r9, %rax + movq %rax, 8(%edi) + jmp .L22 +.L113: + pxor %xmm10, %xmm10 + movapd %xmm10, %xmm11 + movapd %xmm10, %xmm12 + movapd %xmm10, %xmm13 + movapd %xmm10, %xmm14 + jmp .L33 +.L112: + pxor %xmm11, %xmm11 + movapd %xmm11, %xmm12 + movapd %xmm11, %xmm13 + movapd %xmm11, %xmm14 + jmp .L31 +.L97: + pxor %xmm14, %xmm14 + jmp .L40 +.L98: + pxor %xmm13, %xmm13 + movapd %xmm13, %xmm14 + jmp .L42 +.L99: + pxor %xmm12, %xmm12 + movapd %xmm12, %xmm13 + movapd %xmm12, %xmm14 + jmp .L44 +.L100: + pxor %xmm11, %xmm11 + movapd %xmm11, %xmm12 + movapd %xmm11, %xmm13 + movapd %xmm11, %xmm14 + jmp .L46 +.L111: + pxor %xmm12, %xmm12 + movapd %xmm12, %xmm13 + movapd %xmm12, %xmm14 + jmp .L29 +.L110: + pxor %xmm13, %xmm13 + movapd %xmm13, %xmm14 + jmp .L27 +.L109: + pxor %xmm14, %xmm14 + jmp .L25 +.L107: + pxor %xmm10, %xmm10 + movapd %xmm10, %xmm11 + movapd %xmm10, %xmm12 + movapd %xmm10, %xmm13 + movapd %xmm10, %xmm14 + jmp .L16 +.L106: + pxor %xmm11, %xmm11 + movapd %xmm11, %xmm12 + movapd %xmm11, %xmm13 + movapd %xmm11, %xmm14 + jmp .L14 +.L105: + pxor %xmm12, %xmm12 + movapd %xmm12, %xmm13 + movapd %xmm12, %xmm14 + jmp .L12 +.L104: + pxor %xmm13, %xmm13 + movapd %xmm13, %xmm14 + jmp .L10 +.L103: + pxor %xmm14, %xmm14 + jmp .L8 +.LFE0: + .size avcall_call, .-avcall_call + .section .text.unlikely +.LCOLDE1: + .text +.LHOTE1: + .section .eh_frame,"a",@progbits +.Lframe1: + .long .LECIE1-.LSCIE1 +.LSCIE1: + .long 0 + .byte 0x3 + .string "zR" + .uleb128 0x1 + .sleb128 -8 + .uleb128 0x10 + .uleb128 0x1 + .byte 0x1b + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x90 + .uleb128 0x1 + .align 4 +.LECIE1: +.LSFDE1: + .long .LEFDE1-.LASFDE1 +.LASFDE1: + .long .LASFDE1-.Lframe1 + .long .LFB0-. + .long .LFE0-.LFB0 + .uleb128 0 + .byte 0x4 + .long .LCFI0-.LFB0 + .byte 0xe + .uleb128 0x10 + .byte 0x86 + .uleb128 0x2 + .byte 0x4 + .long .LCFI1-.LCFI0 + .byte 0xd + .uleb128 0x6 + .byte 0x4 + .long .LCFI2-.LCFI1 + .byte 0x8c + .uleb128 0x3 + .byte 0x83 + .uleb128 0x4 + .byte 0x4 + .long .LCFI3-.LCFI2 + .byte 0xa + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI4-.LCFI3 + .byte 0xb + .byte 0x4 + .long .LCFI5-.LCFI4 + .byte 0xa + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI6-.LCFI5 + .byte 0xb + .byte 0x4 + .long .LCFI7-.LCFI6 + .byte 0xa + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI8-.LCFI7 + .byte 0xb + .byte 0x4 + .long .LCFI9-.LCFI8 + .byte 0xa + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI10-.LCFI9 + .byte 0xb + .byte 0x4 + .long .LCFI11-.LCFI10 + .byte 0xa + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI12-.LCFI11 + .byte 0xb + .align 4 +.LEFDE1: + .ident "GCC: (GNU) 5.4.0" + .section .note.GNU-stack,"",@progbits diff --git a/avcall/avcall-x86_64.c b/avcall/avcall-x86_64.c new file mode 100644 index 0000000..e3b2627 --- /dev/null +++ b/avcall/avcall-x86_64.c @@ -0,0 +1,342 @@ +/** + Copyright 1993 Bill Triggs + Copyright 1995-2017 Bruno Haible + + 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, see . +**/ +/*---------------------------------------------------------------------- + Foreign function interface for an x86_64 (a.k.a. amd64) with gcc + using the Unix ABI ('gcc -mabi=sysv'). + + This calls a C function with an argument list built up using macros + defined in avcall.h. + + x86_64 Argument Passing Conventions on Unix: + + Documentation is at https://github.com/hjl-tools/x86-psABI/wiki/X86-psABI + + * Arguments: + - Integer or pointer arguments: + The first 6 integer or pointer arguments get passed in integer + registers (%rdi, %rsi, %rdx, %rcx, %r8, %r9). + The remaining ones (as an entire word each) on the stack. + - Floating-point arguments: + Up to 8 float/double arguments are passed in SSE registers + (%xmm0..%xmm7). + The remaining ones (as an entire word each) on the stack. + - Structure arguments: + Structure args are passed as true structures embedded in the + argument stack. + * Return value: + Integers are returned in %rax, %rdx. Float/double values are returned + in %xmm0, %xmm1. To return a structure larger than 16 bytes, the called + function copies the value to space pointed to by its first argument, + and all other arguments are shifted down by one. + * Call-used registers: rax,rdx,rcx,rsi,rdi,r8-r11 + + ----------------------------------------------------------------------*/ +#include "avcall-internal.h" + +#define RETURN(TYPE,VAL) (*(TYPE*)l->raddr = (TYPE)(VAL)) + +/*register __avword iarg1 __asm__("rdi");*/ +/*register __avword iarg2 __asm__("rsi");*/ +/*register __avword iarg3 __asm__("rdx");*/ +/*register __avword iarg4 __asm__("rcx");*/ +/*register __avword iarg5 __asm__("r8");*/ +/*register __avword iarg6 __asm__("r9");*/ + +register double farg1 __asm__("xmm0"); +register double farg2 __asm__("xmm1"); +register double farg3 __asm__("xmm2"); +register double farg4 __asm__("xmm3"); +register double farg5 __asm__("xmm4"); +register double farg6 __asm__("xmm5"); +register double farg7 __asm__("xmm6"); +register double farg8 __asm__("xmm7"); + +int +avcall_call(av_alist* list) +{ + register __avword* sp __asm__("rsp"); /* C names for registers */ +/*register __avword iretreg __asm__("rax");*/ + register __avword iret2reg __asm__("rdx"); + register double dret __asm__("xmm0"); + + __av_alist* l = &AV_LIST_INNER(list); + + __avword* argframe = __builtin_alloca(__AV_ALIST_WORDS * sizeof(__avword)); /* make room for argument list */ + int arglen = l->aptr - l->args; + int farglen = l->faptr - l->fargs; + __avword iret, iret2; + + { + int i; + for (i = 0; i < arglen; i++) /* push function args onto stack */ + argframe[i] = l->args[i]; + } + + /* Call function. + It's OK to pass 8 values in SSE registers even if the called function takes + less than 8 float/double arguments. Similarly for the integer arguments. */ + if (l->rtype == __AVfloat) { + *(float*)l->raddr = + (*(float(*)())l->func)(l->iargs[0], + l->iargs[1], + l->iargs[2], + l->iargs[3], + l->iargs[4], + l->iargs[5], + farglen > 0 ? l->fargs[0] : 0.0, + farglen > 1 ? l->fargs[1] : 0.0, + farglen > 2 ? l->fargs[2] : 0.0, + farglen > 3 ? l->fargs[3] : 0.0, + farglen > 4 ? l->fargs[4] : 0.0, + farglen > 5 ? l->fargs[5] : 0.0, + farglen > 6 ? l->fargs[6] : 0.0, + farglen > 7 ? l->fargs[7] : 0.0); + } else + if (l->rtype == __AVdouble) { + *(double*)l->raddr = + (*(double(*)())l->func)(l->iargs[0], + l->iargs[1], + l->iargs[2], + l->iargs[3], + l->iargs[4], + l->iargs[5], + farglen > 0 ? l->fargs[0] : 0.0, + farglen > 1 ? l->fargs[1] : 0.0, + farglen > 2 ? l->fargs[2] : 0.0, + farglen > 3 ? l->fargs[3] : 0.0, + farglen > 4 ? l->fargs[4] : 0.0, + farglen > 5 ? l->fargs[5] : 0.0, + farglen > 6 ? l->fargs[6] : 0.0, + farglen > 7 ? l->fargs[7] : 0.0); + } else { + iret = (*l->func)(l->iargs[0], + l->iargs[1], + l->iargs[2], + l->iargs[3], + l->iargs[4], + l->iargs[5], + farglen > 0 ? l->fargs[0] : 0.0, + farglen > 1 ? l->fargs[1] : 0.0, + farglen > 2 ? l->fargs[2] : 0.0, + farglen > 3 ? l->fargs[3] : 0.0, + farglen > 4 ? l->fargs[4] : 0.0, + farglen > 5 ? l->fargs[5] : 0.0, + farglen > 6 ? l->fargs[6] : 0.0, + farglen > 7 ? l->fargs[7] : 0.0); + iret2 = iret2reg; + + /* save return value */ + if (l->rtype == __AVvoid) { + } else + if (l->rtype == __AVword) { + RETURN(__avword, iret); + } else + if (l->rtype == __AVchar) { + RETURN(char, iret); + } else + if (l->rtype == __AVschar) { + RETURN(signed char, iret); + } else + if (l->rtype == __AVuchar) { + RETURN(unsigned char, iret); + } else + if (l->rtype == __AVshort) { + RETURN(short, iret); + } else + if (l->rtype == __AVushort) { + RETURN(unsigned short, iret); + } else + if (l->rtype == __AVint) { + RETURN(int, iret); + } else + if (l->rtype == __AVuint) { + RETURN(unsigned int, iret); + } else + if (l->rtype == __AVlong) { + RETURN(long, iret); + } else + if (l->rtype == __AVulong) { + RETURN(unsigned long, iret); + } else + if (l->rtype == __AVlonglong) { + RETURN(long long, iret); + } else + if (l->rtype == __AVulonglong) { + RETURN(unsigned long long, iret); + } else + /* see above + if (l->rtype == __AVfloat) { + } else + if (l->rtype == __AVdouble) { + } else + */ + if (l->rtype == __AVvoidp) { + RETURN(void*, iret); + } else + if (l->rtype == __AVstruct) { + if (l->flags & __AV_REGISTER_STRUCT_RETURN) { + /* Return structs of size <= 16 in registers. */ + if (l->rsize > 0 && l->rsize <= 16) { + void* raddr = l->raddr; + #if 0 /* Unoptimized */ + if (l->rsize == 1) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + } else + if (l->rsize == 2) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + } else + if (l->rsize == 3) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + } else + if (l->rsize == 4) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + } else + if (l->rsize == 5) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>32); + } else + if (l->rsize == 6) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>40); + } else + if (l->rsize == 7) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[6] = (unsigned char)(iret>>48); + } else + if (l->rsize >= 8 && l->rsize <= 16) { + ((unsigned char *)raddr)[0] = (unsigned char)(iret); + ((unsigned char *)raddr)[1] = (unsigned char)(iret>>8); + ((unsigned char *)raddr)[2] = (unsigned char)(iret>>16); + ((unsigned char *)raddr)[3] = (unsigned char)(iret>>24); + ((unsigned char *)raddr)[4] = (unsigned char)(iret>>32); + ((unsigned char *)raddr)[5] = (unsigned char)(iret>>40); + ((unsigned char *)raddr)[6] = (unsigned char)(iret>>48); + ((unsigned char *)raddr)[7] = (unsigned char)(iret>>56); + if (l->rsize == 8) { + } else + if (l->rsize == 9) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + } else + if (l->rsize == 10) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + } else + if (l->rsize == 11) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + } else + if (l->rsize == 12) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + } else + if (l->rsize == 13) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>32); + } else + if (l->rsize == 14) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>40); + } else + if (l->rsize == 15) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+6] = (unsigned char)(iret2>>48); + } else + if (l->rsize == 16) { + ((unsigned char *)raddr)[8+0] = (unsigned char)(iret2); + ((unsigned char *)raddr)[8+1] = (unsigned char)(iret2>>8); + ((unsigned char *)raddr)[8+2] = (unsigned char)(iret2>>16); + ((unsigned char *)raddr)[8+3] = (unsigned char)(iret2>>24); + ((unsigned char *)raddr)[8+4] = (unsigned char)(iret2>>32); + ((unsigned char *)raddr)[8+5] = (unsigned char)(iret2>>40); + ((unsigned char *)raddr)[8+6] = (unsigned char)(iret2>>48); + ((unsigned char *)raddr)[8+7] = (unsigned char)(iret2>>56); + } + } + #else /* Optimized: fewer conditional jumps, fewer memory accesses */ + uintptr_t count = l->rsize; /* > 0, ≤ 2*sizeof(__avword) */ + __avword* wordaddr = (__avword*)((uintptr_t)raddr & ~(uintptr_t)(sizeof(__avword)-1)); + uintptr_t start_offset = (uintptr_t)raddr & (uintptr_t)(sizeof(__avword)-1); /* ≥ 0, < sizeof(__avword) */ + uintptr_t end_offset = start_offset + count; /* > 0, < 3*sizeof(__avword) */ + if (count <= sizeof(__avword)) { + /* Use iret. */ + if (end_offset <= sizeof(__avword)) { + /* 0 < end_offset ≤ sizeof(__avword) */ + __avword mask0 = ((__avword)2 << (end_offset*8-1)) - ((__avword)1 << (start_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret << (start_offset*8))) & mask0; + } else { + /* sizeof(__avword) < end_offset < 2*sizeof(__avword), start_offset > 0 */ + __avword mask0 = - ((__avword)1 << (start_offset*8)); + __avword mask1 = ((__avword)2 << (end_offset*8-sizeof(__avword)*8-1)) - 1; + wordaddr[0] ^= (wordaddr[0] ^ (iret << (start_offset*8))) & mask0; + wordaddr[1] ^= (wordaddr[1] ^ (iret >> (sizeof(__avword)*8-start_offset*8))) & mask1; + } + } else { + /* Use iret, iret2. */ + __avword mask0 = - ((__avword)1 << (start_offset*8)); + wordaddr[0] ^= (wordaddr[0] ^ (iret << (start_offset*8))) & mask0; + if (end_offset <= 2*sizeof(__avword)) { + /* sizeof(__avword) < end_offset ≤ 2*sizeof(__avword) */ + __avword mask1 = ((__avword)2 << (end_offset*8-sizeof(__avword)*8-1)) - 1; + wordaddr[1] ^= (wordaddr[1] ^ ((iret >> (sizeof(__avword)*4-start_offset*4) >> (sizeof(__avword)*4-start_offset*4)) | (iret2 << (start_offset*8)))) & mask1; + } else { + /* 2*sizeof(__avword) < end_offset < 3*sizeof(__avword), start_offset > 0 */ + __avword mask2 = ((__avword)2 << (end_offset*8-2*sizeof(__avword)*8-1)) - 1; + wordaddr[1] = (iret >> (sizeof(__avword)*8-start_offset*8)) | (iret2 << (start_offset*8)); + wordaddr[2] ^= (wordaddr[2] ^ (iret2 >> (sizeof(__avword)*8-start_offset*8))) & mask2; + } + } + #endif + } + } + } + } + return 0; +} diff --git a/avcall/avcall.3 b/avcall/avcall.3 new file mode 100644 index 0000000..c297248 --- /dev/null +++ b/avcall/avcall.3 @@ -0,0 +1,280 @@ +.\" Copyright (C) 1993 Bill Triggs +.\" Copyright (C) 1995-2017 Bruno Haible +.\" +.\" This manual is covered by the GNU GPL. You can redistribute it and/or +.\" modify it under the terms of the GNU General Public License (GPL), either +.\" version 2 of the License, or (at your option) any later version published +.\" by the Free Software Foundation (FSF). +.\" A copy of the license is at . +.\" +.TH AVCALL 3 "23 July 2017" +.SH NAME +avcall \- build a C argument list incrementally and call a C function on it. +.SH SYNOPSIS +.B #include +.LP +.BI "av_alist " alist ";" +.LP +.BI av_start_ type "(" alist ", " "&func" +.RI "[["\c +.BI ", "\c +.I return_type\c +.RB "]" ", "\c +.I "&return_value"\c +.RB "]" ");" +.LP +.BI av_ type "(" alist ", "\c +.RI "["\c +.IB arg_type ","\c +.RI "] "\c +.IB value ");" +.LP +.BI "av_call(" alist ");" +.IX "av_alist" "" "\fLav_alist\fP \(em avcall argument list declaration" +.IX "av_start_type()" "" "\fLav_start_type()\fP \(em initialize avcall function" +.IX "av_type()" "" "\fLav_type()\fP \(em push next argument in avcall list" +.IX "av_call()" "" "\fLav_call()\fP \(em finish avcall argument list and call function" +.SH DESCRIPTION +.LP +This set of macros builds an argument list for a C function and calls +the function on it. It significantly reduces the amount of `glue' code +required for parsers, debuggers, imbedded interpreters, C extensions to +application programs and other situations where collections of functions +need to be called on lists of externally-supplied arguments. + +Function calling conventions differ considerably on different +machines and +.I avcall +attempts to provide some degree of isolation from such architecture +dependencies. + +The interface is like +.BR stdarg (3) +in reverse. All of the macros return 0 for success, < 0 for failure (e.g., +argument list overflow or type-not-supported). +.RS 0 +.TP +(1) +.B #include +.nf +and declare the argument list structure +.BI "av_alist " alist ; +.fi +.TP +(2) +Set any special flags. This is architecture and compiler dependent. +Compiler options that affect passing conventions may need to be flagged +by +.BR "#define" s +before the +.B "#include " +statement. However, the +.I configure +script should have determined which +.BR "#define" s +are needed and put them +at the top of +.BR avcall.h . +.TP +(3) +Initialize the alist with the function address and return value +pointer (if any). There is a separate macro for each simple return type +([u]char, [u]short, [u]int, [u]long, [u]longlong, float, double, where `u' +indicates `unsigned'). The macros for functions returning structures or +pointers require an explicit type argument. +.LP +E.g., +.LP +.BI "av_start_int (" alist ", " &func ", " &int_return ); +.LP +.BI "av_start_double (" alist ", " &func ", " &double_return ); +.LP +.BI "av_start_void (" alist ", " &func ); +.LP +.nf +.BI "av_start_struct (" alist ", " &func ", " struct_type ", " splittable ", " +.BI " " &struct_return ); +.fi +.LP +.nf +.BI "av_start_ptr (" alist ", " &func ", " pointer_type ", " +.BI " " &pointer_return ); +.fi +.LP +The +.I splittable +flag specifies whether the +.I struct_type +can be returned in registers such that every struct field fits entirely in +a single register. This needs to be specified for structs of size +2*sizeof(long). For structs of size <= sizeof(long), +.I splittable +is ignored and assumed to be 1. For structs of size > 2*sizeof(long), +.I splittable +is ignored and assumed to be 0. There are some handy macros for this: +.nf +.BI "av_word_splittable_1 (" type1 ) +.BI "av_word_splittable_2 (" type1 ", " type2 ) +.BI "av_word_splittable_3 (" type1 ", " type2 ", " type3 ) +.BI "av_word_splittable_4 (" type1 ", " type2 ", " type3 ", " type4 ) +.fi +For a struct with three slots +.nf +.BI "struct { " "type1 id1" "; " "type2 id2" "; " "type3 id3" "; }" +.fi +you can specify +.I splittable +as +.BI "av_word_splittable_3 (" type1 ", " type2 ", " type3 ) +.RB . +.TP +(4) +Push the arguments on to the list in order. Again there is a macro +for each simple built-in type, and the macros for structure and pointer +arguments require an extra type argument: +.LP +.BI "av_int (" alist ", " int_value ); +.LP +.BI "av_double (" alist ", " double_value ); +.LP +.BI "av_struct (" alist ", " struct_or_union_type ", " struct_value ); +.LP +.BI "av_ptr (" alist ", " pointer_type ", " pointer_value ); +.TP +(5) +Call the function, set the return value, and tidy up: +.LP +.BI "av_call (" alist ); +.RE + +.SH NOTES + +(1) Functions whose first declaration is in Kernighan & Ritchie style (i.e., +without a typed argument list) MUST use default K&R C expression promotions +(char and short to int, float to double) whether they are compiled by a K&R +or an ANSI compiler, because the true argument types may not be known at the +call point. Such functions typically back-convert their arguments to the +declared types on function entry. (In fact, the only way to pass a true char, +short or float in K&R C is by an explicit cast: +.B func((char)c,(float)f) +). +Similarly, some K&R compilers (such as Sun cc on the sparc) actually +return a float as a double. + +Hence, for arguments of functions declared in K&R style you should use +.B av_int(\|) +and +.B av_double(\|) +rather than +.B av_char(\|), +.B av_short(\|) +or +.B av_float(\|). +If you use a K&R compiler, the avcall header files may be able to +detect this and define +.B av_float(\|), +etc, appropriately, but with an ANSI compiler there is no way +.I avcall +can know how a function was declared, so you have to correct the +argument types yourself. + +(2) The explicit type arguments of the +.B av_struct(\|) +and +.B av_ptr(\|) +macros are typically used to calculate size, alignment, and passing +conventions. This may not be sufficient for some machines with unusual +structure and pointer handling: in this case additional +.B av_start_\c +.I type\c +.B (\|) +and +.B av_\c +.I type\c +.B (\|) +macros may be defined. + +(3) The macros +.BR av_start_longlong(\|) , +.BR av_start_ulonglong(\|) , +.B av_longlong(\|) +and +.B av_ulonglong(\|) +work only if the C compiler has a working +.B long long +64-bit integer type. + +(4) The struct types used in +.B av_start_struct(\|) +and +.B av_struct(\|) +must only contain (signed or unsigned) int, long, long long or pointer fields. +Struct types containing (signed or unsigned) char, short, float, double or +other structs are not supported. + +.SH SEE ALSO +.BR stdarg (3), +.BR varargs (3). + +.SH BUGS + +The current implementations have been tested on a selection of common +cases but there are probably still many bugs. + +There are typically built-in limits on the size of the argument-list, +which may also include the size of any structure arguments. + +The decision whether a struct is to be returned in registers or in memory +considers only the struct's size and alignment. This is inaccurate: for +example, gcc on m68k-next returns +.B "struct { char a,b,c; }" +in registers and +.B "struct { char a[3]; }" +in memory, although both types have the same size and the same alignment. + +.SH NON-BUGS + +All information is passed in CPU registers and the stack. The +.B avcall +package is therefore multithread-safe. + +.SH PORTING AVCALL + +Ports, bug-fixes, and suggestions are most welcome. The macros required +for argument pushing are pretty grungy, but it does seem to be possible +to port avcall to a range of machines. Ports to non-standard or +non-32-bit machines are especially welcome so we can sort the interface +out before it's too late. + +Knowledge about argument passing conventions can be found in the gcc +source, file +.RI gcc-2.6.3/config/ cpu / cpu .h, +section "Stack layout; function entry, exit and calling." + +Some of the grunge is usually handled by a C or assembly level glue +routine that actually pushes the arguments, calls the function and +unpacks any return value. +This is called avcall_call(\|). A precompiled assembler version for +people without gcc is also made available. The routine should ideally +have flags for the passing conventions of other compilers. + +Many of the current routines waste a lot of stack space and generally do +hairy things to stack frames - a bit more assembly code would probably +help things along quite a bit here. + +.SH AUTHOR + +Bill Triggs . + +.SH ACKNOWLEDGEMENTS + +Some initial ideas were stolen from the C interface to the Zelk +extensions to Oliver Laumann's Elk scheme interpreter by J.P.Lewis, NEC +C&C Research, (for Sun4 & SGI), and Roy +Featherstone's personal C interface library +for Sun[34] & SGI. I also looked at the machine-dependent parts of the +GCC and GDB distributions, and put the gcc asm(\|) extensions to good +use. Thanks guys! + +This work was partly supported by EC-ESPRIT Basic Research Action SECOND. + diff --git a/avcall/avcall.h b/avcall/avcall.h new file mode 100644 index 0000000..f429dc8 --- /dev/null +++ b/avcall/avcall.h @@ -0,0 +1,462 @@ +/* + * Copyright 1993-1995 Bill Triggs + * Copyright 1995-2019 Bruno Haible + * + * 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, see . + */ + +#ifndef _AVCALL_H +#define _AVCALL_H +/*---------------------------------------------------------------------- + av_call() foreign function interface. + + Varargs-style macros to build a C argument list incrementally + and call a function on it. + ----------------------------------------------------------------------*/ + +#include + +#include "ffcall-version.h" +#include "ffcall-abi.h" + + +/* Max # words in argument-list and temporary structure storage. + * If defined(__hppa__) && !defined(__hppa64__), this must be a multiple of 2. + */ +#ifndef __AV_ALIST_WORDS +#define __AV_ALIST_WORDS 256 +#endif + +/* Determine whether the current ABI is LLP64 + ('long' = 32-bit, 'long long' = 'void*' = 64-bit). */ +#if defined(__x86_64__) && defined(_WIN32) && !defined(__CYGWIN__) +#define __AV_LLP64 1 +#endif + +/* Determine the alignment of a type at compile time. + */ +#if defined(__GNUC__) || defined(__IBM__ALIGNOF__) +#define __AV_alignof __alignof__ +#elif defined(__cplusplus) +template struct __AV_alignof_helper { char __slot1; type __slot2; }; +#define __AV_alignof(type) offsetof (__AV_alignof_helper, __slot2) +#elif defined(__mips__) || defined(__mipsn32__) || defined(__mips64__) /* SGI compiler */ +#define __AV_alignof __builtin_alignof +#else +#define __AV_offsetof(type,ident) ((unsigned long)&(((type*)0)->ident)) +#define __AV_alignof(type) __AV_offsetof(struct { char __slot1; type __slot2; }, __slot2) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* C builtin types. + */ +#if defined(__mipsn32__) || defined(__x86_64_x32__) || defined(__AV_LLP64) +typedef long long __avword; +#else +typedef long __avword; +#endif + +enum __AVtype +{ + __AVword, + __AVvoid, + __AVchar, + __AVschar, + __AVuchar, + __AVshort, + __AVushort, + __AVint, + __AVuint, + __AVlong, + __AVulong, + __AVlonglong, + __AVulonglong, + __AVfloat, + __AVdouble, + __AVvoidp, + __AVstruct +}; + +enum __AV_alist_flags +{ + + /* how to return structs */ + /* There are basically 3 ways to return structs: + * a. The called function returns a pointer to static data. Not reentrant. + * Not supported any more. + * b. The caller passes the return structure address in a dedicated register + * or as a first (or last), invisible argument. The called function stores + * its result there. + * c. Like b, and the called function also returns the return structure + * address in the return value register. (This is not very distinguishable + * from b.) + * Independently of this, + * r. small structures (<= 4 or <= 8 bytes) may be returned in the return + * value register(s), or + * m. even small structures are passed in memory. + */ + /* gcc-2.6.3 employs the following strategy: + * - If PCC_STATIC_STRUCT_RETURN is defined in the machine description + * it uses method a, else method c. + * - If flag_pcc_struct_return is set (either by -fpcc-struct-return or if + * DEFAULT_PCC_STRUCT_RETURN is defined to 1 in the machine description) + * it uses method m, else (either by -freg-struct-return or if + * DEFAULT_PCC_STRUCT_RETURN is defined to 0 in the machine description) + * method r. + */ + __AV_SMALL_STRUCT_RETURN = 1<<1, /* r: special case for small structs */ + __AV_GCC_STRUCT_RETURN = 1<<2, /* consider 8 byte structs as small */ +#if defined(__sparc__) && !defined(__sparc64__) + __AV_SUNCC_STRUCT_RETURN = 1<<3, + __AV_SUNPROCC_STRUCT_RETURN = 1<<4, +#endif +#if defined(__i386__) + __AV_MSVC_STRUCT_RETURN = 1<<4, +#endif + /* the default way to return structs */ + /* This choice here is based on the assumption that the function you are + * going to call has been compiled with the same compiler you are using to + * include this file. + * If you want to call functions with another struct returning convention, + * just #define __AV_STRUCT_RETURN ... + * before or after #including . + */ +#ifndef __AV_STRUCT_RETURN + __AV_STRUCT_RETURN = +#if defined(__sparc__) && !defined(__sparc64__) && defined(__sun) && (defined(__SUNPRO_C) || defined(__SUNPRO_CC)) /* SUNWspro cc or CC */ + __AV_SUNPROCC_STRUCT_RETURN, +#else +#if (defined(__i386__) && (defined(_WIN32) || defined(__CYGWIN__) || (defined(__MACH__) && defined(__APPLE__)) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__))) || defined(__m68k__) || defined(__mipsn32__) || defined(__mips64__) || defined(__sparc64__) || defined(__hppa__) || defined(__hppa64__) || defined(__arm__) || defined(__armhf__) || defined(__arm64__) || defined(__powerpc64_elfv2__) || defined(__ia64__) || defined(__x86_64__) || defined(__riscv32__) || defined(__riscv64__) + __AV_SMALL_STRUCT_RETURN | +#endif +#if defined(__GNUC__) && !((defined(__mipsn32__) || defined(__mips64__)) && ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ > 3))) + __AV_GCC_STRUCT_RETURN | +#endif +#if defined(__i386__) && defined(_WIN32) && !defined(__CYGWIN__) /* native Windows */ + __AV_MSVC_STRUCT_RETURN | +#endif + 0, +#endif +#endif + + /* how to return floats */ +#if defined(__m68k__) || (defined(__sparc__) && !defined(__sparc64__)) + __AV_SUNCC_FLOAT_RETURN = 1<<5, +#endif +#if defined(__m68k__) + __AV_FREG_FLOAT_RETURN = 1<<6, +#endif + /* the default way to return floats */ + /* This choice here is based on the assumption that the function you are + * going to call has been compiled with the same compiler you are using to + * include this file. + * If you want to call functions with another float returning convention, + * just #define __AV_FLOAT_RETURN ... + * before or after #including . + */ +#ifndef __AV_FLOAT_RETURN +#if (defined(__m68k__) || (defined(__sparc__) && !defined(__sparc64__))) && !defined(__GNUC__) && defined(__sun) && !(defined(__SUNPRO_C) || defined(__SUNPRO_CC)) /* Sun cc or CC */ + __AV_FLOAT_RETURN = __AV_SUNCC_FLOAT_RETURN, +#elif defined(__m68k__) + __AV_FLOAT_RETURN = __AV_FREG_FLOAT_RETURN, +#else + __AV_FLOAT_RETURN = 0, +#endif +#endif + + /* how to pass structs */ +#if defined(__mips__) || defined(__mipsn32__) || defined(__mips64__) + __AV_SGICC_STRUCT_ARGS = 1<<7, +#endif +#if defined(__powerpc__) || defined(__powerpc64__) + __AV_AIXCC_STRUCT_ARGS = 1<<7, +#endif +#if defined(__ia64__) + __AV_OLDGCC_STRUCT_ARGS = 1<<7, +#endif + /* the default way to pass structs */ + /* This choice here is based on the assumption that the function you are + * going to call has been compiled with the same compiler you are using to + * include this file. + * If you want to call functions with another struct passing convention, + * just #define __AV_STRUCT_ARGS ... + * before or after #including . + */ +#ifndef __AV_STRUCT_ARGS +#if (defined(__mips__) && !defined(__mipsn32__) && !defined(__mips64__)) && !defined(__GNUC__) /* SGI mips cc */ + __AV_STRUCT_ARGS = __AV_SGICC_STRUCT_ARGS, +#else +#if (defined(__mipsn32__) || defined(__mips64__)) && (!defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ > 3)) /* SGI mips cc or gcc >= 3.4 */ + __AV_STRUCT_ARGS = __AV_SGICC_STRUCT_ARGS, +#else +#if defined(__powerpc__) && !defined(__powerpc64__) && defined(_AIX) && !defined(__GNUC__) /* AIX 32-bit cc, xlc */ + __AV_STRUCT_ARGS = __AV_AIXCC_STRUCT_ARGS, +#else +#if defined(__powerpc64__) && defined(_AIX) /* AIX 64-bit cc, xlc, gcc */ + __AV_STRUCT_ARGS = __AV_AIXCC_STRUCT_ARGS, +#else +#if defined(__ia64__) && !(defined(__GNUC__) && (__GNUC__ >= 3)) + __AV_STRUCT_ARGS = __AV_OLDGCC_STRUCT_ARGS, +#else + __AV_STRUCT_ARGS = 0, +#endif +#endif +#endif +#endif +#endif +#endif + + /* how to pass floats */ + /* ANSI C compilers and GNU gcc pass floats as floats. + * K&R C compilers pass floats as doubles. We don't support them any more. + */ +#if defined(__powerpc64__) + __AV_AIXCC_FLOAT_ARGS = 1<<8, /* pass floats in the low 4 bytes of an 8-bytes word */ +#endif + /* the default way to pass floats */ + /* This choice here is based on the assumption that the function you are + * going to call has been compiled with the same compiler you are using to + * include this file. + * If you want to call functions with another float passing convention, + * just #define __AV_FLOAT_ARGS ... + * before or after #including . + */ +#ifndef __AV_FLOAT_ARGS +#if defined(__powerpc64__) && defined(_AIX) && !defined(__GNUC__) /* AIX 64-bit xlc */ + __AV_FLOAT_ARGS = __AV_AIXCC_FLOAT_ARGS, +#else + __AV_FLOAT_ARGS = 0, +#endif +#endif + + /* how to pass and return small integer arguments */ + __AV_ANSI_INTEGERS = 0, /* no promotions */ + __AV_TRADITIONAL_INTEGERS = 0, /* promote [u]char, [u]short to [u]int */ + /* Fortunately these two methods are compatible. Our macros work with both. */ + + /* stack cleanup policy */ + __AV_CDECL_CLEANUP = 0, /* caller pops args after return */ + __AV_STDCALL_CLEANUP = 0, /* callee pops args before return */ + /* currently only supported on __i386__ */ +#ifndef __AV_CLEANUP + __AV_CLEANUP = __AV_CDECL_CLEANUP, +#endif + + /* These are for internal use only */ +#if defined(__i386__) || defined(__m68k__) || defined(__mipsn32__) || defined(__mips64__) || defined(__sparc64__) || defined(__alpha__) || defined(__hppa64__) || defined(__arm__) || defined(__armhf__) || defined(__arm64__) || defined(__powerpc__) || defined(__powerpc64__) || defined(__ia64__) || defined(__x86_64__) || (defined(__s390__) && !defined(__s390x__)) || defined(__riscv64__) + __AV_REGISTER_STRUCT_RETURN = 1<<9, +#endif + + __AV_flag_for_broken_compilers_that_dont_like_trailing_commas +}; + +#ifdef _AVCALL_INTERNAL_H +#include "avcall-alist.h" +#endif + +/* An upper bound for sizeof(__av_alist). + The total size of the __av_alist fields, ignoring alignment of fields, + varies from + 40 bytes (for __i386__, __m68k__, __sparc__, __hppa__, __arm__) + to + 232 bytes (for __arm64__). */ +#define __AV_ALIST_SIZE_BOUND 256 + +typedef struct +{ + /* First part: Fixed size __av_alist. */ + union { + char _av_m_room[__AV_ALIST_SIZE_BOUND]; +#ifdef _AVCALL_INTERNAL_H + __av_alist _av_m_alist; +#endif +/* GNU clisp pokes in internals of the alist! + When used by GNU clisp, assume a C compiler that supports anonymous unions + (GCC or an ISO C 11 compiler). */ +#ifdef LISPFUN + int flags; +#endif + /* For alignment. */ + long align1; + double align2; + long long align3; + long double align4; + } +#ifndef LISPFUN + _av_alist_head +#endif + ; + /* Second part: An array whose size depends on __AV_ALIST_WORDS. */ + union { + __avword _av_m_args[__AV_ALIST_WORDS]; + /* For alignment. */ + long align1; + double align2; + long long align3; + long double align4; + } _av_alist_flexarray; +} av_alist; + + +/* Delayed overflow detection */ +extern int avcall_overflown (av_alist* /* LIST */); +#define av_overflown(LIST) avcall_overflown(&(LIST)) + + +/* + * av_start_ macros which specify the return type + */ + +#define __AV_START_FLAGS \ + __AV_STRUCT_RETURN | __AV_FLOAT_RETURN | __AV_STRUCT_ARGS | __AV_FLOAT_ARGS | __AV_CLEANUP + +extern void avcall_start (av_alist* /* LIST */, __avword* /* LIST_ARGS */, __avword* /* LIST_ARGS_END */, __avword(* /* FUNC */)(), void* /* RADDR */, int /* RETTYPE */, int /* FLAGS */); + +#define av_start_void(LIST,FUNC) \ + avcall_start(&(LIST),(LIST)._av_alist_flexarray._av_m_args,&(LIST)._av_alist_flexarray._av_m_args[__AV_ALIST_WORDS],(__avword(*)())(FUNC),0, __AVvoid, __AV_START_FLAGS) +#define av_start_char(LIST,FUNC,RADDR) \ + avcall_start(&(LIST),(LIST)._av_alist_flexarray._av_m_args,&(LIST)._av_alist_flexarray._av_m_args[__AV_ALIST_WORDS],(__avword(*)())(FUNC),RADDR,__AVchar, __AV_START_FLAGS) +#define av_start_schar(LIST,FUNC,RADDR) \ + avcall_start(&(LIST),(LIST)._av_alist_flexarray._av_m_args,&(LIST)._av_alist_flexarray._av_m_args[__AV_ALIST_WORDS],(__avword(*)())(FUNC),RADDR,__AVschar, __AV_START_FLAGS) +#define av_start_uchar(LIST,FUNC,RADDR) \ + avcall_start(&(LIST),(LIST)._av_alist_flexarray._av_m_args,&(LIST)._av_alist_flexarray._av_m_args[__AV_ALIST_WORDS],(__avword(*)())(FUNC),RADDR,__AVuchar, __AV_START_FLAGS) +#define av_start_short(LIST,FUNC,RADDR) \ + avcall_start(&(LIST),(LIST)._av_alist_flexarray._av_m_args,&(LIST)._av_alist_flexarray._av_m_args[__AV_ALIST_WORDS],(__avword(*)())(FUNC),RADDR,__AVshort, __AV_START_FLAGS) +#define av_start_ushort(LIST,FUNC,RADDR) \ + avcall_start(&(LIST),(LIST)._av_alist_flexarray._av_m_args,&(LIST)._av_alist_flexarray._av_m_args[__AV_ALIST_WORDS],(__avword(*)())(FUNC),RADDR,__AVushort, __AV_START_FLAGS) +#define av_start_int(LIST,FUNC,RADDR) \ + avcall_start(&(LIST),(LIST)._av_alist_flexarray._av_m_args,&(LIST)._av_alist_flexarray._av_m_args[__AV_ALIST_WORDS],(__avword(*)())(FUNC),RADDR,__AVint, __AV_START_FLAGS) +#define av_start_uint(LIST,FUNC,RADDR) \ + avcall_start(&(LIST),(LIST)._av_alist_flexarray._av_m_args,&(LIST)._av_alist_flexarray._av_m_args[__AV_ALIST_WORDS],(__avword(*)())(FUNC),RADDR,__AVuint, __AV_START_FLAGS) +#define av_start_long(LIST,FUNC,RADDR) \ + avcall_start(&(LIST),(LIST)._av_alist_flexarray._av_m_args,&(LIST)._av_alist_flexarray._av_m_args[__AV_ALIST_WORDS],(__avword(*)())(FUNC),RADDR,__AVlong, __AV_START_FLAGS) +#define av_start_ulong(LIST,FUNC,RADDR) \ + avcall_start(&(LIST),(LIST)._av_alist_flexarray._av_m_args,&(LIST)._av_alist_flexarray._av_m_args[__AV_ALIST_WORDS],(__avword(*)())(FUNC),RADDR,__AVulong, __AV_START_FLAGS) +#define av_start_longlong(LIST,FUNC,RADDR) \ + avcall_start(&(LIST),(LIST)._av_alist_flexarray._av_m_args,&(LIST)._av_alist_flexarray._av_m_args[__AV_ALIST_WORDS],(__avword(*)())(FUNC),RADDR,__AVlonglong, __AV_START_FLAGS) +#define av_start_ulonglong(LIST,FUNC,RADDR) \ + avcall_start(&(LIST),(LIST)._av_alist_flexarray._av_m_args,&(LIST)._av_alist_flexarray._av_m_args[__AV_ALIST_WORDS],(__avword(*)())(FUNC),RADDR,__AVulonglong,__AV_START_FLAGS) +#define av_start_float(LIST,FUNC,RADDR) \ + avcall_start(&(LIST),(LIST)._av_alist_flexarray._av_m_args,&(LIST)._av_alist_flexarray._av_m_args[__AV_ALIST_WORDS],(__avword(*)())(FUNC),RADDR,__AVfloat, __AV_START_FLAGS) +#define av_start_double(LIST,FUNC,RADDR) \ + avcall_start(&(LIST),(LIST)._av_alist_flexarray._av_m_args,&(LIST)._av_alist_flexarray._av_m_args[__AV_ALIST_WORDS],(__avword(*)())(FUNC),RADDR,__AVdouble, __AV_START_FLAGS) +#define av_start_ptr(LIST,FUNC,TYPE,RADDR) \ + avcall_start(&(LIST),(LIST)._av_alist_flexarray._av_m_args,&(LIST)._av_alist_flexarray._av_m_args[__AV_ALIST_WORDS],(__avword(*)())(FUNC),RADDR,__AVvoidp, __AV_START_FLAGS) + +extern void avcall_start_struct (av_alist* /* LIST */, __avword* /* LIST_ARGS */, __avword* /* LIST_ARGS_END */, __avword(* /* FUNC */)(), size_t /* TYPE_SIZE */, int /* TYPE_SPLITTABLE */, void* /* RADDR */, int /* FLAGS */); + +#define av_start_struct(LIST,FUNC,TYPE,TYPE_SPLITTABLE,RADDR) \ + _av_start_struct(LIST,FUNC,sizeof(TYPE),TYPE_SPLITTABLE,RADDR) +/* Undocumented, but used by GNU clisp. */ +#define _av_start_struct(LIST,FUNC,TYPE_SIZE,TYPE_SPLITTABLE,RADDR) \ + avcall_start_struct(&(LIST),(LIST)._av_alist_flexarray._av_m_args,&(LIST)._av_alist_flexarray._av_m_args[__AV_ALIST_WORDS],(__avword(*)())(FUNC),TYPE_SIZE,TYPE_SPLITTABLE,RADDR,__AV_START_FLAGS) + + +/* + * av_ macros which specify the argument and its type + */ + +/* integer argument types */ + +extern int avcall_arg_long (av_alist* /* LIST */, long /* VAL */); +extern int avcall_arg_ulong (av_alist* /* LIST */, unsigned long /* VAL */); + +#define av_char(LIST,VAL) avcall_arg_long(&(LIST),(char)(VAL)) +#define av_schar(LIST,VAL) avcall_arg_long(&(LIST),(signed char)(VAL)) +#define av_short(LIST,VAL) avcall_arg_long(&(LIST),(short)(VAL)) +#define av_int(LIST,VAL) avcall_arg_long(&(LIST),(int)(VAL)) +#define av_long(LIST,VAL) avcall_arg_long(&(LIST),(long)(VAL)) +#define av_uchar(LIST,VAL) avcall_arg_ulong(&(LIST),(unsigned char)(VAL)) +#define av_ushort(LIST,VAL) avcall_arg_ulong(&(LIST),(unsigned short)(VAL)) +#define av_uint(LIST,VAL) avcall_arg_ulong(&(LIST),(unsigned int)(VAL)) +#define av_ulong(LIST,VAL) avcall_arg_ulong(&(LIST),(unsigned long)(VAL)) + +extern int avcall_arg_ptr (av_alist* /* LIST */, void* /* VAL */); + +#define av_ptr(LIST,TYPE,VAL) avcall_arg_ptr(&(LIST),(TYPE)(VAL)) + +extern int avcall_arg_longlong (av_alist* /* LIST */, long long /* VAL */); +extern int avcall_arg_ulonglong (av_alist* /* LIST */, unsigned long long /* VAL */); + +#define av_longlong(LIST,VAL) avcall_arg_longlong(&(LIST),VAL) +#define av_ulonglong(LIST,VAL) avcall_arg_ulonglong(&(LIST),VAL) + +/* floating-point argument types */ + +extern int avcall_arg_float (av_alist* /* LIST */, float /* VAL */); +#define av_float(LIST,VAL) avcall_arg_float(&(LIST),VAL) + +extern int avcall_arg_double (av_alist* /* LIST */, double /* VAL */); +#define av_double(LIST,VAL) avcall_arg_double(&(LIST),VAL) + +/* + * structure argument types + */ + +extern int avcall_arg_struct (av_alist* /* LIST */, size_t /* TYPE_SIZE */, size_t /* TYPE_ALIGN */, const void* /* VAL_ADDR */); + +#define av_struct(LIST,TYPE,VAL) \ + avcall_arg_struct(&(LIST),sizeof(TYPE),__AV_alignof(TYPE),&(VAL)) +/* _av_struct() is like av_struct(), except that you pass the type's size and alignment + * and the value's address instead of the type and the value themselves. + * Undocumented, but used by GNU clisp. + */ +#define _av_struct(LIST,TYPE_SIZE,TYPE_ALIGN,VAL_ADDR) \ + avcall_arg_struct(&(LIST),TYPE_SIZE,TYPE_ALIGN,VAL_ADDR) + +/* + * calling the function + */ + +extern int avcall_call (av_alist* /* LIST */); +#define av_call(LIST) avcall_call(&(LIST)) + +/* Determine whether a struct type is word-splittable, i.e. whether each of + * its components fit into a register. + * The entire computation is done at compile time. + */ +#define av_word_splittable_1(slot1) \ + (__av_offset1(slot1)/sizeof(__avword) == (__av_offset1(slot1)+sizeof(slot1)-1)/sizeof(__avword)) +#define av_word_splittable_2(slot1,slot2) \ + ((__av_offset1(slot1)/sizeof(__avword) == (__av_offset1(slot1)+sizeof(slot1)-1)/sizeof(__avword)) \ + && (__av_offset2(slot1,slot2)/sizeof(__avword) == (__av_offset2(slot1,slot2)+sizeof(slot2)-1)/sizeof(__avword)) \ + ) +#define av_word_splittable_3(slot1,slot2,slot3) \ + ((__av_offset1(slot1)/sizeof(__avword) == (__av_offset1(slot1)+sizeof(slot1)-1)/sizeof(__avword)) \ + && (__av_offset2(slot1,slot2)/sizeof(__avword) == (__av_offset2(slot1,slot2)+sizeof(slot2)-1)/sizeof(__avword)) \ + && (__av_offset3(slot1,slot2,slot3)/sizeof(__avword) == (__av_offset3(slot1,slot2,slot3)+sizeof(slot3)-1)/sizeof(__avword)) \ + ) +#define av_word_splittable_4(slot1,slot2,slot3,slot4) \ + ((__av_offset1(slot1)/sizeof(__avword) == (__av_offset1(slot1)+sizeof(slot1)-1)/sizeof(__avword)) \ + && (__av_offset2(slot1,slot2)/sizeof(__avword) == (__av_offset2(slot1,slot2)+sizeof(slot2)-1)/sizeof(__avword)) \ + && (__av_offset3(slot1,slot2,slot3)/sizeof(__avword) == (__av_offset3(slot1,slot2,slot3)+sizeof(slot3)-1)/sizeof(__avword)) \ + && (__av_offset4(slot1,slot2,slot3,slot4)/sizeof(__avword) == (__av_offset4(slot1,slot2,slot3,slot4)+sizeof(slot4)-1)/sizeof(__avword)) \ + ) +#define __av_offset1(slot1) \ + 0 +#define __av_offset2(slot1,slot2) \ + ((__av_offset1(slot1)+sizeof(slot1)+__AV_alignof(slot2)-1) & -(long)__AV_alignof(slot2)) +#define __av_offset3(slot1,slot2,slot3) \ + ((__av_offset2(slot1,slot2)+sizeof(slot2)+__AV_alignof(slot3)-1) & -(long)__AV_alignof(slot3)) +#define __av_offset4(slot1,slot2,slot3,slot4) \ + ((__av_offset3(slot1,slot2,slot3)+sizeof(slot3)+__AV_alignof(slot4)-1) & -(long)__AV_alignof(slot4)) + +#ifdef __cplusplus +} +#endif + +#endif /* _AVCALL_H */ diff --git a/avcall/avcall.html b/avcall/avcall.html new file mode 100644 index 0000000..9fcd138 --- /dev/null +++ b/avcall/avcall.html @@ -0,0 +1,277 @@ + + + + + AVCALL manual page + + +

AVCALL manual page

+ + +

+ +


+ + +

Name

+
+ +avcall - build a C argument list incrementally and call a +C function on it. + + +

Synopsis

+
+ +
+#include <avcall.h>
+av_alist alist;
+av_start_type (alist, &func, [[return_type,] &return_value]);
+av_type (alist, [arg_type,] value);
+av_call(alist);
+
+ + +

Description

+
+ +This set of macros builds an argument list for a C function +and calls the function on it. It significantly +reduces the amount of ‘glue’ code required for parsers, +debuggers, imbedded interpreters, C extensions to application +programs and other situations where collections of +functions need to be called on lists of externally- +supplied arguments. +

+Function calling conventions differ considerably on different +machines and avcall attempts to provide some degree +of isolation from such architecture dependencies. +

+The interface is like stdarg(3) in reverse. All of the +macros return 0 for success, < 0 for failure (e.g., argument +list overflow or type-not-supported). +

+

    +
  1. #include <avcall.h> and declare the argument list +structure av_alist alist; +

    +

  2. Set any special flags. This is architecture and compiler +dependent. +Compiler options that affect passing conventions may need +to be flagged by #defines before the #include <avcall.h> +statement. However, the configure script should have +determined which #defines are needed and put them +at the top of avcall.h. +

    +

  3. Initialize the alist with the function address and +return value pointer (if any). There is a separate macro +for each simple return type ([u]char, [u]short, [u]int, +[u]long, [u]longlong, float, double, where ‘u’ indicates +‘unsigned’). The macros for functions returning structures +or pointers require an explicit type argument. +

    +E.g., +

    +av_start_int (alist, &func, &int_return);
    +av_start_double (alist, &func, &double_return);
    +av_start_void (alist, &func);
    +av_start_struct (alist, &func, struct_type, splittable, &struct_return);
    +av_start_ptr (alist, &func, pointer_type, &pointer_return);
    +
    +The splittable flag specifies whether the struct_type can +be returned in registers such that every struct field fits +entirely in a single register. This needs to be specified +for structs of size 2*sizeof(long). For structs of size +<= sizeof(long), splittable is ignored and assumed to be 1. +For structs of size > 2*sizeof(long), splittable is +ignored and assumed to be 0. There are some handy macros +for this: +
    +av_word_splittable_1 (type1)
    +av_word_splittable_2 (type1, type2)
    +av_word_splittable_3 (type1, type2, type3)
    +av_word_splittable_4 (type1, type2, type3, type4)
    +
    +For a struct with three slots +
    +struct { type1 id1; type2 id2; type3 id3; }
    +
    +you can specify splittable as +av_word_splittable_3 (type1, type2, type3). +

    +

  4. Push the arguments on to the list in order. Again +there is a macro for each simple built-in type, and the +macros for structure and pointer arguments require an +extra type argument: +
    +av_int (alist, int_value);
    +av_double (alist, double_value);
    +av_struct (alist, struct_or_union_type, struct_value);
    +av_ptr (alist, pointer_type, pointer_value);
    +
    +
  5. Call the function, set the return value, and tidy up: +av_call (alist); +
+ + +

Notes

+
+ +
    +
  1. Functions whose first declaration is in Kernighan & +Ritchie style (i.e., without a typed argument list) MUST +use default K&R C expression promotions (char and short to +int, float to double) whether they are compiled by a K&R +or an ANSI compiler, because the true argument types may +not be known at the call point. Such functions typically +back-convert their arguments to the declared types on +function entry. (In fact, the only way to pass a true +char, short or float in K&R C is by an explicit cast: +func((char)c,(float)f) ). Similarly, some K&R compilers +(such as Sun cc on the sparc) actually return a float as a +double. +

    +Hence, for arguments of functions declared in K&R style +you should use av_int() and av_double() rather than +av_char(), av_short() or av_float(). If you use a K&R +compiler, the avcall header files may be able to detect +this and define av_float(), etc, appropriately, but with +an ANSI compiler there is no way avcall can know how a +function was declared, so you have to correct the argument +types yourself. +

    +

  2. The explicit type arguments of the av_struct() and +av_ptr() macros are typically used to calculate size, +alignment, and passing conventions. This may not be sufficient for some machines with unusual structure and +pointer handling: in this case additional av_start_type() +and av_type() macros may be defined. +

    +

  3. The macros av_start_longlong(), +av_start_ulonglong(), av_longlong() and +av_ulonglong() work only if the C compiler has a working +long long 64-bit integer type. +

    +

  4. The struct types used in av_start_struct() and +av_struct() must only contain (signed or unsigned) int, +long, long long or pointer fields. Struct types containing +(signed or unsigned) char, short, float, double or other +structs are not supported. +

    +

+ + +

See also

+
+stdarg(3), varargs(3). + + +

Bugs

+
+ +
    +
  • +The current implementations have been tested on a selection +of common cases but there are probably still many +bugs. +
  • +There are typically built-in limits on the size of the +argument-list, which may also include the size of any +structure arguments. +
  • +The decision whether a struct is to be returned in registers or in memory +considers only the struct's size and alignment. This is inaccurate: for +example, gcc on m68k-next returns +struct { char a,b,c; } +in registers and +struct { char a[3]; } +in memory, although both types have the same size and the same alignment. +
+ + +

Non-Bugs

+
+ +All information is passed in CPU registers and the stack. +The avcall package is therefore multithread-safe. + + +

Porting AVCALL

+
+ +Ports, bug-fixes, and suggestions are most welcome. The +macros required for argument pushing are pretty grungy, +but it does seem to be possible to port avcall to a range +of machines. Ports to non-standard or non-32-bit machines +are especially welcome so we can sort the interface out +before it's too late. +

+Knowledge about argument passing conventions can be found +in the gcc source, file gcc-2.6.3/config/cpu/cpu.h, section +"Stack layout; function entry, exit and calling." +

+Some of the grunge is usually handled by a C or assembly +level glue routine that actually pushes the arguments, +calls the function and unpacks any return value. This is +called avcall_call(). A precompiled assembler version for +people without gcc is also made available. The routine should ideally +have flags for the passing conventions of other compilers. +

+Many of the current routines waste a lot of stack space +and generally do hairy things to stack frames - a bit more +assembly code would probably help things along quite a bit +here. +

+ + +

Author

+ + +Bill Triggs <Bill.Triggs@inrialpes.fr>, <Bill.Triggs@imag.fr>. + + +

Acknowledgements

+
+ +Some initial ideas were stolen from the C interface to the +Zelk extensions to Oliver Laumann's Elk scheme interpreter +by J.P.Lewis, NEC C&C Research, <zilla@ccrl.nj.nec.com> +(for Sun4 & SGI), and Roy Featherstone's +<roy@robots.oxford.ac.uk> personal C interface library for +Sun3, Sun4 & SGI. I also looked at the machine-dependent +parts of the GCC and GDB distributions, and put the gcc +asm() extensions to good use. Thanks guys! +

+This work was partly supported by EC-ESPRIT Basic Research +Action SECOND. +

+ +


+ +
AVCALL manual page
+Bruno Haible <bruno@clisp.org> +
+

+Last modified: 14 January 2001. + + + diff --git a/avcall/avcall.man b/avcall/avcall.man new file mode 100644 index 0000000..20f7c03 --- /dev/null +++ b/avcall/avcall.man @@ -0,0 +1,198 @@ +AVCALL(3) Library Functions Manual AVCALL(3) + + + +NAME + avcall - build a C argument list incrementally and call a C function on + it. + +SYNOPSIS + #include  + + av_alist alist; + + av_start_type(alist, &func [[, return_type], &return_value ]); + + av_type(alist, [arg_type,] value); + + av_call(alist); + +DESCRIPTION + This set of macros builds an argument list for a C function and calls + the function on it. It significantly reduces the amount of `glue' code + required for parsers, debuggers, imbedded interpreters, C extensions to + application programs and other situations where collections of func‐ + tions need to be called on lists of externally-supplied arguments. + + Function calling conventions differ considerably on different machines + and avcall attempts to provide some degree of isolation from such + architecture dependencies. + + The interface is like stdarg(3) in reverse. All of the macros return 0 + for success, < 0 for failure (e.g., argument list overflow or type-not- + supported). + + (1) #include  + and declare the argument list structure + av_alist alist; + + (2) Set any special flags. This is architecture and compiler depen‐ + dent. Compiler options that affect passing conventions may need + to be flagged by #defines before the #include state‐ + ment. However, the configure script should have determined which + #defines are needed and put them at the top of avcall.h. + + (3) Initialize the alist with the function address and return value + pointer (if any). There is a separate macro for each simple + return type ([u]char, [u]short, [u]int, [u]long, [u]longlong, + float, double, where `u' indicates `unsigned'). The macros for + functions returning structures or pointers require an explicit + type argument. + + E.g., + + av_start_int (alist, &func, &int_return); + + av_start_double (alist, &func, &double_return); + + av_start_void (alist, &func); + + av_start_struct (alist, &func, struct_type, splittable, + &struct_return); + + av_start_ptr (alist, &func, pointer_type, + &pointer_return); + + The splittable flag specifies whether the struct_type can be returned + in registers such that every struct field fits entirely in a single + register. This needs to be specified for structs of size + 2*sizeof(long). For structs of size <= sizeof(long), splittable is + ignored and assumed to be 1. For structs of size > 2*sizeof(long), + splittable is ignored and assumed to be 0. There are some handy macros + for this: + av_word_splittable_1 (type1) + av_word_splittable_2 (type1, type2) + av_word_splittable_3 (type1, type2, type3) + av_word_splittable_4 (type1, type2, type3, type4) + For a struct with three slots + struct { type1 id1; type2 id2; type3 id3; } + you can specify splittable as av_word_splittable_3 (type1, type2, + type3) . + + (4) Push the arguments on to the list in order. Again there is a + macro for each simple built-in type, and the macros for struc‐ + ture and pointer arguments require an extra type argument: + + av_int (alist, int_value); + + av_double (alist, double_value); + + av_struct (alist, struct_or_union_type, struct_value); + + av_ptr (alist, pointer_type, pointer_value); + + (5) Call the function, set the return value, and tidy up: + + av_call (alist); + + +NOTES + (1) Functions whose first declaration is in Kernighan & Ritchie style + (i.e., without a typed argument list) MUST use default K&R C expression + promotions (char and short to int, float to double) whether they are + compiled by a K&R or an ANSI compiler, because the true argument types + may not be known at the call point. Such functions typically back-con‐ + vert their arguments to the declared types on function entry. (In fact, + the only way to pass a true char, short or float in K&R C is by an + explicit cast: func((char)c,(float)f) ). Similarly, some K&R compilers + (such as Sun cc on the sparc) actually return a float as a double. + + Hence, for arguments of functions declared in K&R style you should use + av_int() and av_double() rather than av_char(), av_short() or + av_float(). If you use a K&R compiler, the avcall header files may be + able to detect this and define av_float(), etc, appropriately, but with + an ANSI compiler there is no way avcall can know how a function was + declared, so you have to correct the argument types yourself. + + (2) The explicit type arguments of the av_struct() and av_ptr() macros + are typically used to calculate size, alignment, and passing conven‐ + tions. This may not be sufficient for some machines with unusual + structure and pointer handling: in this case additional av_start_type() + and av_type() macros may be defined. + + (3) The macros av_start_longlong(), av_start_ulonglong(), av_longlong() + and av_ulonglong() work only if the C compiler has a working long long + 64-bit integer type. + + (4) The struct types used in av_start_struct() and av_struct() must + only contain (signed or unsigned) int, long, long long or pointer + fields. Struct types containing (signed or unsigned) char, short, + float, double or other structs are not supported. + + +SEE ALSO + stdarg(3), varargs(3). + + +BUGS + The current implementations have been tested on a selection of common + cases but there are probably still many bugs. + + There are typically built-in limits on the size of the argument-list, + which may also include the size of any structure arguments. + + The decision whether a struct is to be returned in registers or in mem‐ + ory considers only the struct's size and alignment. This is inaccurate: + for example, gcc on m68k-next returns struct { char a,b,c; } in regis‐ + ters and struct { char a[3]; } in memory, although both types have the + same size and the same alignment. + + +NON-BUGS + All information is passed in CPU registers and the stack. The avcall + package is therefore multithread-safe. + + +PORTING AVCALL + Ports, bug-fixes, and suggestions are most welcome. The macros required + for argument pushing are pretty grungy, but it does seem to be possible + to port avcall to a range of machines. Ports to non-standard or + non-32-bit machines are especially welcome so we can sort the interface + out before it's too late. + + Knowledge about argument passing conventions can be found in the gcc + source, file gcc-2.6.3/config/cpu/cpu.h, section "Stack layout; func‐ + tion entry, exit and calling." + + Some of the grunge is usually handled by a C or assembly level glue + routine that actually pushes the arguments, calls the function and + unpacks any return value. This is called avcall_call(). A precompiled + assembler version for people without gcc is also made available. The + routine should ideally have flags for the passing conventions of other + compilers. + + Many of the current routines waste a lot of stack space and generally + do hairy things to stack frames - a bit more assembly code would proba‐ + bly help things along quite a bit here. + + +AUTHOR + Bill Triggs . + + +ACKNOWLEDGEMENTS + Some initial ideas were stolen from the C interface to the Zelk exten‐ + sions to Oliver Laumann's Elk scheme interpreter by J.P.Lewis, NEC C&C + Research, (for Sun4 & SGI), and Roy Feather‐ + stone's personal C interface library for + Sun[34] & SGI. I also looked at the machine-dependent parts of the GCC + and GDB distributions, and put the gcc asm() extensions to good use. + Thanks guys! + + This work was partly supported by EC-ESPRIT Basic Research Action SEC‐ + OND. + + + + + 23 July 2017 AVCALL(3) diff --git a/avcall/minitests-c++.cc b/avcall/minitests-c++.cc new file mode 100644 index 0000000..1738e11 --- /dev/null +++ b/avcall/minitests-c++.cc @@ -0,0 +1,18 @@ +/* + * Copyright 2017 Bruno Haible + * + * 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, see . + */ + +#include "minitests.c" diff --git a/avcall/minitests.c b/avcall/minitests.c new file mode 100644 index 0000000..b0f50fe --- /dev/null +++ b/avcall/minitests.c @@ -0,0 +1,19 @@ +/* + * Copyright 1999-2001 Bruno Haible + * + * 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, see . + */ + +#define SKIP_EXTRA_STRUCTS +#include "tests.c" diff --git a/avcall/tests.c b/avcall/tests.c new file mode 100644 index 0000000..427a9e9 --- /dev/null +++ b/avcall/tests.c @@ -0,0 +1,1548 @@ +/** + Copyright 1993 Bill Triggs + Copyright 1995-2019 Bruno Haible + + 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, see . +**/ +/*---------------------------------------------------------------------- + Some test routines for avcall foreign function interface. + The coverage is entirely random, this just contains some of the things + that I think are likely to break. + + We really need to add some more pointer (void* / char* / func*) tests + and some varargs ones, and also try to test structure alignment more + throughly. + ----------------------------------------------------------------------*/ + +#include +#include +#include +#include "avcall.h" + +#include "testcases.c" + +#if defined(__hppa__) && defined(__GNUC__) +#if (__GNUC__ == 2 && __GNUC_MINOR__ < 6) +/* gcc-2.5.2 bugs prevent the T test from working. */ +#define SKIP_T +#endif +#endif +#if defined(__m68k__) && defined(__GNUC__) +/* "gcc-2.6.3 -freg-struct-return" returns T = struct { char c[3]; } (which + * has size 4 !) in memory, in contrast to struct { char a,b,c; } and + * struct { char c[4]; } and struct { char a,b,c,d; } which have the same + * size and the same alignment but are returned in registers. I don't know why. + */ +#define SKIP_T +#endif + + +/* + * The way we run these tests - first call the function directly, then + * through av_call() - there is the danger that arguments or results seem + * to be passed correctly, but what we are seeing are in fact the vestiges + * (traces) or the previous call. This may seriously fake the test. + * Avoid this by clearing the registers between the first and the second call. + */ +long clear_traces_i (long a, long b, long c, long d, long e, long f, long g, long h, + long i, long j, long k, long l, long m, long n, long o, long p) +{ return 0; } +float clear_traces_f (float a, float b, float c, float d, float e, float f, float g, + float h, float i, float j, float k, float l, float m, float n, + float o, float p) +{ return 0.0; } +double clear_traces_d (double a, double b, double c, double d, double e, double f, double g, + double h, double i, double j, double k, double l, double m, double n, + double o, double p) +{ return 0.0; } +J clear_traces_J (void) +{ J j; j.l1 = j.l2 = 0; return j; } +void clear_traces (void) +{ clear_traces_i(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); + clear_traces_f(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.0); + clear_traces_d(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.0); + clear_traces_J(); +} + +void + void_tests (void) +{ + av_alist a; + v_v(); + clear_traces(); + av_start_void(a,v_v); + av_call(a); + return; +} +void + int_tests (void) +{ + av_alist a; + int ir; + + ir = i_v(); + fprintf(out,"->%d\n",ir); + fflush(out); + ir = 0; clear_traces(); + av_start_int(a,i_v,&ir); + av_call(a); + fprintf(out,"->%d\n",ir); + fflush(out); + + ir = i_i(i1); + fprintf(out,"->%d\n",ir); + fflush(out); + ir = 0; clear_traces(); + av_start_int(a,i_i,&ir); + av_int(a,i1); + av_call(a); + fprintf(out,"->%d\n",ir); + fflush(out); + + ir = i_i2(i1,i2); + fprintf(out,"->%d\n",ir); + fflush(out); + ir = 0; clear_traces(); + av_start_int(a,i_i2,&ir); + av_int(a,i1); + av_int(a,i2); + av_call(a); + fprintf(out,"->%d\n",ir); + fflush(out); + + ir = i_i4(i1,i2,i3,i4); + fprintf(out,"->%d\n",ir); + fflush(out); + ir = 0; clear_traces(); + av_start_int(a,i_i4,&ir); + av_int(a,i1); + av_int(a,i2); + av_int(a,i3); + av_int(a,i4); + av_call(a); + fprintf(out,"->%d\n",ir); + fflush(out); + + ir = i_i8(i1,i2,i3,i4,i5,i6,i7,i8); + fprintf(out,"->%d\n",ir); + fflush(out); + ir = 0; clear_traces(); + av_start_int(a,i_i8,&ir); + av_int(a,i1); + av_int(a,i2); + av_int(a,i3); + av_int(a,i4); + av_int(a,i5); + av_int(a,i6); + av_int(a,i7); + av_int(a,i8); + av_call(a); + fprintf(out,"->%d\n",ir); + fflush(out); + + ir = i_i16(i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14,i15,i16); + fprintf(out,"->%d\n",ir); + fflush(out); + ir = 0; clear_traces(); + av_start_int(a,i_i16,&ir); + av_int(a,i1); + av_int(a,i2); + av_int(a,i3); + av_int(a,i4); + av_int(a,i5); + av_int(a,i6); + av_int(a,i7); + av_int(a,i8); + av_int(a,i9); + av_int(a,i10); + av_int(a,i11); + av_int(a,i12); + av_int(a,i13); + av_int(a,i14); + av_int(a,i15); + av_int(a,i16); + av_call(a); + fprintf(out,"->%d\n",ir); + fflush(out); + + ir = i_i32(i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14,i15,i16,i17,i18,i19,i20,i21,i22,i23,i24,i25,i26,i27,i28,i29,i30,i31,i32); + fprintf(out,"->%d\n",ir); + fflush(out); + ir = 0; clear_traces(); + av_start_int(a,i_i32,&ir); + av_int(a,i1); + av_int(a,i2); + av_int(a,i3); + av_int(a,i4); + av_int(a,i5); + av_int(a,i6); + av_int(a,i7); + av_int(a,i8); + av_int(a,i9); + av_int(a,i10); + av_int(a,i11); + av_int(a,i12); + av_int(a,i13); + av_int(a,i14); + av_int(a,i15); + av_int(a,i16); + av_int(a,i17); + av_int(a,i18); + av_int(a,i19); + av_int(a,i20); + av_int(a,i21); + av_int(a,i22); + av_int(a,i23); + av_int(a,i24); + av_int(a,i25); + av_int(a,i26); + av_int(a,i27); + av_int(a,i28); + av_int(a,i29); + av_int(a,i30); + av_int(a,i31); + av_int(a,i32); + av_call(a); + fprintf(out,"->%d\n",ir); + fflush(out); + + return; +} +void + float_tests (void) +{ + av_alist a; + float fr; + + fr = f_f(f1); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + av_start_float(a,f_f,&fr); + av_float(a,f1); + av_call(a); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f2(f1,f2); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + av_start_float(a,f_f2,&fr); + av_float(a,f1); + av_float(a,f2); + av_call(a); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f4(f1,f2,f3,f4); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + av_start_float(a,f_f4,&fr); + av_float(a,f1); + av_float(a,f2); + av_float(a,f3); + av_float(a,f4); + av_call(a); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f8(f1,f2,f3,f4,f5,f6,f7,f8); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + av_start_float(a,f_f8,&fr); + av_float(a,f1); + av_float(a,f2); + av_float(a,f3); + av_float(a,f4); + av_float(a,f5); + av_float(a,f6); + av_float(a,f7); + av_float(a,f8); + av_call(a); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f16(f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + av_start_float(a,f_f16,&fr); + av_float(a,f1); + av_float(a,f2); + av_float(a,f3); + av_float(a,f4); + av_float(a,f5); + av_float(a,f6); + av_float(a,f7); + av_float(a,f8); + av_float(a,f9); + av_float(a,f10); + av_float(a,f11); + av_float(a,f12); + av_float(a,f13); + av_float(a,f14); + av_float(a,f15); + av_float(a,f16); + av_call(a); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f24(f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16,f17,f18,f19,f20,f21,f22,f23,f24); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + av_start_float(a,f_f24,&fr); + av_float(a,f1); + av_float(a,f2); + av_float(a,f3); + av_float(a,f4); + av_float(a,f5); + av_float(a,f6); + av_float(a,f7); + av_float(a,f8); + av_float(a,f9); + av_float(a,f10); + av_float(a,f11); + av_float(a,f12); + av_float(a,f13); + av_float(a,f14); + av_float(a,f15); + av_float(a,f16); + av_float(a,f17); + av_float(a,f18); + av_float(a,f19); + av_float(a,f20); + av_float(a,f21); + av_float(a,f22); + av_float(a,f23); + av_float(a,f24); + av_call(a); + fprintf(out,"->%g\n",fr); + fflush(out); +} +void + double_tests (void) +{ + av_alist a; + double dr; + + dr = d_d(d1); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + av_start_double(a,d_d,&dr); + av_double(a,d1); + av_call(a); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d2(d1,d2); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + av_start_double(a,d_d2,&dr); + av_double(a,d1); + av_double(a,d2); + av_call(a); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d4(d1,d2,d3,d4); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + av_start_double(a,d_d4,&dr); + av_double(a,d1); + av_double(a,d2); + av_double(a,d3); + av_double(a,d4); + av_call(a); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d8(d1,d2,d3,d4,d5,d6,d7,d8); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + av_start_double(a,d_d8,&dr); + av_double(a,d1); + av_double(a,d2); + av_double(a,d3); + av_double(a,d4); + av_double(a,d5); + av_double(a,d6); + av_double(a,d7); + av_double(a,d8); + av_call(a); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d16(d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,d14,d15,d16); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + av_start_double(a,d_d16,&dr); + av_double(a,d1); + av_double(a,d2); + av_double(a,d3); + av_double(a,d4); + av_double(a,d5); + av_double(a,d6); + av_double(a,d7); + av_double(a,d8); + av_double(a,d9); + av_double(a,d10); + av_double(a,d11); + av_double(a,d12); + av_double(a,d13); + av_double(a,d14); + av_double(a,d15); + av_double(a,d16); + av_call(a); + fprintf(out,"->%g\n",dr); + fflush(out); + + return; +} +void + pointer_tests (void) +{ + av_alist a; + void* vpr; + + vpr = vp_vpdpcpsp(&uc1,&d2,str3,&I4); + fprintf(out,"->0x%p\n",vpr); + fflush(out); + vpr = 0; clear_traces(); + av_start_ptr(a,vp_vpdpcpsp,void*,&vpr); + av_ptr(a,void*,&uc1); + av_ptr(a,double*,&d2); + av_ptr(a,char*,str3); + av_ptr(a,Int*,&I4); + av_call(a); + fprintf(out,"->0x%p\n",vpr); + fflush(out); + + return; +} +void + mixed_number_tests (void) +{ + av_alist a; + uchar ucr; + ushort usr; + float fr; + double dr; + long long llr; + + /* Unsigned types. + */ + ucr = uc_ucsil(uc1,us2,ui3,ul4); + fprintf(out,"->%u\n",ucr); + fflush(out); + ucr = 0; clear_traces(); + av_start_uchar(a,uc_ucsil,&ucr); + av_uchar(a,uc1); + av_ushort(a,us2); + av_uint(a,ui3); + av_ulong(a,ul4); + av_call(a); + fprintf(out,"->%u\n",ucr); + fflush(out); + + /* Mixed int & float types. + */ + dr = d_iidd(i1,i2,d3,d4); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + av_start_double(a,d_iidd,&dr); + av_int(a,i1); + av_int(a,i2); + av_double(a,d3); + av_double(a,d4); + av_call(a); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_iiidi(i1,i2,i3,d4,i5); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + av_start_double(a,d_iiidi,&dr); + av_int(a,i1); + av_int(a,i2); + av_int(a,i3); + av_double(a,d4); + av_int(a,i5); + av_call(a); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_idid(i1,d2,i3,d4); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + av_start_double(a,d_idid,&dr); + av_int(a,i1); + av_double(a,d2); + av_int(a,i3); + av_double(a,d4); + av_call(a); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_fdi(f1,d2,i3); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + av_start_double(a,d_fdi,&dr); + av_float(a,f1); + av_double(a,d2); + av_int(a,i3); + av_call(a); + fprintf(out,"->%g\n",dr); + fflush(out); + + usr = us_cdcd(c1,d2,c3,d4); + fprintf(out,"->%u\n",usr); + fflush(out); + usr = 0; clear_traces(); + av_start_ushort(a,us_cdcd,&usr); + av_char(a,c1); + av_double(a,d2); + av_char(a,c3); + av_double(a,d4); + av_call(a); + fprintf(out,"->%u\n",usr); + fflush(out); + + /* Long long types. + */ + llr = ll_iiilli(i1,i2,i3,ll1,i13); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + llr = 0; clear_traces(); + av_start_longlong(a,ll_iiilli,&llr); + av_int(a,i1); + av_int(a,i2); + av_int(a,i3); + av_longlong(a,ll1); + av_int(a,i13); + av_call(a); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + + llr = ll_flli(f13,ll1,i13); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + llr = 0; clear_traces(); + av_start_longlong(a,ll_flli,&llr); + av_float(a,f13); + av_longlong(a,ll1); + av_int(a,i13); + av_call(a); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + + fr = f_fi(f1,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + av_start_float(a,f_fi,&fr); + av_float(a,f1); + av_int(a,i9); + av_call(a); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f2i(f1,f2,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + av_start_float(a,f_f2i,&fr); + av_float(a,f1); + av_float(a,f2); + av_int(a,i9); + av_call(a); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f3i(f1,f2,f3,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + av_start_float(a,f_f3i,&fr); + av_float(a,f1); + av_float(a,f2); + av_float(a,f3); + av_int(a,i9); + av_call(a); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f4i(f1,f2,f3,f4,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + av_start_float(a,f_f4i,&fr); + av_float(a,f1); + av_float(a,f2); + av_float(a,f3); + av_float(a,f4); + av_int(a,i9); + av_call(a); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f7i(f1,f2,f3,f4,f5,f6,f7,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + av_start_float(a,f_f7i,&fr); + av_float(a,f1); + av_float(a,f2); + av_float(a,f3); + av_float(a,f4); + av_float(a,f5); + av_float(a,f6); + av_float(a,f7); + av_int(a,i9); + av_call(a); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f8i(f1,f2,f3,f4,f5,f6,f7,f8,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + av_start_float(a,f_f8i,&fr); + av_float(a,f1); + av_float(a,f2); + av_float(a,f3); + av_float(a,f4); + av_float(a,f5); + av_float(a,f6); + av_float(a,f7); + av_float(a,f8); + av_int(a,i9); + av_call(a); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f12i(f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + av_start_float(a,f_f12i,&fr); + av_float(a,f1); + av_float(a,f2); + av_float(a,f3); + av_float(a,f4); + av_float(a,f5); + av_float(a,f6); + av_float(a,f7); + av_float(a,f8); + av_float(a,f9); + av_float(a,f10); + av_float(a,f11); + av_float(a,f12); + av_int(a,i9); + av_call(a); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f13i(f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + av_start_float(a,f_f13i,&fr); + av_float(a,f1); + av_float(a,f2); + av_float(a,f3); + av_float(a,f4); + av_float(a,f5); + av_float(a,f6); + av_float(a,f7); + av_float(a,f8); + av_float(a,f9); + av_float(a,f10); + av_float(a,f11); + av_float(a,f12); + av_float(a,f13); + av_int(a,i9); + av_call(a); + fprintf(out,"->%g\n",fr); + fflush(out); + + dr = d_di(d1,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + av_start_double(a,d_di,&dr); + av_double(a,d1); + av_int(a,i9); + av_call(a); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d2i(d1,d2,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + av_start_double(a,d_d2i,&dr); + av_double(a,d1); + av_double(a,d2); + av_int(a,i9); + av_call(a); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d3i(d1,d2,d3,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + av_start_double(a,d_d3i,&dr); + av_double(a,d1); + av_double(a,d2); + av_double(a,d3); + av_int(a,i9); + av_call(a); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d4i(d1,d2,d3,d4,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + av_start_double(a,d_d4i,&dr); + av_double(a,d1); + av_double(a,d2); + av_double(a,d3); + av_double(a,d4); + av_int(a,i9); + av_call(a); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d7i(d1,d2,d3,d4,d5,d6,d7,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + av_start_double(a,d_d7i,&dr); + av_double(a,d1); + av_double(a,d2); + av_double(a,d3); + av_double(a,d4); + av_double(a,d5); + av_double(a,d6); + av_double(a,d7); + av_int(a,i9); + av_call(a); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d8i(d1,d2,d3,d4,d5,d6,d7,d8,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + av_start_double(a,d_d8i,&dr); + av_double(a,d1); + av_double(a,d2); + av_double(a,d3); + av_double(a,d4); + av_double(a,d5); + av_double(a,d6); + av_double(a,d7); + av_double(a,d8); + av_int(a,i9); + av_call(a); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d12i(d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + av_start_double(a,d_d12i,&dr); + av_double(a,d1); + av_double(a,d2); + av_double(a,d3); + av_double(a,d4); + av_double(a,d5); + av_double(a,d6); + av_double(a,d7); + av_double(a,d8); + av_double(a,d9); + av_double(a,d10); + av_double(a,d11); + av_double(a,d12); + av_int(a,i9); + av_call(a); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d13i(d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + av_start_double(a,d_d13i,&dr); + av_double(a,d1); + av_double(a,d2); + av_double(a,d3); + av_double(a,d4); + av_double(a,d5); + av_double(a,d6); + av_double(a,d7); + av_double(a,d8); + av_double(a,d9); + av_double(a,d10); + av_double(a,d11); + av_double(a,d12); + av_double(a,d13); + av_int(a,i9); + av_call(a); + fprintf(out,"->%g\n",dr); + fflush(out); + + return; +} +void + small_structure_return_tests (void) +{ + av_alist a; + + { + Size1 r = S1_v(); + fprintf(out,"->{%c}\n",r.x1); + fflush(out); + memset(&r,0,sizeof(r)); clear_traces(); + av_start_struct(a,S1_v,Size1,1,&r); + av_call(a); + fprintf(out,"->{%c}\n",r.x1); + fflush(out); + } + { + Size2 r = S2_v(); + fprintf(out,"->{%c%c}\n",r.x1,r.x2); + fflush(out); + memset(&r,0,sizeof(r)); clear_traces(); + av_start_struct(a,S2_v,Size2,1,&r); + av_call(a); + fprintf(out,"->{%c%c}\n",r.x1,r.x2); + fflush(out); + } + { + Size3 r = S3_v(); + fprintf(out,"->{%c%c%c}\n",r.x1,r.x2,r.x3); + fflush(out); + memset(&r,0,sizeof(r)); clear_traces(); + av_start_struct(a,S3_v,Size3,1,&r); + av_call(a); + fprintf(out,"->{%c%c%c}\n",r.x1,r.x2,r.x3); + fflush(out); + } + { + Size4 r = S4_v(); + fprintf(out,"->{%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4); + fflush(out); + memset(&r,0,sizeof(r)); clear_traces(); + av_start_struct(a,S4_v,Size4,1,&r); + av_call(a); + fprintf(out,"->{%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4); + fflush(out); + } + { + Size7 r = S7_v(); + fprintf(out,"->{%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7); + fflush(out); + memset(&r,0,sizeof(r)); clear_traces(); + av_start_struct(a,S7_v,Size7,1,&r); + av_call(a); + fprintf(out,"->{%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7); + fflush(out); + } + { + Size8 r = S8_v(); + fprintf(out,"->{%c%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7,r.x8); + fflush(out); + memset(&r,0,sizeof(r)); clear_traces(); + av_start_struct(a,S8_v,Size8,1,&r); + av_call(a); + fprintf(out,"->{%c%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7,r.x8); + fflush(out); + } + { + Size12 r = S12_v(); + fprintf(out,"->{%c%c%c%c%c%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7,r.x8,r.x9,r.x10,r.x11,r.x12); + fflush(out); + memset(&r,0,sizeof(r)); clear_traces(); + av_start_struct(a,S12_v,Size12,1,&r); + av_call(a); + fprintf(out,"->{%c%c%c%c%c%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7,r.x8,r.x9,r.x10,r.x11,r.x12); + fflush(out); + } + { + Size15 r = S15_v(); + fprintf(out,"->{%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7,r.x8,r.x9,r.x10,r.x11,r.x12,r.x13,r.x14,r.x15); + fflush(out); + memset(&r,0,sizeof(r)); clear_traces(); + av_start_struct(a,S15_v,Size15,1,&r); + av_call(a); + fprintf(out,"->{%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7,r.x8,r.x9,r.x10,r.x11,r.x12,r.x13,r.x14,r.x15); + fflush(out); + } + { + Size16 r = S16_v(); + fprintf(out,"->{%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7,r.x8,r.x9,r.x10,r.x11,r.x12,r.x13,r.x14,r.x15,r.x16); + fflush(out); + memset(&r,0,sizeof(r)); clear_traces(); + av_start_struct(a,S16_v,Size16,1,&r); + av_call(a); + fprintf(out,"->{%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7,r.x8,r.x9,r.x10,r.x11,r.x12,r.x13,r.x14,r.x15,r.x16); + fflush(out); + } +} +void + structure_tests (void) +{ + av_alist a; + Int Ir; + Char Cr; + Float Fr; + Double Dr; + J Jr; + T Tr; + X Xr; + + Ir = I_III(I1,I2,I3); + fprintf(out,"->{%d}\n",Ir.x); + fflush(out); + Ir.x = 0; clear_traces(); + av_start_struct(a,I_III,Int,1,&Ir); + av_struct(a,Int,I1); + av_struct(a,Int,I2); + av_struct(a,Int,I3); + av_call(a); + fprintf(out,"->{%d}\n",Ir.x); + fflush(out); + +#ifndef SKIP_EXTRA_STRUCTS + Cr = C_CdC(C1,d2,C3); + fprintf(out,"->{'%c'}\n",Cr.x); + fflush(out); + Cr.x = '\0'; clear_traces(); + av_start_struct(a,C_CdC,Char,1,&Cr); + av_struct(a,Char,C1); + av_double(a,d2); + av_struct(a,Char,C3); + av_call(a); + fprintf(out,"->{'%c'}\n",Cr.x); + fflush(out); + + Fr = F_Ffd(F1,f2,d3); + fprintf(out,"->{%g}\n",Fr.x); + fflush(out); + Fr.x = 0.0; clear_traces(); + av_start_struct(a,F_Ffd,Float,av_word_splittable_1(float),&Fr); + av_struct(a,Float,F1); + av_float(a,f2); + av_double(a,d3); + av_call(a); + fprintf(out,"->{%g}\n",Fr.x); + fflush(out); + + Dr = D_fDd(f1,D2,d3); + fprintf(out,"->{%g}\n",Dr.x); + fflush(out); + Dr.x = 0.0; clear_traces(); + av_start_struct(a,D_fDd,Double,av_word_splittable_1(double),&Dr); + av_float(a,f1); + av_struct(a,Double,D2); + av_double(a,d3); + av_call(a); + fprintf(out,"->{%g}\n",Dr.x); + fflush(out); + + Dr = D_Dfd(D1,f2,d3); + fprintf(out,"->{%g}\n",Dr.x); + fflush(out); + Dr.x = 0.0; clear_traces(); + av_start_struct(a,D_Dfd,Double,av_word_splittable_1(double),&Dr); + av_struct(a,Double,D1); + av_float(a,f2); + av_double(a,d3); + av_call(a); + fprintf(out,"->{%g}\n",Dr.x); + fflush(out); +#endif + + Jr = J_JiJ(J1,i2,J2); + fprintf(out,"->{%ld,%ld}\n",Jr.l1,Jr.l2); + fflush(out); + Jr.l1 = Jr.l2 = 0; clear_traces(); + av_start_struct(a,J_JiJ,J,av_word_splittable_2(long,long),&Jr); + av_struct(a,J,J1); + av_int(a,i2); + av_struct(a,J,J2); + av_call(a); + fprintf(out,"->{%ld,%ld}\n",Jr.l1,Jr.l2); + fflush(out); + +#ifndef SKIP_EXTRA_STRUCTS +#ifndef SKIP_T + Tr = T_TcT(T1,' ',T2); + fprintf(out,"->{\"%c%c%c\"}\n",Tr.c[0],Tr.c[1],Tr.c[2]); + fflush(out); + Tr.c[0] = Tr.c[1] = Tr.c[2] = 0; clear_traces(); + av_start_struct(a,T_TcT,T,1,&Tr); + av_struct(a,T,T1); + av_char(a,' '); + av_struct(a,T,T2); + av_call(a); + fprintf(out,"->{\"%c%c%c\"}\n",Tr.c[0],Tr.c[1],Tr.c[2]); + fflush(out); +#endif + + Xr = X_BcdB(B1,c2,d3,B2); + fprintf(out,"->{\"%s\",'%c'}\n",Xr.c,Xr.c1); + fflush(out); + Xr.c[0]=Xr.c1='\0'; clear_traces(); + av_start_struct(a,X_BcdB,X,0,&Xr); + av_struct(a,B,B1); + av_char(a,c2); + av_double(a,d3); + av_struct(a,B,B2); + av_call(a); + fprintf(out,"->{\"%s\",'%c'}\n",Xr.c,Xr.c1); + fflush(out); +#endif + + return; +} + +void + gpargs_boundary_tests (void) +{ + av_alist a; + long lr; + long long llr; + float fr; + double dr; + + lr = l_l0J(J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + av_start_long(a,l_l0J,&lr); + av_struct(a,J,J1); + av_long(a,l9); + av_call(a); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l1J(l1,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + av_start_long(a,l_l1J,&lr); + av_long(a,l1); + av_struct(a,J,J1); + av_long(a,l9); + av_call(a); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l2J(l1,l2,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + av_start_long(a,l_l2J,&lr); + av_long(a,l1); + av_long(a,l2); + av_struct(a,J,J1); + av_long(a,l9); + av_call(a); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l3J(l1,l2,l3,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + av_start_long(a,l_l3J,&lr); + av_long(a,l1); + av_long(a,l2); + av_long(a,l3); + av_struct(a,J,J1); + av_long(a,l9); + av_call(a); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l4J(l1,l2,l3,l4,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + av_start_long(a,l_l4J,&lr); + av_long(a,l1); + av_long(a,l2); + av_long(a,l3); + av_long(a,l4); + av_struct(a,J,J1); + av_long(a,l9); + av_call(a); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l5J(l1,l2,l3,l4,l5,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + av_start_long(a,l_l5J,&lr); + av_long(a,l1); + av_long(a,l2); + av_long(a,l3); + av_long(a,l4); + av_long(a,l5); + av_struct(a,J,J1); + av_long(a,l9); + av_call(a); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l6J(l1,l2,l3,l4,l5,l6,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + av_start_long(a,l_l6J,&lr); + av_long(a,l1); + av_long(a,l2); + av_long(a,l3); + av_long(a,l4); + av_long(a,l5); + av_long(a,l6); + av_struct(a,J,J1); + av_long(a,l9); + av_call(a); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l7J(l1,l2,l3,l4,l5,l6,l7,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + av_start_long(a,l_l7J,&lr); + av_long(a,l1); + av_long(a,l2); + av_long(a,l3); + av_long(a,l4); + av_long(a,l5); + av_long(a,l6); + av_long(a,l7); + av_struct(a,J,J1); + av_long(a,l9); + av_call(a); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l0K(K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + av_start_long(a,l_l0K,&lr); + av_struct(a,K,K1); + av_long(a,l9); + av_call(a); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l1K(l1,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + av_start_long(a,l_l1K,&lr); + av_long(a,l1); + av_struct(a,K,K1); + av_long(a,l9); + av_call(a); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l2K(l1,l2,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + av_start_long(a,l_l2K,&lr); + av_long(a,l1); + av_long(a,l2); + av_struct(a,K,K1); + av_long(a,l9); + av_call(a); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l3K(l1,l2,l3,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + av_start_long(a,l_l3K,&lr); + av_long(a,l1); + av_long(a,l2); + av_long(a,l3); + av_struct(a,K,K1); + av_long(a,l9); + av_call(a); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l4K(l1,l2,l3,l4,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + av_start_long(a,l_l4K,&lr); + av_long(a,l1); + av_long(a,l2); + av_long(a,l3); + av_long(a,l4); + av_struct(a,K,K1); + av_long(a,l9); + av_call(a); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l5K(l1,l2,l3,l4,l5,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + av_start_long(a,l_l5K,&lr); + av_long(a,l1); + av_long(a,l2); + av_long(a,l3); + av_long(a,l4); + av_long(a,l5); + av_struct(a,K,K1); + av_long(a,l9); + av_call(a); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l6K(l1,l2,l3,l4,l5,l6,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + av_start_long(a,l_l6K,&lr); + av_long(a,l1); + av_long(a,l2); + av_long(a,l3); + av_long(a,l4); + av_long(a,l5); + av_long(a,l6); + av_struct(a,K,K1); + av_long(a,l9); + av_call(a); + fprintf(out,"->%ld\n",lr); + fflush(out); + + fr = f_f17l3L(f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16,f17,l6,l7,l8,L1); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + av_start_float(a,f_f17l3L,&fr); + av_float(a,f1); + av_float(a,f2); + av_float(a,f3); + av_float(a,f4); + av_float(a,f5); + av_float(a,f6); + av_float(a,f7); + av_float(a,f8); + av_float(a,f9); + av_float(a,f10); + av_float(a,f11); + av_float(a,f12); + av_float(a,f13); + av_float(a,f14); + av_float(a,f15); + av_float(a,f16); + av_float(a,f17); + av_long(a,l6); + av_long(a,l7); + av_long(a,l8); + av_struct(a,L,L1); + av_call(a); + fprintf(out,"->%g\n",fr); + fflush(out); + + dr = d_d17l3L(d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,d14,d15,d16,d17,l6,l7,l8,L1); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + av_start_double(a,d_d17l3L,&dr); + av_double(a,d1); + av_double(a,d2); + av_double(a,d3); + av_double(a,d4); + av_double(a,d5); + av_double(a,d6); + av_double(a,d7); + av_double(a,d8); + av_double(a,d9); + av_double(a,d10); + av_double(a,d11); + av_double(a,d12); + av_double(a,d13); + av_double(a,d14); + av_double(a,d15); + av_double(a,d16); + av_double(a,d17); + av_long(a,l6); + av_long(a,l7); + av_long(a,l8); + av_struct(a,L,L1); + av_call(a); + fprintf(out,"->%g\n",dr); + fflush(out); + + llr = ll_l2ll(l1,l2,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + llr = 0; clear_traces(); + av_start_longlong(a,ll_l2ll,&llr); + av_long(a,l1); + av_long(a,l2); + av_longlong(a,ll1); + av_long(a,l9); + av_call(a); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + + llr = ll_l3ll(l1,l2,l3,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + llr = 0; clear_traces(); + av_start_longlong(a,ll_l3ll,&llr); + av_long(a,l1); + av_long(a,l2); + av_long(a,l3); + av_longlong(a,ll1); + av_long(a,l9); + av_call(a); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + + llr = ll_l4ll(l1,l2,l3,l4,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + llr = 0; clear_traces(); + av_start_longlong(a,ll_l4ll,&llr); + av_long(a,l1); + av_long(a,l2); + av_long(a,l3); + av_long(a,l4); + av_longlong(a,ll1); + av_long(a,l9); + av_call(a); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + + llr = ll_l5ll(l1,l2,l3,l4,l5,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + llr = 0; clear_traces(); + av_start_longlong(a,ll_l5ll,&llr); + av_long(a,l1); + av_long(a,l2); + av_long(a,l3); + av_long(a,l4); + av_long(a,l5); + av_longlong(a,ll1); + av_long(a,l9); + av_call(a); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + + llr = ll_l6ll(l1,l2,l3,l4,l5,l6,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + llr = 0; clear_traces(); + av_start_longlong(a,ll_l6ll,&llr); + av_long(a,l1); + av_long(a,l2); + av_long(a,l3); + av_long(a,l4); + av_long(a,l5); + av_long(a,l6); + av_longlong(a,ll1); + av_long(a,l9); + av_call(a); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + + llr = ll_l7ll(l1,l2,l3,l4,l5,l6,l7,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + llr = 0; clear_traces(); + av_start_longlong(a,ll_l7ll,&llr); + av_long(a,l1); + av_long(a,l2); + av_long(a,l3); + av_long(a,l4); + av_long(a,l5); + av_long(a,l6); + av_long(a,l7); + av_longlong(a,ll1); + av_long(a,l9); + av_call(a); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + + dr = d_l2d(l1,l2,d2,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + av_start_double(a,d_l2d,&dr); + av_long(a,l1); + av_long(a,l2); + av_double(a,d2); + av_long(a,l9); + av_call(a); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_l3d(l1,l2,l3,d2,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + av_start_double(a,d_l3d,&dr); + av_long(a,l1); + av_long(a,l2); + av_long(a,l3); + av_double(a,d2); + av_long(a,l9); + av_call(a); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_l4d(l1,l2,l3,l4,d2,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + av_start_double(a,d_l4d,&dr); + av_long(a,l1); + av_long(a,l2); + av_long(a,l3); + av_long(a,l4); + av_double(a,d2); + av_long(a,l9); + av_call(a); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_l5d(l1,l2,l3,l4,l5,d2,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + av_start_double(a,d_l5d,&dr); + av_long(a,l1); + av_long(a,l2); + av_long(a,l3); + av_long(a,l4); + av_long(a,l5); + av_double(a,d2); + av_long(a,l9); + av_call(a); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_l6d(l1,l2,l3,l4,l5,l6,d2,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + av_start_double(a,d_l6d,&dr); + av_long(a,l1); + av_long(a,l2); + av_long(a,l3); + av_long(a,l4); + av_long(a,l5); + av_long(a,l6); + av_double(a,d2); + av_long(a,l9); + av_call(a); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_l7d(l1,l2,l3,l4,l5,l6,l7,d2,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + av_start_double(a,d_l7d,&dr); + av_long(a,l1); + av_long(a,l2); + av_long(a,l3); + av_long(a,l4); + av_long(a,l5); + av_long(a,l6); + av_long(a,l7); + av_double(a,d2); + av_long(a,l9); + av_call(a); + fprintf(out,"->%g\n",dr); + fflush(out); + + return; +} + +/* Verify that structs larger than 2 words are really + passed by value, not accidentally by reference. */ +void + by_value_tests (void) +{ + av_alist a; + K k; + + k.l1 = l1; + k.l2 = l2; + k.l3 = l3; + k.l4 = l4; + fprintf(out,"by_value:%ld,%ld,%ld,%ld\n",k.l1,k.l2,k.l3,k.l4); + fflush(out); + clear_traces(); + av_start_void(a,v_clobber_K); + av_struct(a,K,k); + av_call(a); + fprintf(out,"by_value:%ld,%ld,%ld,%ld\n",k.l1,k.l2,k.l3,k.l4); + fflush(out); +} + +int + main (void) +{ + out = stdout; + void_tests(); + int_tests(); + float_tests(); + double_tests(); + pointer_tests(); + mixed_number_tests(); + small_structure_return_tests(); + structure_tests(); + gpargs_boundary_tests(); + by_value_tests(); + + exit(0); +} diff --git a/build-aux/ar-lib b/build-aux/ar-lib new file mode 100755 index 0000000..f64465e --- /dev/null +++ b/build-aux/ar-lib @@ -0,0 +1,271 @@ +#! /bin/sh +# Wrapper for Microsoft lib.exe + +me=ar-lib +scriptversion=2019-07-04.01; # UTC + +# Copyright (C) 2010-2019 Free Software Foundation, Inc. +# Written by Peter Rosin . +# +# 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, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + + +# func_error message +func_error () +{ + echo "$me: $1" 1>&2 + exit 1 +} + +file_conv= + +# func_file_conv build_file +# Convert a $build file to $host form and store it in $file +# Currently only supports Windows hosts. +func_file_conv () +{ + file=$1 + case $file in + / | /[!/]*) # absolute file, and not a UNC file + if test -z "$file_conv"; then + # lazily determine how to convert abs files + case `uname -s` in + MINGW*) + file_conv=mingw + ;; + CYGWIN*) + file_conv=cygwin + ;; + *) + file_conv=wine + ;; + esac + fi + case $file_conv in + mingw) + file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` + ;; + cygwin) + file=`cygpath -m "$file" || echo "$file"` + ;; + wine) + file=`winepath -w "$file" || echo "$file"` + ;; + esac + ;; + esac +} + +# func_at_file at_file operation archive +# Iterate over all members in AT_FILE performing OPERATION on ARCHIVE +# for each of them. +# When interpreting the content of the @FILE, do NOT use func_file_conv, +# since the user would need to supply preconverted file names to +# binutils ar, at least for MinGW. +func_at_file () +{ + operation=$2 + archive=$3 + at_file_contents=`cat "$1"` + eval set x "$at_file_contents" + shift + + for member + do + $AR -NOLOGO $operation:"$member" "$archive" || exit $? + done +} + +case $1 in + '') + func_error "no command. Try '$0 --help' for more information." + ;; + -h | --h*) + cat <. +# +# 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, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + +nl=' +' + +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent tools from complaining about whitespace usage. +IFS=" "" $nl" + +file_conv= + +# func_file_conv build_file lazy +# Convert a $build file to $host form and store it in $file +# Currently only supports Windows hosts. If the determined conversion +# type is listed in (the comma separated) LAZY, no conversion will +# take place. +func_file_conv () +{ + file=$1 + case $file in + / | /[!/]*) # absolute file, and not a UNC file + if test -z "$file_conv"; then + # lazily determine how to convert abs files + case `uname -s` in + MINGW*) + file_conv=mingw + ;; + CYGWIN*) + file_conv=cygwin + ;; + *) + file_conv=wine + ;; + esac + fi + case $file_conv/,$2, in + *,$file_conv,*) + ;; + mingw/*) + file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` + ;; + cygwin/*) + file=`cygpath -m "$file" || echo "$file"` + ;; + wine/*) + file=`winepath -w "$file" || echo "$file"` + ;; + esac + ;; + esac +} + +# func_cl_dashL linkdir +# Make cl look for libraries in LINKDIR +func_cl_dashL () +{ + func_file_conv "$1" + if test -z "$lib_path"; then + lib_path=$file + else + lib_path="$lib_path;$file" + fi + linker_opts="$linker_opts -LIBPATH:$file" +} + +# func_cl_dashl library +# Do a library search-path lookup for cl +func_cl_dashl () +{ + lib=$1 + found=no + save_IFS=$IFS + IFS=';' + for dir in $lib_path $LIB + do + IFS=$save_IFS + if $shared && test -f "$dir/$lib.dll.lib"; then + found=yes + lib=$dir/$lib.dll.lib + break + fi + if test -f "$dir/$lib.lib"; then + found=yes + lib=$dir/$lib.lib + break + fi + if test -f "$dir/lib$lib.a"; then + found=yes + lib=$dir/lib$lib.a + break + fi + done + IFS=$save_IFS + + if test "$found" != yes; then + lib=$lib.lib + fi +} + +# func_cl_wrapper cl arg... +# Adjust compile command to suit cl +func_cl_wrapper () +{ + # Assume a capable shell + lib_path= + shared=: + linker_opts= + for arg + do + if test -n "$eat"; then + eat= + else + case $1 in + -o) + # configure might choose to run compile as 'compile cc -o foo foo.c'. + eat=1 + case $2 in + *.o | *.[oO][bB][jJ]) + func_file_conv "$2" + set x "$@" -Fo"$file" + shift + ;; + *) + func_file_conv "$2" + set x "$@" -Fe"$file" + shift + ;; + esac + ;; + -I) + eat=1 + func_file_conv "$2" mingw + set x "$@" -I"$file" + shift + ;; + -I*) + func_file_conv "${1#-I}" mingw + set x "$@" -I"$file" + shift + ;; + -l) + eat=1 + func_cl_dashl "$2" + set x "$@" "$lib" + shift + ;; + -l*) + func_cl_dashl "${1#-l}" + set x "$@" "$lib" + shift + ;; + -L) + eat=1 + func_cl_dashL "$2" + ;; + -L*) + func_cl_dashL "${1#-L}" + ;; + -static) + shared=false + ;; + -Wl,*) + arg=${1#-Wl,} + save_ifs="$IFS"; IFS=',' + for flag in $arg; do + IFS="$save_ifs" + linker_opts="$linker_opts $flag" + done + IFS="$save_ifs" + ;; + -Xlinker) + eat=1 + linker_opts="$linker_opts $2" + ;; + -*) + set x "$@" "$1" + shift + ;; + *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) + func_file_conv "$1" + set x "$@" -Tp"$file" + shift + ;; + *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) + func_file_conv "$1" mingw + set x "$@" "$file" + shift + ;; + *) + set x "$@" "$1" + shift + ;; + esac + fi + shift + done + if test -n "$linker_opts"; then + linker_opts="-link$linker_opts" + fi + exec "$@" $linker_opts + exit 1 +} + +eat= + +case $1 in + '') + echo "$0: No command. Try '$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: compile [--help] [--version] PROGRAM [ARGS] + +Wrapper for compilers which do not understand '-c -o'. +Remove '-o dest.o' from ARGS, run PROGRAM with the remaining +arguments, and rename the output as expected. + +If you are trying to build a whole package this is not the +right script to run: please start by reading the file 'INSTALL'. + +Report bugs to . +EOF + exit $? + ;; + -v | --v*) + echo "compile $scriptversion" + exit $? + ;; + cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \ + icl | *[/\\]icl | icl.exe | *[/\\]icl.exe ) + func_cl_wrapper "$@" # Doesn't return... + ;; +esac + +ofile= +cfile= + +for arg +do + if test -n "$eat"; then + eat= + else + case $1 in + -o) + # configure might choose to run compile as 'compile cc -o foo foo.c'. + # So we strip '-o arg' only if arg is an object. + eat=1 + case $2 in + *.o | *.obj) + ofile=$2 + ;; + *) + set x "$@" -o "$2" + shift + ;; + esac + ;; + *.c) + cfile=$1 + set x "$@" "$1" + shift + ;; + *) + set x "$@" "$1" + shift + ;; + esac + fi + shift +done + +if test -z "$ofile" || test -z "$cfile"; then + # If no '-o' option was seen then we might have been invoked from a + # pattern rule where we don't need one. That is ok -- this is a + # normal compilation that the losing compiler can handle. If no + # '.c' file was seen then we are probably linking. That is also + # ok. + exec "$@" +fi + +# Name of file we expect compiler to create. +cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` + +# Create the lock directory. +# Note: use '[/\\:.-]' here to ensure that we don't use the same name +# that we are using for the .o file. Also, base the name on the expected +# object file name, since that is what matters with a parallel build. +lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d +while true; do + if mkdir "$lockdir" >/dev/null 2>&1; then + break + fi + sleep 1 +done +# FIXME: race condition here if user kills between mkdir and trap. +trap "rmdir '$lockdir'; exit 1" 1 2 15 + +# Run the compile. +"$@" +ret=$? + +if test -f "$cofile"; then + test "$cofile" = "$ofile" || mv "$cofile" "$ofile" +elif test -f "${cofile}bj"; then + test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" +fi + +rmdir "$lockdir" +exit $ret + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC0" +# time-stamp-end: "; # UTC" +# End: diff --git a/build-aux/config.guess b/build-aux/config.guess new file mode 100755 index 0000000..97ad073 --- /dev/null +++ b/build-aux/config.guess @@ -0,0 +1,1662 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright 1992-2019 Free Software Foundation, Inc. + +timestamp='2019-07-24' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 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, see . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). +# +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. +# +# You can get the latest version of this script from: +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess +# +# Please send patches to . + + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Options: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright 1992-2019 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +tmp= +# shellcheck disable=SC2172 +trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15 + +set_cc_for_build() { + : "${TMPDIR=/tmp}" + # shellcheck disable=SC2039 + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } + dummy=$tmp/dummy + case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in + ,,) echo "int x;" > "$dummy.c" + for driver in cc gcc c89 c99 ; do + if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then + CC_FOR_BUILD="$driver" + break + fi + done + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; + esac +} + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if test -f /.attbin/uname ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +case "$UNAME_SYSTEM" in +Linux|GNU|GNU/*) + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + LIBC=gnu + + set_cc_for_build + cat <<-EOF > "$dummy.c" + #include + #if defined(__UCLIBC__) + LIBC=uclibc + #elif defined(__dietlibc__) + LIBC=dietlibc + #else + LIBC=gnu + #endif + EOF + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`" + + # If ldd exists, use it to detect musl libc. + if command -v ldd >/dev/null && \ + ldd --version 2>&1 | grep -q ^musl + then + LIBC=musl + fi + ;; +esac + +# Note: order is significant - the case branches are not exclusive. + +case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ + "/sbin/$sysctl" 2>/dev/null || \ + "/usr/sbin/$sysctl" 2>/dev/null || \ + echo unknown)` + case "$UNAME_MACHINE_ARCH" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + sh5el) machine=sh5le-unknown ;; + earmv*) + arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` + machine="${arch}${endian}"-unknown + ;; + *) machine="$UNAME_MACHINE_ARCH"-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently (or will in the future) and ABI. + case "$UNAME_MACHINE_ARCH" in + earm*) + os=netbsdelf + ;; + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ELF__ + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # Determine ABI tags. + case "$UNAME_MACHINE_ARCH" in + earm*) + expr='s/^earmv[0-9]/-eabi/;s/eb$//' + abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "$UNAME_VERSION" in + Debian*) + release='-gnu' + ;; + *) + release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "$machine-${os}${release}${abi-}" + exit ;; + *:Bitrig:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" + exit ;; + *:LibertyBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` + echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" + exit ;; + *:MidnightBSD:*:*) + echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" + exit ;; + *:ekkoBSD:*:*) + echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" + exit ;; + *:SolidBSD:*:*) + echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" + exit ;; + *:OS108:*:*) + echo "$UNAME_MACHINE"-unknown-os108_"$UNAME_RELEASE" + exit ;; + macppc:MirBSD:*:*) + echo powerpc-unknown-mirbsd"$UNAME_RELEASE" + exit ;; + *:MirBSD:*:*) + echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" + exit ;; + *:Sortix:*:*) + echo "$UNAME_MACHINE"-unknown-sortix + exit ;; + *:Redox:*:*) + echo "$UNAME_MACHINE"-unknown-redox + exit ;; + mips:OSF1:*.*) + echo mips-dec-osf1 + exit ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE=alpha ;; + "EV4.5 (21064)") + UNAME_MACHINE=alpha ;; + "LCA4 (21066/21068)") + UNAME_MACHINE=alpha ;; + "EV5 (21164)") + UNAME_MACHINE=alphaev5 ;; + "EV5.6 (21164A)") + UNAME_MACHINE=alphaev56 ;; + "EV5.6 (21164PC)") + UNAME_MACHINE=alphapca56 ;; + "EV5.7 (21164PC)") + UNAME_MACHINE=alphapca57 ;; + "EV6 (21264)") + UNAME_MACHINE=alphaev6 ;; + "EV6.7 (21264A)") + UNAME_MACHINE=alphaev67 ;; + "EV6.8CB (21264C)") + UNAME_MACHINE=alphaev68 ;; + "EV6.8AL (21264B)") + UNAME_MACHINE=alphaev68 ;; + "EV6.8CX (21264D)") + UNAME_MACHINE=alphaev68 ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE=alphaev69 ;; + "EV7 (21364)") + UNAME_MACHINE=alphaev7 ;; + "EV7.9 (21364A)") + UNAME_MACHINE=alphaev79 ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`" + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + exitcode=$? + trap '' 0 + exit $exitcode ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo "$UNAME_MACHINE"-unknown-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo "$UNAME_MACHINE"-unknown-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix"$UNAME_RELEASE" + exit ;; + arm*:riscos:*:*|arm*:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + s390x:SunOS:*:*) + echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" + exit ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" + exit ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) + echo i386-pc-auroraux"$UNAME_RELEASE" + exit ;; + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) + set_cc_for_build + SUN_ARCH=i386 + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH=x86_64 + fi + fi + echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`" + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos"$UNAME_RELEASE" + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos"$UNAME_RELEASE" + ;; + sun4) + echo sparc-sun-sunos"$UNAME_RELEASE" + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos"$UNAME_RELEASE" + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint"$UNAME_RELEASE" + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint"$UNAME_RELEASE" + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint"$UNAME_RELEASE" + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint"$UNAME_RELEASE" + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint"$UNAME_RELEASE" + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint"$UNAME_RELEASE" + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten"$UNAME_RELEASE" + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten"$UNAME_RELEASE" + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix"$UNAME_RELEASE" + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix"$UNAME_RELEASE" + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix"$UNAME_RELEASE" + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && + dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`"$dummy" "$dummyarg"` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos"$UNAME_RELEASE" + exit ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ] + then + if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \ + [ "$TARGET_BINARY_INTERFACE"x = x ] + then + echo m88k-dg-dgux"$UNAME_RELEASE" + else + echo m88k-dg-dguxbcs"$UNAME_RELEASE" + fi + else + echo i586-dg-dgux"$UNAME_RELEASE" + fi + exit ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit ;; + *:IRIX*:*:*) + echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`" + exit ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" + fi + echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" + exit ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[4567]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/lslpp ] ; then + IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | + awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` + else + IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" + fi + echo "$IBM_ARCH"-ibm-aix"$IBM_REV" + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + case "$UNAME_MACHINE" in + 9000/31?) HP_ARCH=m68000 ;; + 9000/[34]??) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "$sc_cpu_version" in + 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 + 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "$sc_kernel_bits" in + 32) HP_ARCH=hppa2.0n ;; + 64) HP_ARCH=hppa2.0w ;; + '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "$HP_ARCH" = "" ]; then + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ "$HP_ARCH" = hppa2.0w ] + then + set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | + grep -q __LP64__ + then + HP_ARCH=hppa2.0w + else + HP_ARCH=hppa64 + fi + fi + echo "$HP_ARCH"-hp-hpux"$HPUX_REV" + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux"$HPUX_REV" + exit ;; + 3050*:HI-UX:*:*) + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && + { echo "$SYSTEM_NAME"; exit; } + echo unknown-hitachi-hiuxwe2 + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) + echo hppa1.1-hp-bsd + exit ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) + echo hppa1.1-hp-osf + exit ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo "$UNAME_MACHINE"-unknown-osf1mk + else + echo "$UNAME_MACHINE"-unknown-osf1 + fi + exit ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*[A-Z]90:*:*:*) + echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' + exit ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" + exit ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi"$UNAME_RELEASE" + exit ;; + *:BSD/OS:*:*) + echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" + exit ;; + arm:FreeBSD:*:*) + UNAME_PROCESSOR=`uname -p` + set_cc_for_build + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabi + else + echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabihf + fi + exit ;; + *:FreeBSD:*:*) + UNAME_PROCESSOR=`/usr/bin/uname -p` + case "$UNAME_PROCESSOR" in + amd64) + UNAME_PROCESSOR=x86_64 ;; + i386) + UNAME_PROCESSOR=i586 ;; + esac + echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" + exit ;; + i*:CYGWIN*:*) + echo "$UNAME_MACHINE"-pc-cygwin + exit ;; + *:MINGW64*:*) + echo "$UNAME_MACHINE"-pc-mingw64 + exit ;; + *:MINGW*:*) + echo "$UNAME_MACHINE"-pc-mingw32 + exit ;; + *:MSYS*:*) + echo "$UNAME_MACHINE"-pc-msys + exit ;; + i*:PW*:*) + echo "$UNAME_MACHINE"-pc-pw32 + exit ;; + *:Interix*:*) + case "$UNAME_MACHINE" in + x86) + echo i586-pc-interix"$UNAME_RELEASE" + exit ;; + authenticamd | genuineintel | EM64T) + echo x86_64-unknown-interix"$UNAME_RELEASE" + exit ;; + IA64) + echo ia64-unknown-interix"$UNAME_RELEASE" + exit ;; + esac ;; + i*:UWIN*:*) + echo "$UNAME_MACHINE"-pc-uwin + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-pc-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" + exit ;; + *:GNU:*:*) + # the GNU system + echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`" + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC" + exit ;; + *:Minix:*:*) + echo "$UNAME_MACHINE"-unknown-minix + exit ;; + aarch64:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC=gnulibc1 ; fi + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + arc:Linux:*:* | arceb:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + arm*:Linux:*:*) + set_cc_for_build + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + else + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi + else + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf + fi + fi + exit ;; + avr32*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + cris:Linux:*:*) + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" + exit ;; + crisv32:Linux:*:*) + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" + exit ;; + e2k:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + frv:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + hexagon:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + i*86:Linux:*:*) + echo "$UNAME_MACHINE"-pc-linux-"$LIBC" + exit ;; + ia64:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + k1om:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + m32r*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + m68*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + mips:Linux:*:* | mips64:Linux:*:*) + set_cc_for_build + IS_GLIBC=0 + test x"${LIBC}" = xgnu && IS_GLIBC=1 + sed 's/^ //' << EOF > "$dummy.c" + #undef CPU + #undef mips + #undef mipsel + #undef mips64 + #undef mips64el + #if ${IS_GLIBC} && defined(_ABI64) + LIBCABI=gnuabi64 + #else + #if ${IS_GLIBC} && defined(_ABIN32) + LIBCABI=gnuabin32 + #else + LIBCABI=${LIBC} + #endif + #endif + + #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa64r6 + #else + #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa32r6 + #else + #if defined(__mips64) + CPU=mips64 + #else + CPU=mips + #endif + #endif + #endif + + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + MIPS_ENDIAN=el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + MIPS_ENDIAN= + #else + MIPS_ENDIAN= + #endif + #endif +EOF + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`" + test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; } + ;; + mips64el:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + openrisc*:Linux:*:*) + echo or1k-unknown-linux-"$LIBC" + exit ;; + or32:Linux:*:* | or1k*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + padre:Linux:*:*) + echo sparc-unknown-linux-"$LIBC" + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-"$LIBC" + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; + PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; + *) echo hppa-unknown-linux-"$LIBC" ;; + esac + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-"$LIBC" + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-"$LIBC" + exit ;; + ppc64le:Linux:*:*) + echo powerpc64le-unknown-linux-"$LIBC" + exit ;; + ppcle:Linux:*:*) + echo powerpcle-unknown-linux-"$LIBC" + exit ;; + riscv32:Linux:*:* | riscv64:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" + exit ;; + sh64*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + sh*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + tile*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + vax:Linux:*:*) + echo "$UNAME_MACHINE"-dec-linux-"$LIBC" + exit ;; + x86_64:Linux:*:*) + echo "$UNAME_MACHINE"-pc-linux-"$LIBC" + exit ;; + xtensa*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo "$UNAME_MACHINE"-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo "$UNAME_MACHINE"-unknown-stop + exit ;; + i*86:atheos:*:*) + echo "$UNAME_MACHINE"-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo "$UNAME_MACHINE"-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) + echo i386-unknown-lynxos"$UNAME_RELEASE" + exit ;; + i*86:*DOS:*:*) + echo "$UNAME_MACHINE"-pc-msdosdjgpp + exit ;; + i*86:*:4.*:*) + UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" + else + echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}" + exit ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" + else + echo "$UNAME_MACHINE"-pc-sysv32 + fi + exit ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configure will decide that + # this is a cross-build. + echo i586-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + NCR*:*:4.2:* | MPRAS*:*:4.2:*) + OS_REL='.3' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos"$UNAME_RELEASE" + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos"$UNAME_RELEASE" + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos"$UNAME_RELEASE" + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) + echo powerpc-unknown-lynxos"$UNAME_RELEASE" + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv"$UNAME_RELEASE" + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo "$UNAME_MACHINE"-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo "$UNAME_MACHINE"-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux"$UNAME_RELEASE" + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv"$UNAME_RELEASE" + else + echo mips-unknown-sysv"$UNAME_RELEASE" + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + echo i586-pc-haiku + exit ;; + x86_64:Haiku:*:*) + echo x86_64-unknown-haiku + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux"$UNAME_RELEASE" + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux"$UNAME_RELEASE" + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux"$UNAME_RELEASE" + exit ;; + SX-7:SUPER-UX:*:*) + echo sx7-nec-superux"$UNAME_RELEASE" + exit ;; + SX-8:SUPER-UX:*:*) + echo sx8-nec-superux"$UNAME_RELEASE" + exit ;; + SX-8R:SUPER-UX:*:*) + echo sx8r-nec-superux"$UNAME_RELEASE" + exit ;; + SX-ACE:SUPER-UX:*:*) + echo sxace-nec-superux"$UNAME_RELEASE" + exit ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody"$UNAME_RELEASE" + exit ;; + *:Rhapsody:*:*) + echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` + case $UNAME_PROCESSOR in + unknown) UNAME_PROCESSOR=powerpc ;; + esac + if command -v xcode-select > /dev/null 2> /dev/null && \ + ! xcode-select --print-path > /dev/null 2> /dev/null ; then + # Avoid executing cc if there is no toolchain installed as + # cc will be a stub that puts up a graphical alert + # prompting the user to install developer tools. + CC_FOR_BUILD=no_compiler_found + else + set_cc_for_build + fi + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc + if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_PPC >/dev/null + then + UNAME_PROCESSOR=powerpc + fi + elif test "$UNAME_PROCESSOR" = i386 ; then + # uname -m returns i386 or x86_64 + UNAME_PROCESSOR=$UNAME_MACHINE + fi + echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = x86; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NEO-*:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSE-*:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSR-*:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSV-*:NONSTOP_KERNEL:*:*) + echo nsv-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSX-*:NONSTOP_KERNEL:*:*) + echo nsx-tandem-nsk"$UNAME_RELEASE" + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + # shellcheck disable=SC2154 + if test "$cputype" = 386; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo "$UNAME_MACHINE"-unknown-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux"$UNAME_RELEASE" + exit ;; + *:DragonFly:*:*) + echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "$UNAME_MACHINE" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`" + exit ;; + i*86:rdos:*:*) + echo "$UNAME_MACHINE"-pc-rdos + exit ;; + i*86:AROS:*:*) + echo "$UNAME_MACHINE"-pc-aros + exit ;; + x86_64:VMkernel:*:*) + echo "$UNAME_MACHINE"-unknown-esx + exit ;; + amd64:Isilon\ OneFS:*:*) + echo x86_64-unknown-onefs + exit ;; + *:Unleashed:*:*) + echo "$UNAME_MACHINE"-unknown-unleashed"$UNAME_RELEASE" + exit ;; +esac + +# No uname command or uname output not recognized. +set_cc_for_build +cat > "$dummy.c" < +#include +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#include +#if defined(_SIZE_T_) || defined(SIGLOST) +#include +#endif +#endif +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); +#endif + +#if defined (vax) +#if !defined (ultrix) +#include +#if defined (BSD) +#if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +#else +#if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#endif +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#else +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname un; + uname (&un); + printf ("vax-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("vax-dec-ultrix\n"); exit (0); +#endif +#endif +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname *un; + uname (&un); + printf ("mips-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("mips-dec-ultrix\n"); exit (0); +#endif +#endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. +test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; } + +echo "$0: unable to guess system type" >&2 + +case "$UNAME_MACHINE:$UNAME_SYSTEM" in + mips:Linux | mips64:Linux) + # If we got here on MIPS GNU/Linux, output extra information. + cat >&2 <&2 </dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = "$UNAME_MACHINE" +UNAME_RELEASE = "$UNAME_RELEASE" +UNAME_SYSTEM = "$UNAME_SYSTEM" +UNAME_VERSION = "$UNAME_VERSION" +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/build-aux/config.rpath b/build-aux/config.rpath new file mode 100755 index 0000000..be202c1 --- /dev/null +++ b/build-aux/config.rpath @@ -0,0 +1,684 @@ +#! /bin/sh +# Output a system dependent set of variables, describing how to set the +# run time search path of shared libraries in an executable. +# +# Copyright 1996-2019 Free Software Foundation, Inc. +# Taken from GNU libtool, 2001 +# Originally by Gordon Matzigkeit , 1996 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# The first argument passed to this file is the canonical host specification, +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld +# should be set by the caller. +# +# The set of defined variables is at the end of this script. + +# Known limitations: +# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer +# than 256 bytes, otherwise the compiler driver will dump core. The only +# known workaround is to choose shorter directory names for the build +# directory and/or the installation directory. + +# All known linkers require a '.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a +shrext=.so + +host="$1" +host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + +# Code taken from libtool.m4's _LT_CC_BASENAME. + +for cc_temp in $CC""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'` + +# Code taken from libtool.m4's _LT_COMPILER_PIC. + +wl= +if test "$GCC" = yes; then + wl='-Wl,' +else + case "$host_os" in + aix*) + wl='-Wl,' + ;; + mingw* | cygwin* | pw32* | os2* | cegcc*) + ;; + hpux9* | hpux10* | hpux11*) + wl='-Wl,' + ;; + irix5* | irix6* | nonstopux*) + wl='-Wl,' + ;; + linux* | k*bsd*-gnu | kopensolaris*-gnu) + case $cc_basename in + ecc*) + wl='-Wl,' + ;; + icc* | ifort*) + wl='-Wl,' + ;; + lf95*) + wl='-Wl,' + ;; + nagfor*) + wl='-Wl,-Wl,,' + ;; + pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) + wl='-Wl,' + ;; + ccc*) + wl='-Wl,' + ;; + xl* | bgxl* | bgf* | mpixl*) + wl='-Wl,' + ;; + como) + wl='-lopt=' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ F* | *Sun*Fortran*) + wl= + ;; + *Sun\ C*) + wl='-Wl,' + ;; + esac + ;; + esac + ;; + newsos6) + ;; + *nto* | *qnx*) + ;; + osf3* | osf4* | osf5*) + wl='-Wl,' + ;; + rdos*) + ;; + solaris*) + case $cc_basename in + f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) + wl='-Qoption ld ' + ;; + *) + wl='-Wl,' + ;; + esac + ;; + sunos4*) + wl='-Qoption ld ' + ;; + sysv4 | sysv4.2uw2* | sysv4.3*) + wl='-Wl,' + ;; + sysv4*MP*) + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + wl='-Wl,' + ;; + unicos*) + wl='-Wl,' + ;; + uts4*) + ;; + esac +fi + +# Code taken from libtool.m4's _LT_LINKER_SHLIBS. + +hardcode_libdir_flag_spec= +hardcode_libdir_separator= +hardcode_direct=no +hardcode_minus_L=no + +case "$host_os" in + cygwin* | mingw* | pw32* | cegcc*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; +esac + +ld_shlibs=yes +if test "$with_gnu_ld" = yes; then + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + # Unlike libtool, we use -rpath here, not --rpath, since the documented + # option of GNU ld is called -rpath, not --rpath. + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + case "$host_os" in + aix[3-9]*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs=no + fi + ;; + amigaos*) + case "$host_cpu" in + powerpc) + ;; + m68k) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + esac + ;; + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + cygwin* | mingw* | pw32* | cegcc*) + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + haiku*) + ;; + interix[3-9]*) + hardcode_direct=no + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + netbsd*) + ;; + solaris*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) + ld_shlibs=no + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' + else + ld_shlibs=no + fi + ;; + esac + ;; + sunos4*) + hardcode_direct=yes + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + esac + if test "$ld_shlibs" = no; then + hardcode_libdir_flag_spec= + fi +else + case "$host_os" in + aix3*) + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$GCC" = yes; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + aix[4-9]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + else + aix_use_runtimelinking=no + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + fi + hardcode_direct=yes + hardcode_libdir_separator=':' + if test "$GCC" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + hardcode_direct=unsupported + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + ;; + esac + fi + # Begin _LT_AC_SYS_LIBPATH_AIX. + echo 'int main () { return 0; }' > conftest.c + ${CC} ${LDFLAGS} conftest.c -o conftest + aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` + if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` + fi + if test -z "$aix_libpath"; then + aix_libpath="/usr/lib:/lib" + fi + rm -f conftest.c conftest + # End _LT_AC_SYS_LIBPATH_AIX. + if test "$aix_use_runtimelinking" = yes; then + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' + else + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + fi + fi + ;; + amigaos*) + case "$host_cpu" in + powerpc) + ;; + m68k) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + esac + ;; + bsdi[45]*) + ;; + cygwin* | mingw* | pw32* | cegcc*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec=' ' + libext=lib + ;; + darwin* | rhapsody*) + hardcode_direct=no + if { case $cc_basename in ifort*) true;; *) test "$GCC" = yes;; esac; }; then + : + else + ld_shlibs=no + fi + ;; + dgux*) + hardcode_libdir_flag_spec='-L$libdir' + ;; + freebsd2.[01]*) + hardcode_direct=yes + hardcode_minus_L=yes + ;; + freebsd* | dragonfly*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + hpux9*) + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + hpux10*) + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + fi + ;; + hpux11*) + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + case $host_cpu in + hppa*64*|ia64*) + hardcode_direct=no + ;; + *) + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + esac + fi + ;; + irix5* | irix6* | nonstopux*) + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + netbsd*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + newsos6) + hardcode_direct=yes + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + *nto* | *qnx*) + ;; + openbsd*) + if test -f /usr/libexec/ld.so; then + hardcode_direct=yes + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + else + case "$host_os" in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + esac + fi + else + ld_shlibs=no + fi + ;; + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + osf3*) + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + osf4* | osf5*) + if test "$GCC" = yes; then + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + else + # Both cc and cxx compiler support -rpath directly + hardcode_libdir_flag_spec='-rpath $libdir' + fi + hardcode_libdir_separator=: + ;; + solaris*) + hardcode_libdir_flag_spec='-R$libdir' + ;; + sunos4*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + ;; + sysv4) + case $host_vendor in + sni) + hardcode_direct=yes # is this really true??? + ;; + siemens) + hardcode_direct=no + ;; + motorola) + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + esac + ;; + sysv4.3*) + ;; + sysv4*MP*) + if test -d /usr/nec; then + ld_shlibs=yes + fi + ;; + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) + ;; + sysv5* | sco3.2v5* | sco5v6*) + hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' + hardcode_libdir_separator=':' + ;; + uts4*) + hardcode_libdir_flag_spec='-L$libdir' + ;; + *) + ld_shlibs=no + ;; + esac +fi + +# Check dynamic linker characteristics +# Code taken from libtool.m4's _LT_SYS_DYNAMIC_LINKER. +# Unlike libtool.m4, here we don't care about _all_ names of the library, but +# only about the one the linker finds when passed -lNAME. This is the last +# element of library_names_spec in libtool.m4, or possibly two of them if the +# linker has special search rules. +library_names_spec= # the last element of library_names_spec in libtool.m4 +libname_spec='lib$name' +case "$host_os" in + aix3*) + library_names_spec='$libname.a' + ;; + aix[4-9]*) + library_names_spec='$libname$shrext' + ;; + amigaos*) + case "$host_cpu" in + powerpc*) + library_names_spec='$libname$shrext' ;; + m68k) + library_names_spec='$libname.a' ;; + esac + ;; + beos*) + library_names_spec='$libname$shrext' + ;; + bsdi[45]*) + library_names_spec='$libname$shrext' + ;; + cygwin* | mingw* | pw32* | cegcc*) + shrext=.dll + library_names_spec='$libname.dll.a $libname.lib' + ;; + darwin* | rhapsody*) + shrext=.dylib + library_names_spec='$libname$shrext' + ;; + dgux*) + library_names_spec='$libname$shrext' + ;; + freebsd[23].*) + library_names_spec='$libname$shrext$versuffix' + ;; + freebsd* | dragonfly*) + library_names_spec='$libname$shrext' + ;; + gnu*) + library_names_spec='$libname$shrext' + ;; + haiku*) + library_names_spec='$libname$shrext' + ;; + hpux9* | hpux10* | hpux11*) + case $host_cpu in + ia64*) + shrext=.so + ;; + hppa*64*) + shrext=.sl + ;; + *) + shrext=.sl + ;; + esac + library_names_spec='$libname$shrext' + ;; + interix[3-9]*) + library_names_spec='$libname$shrext' + ;; + irix5* | irix6* | nonstopux*) + library_names_spec='$libname$shrext' + case "$host_os" in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;; + *) libsuff= shlibsuff= ;; + esac + ;; + esac + ;; + linux*oldld* | linux*aout* | linux*coff*) + ;; + linux* | k*bsd*-gnu | kopensolaris*-gnu) + library_names_spec='$libname$shrext' + ;; + knetbsd*-gnu) + library_names_spec='$libname$shrext' + ;; + netbsd*) + library_names_spec='$libname$shrext' + ;; + newsos6) + library_names_spec='$libname$shrext' + ;; + *nto* | *qnx*) + library_names_spec='$libname$shrext' + ;; + openbsd*) + library_names_spec='$libname$shrext$versuffix' + ;; + os2*) + libname_spec='$name' + shrext=.dll + library_names_spec='$libname.a' + ;; + osf3* | osf4* | osf5*) + library_names_spec='$libname$shrext' + ;; + rdos*) + ;; + solaris*) + library_names_spec='$libname$shrext' + ;; + sunos4*) + library_names_spec='$libname$shrext$versuffix' + ;; + sysv4 | sysv4.3*) + library_names_spec='$libname$shrext' + ;; + sysv4*MP*) + library_names_spec='$libname$shrext' + ;; + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + library_names_spec='$libname$shrext' + ;; + tpf*) + library_names_spec='$libname$shrext' + ;; + uts4*) + library_names_spec='$libname$shrext' + ;; +esac + +sed_quote_subst='s/\(["`$\\]\)/\\\1/g' +escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"` +shlibext=`echo "$shrext" | sed -e 's,^\.,,'` +escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` +escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` +escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` + +LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). + + +# Please send patches to . +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# You can get the latest version of this script from: +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS + +Canonicalize a configuration name. + +Options: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright 1992-2019 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo "$1" + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Split fields of configuration type +# shellcheck disable=SC2162 +IFS="-" read field1 field2 field3 field4 <&2 + exit 1 + ;; + *-*-*-*) + basic_machine=$field1-$field2 + os=$field3-$field4 + ;; + *-*-*) + # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two + # parts + maybe_os=$field2-$field3 + case $maybe_os in + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc \ + | linux-newlib* | linux-musl* | linux-uclibc* | uclinux-uclibc* \ + | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ + | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ + | storm-chaos* | os2-emx* | rtmk-nova*) + basic_machine=$field1 + os=$maybe_os + ;; + android-linux) + basic_machine=$field1-unknown + os=linux-android + ;; + *) + basic_machine=$field1-$field2 + os=$field3 + ;; + esac + ;; + *-*) + # A lone config we happen to match not fitting any pattern + case $field1-$field2 in + decstation-3100) + basic_machine=mips-dec + os= + ;; + *-*) + # Second component is usually, but not always the OS + case $field2 in + # Prevent following clause from handling this valid os + sun*os*) + basic_machine=$field1 + os=$field2 + ;; + # Manufacturers + dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \ + | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ + | unicom* | ibm* | next | hp | isi* | apollo | altos* \ + | convergent* | ncr* | news | 32* | 3600* | 3100* \ + | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \ + | ultra | tti* | harris | dolphin | highlevel | gould \ + | cbm | ns | masscomp | apple | axis | knuth | cray \ + | microblaze* | sim | cisco \ + | oki | wec | wrs | winbond) + basic_machine=$field1-$field2 + os= + ;; + *) + basic_machine=$field1 + os=$field2 + ;; + esac + ;; + esac + ;; + *) + # Convert single-component short-hands not valid as part of + # multi-component configurations. + case $field1 in + 386bsd) + basic_machine=i386-pc + os=bsd + ;; + a29khif) + basic_machine=a29k-amd + os=udi + ;; + adobe68k) + basic_machine=m68010-adobe + os=scout + ;; + alliant) + basic_machine=fx80-alliant + os= + ;; + altos | altos3068) + basic_machine=m68k-altos + os= + ;; + am29k) + basic_machine=a29k-none + os=bsd + ;; + amdahl) + basic_machine=580-amdahl + os=sysv + ;; + amiga) + basic_machine=m68k-unknown + os= + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=bsd + ;; + aros) + basic_machine=i386-pc + os=aros + ;; + aux) + basic_machine=m68k-apple + os=aux + ;; + balance) + basic_machine=ns32k-sequent + os=dynix + ;; + blackfin) + basic_machine=bfin-unknown + os=linux + ;; + cegcc) + basic_machine=arm-unknown + os=cegcc + ;; + convex-c1) + basic_machine=c1-convex + os=bsd + ;; + convex-c2) + basic_machine=c2-convex + os=bsd + ;; + convex-c32) + basic_machine=c32-convex + os=bsd + ;; + convex-c34) + basic_machine=c34-convex + os=bsd + ;; + convex-c38) + basic_machine=c38-convex + os=bsd + ;; + cray) + basic_machine=j90-cray + os=unicos + ;; + crds | unos) + basic_machine=m68k-crds + os= + ;; + da30) + basic_machine=m68k-da30 + os= + ;; + decstation | pmax | pmin | dec3100 | decstatn) + basic_machine=mips-dec + os= + ;; + delta88) + basic_machine=m88k-motorola + os=sysv3 + ;; + dicos) + basic_machine=i686-pc + os=dicos + ;; + djgpp) + basic_machine=i586-pc + os=msdosdjgpp + ;; + ebmon29k) + basic_machine=a29k-amd + os=ebmon + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=ose + ;; + gmicro) + basic_machine=tron-gmicro + os=sysv + ;; + go32) + basic_machine=i386-pc + os=go32 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=hms + ;; + harris) + basic_machine=m88k-harris + os=sysv3 + ;; + hp300 | hp300hpux) + basic_machine=m68k-hp + os=hpux + ;; + hp300bsd) + basic_machine=m68k-hp + os=bsd + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=proelf + ;; + i386mach) + basic_machine=i386-mach + os=mach + ;; + isi68 | isi) + basic_machine=m68k-isi + os=sysv + ;; + m68knommu) + basic_machine=m68k-unknown + os=linux + ;; + magnum | m3230) + basic_machine=mips-mips + os=sysv + ;; + merlin) + basic_machine=ns32k-utek + os=sysv + ;; + mingw64) + basic_machine=x86_64-pc + os=mingw64 + ;; + mingw32) + basic_machine=i686-pc + os=mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + os=mingw32ce + ;; + monitor) + basic_machine=m68k-rom68k + os=coff + ;; + morphos) + basic_machine=powerpc-unknown + os=morphos + ;; + moxiebox) + basic_machine=moxie-unknown + os=moxiebox + ;; + msdos) + basic_machine=i386-pc + os=msdos + ;; + msys) + basic_machine=i686-pc + os=msys + ;; + mvs) + basic_machine=i370-ibm + os=mvs + ;; + nacl) + basic_machine=le32-unknown + os=nacl + ;; + ncr3000) + basic_machine=i486-ncr + os=sysv4 + ;; + netbsd386) + basic_machine=i386-pc + os=netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=newsos + ;; + news1000) + basic_machine=m68030-sony + os=newsos + ;; + necv70) + basic_machine=v70-nec + os=sysv + ;; + nh3000) + basic_machine=m68k-harris + os=cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=cxux + ;; + nindy960) + basic_machine=i960-intel + os=nindy + ;; + mon960) + basic_machine=i960-intel + os=mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=nonstopux + ;; + os400) + basic_machine=powerpc-ibm + os=os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=ose + ;; + os68k) + basic_machine=m68k-none + os=os68k + ;; + paragon) + basic_machine=i860-intel + os=osf + ;; + parisc) + basic_machine=hppa-unknown + os=linux + ;; + pw32) + basic_machine=i586-unknown + os=pw32 + ;; + rdos | rdos64) + basic_machine=x86_64-pc + os=rdos + ;; + rdos32) + basic_machine=i386-pc + os=rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=coff + ;; + sa29200) + basic_machine=a29k-amd + os=udi + ;; + sei) + basic_machine=mips-sei + os=seiux + ;; + sequent) + basic_machine=i386-sequent + os= + ;; + sps7) + basic_machine=m68k-bull + os=sysv2 + ;; + st2000) + basic_machine=m68k-tandem + os= + ;; + stratus) + basic_machine=i860-stratus + os=sysv4 + ;; + sun2) + basic_machine=m68000-sun + os= + ;; + sun2os3) + basic_machine=m68000-sun + os=sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=sunos4 + ;; + sun3) + basic_machine=m68k-sun + os= + ;; + sun3os3) + basic_machine=m68k-sun + os=sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=sunos4 + ;; + sun4) + basic_machine=sparc-sun + os= + ;; + sun4os3) + basic_machine=sparc-sun + os=sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=solaris2 + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + os= + ;; + sv1) + basic_machine=sv1-cray + os=unicos + ;; + symmetry) + basic_machine=i386-sequent + os=dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=unicos + ;; + t90) + basic_machine=t90-cray + os=unicos + ;; + toad1) + basic_machine=pdp10-xkl + os=tops20 + ;; + tpf) + basic_machine=s390x-ibm + os=tpf + ;; + udi29k) + basic_machine=a29k-amd + os=udi + ;; + ultra3) + basic_machine=a29k-nyu + os=sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=none + ;; + vaxv) + basic_machine=vax-dec + os=sysv + ;; + vms) + basic_machine=vax-dec + os=vms + ;; + vsta) + basic_machine=i386-pc + os=vsta + ;; + vxworks960) + basic_machine=i960-wrs + os=vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=vxworks + ;; + xbox) + basic_machine=i686-pc + os=mingw32 + ;; + ymp) + basic_machine=ymp-cray + os=unicos + ;; + *) + basic_machine=$1 + os= + ;; + esac + ;; +esac + +# Decode 1-component or ad-hoc basic machines +case $basic_machine in + # Here we handle the default manufacturer of certain CPU types. It is in + # some cases the only manufacturer, in others, it is the most popular. + w89k) + cpu=hppa1.1 + vendor=winbond + ;; + op50n) + cpu=hppa1.1 + vendor=oki + ;; + op60c) + cpu=hppa1.1 + vendor=oki + ;; + ibm*) + cpu=i370 + vendor=ibm + ;; + orion105) + cpu=clipper + vendor=highlevel + ;; + mac | mpw | mac-mpw) + cpu=m68k + vendor=apple + ;; + pmac | pmac-mpw) + cpu=powerpc + vendor=apple + ;; + + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + cpu=m68000 + vendor=att + ;; + 3b*) + cpu=we32k + vendor=att + ;; + bluegene*) + cpu=powerpc + vendor=ibm + os=cnk + ;; + decsystem10* | dec10*) + cpu=pdp10 + vendor=dec + os=tops10 + ;; + decsystem20* | dec20*) + cpu=pdp10 + vendor=dec + os=tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + cpu=m68k + vendor=motorola + ;; + dpx2*) + cpu=m68k + vendor=bull + os=sysv3 + ;; + encore | umax | mmax) + cpu=ns32k + vendor=encore + ;; + elxsi) + cpu=elxsi + vendor=elxsi + os=${os:-bsd} + ;; + fx2800) + cpu=i860 + vendor=alliant + ;; + genix) + cpu=ns32k + vendor=ns + ;; + h3050r* | hiux*) + cpu=hppa1.1 + vendor=hitachi + os=hiuxwe2 + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + cpu=hppa1.0 + vendor=hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + cpu=m68000 + vendor=hp + ;; + hp9k3[2-9][0-9]) + cpu=m68k + vendor=hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + cpu=hppa1.0 + vendor=hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + cpu=hppa1.1 + vendor=hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + cpu=hppa1.1 + vendor=hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + cpu=hppa1.1 + vendor=hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + cpu=hppa1.1 + vendor=hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + cpu=hppa1.0 + vendor=hp + ;; + i*86v32) + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + os=sysv32 + ;; + i*86v4*) + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + os=sysv4 + ;; + i*86v) + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + os=sysv + ;; + i*86sol2) + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + os=solaris2 + ;; + j90 | j90-cray) + cpu=j90 + vendor=cray + os=${os:-unicos} + ;; + iris | iris4d) + cpu=mips + vendor=sgi + case $os in + irix*) + ;; + *) + os=irix4 + ;; + esac + ;; + miniframe) + cpu=m68000 + vendor=convergent + ;; + *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*) + cpu=m68k + vendor=atari + os=mint + ;; + news-3600 | risc-news) + cpu=mips + vendor=sony + os=newsos + ;; + next | m*-next) + cpu=m68k + vendor=next + case $os in + openstep*) + ;; + nextstep*) + ;; + ns2*) + os=nextstep2 + ;; + *) + os=nextstep3 + ;; + esac + ;; + np1) + cpu=np1 + vendor=gould + ;; + op50n-* | op60c-*) + cpu=hppa1.1 + vendor=oki + os=proelf + ;; + pa-hitachi) + cpu=hppa1.1 + vendor=hitachi + os=hiuxwe2 + ;; + pbd) + cpu=sparc + vendor=tti + ;; + pbb) + cpu=m68k + vendor=tti + ;; + pc532) + cpu=ns32k + vendor=pc532 + ;; + pn) + cpu=pn + vendor=gould + ;; + power) + cpu=power + vendor=ibm + ;; + ps2) + cpu=i386 + vendor=ibm + ;; + rm[46]00) + cpu=mips + vendor=siemens + ;; + rtpc | rtpc-*) + cpu=romp + vendor=ibm + ;; + sde) + cpu=mipsisa32 + vendor=sde + os=${os:-elf} + ;; + simso-wrs) + cpu=sparclite + vendor=wrs + os=vxworks + ;; + tower | tower-32) + cpu=m68k + vendor=ncr + ;; + vpp*|vx|vx-*) + cpu=f301 + vendor=fujitsu + ;; + w65) + cpu=w65 + vendor=wdc + ;; + w89k-*) + cpu=hppa1.1 + vendor=winbond + os=proelf + ;; + none) + cpu=none + vendor=none + ;; + leon|leon[3-9]) + cpu=sparc + vendor=$basic_machine + ;; + leon-*|leon[3-9]-*) + cpu=sparc + vendor=`echo "$basic_machine" | sed 's/-.*//'` + ;; + + *-*) + # shellcheck disable=SC2162 + IFS="-" read cpu vendor <&2 + exit 1 + ;; + esac + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $vendor in + digital*) + vendor=dec + ;; + commodore*) + vendor=cbm + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x$os != x ] +then +case $os in + # First match some system type aliases that might get confused + # with valid system types. + # solaris* is a basic system type, with this one exception. + auroraux) + os=auroraux + ;; + bluegene*) + os=cnk + ;; + solaris1 | solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + solaris) + os=solaris2 + ;; + unixware*) + os=sysv4.2uw + ;; + gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # es1800 is here to avoid being matched by es* (a different OS) + es1800*) + os=ose + ;; + # Some version numbers need modification + chorusos*) + os=chorusos + ;; + isc) + os=isc2.2 + ;; + sco6) + os=sco5v6 + ;; + sco5) + os=sco3.2v5 + ;; + sco4) + os=sco3.2v4 + ;; + sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + ;; + sco3.2v[4-9]* | sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + ;; + scout) + # Don't match below + ;; + sco*) + os=sco3.2v2 + ;; + psos*) + os=psos + ;; + # Now accept the basic system types. + # The portable systems comes first. + # Each alternative MUST end in a * to match a version number. + # sysv* is not here because it comes later, after sysvr4. + gnu* | bsd* | mach* | minix* | genix* | ultrix* | irix* \ + | *vms* | esix* | aix* | cnk* | sunos | sunos[34]*\ + | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ + | sym* | kopensolaris* | plan9* \ + | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ + | aos* | aros* | cloudabi* | sortix* \ + | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \ + | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \ + | knetbsd* | mirbsd* | netbsd* \ + | bitrig* | openbsd* | solidbsd* | libertybsd* | os108* \ + | ekkobsd* | kfreebsd* | freebsd* | riscix* | lynxos* \ + | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \ + | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \ + | udi* | eabi* | lites* | ieee* | go32* | aux* | hcos* \ + | chorusrdb* | cegcc* | glidix* \ + | cygwin* | msys* | pe* | moss* | proelf* | rtems* \ + | midipix* | mingw32* | mingw64* | linux-gnu* | linux-android* \ + | linux-newlib* | linux-musl* | linux-uclibc* \ + | uxpv* | beos* | mpeix* | udk* | moxiebox* \ + | interix* | uwin* | mks* | rhapsody* | darwin* \ + | openstep* | oskit* | conix* | pw32* | nonstopux* \ + | storm-chaos* | tops10* | tenex* | tops20* | its* \ + | os2* | vos* | palmos* | uclinux* | nucleus* \ + | morphos* | superux* | rtmk* | windiss* \ + | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ + | skyos* | haiku* | rdos* | toppers* | drops* | es* \ + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ + | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ + | nsk* | powerunix) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + qnx*) + case $cpu in + x86 | i*86) + ;; + *) + os=nto-$os + ;; + esac + ;; + hiux*) + os=hiuxwe2 + ;; + nto-qnx*) + ;; + nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + sim | xray | os68k* | v88r* \ + | windows* | osx | abug | netware* | os9* \ + | macos* | mpw* | magic* | mmixware* | mon960* | lnews*) + ;; + linux-dietlibc) + os=linux-dietlibc + ;; + linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + lynx*178) + os=lynxos178 + ;; + lynx*5) + os=lynxos5 + ;; + lynx*) + os=lynxos + ;; + mac*) + os=`echo "$os" | sed -e 's|mac|macos|'` + ;; + opened*) + os=openedition + ;; + os400*) + os=os400 + ;; + sunos5*) + os=`echo "$os" | sed -e 's|sunos5|solaris2|'` + ;; + sunos6*) + os=`echo "$os" | sed -e 's|sunos6|solaris3|'` + ;; + wince*) + os=wince + ;; + utek*) + os=bsd + ;; + dynix*) + os=bsd + ;; + acis*) + os=aos + ;; + atheos*) + os=atheos + ;; + syllable*) + os=syllable + ;; + 386bsd) + os=bsd + ;; + ctix* | uts*) + os=sysv + ;; + nova*) + os=rtmk-nova + ;; + ns2) + os=nextstep2 + ;; + # Preserve the version number of sinix5. + sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + sinix*) + os=sysv4 + ;; + tpf*) + os=tpf + ;; + triton*) + os=sysv3 + ;; + oss*) + os=sysv3 + ;; + svr4*) + os=sysv4 + ;; + svr3) + os=sysv3 + ;; + sysvr4) + os=sysv4 + ;; + # This must come after sysvr4. + sysv*) + ;; + ose*) + os=ose + ;; + *mint | mint[0-9]* | *MiNT | MiNT[0-9]*) + os=mint + ;; + zvmoe) + os=zvmoe + ;; + dicos*) + os=dicos + ;; + pikeos*) + # Until real need of OS specific support for + # particular features comes up, bare metal + # configurations are quite functional. + case $cpu in + arm*) + os=eabi + ;; + *) + os=elf + ;; + esac + ;; + nacl*) + ;; + ios) + ;; + none) + ;; + *-eabi) + ;; + *) + echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $cpu-$vendor in + score-*) + os=elf + ;; + spu-*) + os=elf + ;; + *-acorn) + os=riscix1.2 + ;; + arm*-rebel) + os=linux + ;; + arm*-semi) + os=aout + ;; + c4x-* | tic4x-*) + os=coff + ;; + c8051-*) + os=elf + ;; + clipper-intergraph) + os=clix + ;; + hexagon-*) + os=elf + ;; + tic54x-*) + os=coff + ;; + tic55x-*) + os=coff + ;; + tic6x-*) + os=coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=tops20 + ;; + pdp11-*) + os=none + ;; + *-dec | vax-*) + os=ultrix4.2 + ;; + m68*-apollo) + os=domain + ;; + i386-sun) + os=sunos4.0.2 + ;; + m68000-sun) + os=sunos3 + ;; + m68*-cisco) + os=aout + ;; + mep-*) + os=elf + ;; + mips*-cisco) + os=elf + ;; + mips*-*) + os=elf + ;; + or32-*) + os=coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=sysv3 + ;; + sparc-* | *-sun) + os=sunos4.1.1 + ;; + pru-*) + os=elf + ;; + *-be) + os=beos + ;; + *-ibm) + os=aix + ;; + *-knuth) + os=mmixware + ;; + *-wec) + os=proelf + ;; + *-winbond) + os=proelf + ;; + *-oki) + os=proelf + ;; + *-hp) + os=hpux + ;; + *-hitachi) + os=hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=sysv + ;; + *-cbm) + os=amigaos + ;; + *-dg) + os=dgux + ;; + *-dolphin) + os=sysv3 + ;; + m68k-ccur) + os=rtu + ;; + m88k-omron*) + os=luna + ;; + *-next) + os=nextstep + ;; + *-sequent) + os=ptx + ;; + *-crds) + os=unos + ;; + *-ns) + os=genix + ;; + i370-*) + os=mvs + ;; + *-gould) + os=sysv + ;; + *-highlevel) + os=bsd + ;; + *-encore) + os=bsd + ;; + *-sgi) + os=irix + ;; + *-siemens) + os=sysv4 + ;; + *-masscomp) + os=rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=uxpv + ;; + *-rom68k) + os=coff + ;; + *-*bug) + os=coff + ;; + *-apple) + os=macos + ;; + *-atari*) + os=mint + ;; + *-wrs) + os=vxworks + ;; + *) + os=none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +case $vendor in + unknown) + case $os in + riscix*) + vendor=acorn + ;; + sunos*) + vendor=sun + ;; + cnk*|-aix*) + vendor=ibm + ;; + beos*) + vendor=be + ;; + hpux*) + vendor=hp + ;; + mpeix*) + vendor=hp + ;; + hiux*) + vendor=hitachi + ;; + unos*) + vendor=crds + ;; + dgux*) + vendor=dg + ;; + luna*) + vendor=omron + ;; + genix*) + vendor=ns + ;; + clix*) + vendor=intergraph + ;; + mvs* | opened*) + vendor=ibm + ;; + os400*) + vendor=ibm + ;; + ptx*) + vendor=sequent + ;; + tpf*) + vendor=ibm + ;; + vxsim* | vxworks* | windiss*) + vendor=wrs + ;; + aux*) + vendor=apple + ;; + hms*) + vendor=hitachi + ;; + mpw* | macos*) + vendor=apple + ;; + *mint | mint[0-9]* | *MiNT | MiNT[0-9]*) + vendor=atari + ;; + vos*) + vendor=stratus + ;; + esac + ;; +esac + +echo "$cpu-$vendor-$os" +exit + +# Local variables: +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/build-aux/depcomp b/build-aux/depcomp new file mode 100755 index 0000000..b39f98f --- /dev/null +++ b/build-aux/depcomp @@ -0,0 +1,791 @@ +#! /bin/sh +# depcomp - compile a program generating dependencies as side-effects + +scriptversion=2016-01-11.22; # UTC + +# Copyright (C) 1999-2017 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Originally written by Alexandre Oliva . + +case $1 in + '') + echo "$0: No command. Try '$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: depcomp [--help] [--version] PROGRAM [ARGS] + +Run PROGRAMS ARGS to compile a file, generating dependencies +as side-effects. + +Environment variables: + depmode Dependency tracking mode. + source Source file read by 'PROGRAMS ARGS'. + object Object file output by 'PROGRAMS ARGS'. + DEPDIR directory where to store dependencies. + depfile Dependency file to output. + tmpdepfile Temporary file to use when outputting dependencies. + libtool Whether libtool is used (yes/no). + +Report bugs to . +EOF + exit $? + ;; + -v | --v*) + echo "depcomp $scriptversion" + exit $? + ;; +esac + +# Get the directory component of the given path, and save it in the +# global variables '$dir'. Note that this directory component will +# be either empty or ending with a '/' character. This is deliberate. +set_dir_from () +{ + case $1 in + */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; + *) dir=;; + esac +} + +# Get the suffix-stripped basename of the given path, and save it the +# global variable '$base'. +set_base_from () +{ + base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` +} + +# If no dependency file was actually created by the compiler invocation, +# we still have to create a dummy depfile, to avoid errors with the +# Makefile "include basename.Plo" scheme. +make_dummy_depfile () +{ + echo "#dummy" > "$depfile" +} + +# Factor out some common post-processing of the generated depfile. +# Requires the auxiliary global variable '$tmpdepfile' to be set. +aix_post_process_depfile () +{ + # If the compiler actually managed to produce a dependency file, + # post-process it. + if test -f "$tmpdepfile"; then + # Each line is of the form 'foo.o: dependency.h'. + # Do two passes, one to just change these to + # $object: dependency.h + # and one to simply output + # dependency.h: + # which is needed to avoid the deleted-header problem. + { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" + sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" + } > "$depfile" + rm -f "$tmpdepfile" + else + make_dummy_depfile + fi +} + +# A tabulation character. +tab=' ' +# A newline character. +nl=' +' +# Character ranges might be problematic outside the C locale. +# These definitions help. +upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ +lower=abcdefghijklmnopqrstuvwxyz +digits=0123456789 +alpha=${upper}${lower} + +if test -z "$depmode" || test -z "$source" || test -z "$object"; then + echo "depcomp: Variables source, object and depmode must be set" 1>&2 + exit 1 +fi + +# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. +depfile=${depfile-`echo "$object" | + sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} +tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} + +rm -f "$tmpdepfile" + +# Avoid interferences from the environment. +gccflag= dashmflag= + +# Some modes work just like other modes, but use different flags. We +# parameterize here, but still list the modes in the big case below, +# to make depend.m4 easier to write. Note that we *cannot* use a case +# here, because this file can only contain one case statement. +if test "$depmode" = hp; then + # HP compiler uses -M and no extra arg. + gccflag=-M + depmode=gcc +fi + +if test "$depmode" = dashXmstdout; then + # This is just like dashmstdout with a different argument. + dashmflag=-xM + depmode=dashmstdout +fi + +cygpath_u="cygpath -u -f -" +if test "$depmode" = msvcmsys; then + # This is just like msvisualcpp but w/o cygpath translation. + # Just convert the backslash-escaped backslashes to single forward + # slashes to satisfy depend.m4 + cygpath_u='sed s,\\\\,/,g' + depmode=msvisualcpp +fi + +if test "$depmode" = msvc7msys; then + # This is just like msvc7 but w/o cygpath translation. + # Just convert the backslash-escaped backslashes to single forward + # slashes to satisfy depend.m4 + cygpath_u='sed s,\\\\,/,g' + depmode=msvc7 +fi + +if test "$depmode" = xlc; then + # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. + gccflag=-qmakedep=gcc,-MF + depmode=gcc +fi + +case "$depmode" in +gcc3) +## gcc 3 implements dependency tracking that does exactly what +## we want. Yay! Note: for some reason libtool 1.4 doesn't like +## it if -MD -MP comes after the -MF stuff. Hmm. +## Unfortunately, FreeBSD c89 acceptance of flags depends upon +## the command line argument order; so add the flags where they +## appear in depend2.am. Note that the slowdown incurred here +## affects only configure: in makefiles, %FASTDEP% shortcuts this. + for arg + do + case $arg in + -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; + *) set fnord "$@" "$arg" ;; + esac + shift # fnord + shift # $arg + done + "$@" + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + mv "$tmpdepfile" "$depfile" + ;; + +gcc) +## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. +## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. +## (see the conditional assignment to $gccflag above). +## There are various ways to get dependency output from gcc. Here's +## why we pick this rather obscure method: +## - Don't want to use -MD because we'd like the dependencies to end +## up in a subdir. Having to rename by hand is ugly. +## (We might end up doing this anyway to support other compilers.) +## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like +## -MM, not -M (despite what the docs say). Also, it might not be +## supported by the other compilers which use the 'gcc' depmode. +## - Using -M directly means running the compiler twice (even worse +## than renaming). + if test -z "$gccflag"; then + gccflag=-MD, + fi + "$@" -Wp,"$gccflag$tmpdepfile" + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + # The second -e expression handles DOS-style file names with drive + # letters. + sed -e 's/^[^:]*: / /' \ + -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" +## This next piece of magic avoids the "deleted header file" problem. +## The problem is that when a header file which appears in a .P file +## is deleted, the dependency causes make to die (because there is +## typically no way to rebuild the header). We avoid this by adding +## dummy dependencies for each header file. Too bad gcc doesn't do +## this for us directly. +## Some versions of gcc put a space before the ':'. On the theory +## that the space means something, we add a space to the output as +## well. hp depmode also adds that space, but also prefixes the VPATH +## to the object. Take care to not repeat it in the output. +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ + | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +sgi) + if test "$libtool" = yes; then + "$@" "-Wp,-MDupdate,$tmpdepfile" + else + "$@" -MDupdate "$tmpdepfile" + fi + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + + if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files + echo "$object : \\" > "$depfile" + # Clip off the initial element (the dependent). Don't try to be + # clever and replace this with sed code, as IRIX sed won't handle + # lines with more than a fixed number of characters (4096 in + # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; + # the IRIX cc adds comments like '#:fec' to the end of the + # dependency line. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ + | tr "$nl" ' ' >> "$depfile" + echo >> "$depfile" + # The second pass generates a dummy entry for each header file. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ + >> "$depfile" + else + make_dummy_depfile + fi + rm -f "$tmpdepfile" + ;; + +xlc) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +aix) + # The C for AIX Compiler uses -M and outputs the dependencies + # in a .u file. In older versions, this file always lives in the + # current directory. Also, the AIX compiler puts '$object:' at the + # start of each line; $object doesn't have directory information. + # Version 6 uses the directory in both cases. + set_dir_from "$object" + set_base_from "$object" + if test "$libtool" = yes; then + tmpdepfile1=$dir$base.u + tmpdepfile2=$base.u + tmpdepfile3=$dir.libs/$base.u + "$@" -Wc,-M + else + tmpdepfile1=$dir$base.u + tmpdepfile2=$dir$base.u + tmpdepfile3=$dir$base.u + "$@" -M + fi + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + do + test -f "$tmpdepfile" && break + done + aix_post_process_depfile + ;; + +tcc) + # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 + # FIXME: That version still under development at the moment of writing. + # Make that this statement remains true also for stable, released + # versions. + # It will wrap lines (doesn't matter whether long or short) with a + # trailing '\', as in: + # + # foo.o : \ + # foo.c \ + # foo.h \ + # + # It will put a trailing '\' even on the last line, and will use leading + # spaces rather than leading tabs (at least since its commit 0394caf7 + # "Emit spaces for -MD"). + "$@" -MD -MF "$tmpdepfile" + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. + # We have to change lines of the first kind to '$object: \'. + sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" + # And for each line of the second kind, we have to emit a 'dep.h:' + # dummy dependency, to avoid the deleted-header problem. + sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" + rm -f "$tmpdepfile" + ;; + +## The order of this option in the case statement is important, since the +## shell code in configure will try each of these formats in the order +## listed in this file. A plain '-MD' option would be understood by many +## compilers, so we must ensure this comes after the gcc and icc options. +pgcc) + # Portland's C compiler understands '-MD'. + # Will always output deps to 'file.d' where file is the root name of the + # source file under compilation, even if file resides in a subdirectory. + # The object file name does not affect the name of the '.d' file. + # pgcc 10.2 will output + # foo.o: sub/foo.c sub/foo.h + # and will wrap long lines using '\' : + # foo.o: sub/foo.c ... \ + # sub/foo.h ... \ + # ... + set_dir_from "$object" + # Use the source, not the object, to determine the base name, since + # that's sadly what pgcc will do too. + set_base_from "$source" + tmpdepfile=$base.d + + # For projects that build the same source file twice into different object + # files, the pgcc approach of using the *source* file root name can cause + # problems in parallel builds. Use a locking strategy to avoid stomping on + # the same $tmpdepfile. + lockdir=$base.d-lock + trap " + echo '$0: caught signal, cleaning up...' >&2 + rmdir '$lockdir' + exit 1 + " 1 2 13 15 + numtries=100 + i=$numtries + while test $i -gt 0; do + # mkdir is a portable test-and-set. + if mkdir "$lockdir" 2>/dev/null; then + # This process acquired the lock. + "$@" -MD + stat=$? + # Release the lock. + rmdir "$lockdir" + break + else + # If the lock is being held by a different process, wait + # until the winning process is done or we timeout. + while test -d "$lockdir" && test $i -gt 0; do + sleep 1 + i=`expr $i - 1` + done + fi + i=`expr $i - 1` + done + trap - 1 2 13 15 + if test $i -le 0; then + echo "$0: failed to acquire lock after $numtries attempts" >&2 + echo "$0: check lockdir '$lockdir'" >&2 + exit 1 + fi + + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each line is of the form `foo.o: dependent.h', + # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process this invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ + | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp2) + # The "hp" stanza above does not work with aCC (C++) and HP's ia64 + # compilers, which have integrated preprocessors. The correct option + # to use with these is +Maked; it writes dependencies to a file named + # 'foo.d', which lands next to the object file, wherever that + # happens to be. + # Much of this is similar to the tru64 case; see comments there. + set_dir_from "$object" + set_base_from "$object" + if test "$libtool" = yes; then + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir.libs/$base.d + "$@" -Wc,+Maked + else + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir$base.d + "$@" +Maked + fi + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile1" "$tmpdepfile2" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" + # Add 'dependent.h:' lines. + sed -ne '2,${ + s/^ *// + s/ \\*$// + s/$/:/ + p + }' "$tmpdepfile" >> "$depfile" + else + make_dummy_depfile + fi + rm -f "$tmpdepfile" "$tmpdepfile2" + ;; + +tru64) + # The Tru64 compiler uses -MD to generate dependencies as a side + # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. + # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put + # dependencies in 'foo.d' instead, so we check for that too. + # Subdirectories are respected. + set_dir_from "$object" + set_base_from "$object" + + if test "$libtool" = yes; then + # Libtool generates 2 separate objects for the 2 libraries. These + # two compilations output dependencies in $dir.libs/$base.o.d and + # in $dir$base.o.d. We have to check for both files, because + # one of the two compilations can be disabled. We should prefer + # $dir$base.o.d over $dir.libs/$base.o.d because the latter is + # automatically cleaned when .libs/ is deleted, while ignoring + # the former would cause a distcleancheck panic. + tmpdepfile1=$dir$base.o.d # libtool 1.5 + tmpdepfile2=$dir.libs/$base.o.d # Likewise. + tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 + "$@" -Wc,-MD + else + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir$base.d + tmpdepfile3=$dir$base.d + "$@" -MD + fi + + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + do + test -f "$tmpdepfile" && break + done + # Same post-processing that is required for AIX mode. + aix_post_process_depfile + ;; + +msvc7) + if test "$libtool" = yes; then + showIncludes=-Wc,-showIncludes + else + showIncludes=-showIncludes + fi + "$@" $showIncludes > "$tmpdepfile" + stat=$? + grep -v '^Note: including file: ' "$tmpdepfile" + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + # The first sed program below extracts the file names and escapes + # backslashes for cygpath. The second sed program outputs the file + # name when reading, but also accumulates all include files in the + # hold buffer in order to output them again at the end. This only + # works with sed implementations that can handle large buffers. + sed < "$tmpdepfile" -n ' +/^Note: including file: *\(.*\)/ { + s//\1/ + s/\\/\\\\/g + p +}' | $cygpath_u | sort -u | sed -n ' +s/ /\\ /g +s/\(.*\)/'"$tab"'\1 \\/p +s/.\(.*\) \\/\1:/ +H +$ { + s/.*/'"$tab"'/ + G + p +}' >> "$depfile" + echo >> "$depfile" # make sure the fragment doesn't end with a backslash + rm -f "$tmpdepfile" + ;; + +msvc7msys) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +#nosideeffect) + # This comment above is used by automake to tell side-effect + # dependency tracking mechanisms from slower ones. + +dashmstdout) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + + # Remove '-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + test -z "$dashmflag" && dashmflag=-M + # Require at least two characters before searching for ':' + # in the target name. This is to cope with DOS-style filenames: + # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. + "$@" $dashmflag | + sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process this sed invocation + # correctly. Breaking it into two sed invocations is a workaround. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ + | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +dashXmstdout) + # This case only exists to satisfy depend.m4. It is never actually + # run, as this mode is specially recognized in the preamble. + exit 1 + ;; + +makedepend) + "$@" || exit $? + # Remove any Libtool call + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + # X makedepend + shift + cleared=no eat=no + for arg + do + case $cleared in + no) + set ""; shift + cleared=yes ;; + esac + if test $eat = yes; then + eat=no + continue + fi + case "$arg" in + -D*|-I*) + set fnord "$@" "$arg"; shift ;; + # Strip any option that makedepend may not understand. Remove + # the object too, otherwise makedepend will parse it as a source file. + -arch) + eat=yes ;; + -*|$object) + ;; + *) + set fnord "$@" "$arg"; shift ;; + esac + done + obj_suffix=`echo "$object" | sed 's/^.*\././'` + touch "$tmpdepfile" + ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" + rm -f "$depfile" + # makedepend may prepend the VPATH from the source file name to the object. + # No need to regex-escape $object, excess matching of '.' is harmless. + sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process the last invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed '1,2d' "$tmpdepfile" \ + | tr ' ' "$nl" \ + | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ + | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" "$tmpdepfile".bak + ;; + +cpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + + # Remove '-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + "$@" -E \ + | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ + -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ + | sed '$ s: \\$::' > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + cat < "$tmpdepfile" >> "$depfile" + sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvisualcpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + + IFS=" " + for arg + do + case "$arg" in + -o) + shift + ;; + $object) + shift + ;; + "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") + set fnord "$@" + shift + shift + ;; + *) + set fnord "$@" "$arg" + shift + shift + ;; + esac + done + "$@" -E 2>/dev/null | + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" + echo "$tab" >> "$depfile" + sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvcmsys) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +none) + exec "$@" + ;; + +*) + echo "Unknown depmode $depmode" 1>&2 + exit 1 + ;; +esac + +exit 0 + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC0" +# time-stamp-end: "; # UTC" +# End: diff --git a/build-aux/install-sh b/build-aux/install-sh new file mode 100755 index 0000000..8175c64 --- /dev/null +++ b/build-aux/install-sh @@ -0,0 +1,518 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2018-03-11.20; # UTC + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# 'make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. + +tab=' ' +nl=' +' +IFS=" $tab$nl" + +# Set DOITPROG to "echo" to test this script. + +doit=${DOITPROG-} +doit_exec=${doit:-exec} + +# Put in absolute file names if you don't have them in your path; +# or use environment vars. + +chgrpprog=${CHGRPPROG-chgrp} +chmodprog=${CHMODPROG-chmod} +chownprog=${CHOWNPROG-chown} +cmpprog=${CMPPROG-cmp} +cpprog=${CPPROG-cp} +mkdirprog=${MKDIRPROG-mkdir} +mvprog=${MVPROG-mv} +rmprog=${RMPROG-rm} +stripprog=${STRIPPROG-strip} + +posix_mkdir= + +# Desired mode of installed file. +mode=0755 + +chgrpcmd= +chmodcmd=$chmodprog +chowncmd= +mvcmd=$mvprog +rmcmd="$rmprog -f" +stripcmd= + +src= +dst= +dir_arg= +dst_arg= + +copy_on_change=false +is_target_a_directory=possibly + +usage="\ +Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... + +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. + +Options: + --help display this help and exit. + --version display version info and exit. + + -c (ignored) + -C install only if different (preserve the last data modification time) + -d create directories instead of installing files. + -g GROUP $chgrpprog installed files to GROUP. + -m MODE $chmodprog installed files to MODE. + -o USER $chownprog installed files to USER. + -s $stripprog installed files. + -t DIRECTORY install into DIRECTORY. + -T report an error if DSTFILE is a directory. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG + RMPROG STRIPPROG +" + +while test $# -ne 0; do + case $1 in + -c) ;; + + -C) copy_on_change=true;; + + -d) dir_arg=true;; + + -g) chgrpcmd="$chgrpprog $2" + shift;; + + --help) echo "$usage"; exit $?;; + + -m) mode=$2 + case $mode in + *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; + + -o) chowncmd="$chownprog $2" + shift;; + + -s) stripcmd=$stripprog;; + + -t) + is_target_a_directory=always + dst_arg=$2 + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + shift;; + + -T) is_target_a_directory=never;; + + --version) echo "$0 $scriptversion"; exit $?;; + + --) shift + break;; + + -*) echo "$0: invalid option: $1" >&2 + exit 1;; + + *) break;; + esac + shift +done + +# We allow the use of options -d and -T together, by making -d +# take the precedence; this is for compatibility with GNU install. + +if test -n "$dir_arg"; then + if test -n "$dst_arg"; then + echo "$0: target directory not allowed when installing a directory." >&2 + exit 1 + fi +fi + +if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then + # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dst_arg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dst_arg" + shift # fnord + fi + shift # arg + dst_arg=$arg + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + done +fi + +if test $# -eq 0; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call 'install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +if test -z "$dir_arg"; then + if test $# -gt 1 || test "$is_target_a_directory" = always; then + if test ! -d "$dst_arg"; then + echo "$0: $dst_arg: Is not a directory." >&2 + exit 1 + fi + fi +fi + +if test -z "$dir_arg"; then + do_exit='(exit $ret); exit $ret' + trap "ret=129; $do_exit" 1 + trap "ret=130; $do_exit" 2 + trap "ret=141; $do_exit" 13 + trap "ret=143; $do_exit" 15 + + # Set umask so as not to create temps with too-generous modes. + # However, 'strip' requires both read and write access to temps. + case $mode in + # Optimize common cases. + *644) cp_umask=133;; + *755) cp_umask=22;; + + *[0-7]) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw='% 200' + fi + cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; + *) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw=,u+rw + fi + cp_umask=$mode$u_plus_rw;; + esac +fi + +for src +do + # Protect names problematic for 'test' and other utilities. + case $src in + -* | [=\(\)!]) src=./$src;; + esac + + if test -n "$dir_arg"; then + dst=$src + dstdir=$dst + test -d "$dstdir" + dstdir_status=$? + else + + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dst_arg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + dst=$dst_arg + + # If destination is a directory, append the input filename. + if test -d "$dst"; then + if test "$is_target_a_directory" = never; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 + fi + dstdir=$dst + dstbase=`basename "$src"` + case $dst in + */) dst=$dst$dstbase;; + *) dst=$dst/$dstbase;; + esac + dstdir_status=0 + else + dstdir=`dirname "$dst"` + test -d "$dstdir" + dstdir_status=$? + fi + fi + + case $dstdir in + */) dstdirslash=$dstdir;; + *) dstdirslash=$dstdir/;; + esac + + obsolete_mkdir_used=false + + if test $dstdir_status != 0; then + case $posix_mkdir in + '') + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac + + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + # Note that $RANDOM variable is not portable (e.g. dash); Use it + # here however when possible just to lower collision chance. + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + + trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0 + + # Because "mkdir -p" follows existing symlinks and we likely work + # directly in world-writeable /tmp, make sure that the '$tmpdir' + # directory is successfully created first before we actually test + # 'mkdir -p' feature. + if (umask $mkdir_umask && + $mkdirprog $mkdir_mode "$tmpdir" && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + test_tmpdir="$tmpdir/a" + ls_ld_tmpdir=`ls -ld "$test_tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null + fi + trap '' 0;; + esac;; + esac + + if + $posix_mkdir && ( + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + ) + then : + else + + # The umask is ridiculous, or mkdir does not conform to POSIX, + # or it failed possibly due to a race condition. Create the + # directory the slow way, step by step, checking for races as we go. + + case $dstdir in + /*) prefix='/';; + [-=\(\)!]*) prefix='./';; + *) prefix='';; + esac + + oIFS=$IFS + IFS=/ + set -f + set fnord $dstdir + shift + set +f + IFS=$oIFS + + prefixes= + + for d + do + test X"$d" = X && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ + done + + if test -n "$prefixes"; then + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true + fi + fi + fi + + if test -n "$dir_arg"; then + { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && + { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || + test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 + else + + # Make a couple of temp file names in the proper directory. + dsttmp=${dstdirslash}_inst.$$_ + rmtmp=${dstdirslash}_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + + # Copy the file name to the temp name. + (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && + { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && + { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && + + # If -C, don't bother to copy if it wouldn't change the file. + if $copy_on_change && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + set -f && + set X $old && old=:$2:$4:$5:$6 && + set X $new && new=:$2:$4:$5:$6 && + set +f && + test "$old" = "$new" && + $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 + then + rm -f "$dsttmp" + else + # Rename the file to the real destination. + $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || + + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + { + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" + } + fi || exit 1 + + trap '' 0 + fi +done + +# Local variables: +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC0" +# time-stamp-end: "; # UTC" +# End: diff --git a/build-aux/ltmain.sh b/build-aux/ltmain.sh new file mode 100644 index 0000000..1d0185a --- /dev/null +++ b/build-aux/ltmain.sh @@ -0,0 +1,11149 @@ +#! /bin/sh +## DO NOT EDIT - This file generated from ./build-aux/ltmain.in +## by inline-source v2014-01-03.01 + +# libtool (GNU libtool) 2.4.6 +# Provide generalized library-building support services. +# Written by Gordon Matzigkeit , 1996 + +# Copyright (C) 1996-2015 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# GNU Libtool 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. +# +# As a special exception to the GNU General Public License, +# if you distribute this file as part of a program or library that +# is built using GNU Libtool, you may include this file under the +# same distribution terms that you use for the rest of that program. +# +# GNU Libtool 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, see . + + +PROGRAM=libtool +PACKAGE=libtool +VERSION=2.4.6 +package_revision=2.4.6 + + +## ------ ## +## Usage. ## +## ------ ## + +# Run './libtool --help' for help with using this script from the +# command line. + + +## ------------------------------- ## +## User overridable command paths. ## +## ------------------------------- ## + +# After configure completes, it has a better idea of some of the +# shell tools we need than the defaults used by the functions shared +# with bootstrap, so set those here where they can still be over- +# ridden by the user, but otherwise take precedence. + +: ${AUTOCONF="autoconf"} +: ${AUTOMAKE="automake"} + + +## -------------------------- ## +## Source external libraries. ## +## -------------------------- ## + +# Much of our low-level functionality needs to be sourced from external +# libraries, which are installed to $pkgauxdir. + +# Set a version string for this script. +scriptversion=2015-01-20.17; # UTC + +# General shell script boiler plate, and helper functions. +# Written by Gary V. Vaughan, 2004 + +# Copyright (C) 2004-2015 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# 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 3 of the License, or +# (at your option) any later version. + +# As a special exception to the GNU General Public License, if you distribute +# this file as part of a program or library that is built using GNU Libtool, +# you may include this file under the same distribution terms that you use +# for the rest of that program. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNES 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, see . + +# Please report bugs or propose patches to gary@gnu.org. + + +## ------ ## +## Usage. ## +## ------ ## + +# Evaluate this file near the top of your script to gain access to +# the functions and variables defined here: +# +# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh +# +# If you need to override any of the default environment variable +# settings, do that before evaluating this file. + + +## -------------------- ## +## Shell normalisation. ## +## -------------------- ## + +# Some shells need a little help to be as Bourne compatible as possible. +# Before doing anything else, make sure all that help has been provided! + +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac +fi + +# NLS nuisances: We save the old values in case they are required later. +_G_user_locale= +_G_safe_locale= +for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES +do + eval "if test set = \"\${$_G_var+set}\"; then + save_$_G_var=\$$_G_var + $_G_var=C + export $_G_var + _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" + _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" + fi" +done + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +# Make sure IFS has a sensible default +sp=' ' +nl=' +' +IFS="$sp $nl" + +# There are apparently some retarded systems that use ';' as a PATH separator! +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + + +## ------------------------- ## +## Locate command utilities. ## +## ------------------------- ## + + +# func_executable_p FILE +# ---------------------- +# Check that FILE is an executable regular file. +func_executable_p () +{ + test -f "$1" && test -x "$1" +} + + +# func_path_progs PROGS_LIST CHECK_FUNC [PATH] +# -------------------------------------------- +# Search for either a program that responds to --version with output +# containing "GNU", or else returned by CHECK_FUNC otherwise, by +# trying all the directories in PATH with each of the elements of +# PROGS_LIST. +# +# CHECK_FUNC should accept the path to a candidate program, and +# set $func_check_prog_result if it truncates its output less than +# $_G_path_prog_max characters. +func_path_progs () +{ + _G_progs_list=$1 + _G_check_func=$2 + _G_PATH=${3-"$PATH"} + + _G_path_prog_max=0 + _G_path_prog_found=false + _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} + for _G_dir in $_G_PATH; do + IFS=$_G_save_IFS + test -z "$_G_dir" && _G_dir=. + for _G_prog_name in $_G_progs_list; do + for _exeext in '' .EXE; do + _G_path_prog=$_G_dir/$_G_prog_name$_exeext + func_executable_p "$_G_path_prog" || continue + case `"$_G_path_prog" --version 2>&1` in + *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; + *) $_G_check_func $_G_path_prog + func_path_progs_result=$func_check_prog_result + ;; + esac + $_G_path_prog_found && break 3 + done + done + done + IFS=$_G_save_IFS + test -z "$func_path_progs_result" && { + echo "no acceptable sed could be found in \$PATH" >&2 + exit 1 + } +} + + +# We want to be able to use the functions in this file before configure +# has figured out where the best binaries are kept, which means we have +# to search for them ourselves - except when the results are already set +# where we skip the searches. + +# Unless the user overrides by setting SED, search the path for either GNU +# sed, or the sed that truncates its output the least. +test -z "$SED" && { + _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ + for _G_i in 1 2 3 4 5 6 7; do + _G_sed_script=$_G_sed_script$nl$_G_sed_script + done + echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed + _G_sed_script= + + func_check_prog_sed () + { + _G_path_prog=$1 + + _G_count=0 + printf 0123456789 >conftest.in + while : + do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo '' >> conftest.nl + "$_G_path_prog" -f conftest.sed conftest.out 2>/dev/null || break + diff conftest.out conftest.nl >/dev/null 2>&1 || break + _G_count=`expr $_G_count + 1` + if test "$_G_count" -gt "$_G_path_prog_max"; then + # Best one so far, save it but keep looking for a better one + func_check_prog_result=$_G_path_prog + _G_path_prog_max=$_G_count + fi + # 10*(2^10) chars as input seems more than enough + test 10 -lt "$_G_count" && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out + } + + func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin + rm -f conftest.sed + SED=$func_path_progs_result +} + + +# Unless the user overrides by setting GREP, search the path for either GNU +# grep, or the grep that truncates its output the least. +test -z "$GREP" && { + func_check_prog_grep () + { + _G_path_prog=$1 + + _G_count=0 + _G_path_prog_max=0 + printf 0123456789 >conftest.in + while : + do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo 'GREP' >> conftest.nl + "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' conftest.out 2>/dev/null || break + diff conftest.out conftest.nl >/dev/null 2>&1 || break + _G_count=`expr $_G_count + 1` + if test "$_G_count" -gt "$_G_path_prog_max"; then + # Best one so far, save it but keep looking for a better one + func_check_prog_result=$_G_path_prog + _G_path_prog_max=$_G_count + fi + # 10*(2^10) chars as input seems more than enough + test 10 -lt "$_G_count" && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out + } + + func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin + GREP=$func_path_progs_result +} + + +## ------------------------------- ## +## User overridable command paths. ## +## ------------------------------- ## + +# All uppercase variable names are used for environment variables. These +# variables can be overridden by the user before calling a script that +# uses them if a suitable command of that name is not already available +# in the command search PATH. + +: ${CP="cp -f"} +: ${ECHO="printf %s\n"} +: ${EGREP="$GREP -E"} +: ${FGREP="$GREP -F"} +: ${LN_S="ln -s"} +: ${MAKE="make"} +: ${MKDIR="mkdir"} +: ${MV="mv -f"} +: ${RM="rm -f"} +: ${SHELL="${CONFIG_SHELL-/bin/sh}"} + + +## -------------------- ## +## Useful sed snippets. ## +## -------------------- ## + +sed_dirname='s|/[^/]*$||' +sed_basename='s|^.*/||' + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +sed_quote_subst='s|\([`"$\\]\)|\\\1|g' + +# Same as above, but do not quote variable references. +sed_double_quote_subst='s/\(["`\\]\)/\\\1/g' + +# Sed substitution that turns a string into a regex matching for the +# string literally. +sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' + +# Sed substitution that converts a w32 file name or path +# that contains forward slashes, into one that contains +# (escaped) backslashes. A very naive implementation. +sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' + +# Re-'\' parameter expansions in output of sed_double_quote_subst that +# were '\'-ed in input to the same. If an odd number of '\' preceded a +# '$' in input to sed_double_quote_subst, that '$' was protected from +# expansion. Since each input '\' is now two '\'s, look for any number +# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. +_G_bs='\\' +_G_bs2='\\\\' +_G_bs4='\\\\\\\\' +_G_dollar='\$' +sed_double_backslash="\ + s/$_G_bs4/&\\ +/g + s/^$_G_bs2$_G_dollar/$_G_bs&/ + s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g + s/\n//g" + + +## ----------------- ## +## Global variables. ## +## ----------------- ## + +# Except for the global variables explicitly listed below, the following +# functions in the '^func_' namespace, and the '^require_' namespace +# variables initialised in the 'Resource management' section, sourcing +# this file will not pollute your global namespace with anything +# else. There's no portable way to scope variables in Bourne shell +# though, so actually running these functions will sometimes place +# results into a variable named after the function, and often use +# temporary variables in the '^_G_' namespace. If you are careful to +# avoid using those namespaces casually in your sourcing script, things +# should continue to work as you expect. And, of course, you can freely +# overwrite any of the functions or variables defined here before +# calling anything to customize them. + +EXIT_SUCCESS=0 +EXIT_FAILURE=1 +EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. +EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. + +# Allow overriding, eg assuming that you follow the convention of +# putting '$debug_cmd' at the start of all your functions, you can get +# bash to show function call trace with: +# +# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name +debug_cmd=${debug_cmd-":"} +exit_cmd=: + +# By convention, finish your script with: +# +# exit $exit_status +# +# so that you can set exit_status to non-zero if you want to indicate +# something went wrong during execution without actually bailing out at +# the point of failure. +exit_status=$EXIT_SUCCESS + +# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh +# is ksh but when the shell is invoked as "sh" and the current value of +# the _XPG environment variable is not equal to 1 (one), the special +# positional parameter $0, within a function call, is the name of the +# function. +progpath=$0 + +# The name of this program. +progname=`$ECHO "$progpath" |$SED "$sed_basename"` + +# Make sure we have an absolute progpath for reexecution: +case $progpath in + [\\/]*|[A-Za-z]:\\*) ;; + *[\\/]*) + progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` + progdir=`cd "$progdir" && pwd` + progpath=$progdir/$progname + ;; + *) + _G_IFS=$IFS + IFS=${PATH_SEPARATOR-:} + for progdir in $PATH; do + IFS=$_G_IFS + test -x "$progdir/$progname" && break + done + IFS=$_G_IFS + test -n "$progdir" || progdir=`pwd` + progpath=$progdir/$progname + ;; +esac + + +## ----------------- ## +## Standard options. ## +## ----------------- ## + +# The following options affect the operation of the functions defined +# below, and should be set appropriately depending on run-time para- +# meters passed on the command line. + +opt_dry_run=false +opt_quiet=false +opt_verbose=false + +# Categories 'all' and 'none' are always available. Append any others +# you will pass as the first argument to func_warning from your own +# code. +warning_categories= + +# By default, display warnings according to 'opt_warning_types'. Set +# 'warning_func' to ':' to elide all warnings, or func_fatal_error to +# treat the next displayed warning as a fatal error. +warning_func=func_warn_and_continue + +# Set to 'all' to display all warnings, 'none' to suppress all +# warnings, or a space delimited list of some subset of +# 'warning_categories' to display only the listed warnings. +opt_warning_types=all + + +## -------------------- ## +## Resource management. ## +## -------------------- ## + +# This section contains definitions for functions that each ensure a +# particular resource (a file, or a non-empty configuration variable for +# example) is available, and if appropriate to extract default values +# from pertinent package files. Call them using their associated +# 'require_*' variable to ensure that they are executed, at most, once. +# +# It's entirely deliberate that calling these functions can set +# variables that don't obey the namespace limitations obeyed by the rest +# of this file, in order that that they be as useful as possible to +# callers. + + +# require_term_colors +# ------------------- +# Allow display of bold text on terminals that support it. +require_term_colors=func_require_term_colors +func_require_term_colors () +{ + $debug_cmd + + test -t 1 && { + # COLORTERM and USE_ANSI_COLORS environment variables take + # precedence, because most terminfo databases neglect to describe + # whether color sequences are supported. + test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} + + if test 1 = "$USE_ANSI_COLORS"; then + # Standard ANSI escape sequences + tc_reset='' + tc_bold=''; tc_standout='' + tc_red=''; tc_green='' + tc_blue=''; tc_cyan='' + else + # Otherwise trust the terminfo database after all. + test -n "`tput sgr0 2>/dev/null`" && { + tc_reset=`tput sgr0` + test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` + tc_standout=$tc_bold + test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` + test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` + test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` + test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` + test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` + } + fi + } + + require_term_colors=: +} + + +## ----------------- ## +## Function library. ## +## ----------------- ## + +# This section contains a variety of useful functions to call in your +# scripts. Take note of the portable wrappers for features provided by +# some modern shells, which will fall back to slower equivalents on +# less featureful shells. + + +# func_append VAR VALUE +# --------------------- +# Append VALUE onto the existing contents of VAR. + + # We should try to minimise forks, especially on Windows where they are + # unreasonably slow, so skip the feature probes when bash or zsh are + # being used: + if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then + : ${_G_HAVE_ARITH_OP="yes"} + : ${_G_HAVE_XSI_OPS="yes"} + # The += operator was introduced in bash 3.1 + case $BASH_VERSION in + [12].* | 3.0 | 3.0*) ;; + *) + : ${_G_HAVE_PLUSEQ_OP="yes"} + ;; + esac + fi + + # _G_HAVE_PLUSEQ_OP + # Can be empty, in which case the shell is probed, "yes" if += is + # useable or anything else if it does not work. + test -z "$_G_HAVE_PLUSEQ_OP" \ + && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ + && _G_HAVE_PLUSEQ_OP=yes + +if test yes = "$_G_HAVE_PLUSEQ_OP" +then + # This is an XSI compatible shell, allowing a faster implementation... + eval 'func_append () + { + $debug_cmd + + eval "$1+=\$2" + }' +else + # ...otherwise fall back to using expr, which is often a shell builtin. + func_append () + { + $debug_cmd + + eval "$1=\$$1\$2" + } +fi + + +# func_append_quoted VAR VALUE +# ---------------------------- +# Quote VALUE and append to the end of shell variable VAR, separated +# by a space. +if test yes = "$_G_HAVE_PLUSEQ_OP"; then + eval 'func_append_quoted () + { + $debug_cmd + + func_quote_for_eval "$2" + eval "$1+=\\ \$func_quote_for_eval_result" + }' +else + func_append_quoted () + { + $debug_cmd + + func_quote_for_eval "$2" + eval "$1=\$$1\\ \$func_quote_for_eval_result" + } +fi + + +# func_append_uniq VAR VALUE +# -------------------------- +# Append unique VALUE onto the existing contents of VAR, assuming +# entries are delimited by the first character of VALUE. For example: +# +# func_append_uniq options " --another-option option-argument" +# +# will only append to $options if " --another-option option-argument " +# is not already present somewhere in $options already (note spaces at +# each end implied by leading space in second argument). +func_append_uniq () +{ + $debug_cmd + + eval _G_current_value='`$ECHO $'$1'`' + _G_delim=`expr "$2" : '\(.\)'` + + case $_G_delim$_G_current_value$_G_delim in + *"$2$_G_delim"*) ;; + *) func_append "$@" ;; + esac +} + + +# func_arith TERM... +# ------------------ +# Set func_arith_result to the result of evaluating TERMs. + test -z "$_G_HAVE_ARITH_OP" \ + && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ + && _G_HAVE_ARITH_OP=yes + +if test yes = "$_G_HAVE_ARITH_OP"; then + eval 'func_arith () + { + $debug_cmd + + func_arith_result=$(( $* )) + }' +else + func_arith () + { + $debug_cmd + + func_arith_result=`expr "$@"` + } +fi + + +# func_basename FILE +# ------------------ +# Set func_basename_result to FILE with everything up to and including +# the last / stripped. +if test yes = "$_G_HAVE_XSI_OPS"; then + # If this shell supports suffix pattern removal, then use it to avoid + # forking. Hide the definitions single quotes in case the shell chokes + # on unsupported syntax... + _b='func_basename_result=${1##*/}' + _d='case $1 in + */*) func_dirname_result=${1%/*}$2 ;; + * ) func_dirname_result=$3 ;; + esac' + +else + # ...otherwise fall back to using sed. + _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' + _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` + if test "X$func_dirname_result" = "X$1"; then + func_dirname_result=$3 + else + func_append func_dirname_result "$2" + fi' +fi + +eval 'func_basename () +{ + $debug_cmd + + '"$_b"' +}' + + +# func_dirname FILE APPEND NONDIR_REPLACEMENT +# ------------------------------------------- +# Compute the dirname of FILE. If nonempty, add APPEND to the result, +# otherwise set result to NONDIR_REPLACEMENT. +eval 'func_dirname () +{ + $debug_cmd + + '"$_d"' +}' + + +# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT +# -------------------------------------------------------- +# Perform func_basename and func_dirname in a single function +# call: +# dirname: Compute the dirname of FILE. If nonempty, +# add APPEND to the result, otherwise set result +# to NONDIR_REPLACEMENT. +# value returned in "$func_dirname_result" +# basename: Compute filename of FILE. +# value retuned in "$func_basename_result" +# For efficiency, we do not delegate to the functions above but instead +# duplicate the functionality here. +eval 'func_dirname_and_basename () +{ + $debug_cmd + + '"$_b"' + '"$_d"' +}' + + +# func_echo ARG... +# ---------------- +# Echo program name prefixed message. +func_echo () +{ + $debug_cmd + + _G_message=$* + + func_echo_IFS=$IFS + IFS=$nl + for _G_line in $_G_message; do + IFS=$func_echo_IFS + $ECHO "$progname: $_G_line" + done + IFS=$func_echo_IFS +} + + +# func_echo_all ARG... +# -------------------- +# Invoke $ECHO with all args, space-separated. +func_echo_all () +{ + $ECHO "$*" +} + + +# func_echo_infix_1 INFIX ARG... +# ------------------------------ +# Echo program name, followed by INFIX on the first line, with any +# additional lines not showing INFIX. +func_echo_infix_1 () +{ + $debug_cmd + + $require_term_colors + + _G_infix=$1; shift + _G_indent=$_G_infix + _G_prefix="$progname: $_G_infix: " + _G_message=$* + + # Strip color escape sequences before counting printable length + for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" + do + test -n "$_G_tc" && { + _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` + _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` + } + done + _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes + + func_echo_infix_1_IFS=$IFS + IFS=$nl + for _G_line in $_G_message; do + IFS=$func_echo_infix_1_IFS + $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 + _G_prefix=$_G_indent + done + IFS=$func_echo_infix_1_IFS +} + + +# func_error ARG... +# ----------------- +# Echo program name prefixed message to standard error. +func_error () +{ + $debug_cmd + + $require_term_colors + + func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 +} + + +# func_fatal_error ARG... +# ----------------------- +# Echo program name prefixed message to standard error, and exit. +func_fatal_error () +{ + $debug_cmd + + func_error "$*" + exit $EXIT_FAILURE +} + + +# func_grep EXPRESSION FILENAME +# ----------------------------- +# Check whether EXPRESSION matches any line of FILENAME, without output. +func_grep () +{ + $debug_cmd + + $GREP "$1" "$2" >/dev/null 2>&1 +} + + +# func_len STRING +# --------------- +# Set func_len_result to the length of STRING. STRING may not +# start with a hyphen. + test -z "$_G_HAVE_XSI_OPS" \ + && (eval 'x=a/b/c; + test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ + && _G_HAVE_XSI_OPS=yes + +if test yes = "$_G_HAVE_XSI_OPS"; then + eval 'func_len () + { + $debug_cmd + + func_len_result=${#1} + }' +else + func_len () + { + $debug_cmd + + func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` + } +fi + + +# func_mkdir_p DIRECTORY-PATH +# --------------------------- +# Make sure the entire path to DIRECTORY-PATH is available. +func_mkdir_p () +{ + $debug_cmd + + _G_directory_path=$1 + _G_dir_list= + + if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then + + # Protect directory names starting with '-' + case $_G_directory_path in + -*) _G_directory_path=./$_G_directory_path ;; + esac + + # While some portion of DIR does not yet exist... + while test ! -d "$_G_directory_path"; do + # ...make a list in topmost first order. Use a colon delimited + # list incase some portion of path contains whitespace. + _G_dir_list=$_G_directory_path:$_G_dir_list + + # If the last portion added has no slash in it, the list is done + case $_G_directory_path in */*) ;; *) break ;; esac + + # ...otherwise throw away the child directory and loop + _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` + done + _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` + + func_mkdir_p_IFS=$IFS; IFS=: + for _G_dir in $_G_dir_list; do + IFS=$func_mkdir_p_IFS + # mkdir can fail with a 'File exist' error if two processes + # try to create one of the directories concurrently. Don't + # stop in that case! + $MKDIR "$_G_dir" 2>/dev/null || : + done + IFS=$func_mkdir_p_IFS + + # Bail out if we (or some other process) failed to create a directory. + test -d "$_G_directory_path" || \ + func_fatal_error "Failed to create '$1'" + fi +} + + +# func_mktempdir [BASENAME] +# ------------------------- +# Make a temporary directory that won't clash with other running +# libtool processes, and avoids race conditions if possible. If +# given, BASENAME is the basename for that directory. +func_mktempdir () +{ + $debug_cmd + + _G_template=${TMPDIR-/tmp}/${1-$progname} + + if test : = "$opt_dry_run"; then + # Return a directory name, but don't create it in dry-run mode + _G_tmpdir=$_G_template-$$ + else + + # If mktemp works, use that first and foremost + _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` + + if test ! -d "$_G_tmpdir"; then + # Failing that, at least try and use $RANDOM to avoid a race + _G_tmpdir=$_G_template-${RANDOM-0}$$ + + func_mktempdir_umask=`umask` + umask 0077 + $MKDIR "$_G_tmpdir" + umask $func_mktempdir_umask + fi + + # If we're not in dry-run mode, bomb out on failure + test -d "$_G_tmpdir" || \ + func_fatal_error "cannot create temporary directory '$_G_tmpdir'" + fi + + $ECHO "$_G_tmpdir" +} + + +# func_normal_abspath PATH +# ------------------------ +# Remove doubled-up and trailing slashes, "." path components, +# and cancel out any ".." path components in PATH after making +# it an absolute path. +func_normal_abspath () +{ + $debug_cmd + + # These SED scripts presuppose an absolute path with a trailing slash. + _G_pathcar='s|^/\([^/]*\).*$|\1|' + _G_pathcdr='s|^/[^/]*||' + _G_removedotparts=':dotsl + s|/\./|/|g + t dotsl + s|/\.$|/|' + _G_collapseslashes='s|/\{1,\}|/|g' + _G_finalslash='s|/*$|/|' + + # Start from root dir and reassemble the path. + func_normal_abspath_result= + func_normal_abspath_tpath=$1 + func_normal_abspath_altnamespace= + case $func_normal_abspath_tpath in + "") + # Empty path, that just means $cwd. + func_stripname '' '/' "`pwd`" + func_normal_abspath_result=$func_stripname_result + return + ;; + # The next three entries are used to spot a run of precisely + # two leading slashes without using negated character classes; + # we take advantage of case's first-match behaviour. + ///*) + # Unusual form of absolute path, do nothing. + ;; + //*) + # Not necessarily an ordinary path; POSIX reserves leading '//' + # and for example Cygwin uses it to access remote file shares + # over CIFS/SMB, so we conserve a leading double slash if found. + func_normal_abspath_altnamespace=/ + ;; + /*) + # Absolute path, do nothing. + ;; + *) + # Relative path, prepend $cwd. + func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath + ;; + esac + + # Cancel out all the simple stuff to save iterations. We also want + # the path to end with a slash for ease of parsing, so make sure + # there is one (and only one) here. + func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ + -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` + while :; do + # Processed it all yet? + if test / = "$func_normal_abspath_tpath"; then + # If we ascended to the root using ".." the result may be empty now. + if test -z "$func_normal_abspath_result"; then + func_normal_abspath_result=/ + fi + break + fi + func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ + -e "$_G_pathcar"` + func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ + -e "$_G_pathcdr"` + # Figure out what to do with it + case $func_normal_abspath_tcomponent in + "") + # Trailing empty path component, ignore it. + ;; + ..) + # Parent dir; strip last assembled component from result. + func_dirname "$func_normal_abspath_result" + func_normal_abspath_result=$func_dirname_result + ;; + *) + # Actual path component, append it. + func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" + ;; + esac + done + # Restore leading double-slash if one was found on entry. + func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result +} + + +# func_notquiet ARG... +# -------------------- +# Echo program name prefixed message only when not in quiet mode. +func_notquiet () +{ + $debug_cmd + + $opt_quiet || func_echo ${1+"$@"} + + # A bug in bash halts the script if the last line of a function + # fails when set -e is in force, so we need another command to + # work around that: + : +} + + +# func_relative_path SRCDIR DSTDIR +# -------------------------------- +# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. +func_relative_path () +{ + $debug_cmd + + func_relative_path_result= + func_normal_abspath "$1" + func_relative_path_tlibdir=$func_normal_abspath_result + func_normal_abspath "$2" + func_relative_path_tbindir=$func_normal_abspath_result + + # Ascend the tree starting from libdir + while :; do + # check if we have found a prefix of bindir + case $func_relative_path_tbindir in + $func_relative_path_tlibdir) + # found an exact match + func_relative_path_tcancelled= + break + ;; + $func_relative_path_tlibdir*) + # found a matching prefix + func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" + func_relative_path_tcancelled=$func_stripname_result + if test -z "$func_relative_path_result"; then + func_relative_path_result=. + fi + break + ;; + *) + func_dirname $func_relative_path_tlibdir + func_relative_path_tlibdir=$func_dirname_result + if test -z "$func_relative_path_tlibdir"; then + # Have to descend all the way to the root! + func_relative_path_result=../$func_relative_path_result + func_relative_path_tcancelled=$func_relative_path_tbindir + break + fi + func_relative_path_result=../$func_relative_path_result + ;; + esac + done + + # Now calculate path; take care to avoid doubling-up slashes. + func_stripname '' '/' "$func_relative_path_result" + func_relative_path_result=$func_stripname_result + func_stripname '/' '/' "$func_relative_path_tcancelled" + if test -n "$func_stripname_result"; then + func_append func_relative_path_result "/$func_stripname_result" + fi + + # Normalisation. If bindir is libdir, return '.' else relative path. + if test -n "$func_relative_path_result"; then + func_stripname './' '' "$func_relative_path_result" + func_relative_path_result=$func_stripname_result + fi + + test -n "$func_relative_path_result" || func_relative_path_result=. + + : +} + + +# func_quote_for_eval ARG... +# -------------------------- +# Aesthetically quote ARGs to be evaled later. +# This function returns two values: +# i) func_quote_for_eval_result +# double-quoted, suitable for a subsequent eval +# ii) func_quote_for_eval_unquoted_result +# has all characters that are still active within double +# quotes backslashified. +func_quote_for_eval () +{ + $debug_cmd + + func_quote_for_eval_unquoted_result= + func_quote_for_eval_result= + while test 0 -lt $#; do + case $1 in + *[\\\`\"\$]*) + _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; + *) + _G_unquoted_arg=$1 ;; + esac + if test -n "$func_quote_for_eval_unquoted_result"; then + func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" + else + func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" + fi + + case $_G_unquoted_arg in + # Double-quote args containing shell metacharacters to delay + # word splitting, command substitution and variable expansion + # for a subsequent eval. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + _G_quoted_arg=\"$_G_unquoted_arg\" + ;; + *) + _G_quoted_arg=$_G_unquoted_arg + ;; + esac + + if test -n "$func_quote_for_eval_result"; then + func_append func_quote_for_eval_result " $_G_quoted_arg" + else + func_append func_quote_for_eval_result "$_G_quoted_arg" + fi + shift + done +} + + +# func_quote_for_expand ARG +# ------------------------- +# Aesthetically quote ARG to be evaled later; same as above, +# but do not quote variable references. +func_quote_for_expand () +{ + $debug_cmd + + case $1 in + *[\\\`\"]*) + _G_arg=`$ECHO "$1" | $SED \ + -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; + *) + _G_arg=$1 ;; + esac + + case $_G_arg in + # Double-quote args containing shell metacharacters to delay + # word splitting and command substitution for a subsequent eval. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + _G_arg=\"$_G_arg\" + ;; + esac + + func_quote_for_expand_result=$_G_arg +} + + +# func_stripname PREFIX SUFFIX NAME +# --------------------------------- +# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +if test yes = "$_G_HAVE_XSI_OPS"; then + eval 'func_stripname () + { + $debug_cmd + + # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are + # positional parameters, so assign one to ordinary variable first. + func_stripname_result=$3 + func_stripname_result=${func_stripname_result#"$1"} + func_stripname_result=${func_stripname_result%"$2"} + }' +else + func_stripname () + { + $debug_cmd + + case $2 in + .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; + *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; + esac + } +fi + + +# func_show_eval CMD [FAIL_EXP] +# ----------------------------- +# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is +# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP +# is given, then evaluate it. +func_show_eval () +{ + $debug_cmd + + _G_cmd=$1 + _G_fail_exp=${2-':'} + + func_quote_for_expand "$_G_cmd" + eval "func_notquiet $func_quote_for_expand_result" + + $opt_dry_run || { + eval "$_G_cmd" + _G_status=$? + if test 0 -ne "$_G_status"; then + eval "(exit $_G_status); $_G_fail_exp" + fi + } +} + + +# func_show_eval_locale CMD [FAIL_EXP] +# ------------------------------------ +# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is +# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP +# is given, then evaluate it. Use the saved locale for evaluation. +func_show_eval_locale () +{ + $debug_cmd + + _G_cmd=$1 + _G_fail_exp=${2-':'} + + $opt_quiet || { + func_quote_for_expand "$_G_cmd" + eval "func_echo $func_quote_for_expand_result" + } + + $opt_dry_run || { + eval "$_G_user_locale + $_G_cmd" + _G_status=$? + eval "$_G_safe_locale" + if test 0 -ne "$_G_status"; then + eval "(exit $_G_status); $_G_fail_exp" + fi + } +} + + +# func_tr_sh +# ---------- +# Turn $1 into a string suitable for a shell variable name. +# Result is stored in $func_tr_sh_result. All characters +# not in the set a-zA-Z0-9_ are replaced with '_'. Further, +# if $1 begins with a digit, a '_' is prepended as well. +func_tr_sh () +{ + $debug_cmd + + case $1 in + [0-9]* | *[!a-zA-Z0-9_]*) + func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` + ;; + * ) + func_tr_sh_result=$1 + ;; + esac +} + + +# func_verbose ARG... +# ------------------- +# Echo program name prefixed message in verbose mode only. +func_verbose () +{ + $debug_cmd + + $opt_verbose && func_echo "$*" + + : +} + + +# func_warn_and_continue ARG... +# ----------------------------- +# Echo program name prefixed warning message to standard error. +func_warn_and_continue () +{ + $debug_cmd + + $require_term_colors + + func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 +} + + +# func_warning CATEGORY ARG... +# ---------------------------- +# Echo program name prefixed warning message to standard error. Warning +# messages can be filtered according to CATEGORY, where this function +# elides messages where CATEGORY is not listed in the global variable +# 'opt_warning_types'. +func_warning () +{ + $debug_cmd + + # CATEGORY must be in the warning_categories list! + case " $warning_categories " in + *" $1 "*) ;; + *) func_internal_error "invalid warning category '$1'" ;; + esac + + _G_category=$1 + shift + + case " $opt_warning_types " in + *" $_G_category "*) $warning_func ${1+"$@"} ;; + esac +} + + +# func_sort_ver VER1 VER2 +# ----------------------- +# 'sort -V' is not generally available. +# Note this deviates from the version comparison in automake +# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a +# but this should suffice as we won't be specifying old +# version formats or redundant trailing .0 in bootstrap.conf. +# If we did want full compatibility then we should probably +# use m4_version_compare from autoconf. +func_sort_ver () +{ + $debug_cmd + + printf '%s\n%s\n' "$1" "$2" \ + | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n +} + +# func_lt_ver PREV CURR +# --------------------- +# Return true if PREV and CURR are in the correct order according to +# func_sort_ver, otherwise false. Use it like this: +# +# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." +func_lt_ver () +{ + $debug_cmd + + test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` +} + + +# Local variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" +# time-stamp-time-zone: "UTC" +# End: +#! /bin/sh + +# Set a version string for this script. +scriptversion=2014-01-07.03; # UTC + +# A portable, pluggable option parser for Bourne shell. +# Written by Gary V. Vaughan, 2010 + +# Copyright (C) 2010-2015 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# 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 3 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, see . + +# Please report bugs or propose patches to gary@gnu.org. + + +## ------ ## +## Usage. ## +## ------ ## + +# This file is a library for parsing options in your shell scripts along +# with assorted other useful supporting features that you can make use +# of too. +# +# For the simplest scripts you might need only: +# +# #!/bin/sh +# . relative/path/to/funclib.sh +# . relative/path/to/options-parser +# scriptversion=1.0 +# func_options ${1+"$@"} +# eval set dummy "$func_options_result"; shift +# ...rest of your script... +# +# In order for the '--version' option to work, you will need to have a +# suitably formatted comment like the one at the top of this file +# starting with '# Written by ' and ending with '# warranty; '. +# +# For '-h' and '--help' to work, you will also need a one line +# description of your script's purpose in a comment directly above the +# '# Written by ' line, like the one at the top of this file. +# +# The default options also support '--debug', which will turn on shell +# execution tracing (see the comment above debug_cmd below for another +# use), and '--verbose' and the func_verbose function to allow your script +# to display verbose messages only when your user has specified +# '--verbose'. +# +# After sourcing this file, you can plug processing for additional +# options by amending the variables from the 'Configuration' section +# below, and following the instructions in the 'Option parsing' +# section further down. + +## -------------- ## +## Configuration. ## +## -------------- ## + +# You should override these variables in your script after sourcing this +# file so that they reflect the customisations you have added to the +# option parser. + +# The usage line for option parsing errors and the start of '-h' and +# '--help' output messages. You can embed shell variables for delayed +# expansion at the time the message is displayed, but you will need to +# quote other shell meta-characters carefully to prevent them being +# expanded when the contents are evaled. +usage='$progpath [OPTION]...' + +# Short help message in response to '-h' and '--help'. Add to this or +# override it after sourcing this library to reflect the full set of +# options your script accepts. +usage_message="\ + --debug enable verbose shell tracing + -W, --warnings=CATEGORY + report the warnings falling in CATEGORY [all] + -v, --verbose verbosely report processing + --version print version information and exit + -h, --help print short or long help message and exit +" + +# Additional text appended to 'usage_message' in response to '--help'. +long_help_message=" +Warning categories include: + 'all' show all warnings + 'none' turn off all the warnings + 'error' warnings are treated as fatal errors" + +# Help message printed before fatal option parsing errors. +fatal_help="Try '\$progname --help' for more information." + + + +## ------------------------- ## +## Hook function management. ## +## ------------------------- ## + +# This section contains functions for adding, removing, and running hooks +# to the main code. A hook is just a named list of of function, that can +# be run in order later on. + +# func_hookable FUNC_NAME +# ----------------------- +# Declare that FUNC_NAME will run hooks added with +# 'func_add_hook FUNC_NAME ...'. +func_hookable () +{ + $debug_cmd + + func_append hookable_fns " $1" +} + + +# func_add_hook FUNC_NAME HOOK_FUNC +# --------------------------------- +# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must +# first have been declared "hookable" by a call to 'func_hookable'. +func_add_hook () +{ + $debug_cmd + + case " $hookable_fns " in + *" $1 "*) ;; + *) func_fatal_error "'$1' does not accept hook functions." ;; + esac + + eval func_append ${1}_hooks '" $2"' +} + + +# func_remove_hook FUNC_NAME HOOK_FUNC +# ------------------------------------ +# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. +func_remove_hook () +{ + $debug_cmd + + eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' +} + + +# func_run_hooks FUNC_NAME [ARG]... +# --------------------------------- +# Run all hook functions registered to FUNC_NAME. +# It is assumed that the list of hook functions contains nothing more +# than a whitespace-delimited list of legal shell function names, and +# no effort is wasted trying to catch shell meta-characters or preserve +# whitespace. +func_run_hooks () +{ + $debug_cmd + + case " $hookable_fns " in + *" $1 "*) ;; + *) func_fatal_error "'$1' does not support hook funcions.n" ;; + esac + + eval _G_hook_fns=\$$1_hooks; shift + + for _G_hook in $_G_hook_fns; do + eval $_G_hook '"$@"' + + # store returned options list back into positional + # parameters for next 'cmd' execution. + eval _G_hook_result=\$${_G_hook}_result + eval set dummy "$_G_hook_result"; shift + done + + func_quote_for_eval ${1+"$@"} + func_run_hooks_result=$func_quote_for_eval_result +} + + + +## --------------- ## +## Option parsing. ## +## --------------- ## + +# In order to add your own option parsing hooks, you must accept the +# full positional parameter list in your hook function, remove any +# options that you action, and then pass back the remaining unprocessed +# options in '_result', escaped suitably for +# 'eval'. Like this: +# +# my_options_prep () +# { +# $debug_cmd +# +# # Extend the existing usage message. +# usage_message=$usage_message' +# -s, --silent don'\''t print informational messages +# ' +# +# func_quote_for_eval ${1+"$@"} +# my_options_prep_result=$func_quote_for_eval_result +# } +# func_add_hook func_options_prep my_options_prep +# +# +# my_silent_option () +# { +# $debug_cmd +# +# # Note that for efficiency, we parse as many options as we can +# # recognise in a loop before passing the remainder back to the +# # caller on the first unrecognised argument we encounter. +# while test $# -gt 0; do +# opt=$1; shift +# case $opt in +# --silent|-s) opt_silent=: ;; +# # Separate non-argument short options: +# -s*) func_split_short_opt "$_G_opt" +# set dummy "$func_split_short_opt_name" \ +# "-$func_split_short_opt_arg" ${1+"$@"} +# shift +# ;; +# *) set dummy "$_G_opt" "$*"; shift; break ;; +# esac +# done +# +# func_quote_for_eval ${1+"$@"} +# my_silent_option_result=$func_quote_for_eval_result +# } +# func_add_hook func_parse_options my_silent_option +# +# +# my_option_validation () +# { +# $debug_cmd +# +# $opt_silent && $opt_verbose && func_fatal_help "\ +# '--silent' and '--verbose' options are mutually exclusive." +# +# func_quote_for_eval ${1+"$@"} +# my_option_validation_result=$func_quote_for_eval_result +# } +# func_add_hook func_validate_options my_option_validation +# +# You'll alse need to manually amend $usage_message to reflect the extra +# options you parse. It's preferable to append if you can, so that +# multiple option parsing hooks can be added safely. + + +# func_options [ARG]... +# --------------------- +# All the functions called inside func_options are hookable. See the +# individual implementations for details. +func_hookable func_options +func_options () +{ + $debug_cmd + + func_options_prep ${1+"$@"} + eval func_parse_options \ + ${func_options_prep_result+"$func_options_prep_result"} + eval func_validate_options \ + ${func_parse_options_result+"$func_parse_options_result"} + + eval func_run_hooks func_options \ + ${func_validate_options_result+"$func_validate_options_result"} + + # save modified positional parameters for caller + func_options_result=$func_run_hooks_result +} + + +# func_options_prep [ARG]... +# -------------------------- +# All initialisations required before starting the option parse loop. +# Note that when calling hook functions, we pass through the list of +# positional parameters. If a hook function modifies that list, and +# needs to propogate that back to rest of this script, then the complete +# modified list must be put in 'func_run_hooks_result' before +# returning. +func_hookable func_options_prep +func_options_prep () +{ + $debug_cmd + + # Option defaults: + opt_verbose=false + opt_warning_types= + + func_run_hooks func_options_prep ${1+"$@"} + + # save modified positional parameters for caller + func_options_prep_result=$func_run_hooks_result +} + + +# func_parse_options [ARG]... +# --------------------------- +# The main option parsing loop. +func_hookable func_parse_options +func_parse_options () +{ + $debug_cmd + + func_parse_options_result= + + # this just eases exit handling + while test $# -gt 0; do + # Defer to hook functions for initial option parsing, so they + # get priority in the event of reusing an option name. + func_run_hooks func_parse_options ${1+"$@"} + + # Adjust func_parse_options positional parameters to match + eval set dummy "$func_run_hooks_result"; shift + + # Break out of the loop if we already parsed every option. + test $# -gt 0 || break + + _G_opt=$1 + shift + case $_G_opt in + --debug|-x) debug_cmd='set -x' + func_echo "enabling shell trace mode" + $debug_cmd + ;; + + --no-warnings|--no-warning|--no-warn) + set dummy --warnings none ${1+"$@"} + shift + ;; + + --warnings|--warning|-W) + test $# = 0 && func_missing_arg $_G_opt && break + case " $warning_categories $1" in + *" $1 "*) + # trailing space prevents matching last $1 above + func_append_uniq opt_warning_types " $1" + ;; + *all) + opt_warning_types=$warning_categories + ;; + *none) + opt_warning_types=none + warning_func=: + ;; + *error) + opt_warning_types=$warning_categories + warning_func=func_fatal_error + ;; + *) + func_fatal_error \ + "unsupported warning category: '$1'" + ;; + esac + shift + ;; + + --verbose|-v) opt_verbose=: ;; + --version) func_version ;; + -\?|-h) func_usage ;; + --help) func_help ;; + + # Separate optargs to long options (plugins may need this): + --*=*) func_split_equals "$_G_opt" + set dummy "$func_split_equals_lhs" \ + "$func_split_equals_rhs" ${1+"$@"} + shift + ;; + + # Separate optargs to short options: + -W*) + func_split_short_opt "$_G_opt" + set dummy "$func_split_short_opt_name" \ + "$func_split_short_opt_arg" ${1+"$@"} + shift + ;; + + # Separate non-argument short options: + -\?*|-h*|-v*|-x*) + func_split_short_opt "$_G_opt" + set dummy "$func_split_short_opt_name" \ + "-$func_split_short_opt_arg" ${1+"$@"} + shift + ;; + + --) break ;; + -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; + *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; + esac + done + + # save modified positional parameters for caller + func_quote_for_eval ${1+"$@"} + func_parse_options_result=$func_quote_for_eval_result +} + + +# func_validate_options [ARG]... +# ------------------------------ +# Perform any sanity checks on option settings and/or unconsumed +# arguments. +func_hookable func_validate_options +func_validate_options () +{ + $debug_cmd + + # Display all warnings if -W was not given. + test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" + + func_run_hooks func_validate_options ${1+"$@"} + + # Bail if the options were screwed! + $exit_cmd $EXIT_FAILURE + + # save modified positional parameters for caller + func_validate_options_result=$func_run_hooks_result +} + + + +## ----------------- ## +## Helper functions. ## +## ----------------- ## + +# This section contains the helper functions used by the rest of the +# hookable option parser framework in ascii-betical order. + + +# func_fatal_help ARG... +# ---------------------- +# Echo program name prefixed message to standard error, followed by +# a help hint, and exit. +func_fatal_help () +{ + $debug_cmd + + eval \$ECHO \""Usage: $usage"\" + eval \$ECHO \""$fatal_help"\" + func_error ${1+"$@"} + exit $EXIT_FAILURE +} + + +# func_help +# --------- +# Echo long help message to standard output and exit. +func_help () +{ + $debug_cmd + + func_usage_message + $ECHO "$long_help_message" + exit 0 +} + + +# func_missing_arg ARGNAME +# ------------------------ +# Echo program name prefixed message to standard error and set global +# exit_cmd. +func_missing_arg () +{ + $debug_cmd + + func_error "Missing argument for '$1'." + exit_cmd=exit +} + + +# func_split_equals STRING +# ------------------------ +# Set func_split_equals_lhs and func_split_equals_rhs shell variables after +# splitting STRING at the '=' sign. +test -z "$_G_HAVE_XSI_OPS" \ + && (eval 'x=a/b/c; + test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ + && _G_HAVE_XSI_OPS=yes + +if test yes = "$_G_HAVE_XSI_OPS" +then + # This is an XSI compatible shell, allowing a faster implementation... + eval 'func_split_equals () + { + $debug_cmd + + func_split_equals_lhs=${1%%=*} + func_split_equals_rhs=${1#*=} + test "x$func_split_equals_lhs" = "x$1" \ + && func_split_equals_rhs= + }' +else + # ...otherwise fall back to using expr, which is often a shell builtin. + func_split_equals () + { + $debug_cmd + + func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` + func_split_equals_rhs= + test "x$func_split_equals_lhs" = "x$1" \ + || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` + } +fi #func_split_equals + + +# func_split_short_opt SHORTOPT +# ----------------------------- +# Set func_split_short_opt_name and func_split_short_opt_arg shell +# variables after splitting SHORTOPT after the 2nd character. +if test yes = "$_G_HAVE_XSI_OPS" +then + # This is an XSI compatible shell, allowing a faster implementation... + eval 'func_split_short_opt () + { + $debug_cmd + + func_split_short_opt_arg=${1#??} + func_split_short_opt_name=${1%"$func_split_short_opt_arg"} + }' +else + # ...otherwise fall back to using expr, which is often a shell builtin. + func_split_short_opt () + { + $debug_cmd + + func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` + func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` + } +fi #func_split_short_opt + + +# func_usage +# ---------- +# Echo short help message to standard output and exit. +func_usage () +{ + $debug_cmd + + func_usage_message + $ECHO "Run '$progname --help |${PAGER-more}' for full usage" + exit 0 +} + + +# func_usage_message +# ------------------ +# Echo short help message to standard output. +func_usage_message () +{ + $debug_cmd + + eval \$ECHO \""Usage: $usage"\" + echo + $SED -n 's|^# || + /^Written by/{ + x;p;x + } + h + /^Written by/q' < "$progpath" + echo + eval \$ECHO \""$usage_message"\" +} + + +# func_version +# ------------ +# Echo version message to standard output and exit. +func_version () +{ + $debug_cmd + + printf '%s\n' "$progname $scriptversion" + $SED -n ' + /(C)/!b go + :more + /\./!{ + N + s|\n# | | + b more + } + :go + /^# Written by /,/# warranty; / { + s|^# || + s|^# *$|| + s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| + p + } + /^# Written by / { + s|^# || + p + } + /^warranty; /q' < "$progpath" + + exit $? +} + + +# Local variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" +# time-stamp-time-zone: "UTC" +# End: + +# Set a version string. +scriptversion='(GNU libtool) 2.4.6' + + +# func_echo ARG... +# ---------------- +# Libtool also displays the current mode in messages, so override +# funclib.sh func_echo with this custom definition. +func_echo () +{ + $debug_cmd + + _G_message=$* + + func_echo_IFS=$IFS + IFS=$nl + for _G_line in $_G_message; do + IFS=$func_echo_IFS + $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" + done + IFS=$func_echo_IFS +} + + +# func_warning ARG... +# ------------------- +# Libtool warnings are not categorized, so override funclib.sh +# func_warning with this simpler definition. +func_warning () +{ + $debug_cmd + + $warning_func ${1+"$@"} +} + + +## ---------------- ## +## Options parsing. ## +## ---------------- ## + +# Hook in the functions to make sure our own options are parsed during +# the option parsing loop. + +usage='$progpath [OPTION]... [MODE-ARG]...' + +# Short help message in response to '-h'. +usage_message="Options: + --config show all configuration variables + --debug enable verbose shell tracing + -n, --dry-run display commands without modifying any files + --features display basic configuration information and exit + --mode=MODE use operation mode MODE + --no-warnings equivalent to '-Wnone' + --preserve-dup-deps don't remove duplicate dependency libraries + --quiet, --silent don't print informational messages + --tag=TAG use configuration variables from tag TAG + -v, --verbose print more informational messages than default + --version print version information + -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] + -h, --help, --help-all print short, long, or detailed help message +" + +# Additional text appended to 'usage_message' in response to '--help'. +func_help () +{ + $debug_cmd + + func_usage_message + $ECHO "$long_help_message + +MODE must be one of the following: + + clean remove files from the build directory + compile compile a source file into a libtool object + execute automatically set library path, then run a program + finish complete the installation of libtool libraries + install install libraries or executables + link create a library or an executable + uninstall remove libraries from an installed directory + +MODE-ARGS vary depending on the MODE. When passed as first option, +'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. +Try '$progname --help --mode=MODE' for a more detailed description of MODE. + +When reporting a bug, please describe a test case to reproduce it and +include the following information: + + host-triplet: $host + shell: $SHELL + compiler: $LTCC + compiler flags: $LTCFLAGS + linker: $LD (gnu? $with_gnu_ld) + version: $progname (GNU libtool) 2.4.6 + automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` + autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` + +Report bugs to . +GNU libtool home page: . +General help using GNU software: ." + exit 0 +} + + +# func_lo2o OBJECT-NAME +# --------------------- +# Transform OBJECT-NAME from a '.lo' suffix to the platform specific +# object suffix. + +lo2o=s/\\.lo\$/.$objext/ +o2lo=s/\\.$objext\$/.lo/ + +if test yes = "$_G_HAVE_XSI_OPS"; then + eval 'func_lo2o () + { + case $1 in + *.lo) func_lo2o_result=${1%.lo}.$objext ;; + * ) func_lo2o_result=$1 ;; + esac + }' + + # func_xform LIBOBJ-OR-SOURCE + # --------------------------- + # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) + # suffix to a '.lo' libtool-object suffix. + eval 'func_xform () + { + func_xform_result=${1%.*}.lo + }' +else + # ...otherwise fall back to using sed. + func_lo2o () + { + func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` + } + + func_xform () + { + func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` + } +fi + + +# func_fatal_configuration ARG... +# ------------------------------- +# Echo program name prefixed message to standard error, followed by +# a configuration failure hint, and exit. +func_fatal_configuration () +{ + func__fatal_error ${1+"$@"} \ + "See the $PACKAGE documentation for more information." \ + "Fatal configuration error." +} + + +# func_config +# ----------- +# Display the configuration for all the tags in this script. +func_config () +{ + re_begincf='^# ### BEGIN LIBTOOL' + re_endcf='^# ### END LIBTOOL' + + # Default configuration. + $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" + + # Now print the configurations for the tags. + for tagname in $taglist; do + $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" + done + + exit $? +} + + +# func_features +# ------------- +# Display the features supported by this script. +func_features () +{ + echo "host: $host" + if test yes = "$build_libtool_libs"; then + echo "enable shared libraries" + else + echo "disable shared libraries" + fi + if test yes = "$build_old_libs"; then + echo "enable static libraries" + else + echo "disable static libraries" + fi + + exit $? +} + + +# func_enable_tag TAGNAME +# ----------------------- +# Verify that TAGNAME is valid, and either flag an error and exit, or +# enable the TAGNAME tag. We also add TAGNAME to the global $taglist +# variable here. +func_enable_tag () +{ + # Global variable: + tagname=$1 + + re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" + re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" + sed_extractcf=/$re_begincf/,/$re_endcf/p + + # Validate tagname. + case $tagname in + *[!-_A-Za-z0-9,/]*) + func_fatal_error "invalid tag name: $tagname" + ;; + esac + + # Don't test for the "default" C tag, as we know it's + # there but not specially marked. + case $tagname in + CC) ;; + *) + if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then + taglist="$taglist $tagname" + + # Evaluate the configuration. Be careful to quote the path + # and the sed script, to avoid splitting on whitespace, but + # also don't use non-portable quotes within backquotes within + # quotes we have to do it in 2 steps: + extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` + eval "$extractedcf" + else + func_error "ignoring unknown tag $tagname" + fi + ;; + esac +} + + +# func_check_version_match +# ------------------------ +# Ensure that we are using m4 macros, and libtool script from the same +# release of libtool. +func_check_version_match () +{ + if test "$package_revision" != "$macro_revision"; then + if test "$VERSION" != "$macro_version"; then + if test -z "$macro_version"; then + cat >&2 <<_LT_EOF +$progname: Version mismatch error. This is $PACKAGE $VERSION, but the +$progname: definition of this LT_INIT comes from an older release. +$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION +$progname: and run autoconf again. +_LT_EOF + else + cat >&2 <<_LT_EOF +$progname: Version mismatch error. This is $PACKAGE $VERSION, but the +$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. +$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION +$progname: and run autoconf again. +_LT_EOF + fi + else + cat >&2 <<_LT_EOF +$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, +$progname: but the definition of this LT_INIT comes from revision $macro_revision. +$progname: You should recreate aclocal.m4 with macros from revision $package_revision +$progname: of $PACKAGE $VERSION and run autoconf again. +_LT_EOF + fi + + exit $EXIT_MISMATCH + fi +} + + +# libtool_options_prep [ARG]... +# ----------------------------- +# Preparation for options parsed by libtool. +libtool_options_prep () +{ + $debug_mode + + # Option defaults: + opt_config=false + opt_dlopen= + opt_dry_run=false + opt_help=false + opt_mode= + opt_preserve_dup_deps=false + opt_quiet=false + + nonopt= + preserve_args= + + # Shorthand for --mode=foo, only valid as the first argument + case $1 in + clean|clea|cle|cl) + shift; set dummy --mode clean ${1+"$@"}; shift + ;; + compile|compil|compi|comp|com|co|c) + shift; set dummy --mode compile ${1+"$@"}; shift + ;; + execute|execut|execu|exec|exe|ex|e) + shift; set dummy --mode execute ${1+"$@"}; shift + ;; + finish|finis|fini|fin|fi|f) + shift; set dummy --mode finish ${1+"$@"}; shift + ;; + install|instal|insta|inst|ins|in|i) + shift; set dummy --mode install ${1+"$@"}; shift + ;; + link|lin|li|l) + shift; set dummy --mode link ${1+"$@"}; shift + ;; + uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) + shift; set dummy --mode uninstall ${1+"$@"}; shift + ;; + esac + + # Pass back the list of options. + func_quote_for_eval ${1+"$@"} + libtool_options_prep_result=$func_quote_for_eval_result +} +func_add_hook func_options_prep libtool_options_prep + + +# libtool_parse_options [ARG]... +# --------------------------------- +# Provide handling for libtool specific options. +libtool_parse_options () +{ + $debug_cmd + + # Perform our own loop to consume as many options as possible in + # each iteration. + while test $# -gt 0; do + _G_opt=$1 + shift + case $_G_opt in + --dry-run|--dryrun|-n) + opt_dry_run=: + ;; + + --config) func_config ;; + + --dlopen|-dlopen) + opt_dlopen="${opt_dlopen+$opt_dlopen +}$1" + shift + ;; + + --preserve-dup-deps) + opt_preserve_dup_deps=: ;; + + --features) func_features ;; + + --finish) set dummy --mode finish ${1+"$@"}; shift ;; + + --help) opt_help=: ;; + + --help-all) opt_help=': help-all' ;; + + --mode) test $# = 0 && func_missing_arg $_G_opt && break + opt_mode=$1 + case $1 in + # Valid mode arguments: + clean|compile|execute|finish|install|link|relink|uninstall) ;; + + # Catch anything else as an error + *) func_error "invalid argument for $_G_opt" + exit_cmd=exit + break + ;; + esac + shift + ;; + + --no-silent|--no-quiet) + opt_quiet=false + func_append preserve_args " $_G_opt" + ;; + + --no-warnings|--no-warning|--no-warn) + opt_warning=false + func_append preserve_args " $_G_opt" + ;; + + --no-verbose) + opt_verbose=false + func_append preserve_args " $_G_opt" + ;; + + --silent|--quiet) + opt_quiet=: + opt_verbose=false + func_append preserve_args " $_G_opt" + ;; + + --tag) test $# = 0 && func_missing_arg $_G_opt && break + opt_tag=$1 + func_append preserve_args " $_G_opt $1" + func_enable_tag "$1" + shift + ;; + + --verbose|-v) opt_quiet=false + opt_verbose=: + func_append preserve_args " $_G_opt" + ;; + + # An option not handled by this hook function: + *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; + esac + done + + + # save modified positional parameters for caller + func_quote_for_eval ${1+"$@"} + libtool_parse_options_result=$func_quote_for_eval_result +} +func_add_hook func_parse_options libtool_parse_options + + + +# libtool_validate_options [ARG]... +# --------------------------------- +# Perform any sanity checks on option settings and/or unconsumed +# arguments. +libtool_validate_options () +{ + # save first non-option argument + if test 0 -lt $#; then + nonopt=$1 + shift + fi + + # preserve --debug + test : = "$debug_cmd" || func_append preserve_args " --debug" + + case $host in + # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 + # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 + *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) + # don't eliminate duplications in $postdeps and $predeps + opt_duplicate_compiler_generated_deps=: + ;; + *) + opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps + ;; + esac + + $opt_help || { + # Sanity checks first: + func_check_version_match + + test yes != "$build_libtool_libs" \ + && test yes != "$build_old_libs" \ + && func_fatal_configuration "not configured to build any kind of library" + + # Darwin sucks + eval std_shrext=\"$shrext_cmds\" + + # Only execute mode is allowed to have -dlopen flags. + if test -n "$opt_dlopen" && test execute != "$opt_mode"; then + func_error "unrecognized option '-dlopen'" + $ECHO "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Change the help message to a mode-specific one. + generic_help=$help + help="Try '$progname --help --mode=$opt_mode' for more information." + } + + # Pass back the unparsed argument list + func_quote_for_eval ${1+"$@"} + libtool_validate_options_result=$func_quote_for_eval_result +} +func_add_hook func_validate_options libtool_validate_options + + +# Process options as early as possible so that --help and --version +# can return quickly. +func_options ${1+"$@"} +eval set dummy "$func_options_result"; shift + + + +## ----------- ## +## Main. ## +## ----------- ## + +magic='%%%MAGIC variable%%%' +magic_exe='%%%MAGIC EXE variable%%%' + +# Global variables. +extracted_archives= +extracted_serial=0 + +# If this variable is set in any of the actions, the command in it +# will be execed at the end. This prevents here-documents from being +# left over by shells. +exec_cmd= + + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +$1 +_LTECHO_EOF' +} + +# func_generated_by_libtool +# True iff stdin has been generated by Libtool. This function is only +# a basic sanity check; it will hardly flush out determined imposters. +func_generated_by_libtool_p () +{ + $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 +} + +# func_lalib_p file +# True iff FILE is a libtool '.la' library or '.lo' object file. +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_lalib_p () +{ + test -f "$1" && + $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p +} + +# func_lalib_unsafe_p file +# True iff FILE is a libtool '.la' library or '.lo' object file. +# This function implements the same check as func_lalib_p without +# resorting to external programs. To this end, it redirects stdin and +# closes it afterwards, without saving the original file descriptor. +# As a safety measure, use it only where a negative result would be +# fatal anyway. Works if 'file' does not exist. +func_lalib_unsafe_p () +{ + lalib_p=no + if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then + for lalib_p_l in 1 2 3 4 + do + read lalib_p_line + case $lalib_p_line in + \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; + esac + done + exec 0<&5 5<&- + fi + test yes = "$lalib_p" +} + +# func_ltwrapper_script_p file +# True iff FILE is a libtool wrapper script +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_ltwrapper_script_p () +{ + test -f "$1" && + $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p +} + +# func_ltwrapper_executable_p file +# True iff FILE is a libtool wrapper executable +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_ltwrapper_executable_p () +{ + func_ltwrapper_exec_suffix= + case $1 in + *.exe) ;; + *) func_ltwrapper_exec_suffix=.exe ;; + esac + $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 +} + +# func_ltwrapper_scriptname file +# Assumes file is an ltwrapper_executable +# uses $file to determine the appropriate filename for a +# temporary ltwrapper_script. +func_ltwrapper_scriptname () +{ + func_dirname_and_basename "$1" "" "." + func_stripname '' '.exe' "$func_basename_result" + func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper +} + +# func_ltwrapper_p file +# True iff FILE is a libtool wrapper script or wrapper executable +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_ltwrapper_p () +{ + func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" +} + + +# func_execute_cmds commands fail_cmd +# Execute tilde-delimited COMMANDS. +# If FAIL_CMD is given, eval that upon failure. +# FAIL_CMD may read-access the current command in variable CMD! +func_execute_cmds () +{ + $debug_cmd + + save_ifs=$IFS; IFS='~' + for cmd in $1; do + IFS=$sp$nl + eval cmd=\"$cmd\" + IFS=$save_ifs + func_show_eval "$cmd" "${2-:}" + done + IFS=$save_ifs +} + + +# func_source file +# Source FILE, adding directory component if necessary. +# Note that it is not necessary on cygwin/mingw to append a dot to +# FILE even if both FILE and FILE.exe exist: automatic-append-.exe +# behavior happens only for exec(3), not for open(2)! Also, sourcing +# 'FILE.' does not work on cygwin managed mounts. +func_source () +{ + $debug_cmd + + case $1 in + */* | *\\*) . "$1" ;; + *) . "./$1" ;; + esac +} + + +# func_resolve_sysroot PATH +# Replace a leading = in PATH with a sysroot. Store the result into +# func_resolve_sysroot_result +func_resolve_sysroot () +{ + func_resolve_sysroot_result=$1 + case $func_resolve_sysroot_result in + =*) + func_stripname '=' '' "$func_resolve_sysroot_result" + func_resolve_sysroot_result=$lt_sysroot$func_stripname_result + ;; + esac +} + +# func_replace_sysroot PATH +# If PATH begins with the sysroot, replace it with = and +# store the result into func_replace_sysroot_result. +func_replace_sysroot () +{ + case $lt_sysroot:$1 in + ?*:"$lt_sysroot"*) + func_stripname "$lt_sysroot" '' "$1" + func_replace_sysroot_result='='$func_stripname_result + ;; + *) + # Including no sysroot. + func_replace_sysroot_result=$1 + ;; + esac +} + +# func_infer_tag arg +# Infer tagged configuration to use if any are available and +# if one wasn't chosen via the "--tag" command line option. +# Only attempt this if the compiler in the base compile +# command doesn't match the default compiler. +# arg is usually of the form 'gcc ...' +func_infer_tag () +{ + $debug_cmd + + if test -n "$available_tags" && test -z "$tagname"; then + CC_quoted= + for arg in $CC; do + func_append_quoted CC_quoted "$arg" + done + CC_expanded=`func_echo_all $CC` + CC_quoted_expanded=`func_echo_all $CC_quoted` + case $@ in + # Blanks in the command may have been stripped by the calling shell, + # but not from the CC environment variable when configure was run. + " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ + " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; + # Blanks at the start of $base_compile will cause this to fail + # if we don't check for them as well. + *) + for z in $available_tags; do + if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then + # Evaluate the configuration. + eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" + CC_quoted= + for arg in $CC; do + # Double-quote args containing other shell metacharacters. + func_append_quoted CC_quoted "$arg" + done + CC_expanded=`func_echo_all $CC` + CC_quoted_expanded=`func_echo_all $CC_quoted` + case "$@ " in + " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ + " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) + # The compiler in the base compile command matches + # the one in the tagged configuration. + # Assume this is the tagged configuration we want. + tagname=$z + break + ;; + esac + fi + done + # If $tagname still isn't set, then no tagged configuration + # was found and let the user know that the "--tag" command + # line option must be used. + if test -z "$tagname"; then + func_echo "unable to infer tagged configuration" + func_fatal_error "specify a tag with '--tag'" +# else +# func_verbose "using $tagname tagged configuration" + fi + ;; + esac + fi +} + + + +# func_write_libtool_object output_name pic_name nonpic_name +# Create a libtool object file (analogous to a ".la" file), +# but don't create it if we're doing a dry run. +func_write_libtool_object () +{ + write_libobj=$1 + if test yes = "$build_libtool_libs"; then + write_lobj=\'$2\' + else + write_lobj=none + fi + + if test yes = "$build_old_libs"; then + write_oldobj=\'$3\' + else + write_oldobj=none + fi + + $opt_dry_run || { + cat >${write_libobj}T </dev/null` + if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then + func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | + $SED -e "$sed_naive_backslashify"` + else + func_convert_core_file_wine_to_w32_result= + fi + fi +} +# end: func_convert_core_file_wine_to_w32 + + +# func_convert_core_path_wine_to_w32 ARG +# Helper function used by path conversion functions when $build is *nix, and +# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly +# configured wine environment available, with the winepath program in $build's +# $PATH. Assumes ARG has no leading or trailing path separator characters. +# +# ARG is path to be converted from $build format to win32. +# Result is available in $func_convert_core_path_wine_to_w32_result. +# Unconvertible file (directory) names in ARG are skipped; if no directory names +# are convertible, then the result may be empty. +func_convert_core_path_wine_to_w32 () +{ + $debug_cmd + + # unfortunately, winepath doesn't convert paths, only file names + func_convert_core_path_wine_to_w32_result= + if test -n "$1"; then + oldIFS=$IFS + IFS=: + for func_convert_core_path_wine_to_w32_f in $1; do + IFS=$oldIFS + func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" + if test -n "$func_convert_core_file_wine_to_w32_result"; then + if test -z "$func_convert_core_path_wine_to_w32_result"; then + func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result + else + func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" + fi + fi + done + IFS=$oldIFS + fi +} +# end: func_convert_core_path_wine_to_w32 + + +# func_cygpath ARGS... +# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when +# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) +# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or +# (2), returns the Cygwin file name or path in func_cygpath_result (input +# file name or path is assumed to be in w32 format, as previously converted +# from $build's *nix or MSYS format). In case (3), returns the w32 file name +# or path in func_cygpath_result (input file name or path is assumed to be in +# Cygwin format). Returns an empty string on error. +# +# ARGS are passed to cygpath, with the last one being the file name or path to +# be converted. +# +# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH +# environment variable; do not put it in $PATH. +func_cygpath () +{ + $debug_cmd + + if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then + func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` + if test "$?" -ne 0; then + # on failure, ensure result is empty + func_cygpath_result= + fi + else + func_cygpath_result= + func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" + fi +} +#end: func_cygpath + + +# func_convert_core_msys_to_w32 ARG +# Convert file name or path ARG from MSYS format to w32 format. Return +# result in func_convert_core_msys_to_w32_result. +func_convert_core_msys_to_w32 () +{ + $debug_cmd + + # awkward: cmd appends spaces to result + func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | + $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` +} +#end: func_convert_core_msys_to_w32 + + +# func_convert_file_check ARG1 ARG2 +# Verify that ARG1 (a file name in $build format) was converted to $host +# format in ARG2. Otherwise, emit an error message, but continue (resetting +# func_to_host_file_result to ARG1). +func_convert_file_check () +{ + $debug_cmd + + if test -z "$2" && test -n "$1"; then + func_error "Could not determine host file name corresponding to" + func_error " '$1'" + func_error "Continuing, but uninstalled executables may not work." + # Fallback: + func_to_host_file_result=$1 + fi +} +# end func_convert_file_check + + +# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH +# Verify that FROM_PATH (a path in $build format) was converted to $host +# format in TO_PATH. Otherwise, emit an error message, but continue, resetting +# func_to_host_file_result to a simplistic fallback value (see below). +func_convert_path_check () +{ + $debug_cmd + + if test -z "$4" && test -n "$3"; then + func_error "Could not determine the host path corresponding to" + func_error " '$3'" + func_error "Continuing, but uninstalled executables may not work." + # Fallback. This is a deliberately simplistic "conversion" and + # should not be "improved". See libtool.info. + if test "x$1" != "x$2"; then + lt_replace_pathsep_chars="s|$1|$2|g" + func_to_host_path_result=`echo "$3" | + $SED -e "$lt_replace_pathsep_chars"` + else + func_to_host_path_result=$3 + fi + fi +} +# end func_convert_path_check + + +# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG +# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT +# and appending REPL if ORIG matches BACKPAT. +func_convert_path_front_back_pathsep () +{ + $debug_cmd + + case $4 in + $1 ) func_to_host_path_result=$3$func_to_host_path_result + ;; + esac + case $4 in + $2 ) func_append func_to_host_path_result "$3" + ;; + esac +} +# end func_convert_path_front_back_pathsep + + +################################################## +# $build to $host FILE NAME CONVERSION FUNCTIONS # +################################################## +# invoked via '$to_host_file_cmd ARG' +# +# In each case, ARG is the path to be converted from $build to $host format. +# Result will be available in $func_to_host_file_result. + + +# func_to_host_file ARG +# Converts the file name ARG from $build format to $host format. Return result +# in func_to_host_file_result. +func_to_host_file () +{ + $debug_cmd + + $to_host_file_cmd "$1" +} +# end func_to_host_file + + +# func_to_tool_file ARG LAZY +# converts the file name ARG from $build format to toolchain format. Return +# result in func_to_tool_file_result. If the conversion in use is listed +# in (the comma separated) LAZY, no conversion takes place. +func_to_tool_file () +{ + $debug_cmd + + case ,$2, in + *,"$to_tool_file_cmd",*) + func_to_tool_file_result=$1 + ;; + *) + $to_tool_file_cmd "$1" + func_to_tool_file_result=$func_to_host_file_result + ;; + esac +} +# end func_to_tool_file + + +# func_convert_file_noop ARG +# Copy ARG to func_to_host_file_result. +func_convert_file_noop () +{ + func_to_host_file_result=$1 +} +# end func_convert_file_noop + + +# func_convert_file_msys_to_w32 ARG +# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic +# conversion to w32 is not available inside the cwrapper. Returns result in +# func_to_host_file_result. +func_convert_file_msys_to_w32 () +{ + $debug_cmd + + func_to_host_file_result=$1 + if test -n "$1"; then + func_convert_core_msys_to_w32 "$1" + func_to_host_file_result=$func_convert_core_msys_to_w32_result + fi + func_convert_file_check "$1" "$func_to_host_file_result" +} +# end func_convert_file_msys_to_w32 + + +# func_convert_file_cygwin_to_w32 ARG +# Convert file name ARG from Cygwin to w32 format. Returns result in +# func_to_host_file_result. +func_convert_file_cygwin_to_w32 () +{ + $debug_cmd + + func_to_host_file_result=$1 + if test -n "$1"; then + # because $build is cygwin, we call "the" cygpath in $PATH; no need to use + # LT_CYGPATH in this case. + func_to_host_file_result=`cygpath -m "$1"` + fi + func_convert_file_check "$1" "$func_to_host_file_result" +} +# end func_convert_file_cygwin_to_w32 + + +# func_convert_file_nix_to_w32 ARG +# Convert file name ARG from *nix to w32 format. Requires a wine environment +# and a working winepath. Returns result in func_to_host_file_result. +func_convert_file_nix_to_w32 () +{ + $debug_cmd + + func_to_host_file_result=$1 + if test -n "$1"; then + func_convert_core_file_wine_to_w32 "$1" + func_to_host_file_result=$func_convert_core_file_wine_to_w32_result + fi + func_convert_file_check "$1" "$func_to_host_file_result" +} +# end func_convert_file_nix_to_w32 + + +# func_convert_file_msys_to_cygwin ARG +# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. +# Returns result in func_to_host_file_result. +func_convert_file_msys_to_cygwin () +{ + $debug_cmd + + func_to_host_file_result=$1 + if test -n "$1"; then + func_convert_core_msys_to_w32 "$1" + func_cygpath -u "$func_convert_core_msys_to_w32_result" + func_to_host_file_result=$func_cygpath_result + fi + func_convert_file_check "$1" "$func_to_host_file_result" +} +# end func_convert_file_msys_to_cygwin + + +# func_convert_file_nix_to_cygwin ARG +# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed +# in a wine environment, working winepath, and LT_CYGPATH set. Returns result +# in func_to_host_file_result. +func_convert_file_nix_to_cygwin () +{ + $debug_cmd + + func_to_host_file_result=$1 + if test -n "$1"; then + # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. + func_convert_core_file_wine_to_w32 "$1" + func_cygpath -u "$func_convert_core_file_wine_to_w32_result" + func_to_host_file_result=$func_cygpath_result + fi + func_convert_file_check "$1" "$func_to_host_file_result" +} +# end func_convert_file_nix_to_cygwin + + +############################################# +# $build to $host PATH CONVERSION FUNCTIONS # +############################################# +# invoked via '$to_host_path_cmd ARG' +# +# In each case, ARG is the path to be converted from $build to $host format. +# The result will be available in $func_to_host_path_result. +# +# Path separators are also converted from $build format to $host format. If +# ARG begins or ends with a path separator character, it is preserved (but +# converted to $host format) on output. +# +# All path conversion functions are named using the following convention: +# file name conversion function : func_convert_file_X_to_Y () +# path conversion function : func_convert_path_X_to_Y () +# where, for any given $build/$host combination the 'X_to_Y' value is the +# same. If conversion functions are added for new $build/$host combinations, +# the two new functions must follow this pattern, or func_init_to_host_path_cmd +# will break. + + +# func_init_to_host_path_cmd +# Ensures that function "pointer" variable $to_host_path_cmd is set to the +# appropriate value, based on the value of $to_host_file_cmd. +to_host_path_cmd= +func_init_to_host_path_cmd () +{ + $debug_cmd + + if test -z "$to_host_path_cmd"; then + func_stripname 'func_convert_file_' '' "$to_host_file_cmd" + to_host_path_cmd=func_convert_path_$func_stripname_result + fi +} + + +# func_to_host_path ARG +# Converts the path ARG from $build format to $host format. Return result +# in func_to_host_path_result. +func_to_host_path () +{ + $debug_cmd + + func_init_to_host_path_cmd + $to_host_path_cmd "$1" +} +# end func_to_host_path + + +# func_convert_path_noop ARG +# Copy ARG to func_to_host_path_result. +func_convert_path_noop () +{ + func_to_host_path_result=$1 +} +# end func_convert_path_noop + + +# func_convert_path_msys_to_w32 ARG +# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic +# conversion to w32 is not available inside the cwrapper. Returns result in +# func_to_host_path_result. +func_convert_path_msys_to_w32 () +{ + $debug_cmd + + func_to_host_path_result=$1 + if test -n "$1"; then + # Remove leading and trailing path separator characters from ARG. MSYS + # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; + # and winepath ignores them completely. + func_stripname : : "$1" + func_to_host_path_tmp1=$func_stripname_result + func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" + func_to_host_path_result=$func_convert_core_msys_to_w32_result + func_convert_path_check : ";" \ + "$func_to_host_path_tmp1" "$func_to_host_path_result" + func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" + fi +} +# end func_convert_path_msys_to_w32 + + +# func_convert_path_cygwin_to_w32 ARG +# Convert path ARG from Cygwin to w32 format. Returns result in +# func_to_host_file_result. +func_convert_path_cygwin_to_w32 () +{ + $debug_cmd + + func_to_host_path_result=$1 + if test -n "$1"; then + # See func_convert_path_msys_to_w32: + func_stripname : : "$1" + func_to_host_path_tmp1=$func_stripname_result + func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` + func_convert_path_check : ";" \ + "$func_to_host_path_tmp1" "$func_to_host_path_result" + func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" + fi +} +# end func_convert_path_cygwin_to_w32 + + +# func_convert_path_nix_to_w32 ARG +# Convert path ARG from *nix to w32 format. Requires a wine environment and +# a working winepath. Returns result in func_to_host_file_result. +func_convert_path_nix_to_w32 () +{ + $debug_cmd + + func_to_host_path_result=$1 + if test -n "$1"; then + # See func_convert_path_msys_to_w32: + func_stripname : : "$1" + func_to_host_path_tmp1=$func_stripname_result + func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" + func_to_host_path_result=$func_convert_core_path_wine_to_w32_result + func_convert_path_check : ";" \ + "$func_to_host_path_tmp1" "$func_to_host_path_result" + func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" + fi +} +# end func_convert_path_nix_to_w32 + + +# func_convert_path_msys_to_cygwin ARG +# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. +# Returns result in func_to_host_file_result. +func_convert_path_msys_to_cygwin () +{ + $debug_cmd + + func_to_host_path_result=$1 + if test -n "$1"; then + # See func_convert_path_msys_to_w32: + func_stripname : : "$1" + func_to_host_path_tmp1=$func_stripname_result + func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" + func_cygpath -u -p "$func_convert_core_msys_to_w32_result" + func_to_host_path_result=$func_cygpath_result + func_convert_path_check : : \ + "$func_to_host_path_tmp1" "$func_to_host_path_result" + func_convert_path_front_back_pathsep ":*" "*:" : "$1" + fi +} +# end func_convert_path_msys_to_cygwin + + +# func_convert_path_nix_to_cygwin ARG +# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a +# a wine environment, working winepath, and LT_CYGPATH set. Returns result in +# func_to_host_file_result. +func_convert_path_nix_to_cygwin () +{ + $debug_cmd + + func_to_host_path_result=$1 + if test -n "$1"; then + # Remove leading and trailing path separator characters from + # ARG. msys behavior is inconsistent here, cygpath turns them + # into '.;' and ';.', and winepath ignores them completely. + func_stripname : : "$1" + func_to_host_path_tmp1=$func_stripname_result + func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" + func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" + func_to_host_path_result=$func_cygpath_result + func_convert_path_check : : \ + "$func_to_host_path_tmp1" "$func_to_host_path_result" + func_convert_path_front_back_pathsep ":*" "*:" : "$1" + fi +} +# end func_convert_path_nix_to_cygwin + + +# func_dll_def_p FILE +# True iff FILE is a Windows DLL '.def' file. +# Keep in sync with _LT_DLL_DEF_P in libtool.m4 +func_dll_def_p () +{ + $debug_cmd + + func_dll_def_p_tmp=`$SED -n \ + -e 's/^[ ]*//' \ + -e '/^\(;.*\)*$/d' \ + -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ + -e q \ + "$1"` + test DEF = "$func_dll_def_p_tmp" +} + + +# func_mode_compile arg... +func_mode_compile () +{ + $debug_cmd + + # Get the compilation command and the source file. + base_compile= + srcfile=$nonopt # always keep a non-empty value in "srcfile" + suppress_opt=yes + suppress_output= + arg_mode=normal + libobj= + later= + pie_flag= + + for arg + do + case $arg_mode in + arg ) + # do not "continue". Instead, add this to base_compile + lastarg=$arg + arg_mode=normal + ;; + + target ) + libobj=$arg + arg_mode=normal + continue + ;; + + normal ) + # Accept any command-line options. + case $arg in + -o) + test -n "$libobj" && \ + func_fatal_error "you cannot specify '-o' more than once" + arg_mode=target + continue + ;; + + -pie | -fpie | -fPIE) + func_append pie_flag " $arg" + continue + ;; + + -shared | -static | -prefer-pic | -prefer-non-pic) + func_append later " $arg" + continue + ;; + + -no-suppress) + suppress_opt=no + continue + ;; + + -Xcompiler) + arg_mode=arg # the next one goes into the "base_compile" arg list + continue # The current "srcfile" will either be retained or + ;; # replaced later. I would guess that would be a bug. + + -Wc,*) + func_stripname '-Wc,' '' "$arg" + args=$func_stripname_result + lastarg= + save_ifs=$IFS; IFS=, + for arg in $args; do + IFS=$save_ifs + func_append_quoted lastarg "$arg" + done + IFS=$save_ifs + func_stripname ' ' '' "$lastarg" + lastarg=$func_stripname_result + + # Add the arguments to base_compile. + func_append base_compile " $lastarg" + continue + ;; + + *) + # Accept the current argument as the source file. + # The previous "srcfile" becomes the current argument. + # + lastarg=$srcfile + srcfile=$arg + ;; + esac # case $arg + ;; + esac # case $arg_mode + + # Aesthetically quote the previous argument. + func_append_quoted base_compile "$lastarg" + done # for arg + + case $arg_mode in + arg) + func_fatal_error "you must specify an argument for -Xcompile" + ;; + target) + func_fatal_error "you must specify a target with '-o'" + ;; + *) + # Get the name of the library object. + test -z "$libobj" && { + func_basename "$srcfile" + libobj=$func_basename_result + } + ;; + esac + + # Recognize several different file suffixes. + # If the user specifies -o file.o, it is replaced with file.lo + case $libobj in + *.[cCFSifmso] | \ + *.ada | *.adb | *.ads | *.asm | \ + *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ + *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) + func_xform "$libobj" + libobj=$func_xform_result + ;; + esac + + case $libobj in + *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; + *) + func_fatal_error "cannot determine name of library object from '$libobj'" + ;; + esac + + func_infer_tag $base_compile + + for arg in $later; do + case $arg in + -shared) + test yes = "$build_libtool_libs" \ + || func_fatal_configuration "cannot build a shared library" + build_old_libs=no + continue + ;; + + -static) + build_libtool_libs=no + build_old_libs=yes + continue + ;; + + -prefer-pic) + pic_mode=yes + continue + ;; + + -prefer-non-pic) + pic_mode=no + continue + ;; + esac + done + + func_quote_for_eval "$libobj" + test "X$libobj" != "X$func_quote_for_eval_result" \ + && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ + && func_warning "libobj name '$libobj' may not contain shell special characters." + func_dirname_and_basename "$obj" "/" "" + objname=$func_basename_result + xdir=$func_dirname_result + lobj=$xdir$objdir/$objname + + test -z "$base_compile" && \ + func_fatal_help "you must specify a compilation command" + + # Delete any leftover library objects. + if test yes = "$build_old_libs"; then + removelist="$obj $lobj $libobj ${libobj}T" + else + removelist="$lobj $libobj ${libobj}T" + fi + + # On Cygwin there's no "real" PIC flag so we must build both object types + case $host_os in + cygwin* | mingw* | pw32* | os2* | cegcc*) + pic_mode=default + ;; + esac + if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then + # non-PIC code in shared libraries is not supported + pic_mode=default + fi + + # Calculate the filename of the output object if compiler does + # not support -o with -c + if test no = "$compiler_c_o"; then + output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext + lockfile=$output_obj.lock + else + output_obj= + need_locks=no + lockfile= + fi + + # Lock this critical section if it is needed + # We use this script file to make the link, it avoids creating a new file + if test yes = "$need_locks"; then + until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do + func_echo "Waiting for $lockfile to be removed" + sleep 2 + done + elif test warn = "$need_locks"; then + if test -f "$lockfile"; then + $ECHO "\ +*** ERROR, $lockfile exists and contains: +`cat $lockfile 2>/dev/null` + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support '-c' and '-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $opt_dry_run || $RM $removelist + exit $EXIT_FAILURE + fi + func_append removelist " $output_obj" + $ECHO "$srcfile" > "$lockfile" + fi + + $opt_dry_run || $RM $removelist + func_append removelist " $lockfile" + trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 + + func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 + srcfile=$func_to_tool_file_result + func_quote_for_eval "$srcfile" + qsrcfile=$func_quote_for_eval_result + + # Only build a PIC object if we are building libtool libraries. + if test yes = "$build_libtool_libs"; then + # Without this assignment, base_compile gets emptied. + fbsd_hideous_sh_bug=$base_compile + + if test no != "$pic_mode"; then + command="$base_compile $qsrcfile $pic_flag" + else + # Don't build PIC code + command="$base_compile $qsrcfile" + fi + + func_mkdir_p "$xdir$objdir" + + if test -z "$output_obj"; then + # Place PIC objects in $objdir + func_append command " -o $lobj" + fi + + func_show_eval_locale "$command" \ + 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' + + if test warn = "$need_locks" && + test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then + $ECHO "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support '-c' and '-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $opt_dry_run || $RM $removelist + exit $EXIT_FAILURE + fi + + # Just move the object if needed, then go on to compile the next one + if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then + func_show_eval '$MV "$output_obj" "$lobj"' \ + 'error=$?; $opt_dry_run || $RM $removelist; exit $error' + fi + + # Allow error messages only from the first compilation. + if test yes = "$suppress_opt"; then + suppress_output=' >/dev/null 2>&1' + fi + fi + + # Only build a position-dependent object if we build old libraries. + if test yes = "$build_old_libs"; then + if test yes != "$pic_mode"; then + # Don't build PIC code + command="$base_compile $qsrcfile$pie_flag" + else + command="$base_compile $qsrcfile $pic_flag" + fi + if test yes = "$compiler_c_o"; then + func_append command " -o $obj" + fi + + # Suppress compiler output if we already did a PIC compilation. + func_append command "$suppress_output" + func_show_eval_locale "$command" \ + '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' + + if test warn = "$need_locks" && + test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then + $ECHO "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support '-c' and '-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $opt_dry_run || $RM $removelist + exit $EXIT_FAILURE + fi + + # Just move the object if needed + if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then + func_show_eval '$MV "$output_obj" "$obj"' \ + 'error=$?; $opt_dry_run || $RM $removelist; exit $error' + fi + fi + + $opt_dry_run || { + func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" + + # Unlock the critical section if it was locked + if test no != "$need_locks"; then + removelist=$lockfile + $RM "$lockfile" + fi + } + + exit $EXIT_SUCCESS +} + +$opt_help || { + test compile = "$opt_mode" && func_mode_compile ${1+"$@"} +} + +func_mode_help () +{ + # We need to display help for each of the modes. + case $opt_mode in + "") + # Generic help is extracted from the usage comments + # at the start of this file. + func_help + ;; + + clean) + $ECHO \ +"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... + +Remove files from the build directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed +to RM. + +If FILE is a libtool library, object or program, all the files associated +with it are deleted. Otherwise, only FILE itself is deleted using RM." + ;; + + compile) + $ECHO \ +"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE + +Compile a source file into a libtool library object. + +This mode accepts the following additional options: + + -o OUTPUT-FILE set the output file name to OUTPUT-FILE + -no-suppress do not suppress compiler output for multiple passes + -prefer-pic try to build PIC objects only + -prefer-non-pic try to build non-PIC objects only + -shared do not build a '.o' file suitable for static linking + -static only build a '.o' file suitable for static linking + -Wc,FLAG pass FLAG directly to the compiler + +COMPILE-COMMAND is a command to be used in creating a 'standard' object file +from the given SOURCEFILE. + +The output file name is determined by removing the directory component from +SOURCEFILE, then substituting the C source code suffix '.c' with the +library object suffix, '.lo'." + ;; + + execute) + $ECHO \ +"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... + +Automatically set library path, then run a program. + +This mode accepts the following additional options: + + -dlopen FILE add the directory containing FILE to the library path + +This mode sets the library path environment variable according to '-dlopen' +flags. + +If any of the ARGS are libtool executable wrappers, then they are translated +into their corresponding uninstalled binary, and any of their required library +directories are added to the library path. + +Then, COMMAND is executed, with ARGS as arguments." + ;; + + finish) + $ECHO \ +"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... + +Complete the installation of libtool libraries. + +Each LIBDIR is a directory that contains libtool libraries. + +The commands that this mode executes may require superuser privileges. Use +the '--dry-run' option if you just want to see what would be executed." + ;; + + install) + $ECHO \ +"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... + +Install executables or libraries. + +INSTALL-COMMAND is the installation command. The first component should be +either the 'install' or 'cp' program. + +The following components of INSTALL-COMMAND are treated specially: + + -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation + +The rest of the components are interpreted as arguments to that command (only +BSD-compatible install options are recognized)." + ;; + + link) + $ECHO \ +"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... + +Link object files or libraries together to form another library, or to +create an executable program. + +LINK-COMMAND is a command using the C compiler that you would use to create +a program from several object files. + +The following components of LINK-COMMAND are treated specially: + + -all-static do not do any dynamic linking at all + -static do not do any dynamic linking at all + -avoid-version do not add a version suffix if possible + -bindir BINDIR specify path to binaries directory (for systems where + libraries must be found in the PATH setting at runtime) + -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime + -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols + -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) + -export-symbols SYMFILE + try to export only the symbols listed in SYMFILE + -export-symbols-regex REGEX + try to export only the symbols matching REGEX + -LLIBDIR search LIBDIR for required installed libraries + -lNAME OUTPUT-FILE requires the installed library libNAME + -module build a library that can dlopened + -no-fast-install disable the fast-install mode + -no-install link a not-installable executable + -no-undefined declare that a library does not refer to external symbols + -o OUTPUT-FILE create OUTPUT-FILE from the specified objects + -objectlist FILE use a list of object files found in FILE to specify objects + -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) + -precious-files-regex REGEX + don't remove output files matching REGEX + -release RELEASE specify package release information + -rpath LIBDIR the created library will eventually be installed in LIBDIR + -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries + -shared only do dynamic linking of libtool libraries + -shrext SUFFIX override the standard shared library file extension + -static-uninstalled-libs + do not do any dynamic linking of uninstalled libtool libraries + -static-libtool-libs + do not do any dynamic linking of libtool libraries + -version-info CURRENT[:REVISION[:AGE]] + specify library version info [each variable defaults to 0] + -weak LIBNAME declare that the target provides the LIBNAME interface + -Wc,FLAG + -Xcompiler FLAG pass linker-specific FLAG directly to the compiler + -Wl,FLAG + -Xlinker FLAG pass linker-specific FLAG directly to the linker + -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) + +All other options (arguments beginning with '-') are ignored. + +Every other argument is treated as a filename. Files ending in '.la' are +treated as uninstalled libtool libraries, other files are standard or library +object files. + +If the OUTPUT-FILE ends in '.la', then a libtool library is created, +only library objects ('.lo' files) may be specified, and '-rpath' is +required, except when creating a convenience library. + +If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created +using 'ar' and 'ranlib', or on Windows using 'lib'. + +If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file +is created, otherwise an executable program is created." + ;; + + uninstall) + $ECHO \ +"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... + +Remove libraries from an installation directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed +to RM. + +If FILE is a libtool library, all the files associated with it are deleted. +Otherwise, only FILE itself is deleted using RM." + ;; + + *) + func_fatal_help "invalid operation mode '$opt_mode'" + ;; + esac + + echo + $ECHO "Try '$progname --help' for more information about other modes." +} + +# Now that we've collected a possible --mode arg, show help if necessary +if $opt_help; then + if test : = "$opt_help"; then + func_mode_help + else + { + func_help noexit + for opt_mode in compile link execute install finish uninstall clean; do + func_mode_help + done + } | $SED -n '1p; 2,$s/^Usage:/ or: /p' + { + func_help noexit + for opt_mode in compile link execute install finish uninstall clean; do + echo + func_mode_help + done + } | + $SED '1d + /^When reporting/,/^Report/{ + H + d + } + $x + /information about other modes/d + /more detailed .*MODE/d + s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' + fi + exit $? +fi + + +# func_mode_execute arg... +func_mode_execute () +{ + $debug_cmd + + # The first argument is the command name. + cmd=$nonopt + test -z "$cmd" && \ + func_fatal_help "you must specify a COMMAND" + + # Handle -dlopen flags immediately. + for file in $opt_dlopen; do + test -f "$file" \ + || func_fatal_help "'$file' is not a file" + + dir= + case $file in + *.la) + func_resolve_sysroot "$file" + file=$func_resolve_sysroot_result + + # Check to see that this really is a libtool archive. + func_lalib_unsafe_p "$file" \ + || func_fatal_help "'$lib' is not a valid libtool archive" + + # Read the libtool library. + dlname= + library_names= + func_source "$file" + + # Skip this library if it cannot be dlopened. + if test -z "$dlname"; then + # Warn if it was a shared library. + test -n "$library_names" && \ + func_warning "'$file' was not linked with '-export-dynamic'" + continue + fi + + func_dirname "$file" "" "." + dir=$func_dirname_result + + if test -f "$dir/$objdir/$dlname"; then + func_append dir "/$objdir" + else + if test ! -f "$dir/$dlname"; then + func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" + fi + fi + ;; + + *.lo) + # Just add the directory containing the .lo file. + func_dirname "$file" "" "." + dir=$func_dirname_result + ;; + + *) + func_warning "'-dlopen' is ignored for non-libtool libraries and objects" + continue + ;; + esac + + # Get the absolute pathname. + absdir=`cd "$dir" && pwd` + test -n "$absdir" && dir=$absdir + + # Now add the directory to shlibpath_var. + if eval "test -z \"\$$shlibpath_var\""; then + eval "$shlibpath_var=\"\$dir\"" + else + eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" + fi + done + + # This variable tells wrapper scripts just to set shlibpath_var + # rather than running their programs. + libtool_execute_magic=$magic + + # Check if any of the arguments is a wrapper script. + args= + for file + do + case $file in + -* | *.la | *.lo ) ;; + *) + # Do a test to see if this is really a libtool program. + if func_ltwrapper_script_p "$file"; then + func_source "$file" + # Transform arg to wrapped name. + file=$progdir/$program + elif func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + func_source "$func_ltwrapper_scriptname_result" + # Transform arg to wrapped name. + file=$progdir/$program + fi + ;; + esac + # Quote arguments (to preserve shell metacharacters). + func_append_quoted args "$file" + done + + if $opt_dry_run; then + # Display what would be done. + if test -n "$shlibpath_var"; then + eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" + echo "export $shlibpath_var" + fi + $ECHO "$cmd$args" + exit $EXIT_SUCCESS + else + if test -n "$shlibpath_var"; then + # Export the shlibpath_var. + eval "export $shlibpath_var" + fi + + # Restore saved environment variables + for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES + do + eval "if test \"\${save_$lt_var+set}\" = set; then + $lt_var=\$save_$lt_var; export $lt_var + else + $lt_unset $lt_var + fi" + done + + # Now prepare to actually exec the command. + exec_cmd=\$cmd$args + fi +} + +test execute = "$opt_mode" && func_mode_execute ${1+"$@"} + + +# func_mode_finish arg... +func_mode_finish () +{ + $debug_cmd + + libs= + libdirs= + admincmds= + + for opt in "$nonopt" ${1+"$@"} + do + if test -d "$opt"; then + func_append libdirs " $opt" + + elif test -f "$opt"; then + if func_lalib_unsafe_p "$opt"; then + func_append libs " $opt" + else + func_warning "'$opt' is not a valid libtool archive" + fi + + else + func_fatal_error "invalid argument '$opt'" + fi + done + + if test -n "$libs"; then + if test -n "$lt_sysroot"; then + sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` + sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" + else + sysroot_cmd= + fi + + # Remove sysroot references + if $opt_dry_run; then + for lib in $libs; do + echo "removing references to $lt_sysroot and '=' prefixes from $lib" + done + else + tmpdir=`func_mktempdir` + for lib in $libs; do + $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ + > $tmpdir/tmp-la + mv -f $tmpdir/tmp-la $lib + done + ${RM}r "$tmpdir" + fi + fi + + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + for libdir in $libdirs; do + if test -n "$finish_cmds"; then + # Do each command in the finish commands. + func_execute_cmds "$finish_cmds" 'admincmds="$admincmds +'"$cmd"'"' + fi + if test -n "$finish_eval"; then + # Do the single finish_eval. + eval cmds=\"$finish_eval\" + $opt_dry_run || eval "$cmds" || func_append admincmds " + $cmds" + fi + done + fi + + # Exit here if they wanted silent mode. + $opt_quiet && exit $EXIT_SUCCESS + + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + echo "----------------------------------------------------------------------" + echo "Libraries have been installed in:" + for libdir in $libdirs; do + $ECHO " $libdir" + done + echo + echo "If you ever happen to want to link against installed libraries" + echo "in a given directory, LIBDIR, you must either use libtool, and" + echo "specify the full pathname of the library, or use the '-LLIBDIR'" + echo "flag during linking and do at least one of the following:" + if test -n "$shlibpath_var"; then + echo " - add LIBDIR to the '$shlibpath_var' environment variable" + echo " during execution" + fi + if test -n "$runpath_var"; then + echo " - add LIBDIR to the '$runpath_var' environment variable" + echo " during linking" + fi + if test -n "$hardcode_libdir_flag_spec"; then + libdir=LIBDIR + eval flag=\"$hardcode_libdir_flag_spec\" + + $ECHO " - use the '$flag' linker flag" + fi + if test -n "$admincmds"; then + $ECHO " - have your system administrator run these commands:$admincmds" + fi + if test -f /etc/ld.so.conf; then + echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" + fi + echo + + echo "See any operating system documentation about shared libraries for" + case $host in + solaris2.[6789]|solaris2.1[0-9]) + echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" + echo "pages." + ;; + *) + echo "more information, such as the ld(1) and ld.so(8) manual pages." + ;; + esac + echo "----------------------------------------------------------------------" + fi + exit $EXIT_SUCCESS +} + +test finish = "$opt_mode" && func_mode_finish ${1+"$@"} + + +# func_mode_install arg... +func_mode_install () +{ + $debug_cmd + + # There may be an optional sh(1) argument at the beginning of + # install_prog (especially on Windows NT). + if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || + # Allow the use of GNU shtool's install command. + case $nonopt in *shtool*) :;; *) false;; esac + then + # Aesthetically quote it. + func_quote_for_eval "$nonopt" + install_prog="$func_quote_for_eval_result " + arg=$1 + shift + else + install_prog= + arg=$nonopt + fi + + # The real first argument should be the name of the installation program. + # Aesthetically quote it. + func_quote_for_eval "$arg" + func_append install_prog "$func_quote_for_eval_result" + install_shared_prog=$install_prog + case " $install_prog " in + *[\\\ /]cp\ *) install_cp=: ;; + *) install_cp=false ;; + esac + + # We need to accept at least all the BSD install flags. + dest= + files= + opts= + prev= + install_type= + isdir=false + stripme= + no_mode=: + for arg + do + arg2= + if test -n "$dest"; then + func_append files " $dest" + dest=$arg + continue + fi + + case $arg in + -d) isdir=: ;; + -f) + if $install_cp; then :; else + prev=$arg + fi + ;; + -g | -m | -o) + prev=$arg + ;; + -s) + stripme=" -s" + continue + ;; + -*) + ;; + *) + # If the previous option needed an argument, then skip it. + if test -n "$prev"; then + if test X-m = "X$prev" && test -n "$install_override_mode"; then + arg2=$install_override_mode + no_mode=false + fi + prev= + else + dest=$arg + continue + fi + ;; + esac + + # Aesthetically quote the argument. + func_quote_for_eval "$arg" + func_append install_prog " $func_quote_for_eval_result" + if test -n "$arg2"; then + func_quote_for_eval "$arg2" + fi + func_append install_shared_prog " $func_quote_for_eval_result" + done + + test -z "$install_prog" && \ + func_fatal_help "you must specify an install program" + + test -n "$prev" && \ + func_fatal_help "the '$prev' option requires an argument" + + if test -n "$install_override_mode" && $no_mode; then + if $install_cp; then :; else + func_quote_for_eval "$install_override_mode" + func_append install_shared_prog " -m $func_quote_for_eval_result" + fi + fi + + if test -z "$files"; then + if test -z "$dest"; then + func_fatal_help "no file or destination specified" + else + func_fatal_help "you must specify a destination" + fi + fi + + # Strip any trailing slash from the destination. + func_stripname '' '/' "$dest" + dest=$func_stripname_result + + # Check to see that the destination is a directory. + test -d "$dest" && isdir=: + if $isdir; then + destdir=$dest + destname= + else + func_dirname_and_basename "$dest" "" "." + destdir=$func_dirname_result + destname=$func_basename_result + + # Not a directory, so check to see that there is only one file specified. + set dummy $files; shift + test "$#" -gt 1 && \ + func_fatal_help "'$dest' is not a directory" + fi + case $destdir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + for file in $files; do + case $file in + *.lo) ;; + *) + func_fatal_help "'$destdir' must be an absolute directory name" + ;; + esac + done + ;; + esac + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic=$magic + + staticlibs= + future_libdirs= + current_libdirs= + for file in $files; do + + # Do each installation. + case $file in + *.$libext) + # Do the static libraries later. + func_append staticlibs " $file" + ;; + + *.la) + func_resolve_sysroot "$file" + file=$func_resolve_sysroot_result + + # Check to see that this really is a libtool archive. + func_lalib_unsafe_p "$file" \ + || func_fatal_help "'$file' is not a valid libtool archive" + + library_names= + old_library= + relink_command= + func_source "$file" + + # Add the libdir to current_libdirs if it is the destination. + if test "X$destdir" = "X$libdir"; then + case "$current_libdirs " in + *" $libdir "*) ;; + *) func_append current_libdirs " $libdir" ;; + esac + else + # Note the libdir as a future libdir. + case "$future_libdirs " in + *" $libdir "*) ;; + *) func_append future_libdirs " $libdir" ;; + esac + fi + + func_dirname "$file" "/" "" + dir=$func_dirname_result + func_append dir "$objdir" + + if test -n "$relink_command"; then + # Determine the prefix the user has applied to our future dir. + inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` + + # Don't allow the user to place us outside of our expected + # location b/c this prevents finding dependent libraries that + # are installed to the same prefix. + # At present, this check doesn't affect windows .dll's that + # are installed into $libdir/../bin (currently, that works fine) + # but it's something to keep an eye on. + test "$inst_prefix_dir" = "$destdir" && \ + func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" + + if test -n "$inst_prefix_dir"; then + # Stick the inst_prefix_dir data into the link command. + relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` + else + relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` + fi + + func_warning "relinking '$file'" + func_show_eval "$relink_command" \ + 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' + fi + + # See the names of the shared library. + set dummy $library_names; shift + if test -n "$1"; then + realname=$1 + shift + + srcname=$realname + test -n "$relink_command" && srcname=${realname}T + + # Install the shared library and build the symlinks. + func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ + 'exit $?' + tstripme=$stripme + case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + case $realname in + *.dll.a) + tstripme= + ;; + esac + ;; + os2*) + case $realname in + *_dll.a) + tstripme= + ;; + esac + ;; + esac + if test -n "$tstripme" && test -n "$striplib"; then + func_show_eval "$striplib $destdir/$realname" 'exit $?' + fi + + if test "$#" -gt 0; then + # Delete the old symlinks, and create new ones. + # Try 'ln -sf' first, because the 'ln' binary might depend on + # the symlink we replace! Solaris /bin/ln does not understand -f, + # so we also need to try rm && ln -s. + for linkname + do + test "$linkname" != "$realname" \ + && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" + done + fi + + # Do each command in the postinstall commands. + lib=$destdir/$realname + func_execute_cmds "$postinstall_cmds" 'exit $?' + fi + + # Install the pseudo-library for information purposes. + func_basename "$file" + name=$func_basename_result + instname=$dir/${name}i + func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' + + # Maybe install the static library, too. + test -n "$old_library" && func_append staticlibs " $dir/$old_library" + ;; + + *.lo) + # Install (i.e. copy) a libtool object. + + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile=$destdir/$destname + else + func_basename "$file" + destfile=$func_basename_result + destfile=$destdir/$destfile + fi + + # Deduce the name of the destination old-style object file. + case $destfile in + *.lo) + func_lo2o "$destfile" + staticdest=$func_lo2o_result + ;; + *.$objext) + staticdest=$destfile + destfile= + ;; + *) + func_fatal_help "cannot copy a libtool object to '$destfile'" + ;; + esac + + # Install the libtool object if requested. + test -n "$destfile" && \ + func_show_eval "$install_prog $file $destfile" 'exit $?' + + # Install the old object if enabled. + if test yes = "$build_old_libs"; then + # Deduce the name of the old-style object file. + func_lo2o "$file" + staticobj=$func_lo2o_result + func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' + fi + exit $EXIT_SUCCESS + ;; + + *) + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile=$destdir/$destname + else + func_basename "$file" + destfile=$func_basename_result + destfile=$destdir/$destfile + fi + + # If the file is missing, and there is a .exe on the end, strip it + # because it is most likely a libtool script we actually want to + # install + stripped_ext= + case $file in + *.exe) + if test ! -f "$file"; then + func_stripname '' '.exe' "$file" + file=$func_stripname_result + stripped_ext=.exe + fi + ;; + esac + + # Do a test to see if this is really a libtool program. + case $host in + *cygwin* | *mingw*) + if func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + wrapper=$func_ltwrapper_scriptname_result + else + func_stripname '' '.exe' "$file" + wrapper=$func_stripname_result + fi + ;; + *) + wrapper=$file + ;; + esac + if func_ltwrapper_script_p "$wrapper"; then + notinst_deplibs= + relink_command= + + func_source "$wrapper" + + # Check the variables that should have been set. + test -z "$generated_by_libtool_version" && \ + func_fatal_error "invalid libtool wrapper script '$wrapper'" + + finalize=: + for lib in $notinst_deplibs; do + # Check to see that each library is installed. + libdir= + if test -f "$lib"; then + func_source "$lib" + fi + libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` + if test -n "$libdir" && test ! -f "$libfile"; then + func_warning "'$lib' has not been installed in '$libdir'" + finalize=false + fi + done + + relink_command= + func_source "$wrapper" + + outputname= + if test no = "$fast_install" && test -n "$relink_command"; then + $opt_dry_run || { + if $finalize; then + tmpdir=`func_mktempdir` + func_basename "$file$stripped_ext" + file=$func_basename_result + outputname=$tmpdir/$file + # Replace the output file specification. + relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` + + $opt_quiet || { + func_quote_for_expand "$relink_command" + eval "func_echo $func_quote_for_expand_result" + } + if eval "$relink_command"; then : + else + func_error "error: relink '$file' with the above command before installing it" + $opt_dry_run || ${RM}r "$tmpdir" + continue + fi + file=$outputname + else + func_warning "cannot relink '$file'" + fi + } + else + # Install the binary that we compiled earlier. + file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` + fi + fi + + # remove .exe since cygwin /usr/bin/install will append another + # one anyway + case $install_prog,$host in + */usr/bin/install*,*cygwin*) + case $file:$destfile in + *.exe:*.exe) + # this is ok + ;; + *.exe:*) + destfile=$destfile.exe + ;; + *:*.exe) + func_stripname '' '.exe' "$destfile" + destfile=$func_stripname_result + ;; + esac + ;; + esac + func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' + $opt_dry_run || if test -n "$outputname"; then + ${RM}r "$tmpdir" + fi + ;; + esac + done + + for file in $staticlibs; do + func_basename "$file" + name=$func_basename_result + + # Set up the ranlib parameters. + oldlib=$destdir/$name + func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 + tool_oldlib=$func_to_tool_file_result + + func_show_eval "$install_prog \$file \$oldlib" 'exit $?' + + if test -n "$stripme" && test -n "$old_striplib"; then + func_show_eval "$old_striplib $tool_oldlib" 'exit $?' + fi + + # Do each command in the postinstall commands. + func_execute_cmds "$old_postinstall_cmds" 'exit $?' + done + + test -n "$future_libdirs" && \ + func_warning "remember to run '$progname --finish$future_libdirs'" + + if test -n "$current_libdirs"; then + # Maybe just do a dry run. + $opt_dry_run && current_libdirs=" -n$current_libdirs" + exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' + else + exit $EXIT_SUCCESS + fi +} + +test install = "$opt_mode" && func_mode_install ${1+"$@"} + + +# func_generate_dlsyms outputname originator pic_p +# Extract symbols from dlprefiles and create ${outputname}S.o with +# a dlpreopen symbol table. +func_generate_dlsyms () +{ + $debug_cmd + + my_outputname=$1 + my_originator=$2 + my_pic_p=${3-false} + my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` + my_dlsyms= + + if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then + if test -n "$NM" && test -n "$global_symbol_pipe"; then + my_dlsyms=${my_outputname}S.c + else + func_error "not configured to extract global symbols from dlpreopened files" + fi + fi + + if test -n "$my_dlsyms"; then + case $my_dlsyms in + "") ;; + *.c) + # Discover the nlist of each of the dlfiles. + nlist=$output_objdir/$my_outputname.nm + + func_show_eval "$RM $nlist ${nlist}S ${nlist}T" + + # Parse the name list into a source file. + func_verbose "creating $output_objdir/$my_dlsyms" + + $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ +/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ +/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ + +#ifdef __cplusplus +extern \"C\" { +#endif + +#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) +#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" +#endif + +/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ +#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE +/* DATA imports from DLLs on WIN32 can't be const, because runtime + relocations are performed -- see ld's documentation on pseudo-relocs. */ +# define LT_DLSYM_CONST +#elif defined __osf__ +/* This system does not cope well with relocations in const data. */ +# define LT_DLSYM_CONST +#else +# define LT_DLSYM_CONST const +#endif + +#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) + +/* External symbol declarations for the compiler. */\ +" + + if test yes = "$dlself"; then + func_verbose "generating symbol list for '$output'" + + $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" + + # Add our own program objects to the symbol list. + progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` + for progfile in $progfiles; do + func_to_tool_file "$progfile" func_convert_file_msys_to_w32 + func_verbose "extracting global C symbols from '$func_to_tool_file_result'" + $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" + done + + if test -n "$exclude_expsyms"; then + $opt_dry_run || { + eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' + eval '$MV "$nlist"T "$nlist"' + } + fi + + if test -n "$export_symbols_regex"; then + $opt_dry_run || { + eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' + eval '$MV "$nlist"T "$nlist"' + } + fi + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + export_symbols=$output_objdir/$outputname.exp + $opt_dry_run || { + $RM $export_symbols + eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' + case $host in + *cygwin* | *mingw* | *cegcc* ) + eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' + eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' + ;; + esac + } + else + $opt_dry_run || { + eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' + eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' + eval '$MV "$nlist"T "$nlist"' + case $host in + *cygwin* | *mingw* | *cegcc* ) + eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' + eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' + ;; + esac + } + fi + fi + + for dlprefile in $dlprefiles; do + func_verbose "extracting global C symbols from '$dlprefile'" + func_basename "$dlprefile" + name=$func_basename_result + case $host in + *cygwin* | *mingw* | *cegcc* ) + # if an import library, we need to obtain dlname + if func_win32_import_lib_p "$dlprefile"; then + func_tr_sh "$dlprefile" + eval "curr_lafile=\$libfile_$func_tr_sh_result" + dlprefile_dlbasename= + if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then + # Use subshell, to avoid clobbering current variable values + dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` + if test -n "$dlprefile_dlname"; then + func_basename "$dlprefile_dlname" + dlprefile_dlbasename=$func_basename_result + else + # no lafile. user explicitly requested -dlpreopen . + $sharedlib_from_linklib_cmd "$dlprefile" + dlprefile_dlbasename=$sharedlib_from_linklib_result + fi + fi + $opt_dry_run || { + if test -n "$dlprefile_dlbasename"; then + eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' + else + func_warning "Could not compute DLL name from $name" + eval '$ECHO ": $name " >> "$nlist"' + fi + func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 + eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | + $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" + } + else # not an import lib + $opt_dry_run || { + eval '$ECHO ": $name " >> "$nlist"' + func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 + eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" + } + fi + ;; + *) + $opt_dry_run || { + eval '$ECHO ": $name " >> "$nlist"' + func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 + eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" + } + ;; + esac + done + + $opt_dry_run || { + # Make sure we have at least an empty file. + test -f "$nlist" || : > "$nlist" + + if test -n "$exclude_expsyms"; then + $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T + $MV "$nlist"T "$nlist" + fi + + # Try sorting and uniquifying the output. + if $GREP -v "^: " < "$nlist" | + if sort -k 3 /dev/null 2>&1; then + sort -k 3 + else + sort +2 + fi | + uniq > "$nlist"S; then + : + else + $GREP -v "^: " < "$nlist" > "$nlist"S + fi + + if test -f "$nlist"S; then + eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' + else + echo '/* NONE */' >> "$output_objdir/$my_dlsyms" + fi + + func_show_eval '$RM "${nlist}I"' + if test -n "$global_symbol_to_import"; then + eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' + fi + + echo >> "$output_objdir/$my_dlsyms" "\ + +/* The mapping between symbol names and symbols. */ +typedef struct { + const char *name; + void *address; +} lt_dlsymlist; +extern LT_DLSYM_CONST lt_dlsymlist +lt_${my_prefix}_LTX_preloaded_symbols[];\ +" + + if test -s "$nlist"I; then + echo >> "$output_objdir/$my_dlsyms" "\ +static void lt_syminit(void) +{ + LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; + for (; symbol->name; ++symbol) + {" + $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" + echo >> "$output_objdir/$my_dlsyms" "\ + } +}" + fi + echo >> "$output_objdir/$my_dlsyms" "\ +LT_DLSYM_CONST lt_dlsymlist +lt_${my_prefix}_LTX_preloaded_symbols[] = +{ {\"$my_originator\", (void *) 0}," + + if test -s "$nlist"I; then + echo >> "$output_objdir/$my_dlsyms" "\ + {\"@INIT@\", (void *) <_syminit}," + fi + + case $need_lib_prefix in + no) + eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" + ;; + *) + eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" + ;; + esac + echo >> "$output_objdir/$my_dlsyms" "\ + {0, (void *) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt_${my_prefix}_LTX_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif\ +" + } # !$opt_dry_run + + pic_flag_for_symtable= + case "$compile_command " in + *" -static "*) ;; + *) + case $host in + # compiling the symbol table file with pic_flag works around + # a FreeBSD bug that causes programs to crash when -lm is + # linked before any other PIC object. But we must not use + # pic_flag when linking with -static. The problem exists in + # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. + *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) + pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; + *-*-hpux*) + pic_flag_for_symtable=" $pic_flag" ;; + *) + $my_pic_p && pic_flag_for_symtable=" $pic_flag" + ;; + esac + ;; + esac + symtab_cflags= + for arg in $LTCFLAGS; do + case $arg in + -pie | -fpie | -fPIE) ;; + *) func_append symtab_cflags " $arg" ;; + esac + done + + # Now compile the dynamic symbol file. + func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' + + # Clean up the generated files. + func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' + + # Transform the symbol file into the correct name. + symfileobj=$output_objdir/${my_outputname}S.$objext + case $host in + *cygwin* | *mingw* | *cegcc* ) + if test -f "$output_objdir/$my_outputname.def"; then + compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` + finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` + else + compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` + finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` + fi + ;; + *) + compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` + finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` + ;; + esac + ;; + *) + func_fatal_error "unknown suffix for '$my_dlsyms'" + ;; + esac + else + # We keep going just in case the user didn't refer to + # lt_preloaded_symbols. The linker will fail if global_symbol_pipe + # really was required. + + # Nullify the symbol file. + compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` + finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` + fi +} + +# func_cygming_gnu_implib_p ARG +# This predicate returns with zero status (TRUE) if +# ARG is a GNU/binutils-style import library. Returns +# with nonzero status (FALSE) otherwise. +func_cygming_gnu_implib_p () +{ + $debug_cmd + + func_to_tool_file "$1" func_convert_file_msys_to_w32 + func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` + test -n "$func_cygming_gnu_implib_tmp" +} + +# func_cygming_ms_implib_p ARG +# This predicate returns with zero status (TRUE) if +# ARG is an MS-style import library. Returns +# with nonzero status (FALSE) otherwise. +func_cygming_ms_implib_p () +{ + $debug_cmd + + func_to_tool_file "$1" func_convert_file_msys_to_w32 + func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` + test -n "$func_cygming_ms_implib_tmp" +} + +# func_win32_libid arg +# return the library type of file 'arg' +# +# Need a lot of goo to handle *both* DLLs and import libs +# Has to be a shell function in order to 'eat' the argument +# that is supplied when $file_magic_command is called. +# Despite the name, also deal with 64 bit binaries. +func_win32_libid () +{ + $debug_cmd + + win32_libid_type=unknown + win32_fileres=`file -L $1 2>/dev/null` + case $win32_fileres in + *ar\ archive\ import\ library*) # definitely import + win32_libid_type="x86 archive import" + ;; + *ar\ archive*) # could be an import, or static + # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. + if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | + $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then + case $nm_interface in + "MS dumpbin") + if func_cygming_ms_implib_p "$1" || + func_cygming_gnu_implib_p "$1" + then + win32_nmres=import + else + win32_nmres= + fi + ;; + *) + func_to_tool_file "$1" func_convert_file_msys_to_w32 + win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | + $SED -n -e ' + 1,100{ + / I /{ + s|.*|import| + p + q + } + }'` + ;; + esac + case $win32_nmres in + import*) win32_libid_type="x86 archive import";; + *) win32_libid_type="x86 archive static";; + esac + fi + ;; + *DLL*) + win32_libid_type="x86 DLL" + ;; + *executable*) # but shell scripts are "executable" too... + case $win32_fileres in + *MS\ Windows\ PE\ Intel*) + win32_libid_type="x86 DLL" + ;; + esac + ;; + esac + $ECHO "$win32_libid_type" +} + +# func_cygming_dll_for_implib ARG +# +# Platform-specific function to extract the +# name of the DLL associated with the specified +# import library ARG. +# Invoked by eval'ing the libtool variable +# $sharedlib_from_linklib_cmd +# Result is available in the variable +# $sharedlib_from_linklib_result +func_cygming_dll_for_implib () +{ + $debug_cmd + + sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` +} + +# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs +# +# The is the core of a fallback implementation of a +# platform-specific function to extract the name of the +# DLL associated with the specified import library LIBNAME. +# +# SECTION_NAME is either .idata$6 or .idata$7, depending +# on the platform and compiler that created the implib. +# +# Echos the name of the DLL associated with the +# specified import library. +func_cygming_dll_for_implib_fallback_core () +{ + $debug_cmd + + match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` + $OBJDUMP -s --section "$1" "$2" 2>/dev/null | + $SED '/^Contents of section '"$match_literal"':/{ + # Place marker at beginning of archive member dllname section + s/.*/====MARK====/ + p + d + } + # These lines can sometimes be longer than 43 characters, but + # are always uninteresting + /:[ ]*file format pe[i]\{,1\}-/d + /^In archive [^:]*:/d + # Ensure marker is printed + /^====MARK====/p + # Remove all lines with less than 43 characters + /^.\{43\}/!d + # From remaining lines, remove first 43 characters + s/^.\{43\}//' | + $SED -n ' + # Join marker and all lines until next marker into a single line + /^====MARK====/ b para + H + $ b para + b + :para + x + s/\n//g + # Remove the marker + s/^====MARK====// + # Remove trailing dots and whitespace + s/[\. \t]*$// + # Print + /./p' | + # we now have a list, one entry per line, of the stringified + # contents of the appropriate section of all members of the + # archive that possess that section. Heuristic: eliminate + # all those that have a first or second character that is + # a '.' (that is, objdump's representation of an unprintable + # character.) This should work for all archives with less than + # 0x302f exports -- but will fail for DLLs whose name actually + # begins with a literal '.' or a single character followed by + # a '.'. + # + # Of those that remain, print the first one. + $SED -e '/^\./d;/^.\./d;q' +} + +# func_cygming_dll_for_implib_fallback ARG +# Platform-specific function to extract the +# name of the DLL associated with the specified +# import library ARG. +# +# This fallback implementation is for use when $DLLTOOL +# does not support the --identify-strict option. +# Invoked by eval'ing the libtool variable +# $sharedlib_from_linklib_cmd +# Result is available in the variable +# $sharedlib_from_linklib_result +func_cygming_dll_for_implib_fallback () +{ + $debug_cmd + + if func_cygming_gnu_implib_p "$1"; then + # binutils import library + sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` + elif func_cygming_ms_implib_p "$1"; then + # ms-generated import library + sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` + else + # unknown + sharedlib_from_linklib_result= + fi +} + + +# func_extract_an_archive dir oldlib +func_extract_an_archive () +{ + $debug_cmd + + f_ex_an_ar_dir=$1; shift + f_ex_an_ar_oldlib=$1 + if test yes = "$lock_old_archive_extraction"; then + lockfile=$f_ex_an_ar_oldlib.lock + until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do + func_echo "Waiting for $lockfile to be removed" + sleep 2 + done + fi + func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ + 'stat=$?; rm -f "$lockfile"; exit $stat' + if test yes = "$lock_old_archive_extraction"; then + $opt_dry_run || rm -f "$lockfile" + fi + if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then + : + else + func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" + fi +} + + +# func_extract_archives gentop oldlib ... +func_extract_archives () +{ + $debug_cmd + + my_gentop=$1; shift + my_oldlibs=${1+"$@"} + my_oldobjs= + my_xlib= + my_xabs= + my_xdir= + + for my_xlib in $my_oldlibs; do + # Extract the objects. + case $my_xlib in + [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; + *) my_xabs=`pwd`"/$my_xlib" ;; + esac + func_basename "$my_xlib" + my_xlib=$func_basename_result + my_xlib_u=$my_xlib + while :; do + case " $extracted_archives " in + *" $my_xlib_u "*) + func_arith $extracted_serial + 1 + extracted_serial=$func_arith_result + my_xlib_u=lt$extracted_serial-$my_xlib ;; + *) break ;; + esac + done + extracted_archives="$extracted_archives $my_xlib_u" + my_xdir=$my_gentop/$my_xlib_u + + func_mkdir_p "$my_xdir" + + case $host in + *-darwin*) + func_verbose "Extracting $my_xabs" + # Do not bother doing anything if just a dry run + $opt_dry_run || { + darwin_orig_dir=`pwd` + cd $my_xdir || exit $? + darwin_archive=$my_xabs + darwin_curdir=`pwd` + func_basename "$darwin_archive" + darwin_base_archive=$func_basename_result + darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` + if test -n "$darwin_arches"; then + darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` + darwin_arch= + func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" + for darwin_arch in $darwin_arches; do + func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" + $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" + cd "unfat-$$/$darwin_base_archive-$darwin_arch" + func_extract_an_archive "`pwd`" "$darwin_base_archive" + cd "$darwin_curdir" + $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" + done # $darwin_arches + ## Okay now we've a bunch of thin objects, gotta fatten them up :) + darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` + darwin_file= + darwin_files= + for darwin_file in $darwin_filelist; do + darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` + $LIPO -create -output "$darwin_file" $darwin_files + done # $darwin_filelist + $RM -rf unfat-$$ + cd "$darwin_orig_dir" + else + cd $darwin_orig_dir + func_extract_an_archive "$my_xdir" "$my_xabs" + fi # $darwin_arches + } # !$opt_dry_run + ;; + *) + func_extract_an_archive "$my_xdir" "$my_xabs" + ;; + esac + my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` + done + + func_extract_archives_result=$my_oldobjs +} + + +# func_emit_wrapper [arg=no] +# +# Emit a libtool wrapper script on stdout. +# Don't directly open a file because we may want to +# incorporate the script contents within a cygwin/mingw +# wrapper executable. Must ONLY be called from within +# func_mode_link because it depends on a number of variables +# set therein. +# +# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR +# variable will take. If 'yes', then the emitted script +# will assume that the directory where it is stored is +# the $objdir directory. This is a cygwin/mingw-specific +# behavior. +func_emit_wrapper () +{ + func_emit_wrapper_arg1=${1-no} + + $ECHO "\ +#! $SHELL + +# $output - temporary wrapper script for $objdir/$outputname +# Generated by $PROGRAM (GNU $PACKAGE) $VERSION +# +# The $output program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +sed_quote_subst='$sed_quote_subst' + +# Be Bourne compatible +if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command=\"$relink_command\" + +# This environment variable determines our operation mode. +if test \"\$libtool_install_magic\" = \"$magic\"; then + # install mode needs the following variables: + generated_by_libtool_version='$macro_version' + notinst_deplibs='$notinst_deplibs' +else + # When we are sourced in execute mode, \$file and \$ECHO are already set. + if test \"\$libtool_execute_magic\" != \"$magic\"; then + file=\"\$0\"" + + qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` + $ECHO "\ + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +\$1 +_LTECHO_EOF' +} + ECHO=\"$qECHO\" + fi + +# Very basic option parsing. These options are (a) specific to +# the libtool wrapper, (b) are identical between the wrapper +# /script/ and the wrapper /executable/ that is used only on +# windows platforms, and (c) all begin with the string "--lt-" +# (application programs are unlikely to have options that match +# this pattern). +# +# There are only two supported options: --lt-debug and +# --lt-dump-script. There is, deliberately, no --lt-help. +# +# The first argument to this parsing function should be the +# script's $0 value, followed by "$@". +lt_option_debug= +func_parse_lt_options () +{ + lt_script_arg0=\$0 + shift + for lt_opt + do + case \"\$lt_opt\" in + --lt-debug) lt_option_debug=1 ;; + --lt-dump-script) + lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` + test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. + lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` + cat \"\$lt_dump_D/\$lt_dump_F\" + exit 0 + ;; + --lt-*) + \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 + exit 1 + ;; + esac + done + + # Print the debug banner immediately: + if test -n \"\$lt_option_debug\"; then + echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 + fi +} + +# Used when --lt-debug. Prints its arguments to stdout +# (redirection is the responsibility of the caller) +func_lt_dump_args () +{ + lt_dump_args_N=1; + for lt_arg + do + \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" + lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` + done +} + +# Core function for launching the target application +func_exec_program_core () +{ +" + case $host in + # Backslashes separate directories on plain windows + *-*-mingw | *-*-os2* | *-cegcc*) + $ECHO "\ + if test -n \"\$lt_option_debug\"; then + \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 + func_lt_dump_args \${1+\"\$@\"} 1>&2 + fi + exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} +" + ;; + + *) + $ECHO "\ + if test -n \"\$lt_option_debug\"; then + \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 + func_lt_dump_args \${1+\"\$@\"} 1>&2 + fi + exec \"\$progdir/\$program\" \${1+\"\$@\"} +" + ;; + esac + $ECHO "\ + \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 + exit 1 +} + +# A function to encapsulate launching the target application +# Strips options in the --lt-* namespace from \$@ and +# launches target application with the remaining arguments. +func_exec_program () +{ + case \" \$* \" in + *\\ --lt-*) + for lt_wr_arg + do + case \$lt_wr_arg in + --lt-*) ;; + *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; + esac + shift + done ;; + esac + func_exec_program_core \${1+\"\$@\"} +} + + # Parse options + func_parse_lt_options \"\$0\" \${1+\"\$@\"} + + # Find the directory that this script lives in. + thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` + test \"x\$thisdir\" = \"x\$file\" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` + while test -n \"\$file\"; do + destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` + + # If there was a directory component, then change thisdir. + if test \"x\$destdir\" != \"x\$file\"; then + case \"\$destdir\" in + [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; + *) thisdir=\"\$thisdir/\$destdir\" ;; + esac + fi + + file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` + file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` + done + + # Usually 'no', except on cygwin/mingw when embedded into + # the cwrapper. + WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 + if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then + # special case for '.' + if test \"\$thisdir\" = \".\"; then + thisdir=\`pwd\` + fi + # remove .libs from thisdir + case \"\$thisdir\" in + *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; + $objdir ) thisdir=. ;; + esac + fi + + # Try to get the absolute directory name. + absdir=\`cd \"\$thisdir\" && pwd\` + test -n \"\$absdir\" && thisdir=\"\$absdir\" +" + + if test yes = "$fast_install"; then + $ECHO "\ + program=lt-'$outputname'$exeext + progdir=\"\$thisdir/$objdir\" + + if test ! -f \"\$progdir/\$program\" || + { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ + test \"X\$file\" != \"X\$progdir/\$program\"; }; then + + file=\"\$\$-\$program\" + + if test ! -d \"\$progdir\"; then + $MKDIR \"\$progdir\" + else + $RM \"\$progdir/\$file\" + fi" + + $ECHO "\ + + # relink executable if necessary + if test -n \"\$relink_command\"; then + if relink_command_output=\`eval \$relink_command 2>&1\`; then : + else + \$ECHO \"\$relink_command_output\" >&2 + $RM \"\$progdir/\$file\" + exit 1 + fi + fi + + $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || + { $RM \"\$progdir/\$program\"; + $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } + $RM \"\$progdir/\$file\" + fi" + else + $ECHO "\ + program='$outputname' + progdir=\"\$thisdir/$objdir\" +" + fi + + $ECHO "\ + + if test -f \"\$progdir/\$program\"; then" + + # fixup the dll searchpath if we need to. + # + # Fix the DLL searchpath if we need to. Do this before prepending + # to shlibpath, because on Windows, both are PATH and uninstalled + # libraries must come first. + if test -n "$dllsearchpath"; then + $ECHO "\ + # Add the dll search path components to the executable PATH + PATH=$dllsearchpath:\$PATH +" + fi + + # Export our shlibpath_var if we have one. + if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then + $ECHO "\ + # Add our own library path to $shlibpath_var + $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" + + # Some systems cannot cope with colon-terminated $shlibpath_var + # The second colon is a workaround for a bug in BeOS R4 sed + $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` + + export $shlibpath_var +" + fi + + $ECHO "\ + if test \"\$libtool_execute_magic\" != \"$magic\"; then + # Run the actual program with our arguments. + func_exec_program \${1+\"\$@\"} + fi + else + # The program doesn't exist. + \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 + \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 + \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 + exit 1 + fi +fi\ +" +} + + +# func_emit_cwrapperexe_src +# emit the source code for a wrapper executable on stdout +# Must ONLY be called from within func_mode_link because +# it depends on a number of variable set therein. +func_emit_cwrapperexe_src () +{ + cat < +#include +#ifdef _MSC_VER +# include +# include +# include +#else +# include +# include +# ifdef __CYGWIN__ +# include +# endif +#endif +#include +#include +#include +#include +#include +#include +#include +#include + +#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) + +/* declarations of non-ANSI functions */ +#if defined __MINGW32__ +# ifdef __STRICT_ANSI__ +int _putenv (const char *); +# endif +#elif defined __CYGWIN__ +# ifdef __STRICT_ANSI__ +char *realpath (const char *, char *); +int putenv (char *); +int setenv (const char *, const char *, int); +# endif +/* #elif defined other_platform || defined ... */ +#endif + +/* portability defines, excluding path handling macros */ +#if defined _MSC_VER +# define setmode _setmode +# define stat _stat +# define chmod _chmod +# define getcwd _getcwd +# define putenv _putenv +# define S_IXUSR _S_IEXEC +#elif defined __MINGW32__ +# define setmode _setmode +# define stat _stat +# define chmod _chmod +# define getcwd _getcwd +# define putenv _putenv +#elif defined __CYGWIN__ +# define HAVE_SETENV +# define FOPEN_WB "wb" +/* #elif defined other platforms ... */ +#endif + +#if defined PATH_MAX +# define LT_PATHMAX PATH_MAX +#elif defined MAXPATHLEN +# define LT_PATHMAX MAXPATHLEN +#else +# define LT_PATHMAX 1024 +#endif + +#ifndef S_IXOTH +# define S_IXOTH 0 +#endif +#ifndef S_IXGRP +# define S_IXGRP 0 +#endif + +/* path handling portability macros */ +#ifndef DIR_SEPARATOR +# define DIR_SEPARATOR '/' +# define PATH_SEPARATOR ':' +#endif + +#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ + defined __OS2__ +# define HAVE_DOS_BASED_FILE_SYSTEM +# define FOPEN_WB "wb" +# ifndef DIR_SEPARATOR_2 +# define DIR_SEPARATOR_2 '\\' +# endif +# ifndef PATH_SEPARATOR_2 +# define PATH_SEPARATOR_2 ';' +# endif +#endif + +#ifndef DIR_SEPARATOR_2 +# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) +#else /* DIR_SEPARATOR_2 */ +# define IS_DIR_SEPARATOR(ch) \ + (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) +#endif /* DIR_SEPARATOR_2 */ + +#ifndef PATH_SEPARATOR_2 +# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) +#else /* PATH_SEPARATOR_2 */ +# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) +#endif /* PATH_SEPARATOR_2 */ + +#ifndef FOPEN_WB +# define FOPEN_WB "w" +#endif +#ifndef _O_BINARY +# define _O_BINARY 0 +#endif + +#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) +#define XFREE(stale) do { \ + if (stale) { free (stale); stale = 0; } \ +} while (0) + +#if defined LT_DEBUGWRAPPER +static int lt_debug = 1; +#else +static int lt_debug = 0; +#endif + +const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ + +void *xmalloc (size_t num); +char *xstrdup (const char *string); +const char *base_name (const char *name); +char *find_executable (const char *wrapper); +char *chase_symlinks (const char *pathspec); +int make_executable (const char *path); +int check_executable (const char *path); +char *strendzap (char *str, const char *pat); +void lt_debugprintf (const char *file, int line, const char *fmt, ...); +void lt_fatal (const char *file, int line, const char *message, ...); +static const char *nonnull (const char *s); +static const char *nonempty (const char *s); +void lt_setenv (const char *name, const char *value); +char *lt_extend_str (const char *orig_value, const char *add, int to_end); +void lt_update_exe_path (const char *name, const char *value); +void lt_update_lib_path (const char *name, const char *value); +char **prepare_spawn (char **argv); +void lt_dump_script (FILE *f); +EOF + + cat <= 0) + && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) + return 1; + else + return 0; +} + +int +make_executable (const char *path) +{ + int rval = 0; + struct stat st; + + lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", + nonempty (path)); + if ((!path) || (!*path)) + return 0; + + if (stat (path, &st) >= 0) + { + rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); + } + return rval; +} + +/* Searches for the full path of the wrapper. Returns + newly allocated full path name if found, NULL otherwise + Does not chase symlinks, even on platforms that support them. +*/ +char * +find_executable (const char *wrapper) +{ + int has_slash = 0; + const char *p; + const char *p_next; + /* static buffer for getcwd */ + char tmp[LT_PATHMAX + 1]; + size_t tmp_len; + char *concat_name; + + lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", + nonempty (wrapper)); + + if ((wrapper == NULL) || (*wrapper == '\0')) + return NULL; + + /* Absolute path? */ +#if defined HAVE_DOS_BASED_FILE_SYSTEM + if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') + { + concat_name = xstrdup (wrapper); + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + } + else + { +#endif + if (IS_DIR_SEPARATOR (wrapper[0])) + { + concat_name = xstrdup (wrapper); + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + } +#if defined HAVE_DOS_BASED_FILE_SYSTEM + } +#endif + + for (p = wrapper; *p; p++) + if (*p == '/') + { + has_slash = 1; + break; + } + if (!has_slash) + { + /* no slashes; search PATH */ + const char *path = getenv ("PATH"); + if (path != NULL) + { + for (p = path; *p; p = p_next) + { + const char *q; + size_t p_len; + for (q = p; *q; q++) + if (IS_PATH_SEPARATOR (*q)) + break; + p_len = (size_t) (q - p); + p_next = (*q == '\0' ? q : q + 1); + if (p_len == 0) + { + /* empty path: current directory */ + if (getcwd (tmp, LT_PATHMAX) == NULL) + lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", + nonnull (strerror (errno))); + tmp_len = strlen (tmp); + concat_name = + XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); + memcpy (concat_name, tmp, tmp_len); + concat_name[tmp_len] = '/'; + strcpy (concat_name + tmp_len + 1, wrapper); + } + else + { + concat_name = + XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); + memcpy (concat_name, p, p_len); + concat_name[p_len] = '/'; + strcpy (concat_name + p_len + 1, wrapper); + } + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + } + } + /* not found in PATH; assume curdir */ + } + /* Relative path | not found in path: prepend cwd */ + if (getcwd (tmp, LT_PATHMAX) == NULL) + lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", + nonnull (strerror (errno))); + tmp_len = strlen (tmp); + concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); + memcpy (concat_name, tmp, tmp_len); + concat_name[tmp_len] = '/'; + strcpy (concat_name + tmp_len + 1, wrapper); + + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + return NULL; +} + +char * +chase_symlinks (const char *pathspec) +{ +#ifndef S_ISLNK + return xstrdup (pathspec); +#else + char buf[LT_PATHMAX]; + struct stat s; + char *tmp_pathspec = xstrdup (pathspec); + char *p; + int has_symlinks = 0; + while (strlen (tmp_pathspec) && !has_symlinks) + { + lt_debugprintf (__FILE__, __LINE__, + "checking path component for symlinks: %s\n", + tmp_pathspec); + if (lstat (tmp_pathspec, &s) == 0) + { + if (S_ISLNK (s.st_mode) != 0) + { + has_symlinks = 1; + break; + } + + /* search backwards for last DIR_SEPARATOR */ + p = tmp_pathspec + strlen (tmp_pathspec) - 1; + while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) + p--; + if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) + { + /* no more DIR_SEPARATORS left */ + break; + } + *p = '\0'; + } + else + { + lt_fatal (__FILE__, __LINE__, + "error accessing file \"%s\": %s", + tmp_pathspec, nonnull (strerror (errno))); + } + } + XFREE (tmp_pathspec); + + if (!has_symlinks) + { + return xstrdup (pathspec); + } + + tmp_pathspec = realpath (pathspec, buf); + if (tmp_pathspec == 0) + { + lt_fatal (__FILE__, __LINE__, + "could not follow symlinks for %s", pathspec); + } + return xstrdup (tmp_pathspec); +#endif +} + +char * +strendzap (char *str, const char *pat) +{ + size_t len, patlen; + + assert (str != NULL); + assert (pat != NULL); + + len = strlen (str); + patlen = strlen (pat); + + if (patlen <= len) + { + str += len - patlen; + if (STREQ (str, pat)) + *str = '\0'; + } + return str; +} + +void +lt_debugprintf (const char *file, int line, const char *fmt, ...) +{ + va_list args; + if (lt_debug) + { + (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); + va_start (args, fmt); + (void) vfprintf (stderr, fmt, args); + va_end (args); + } +} + +static void +lt_error_core (int exit_status, const char *file, + int line, const char *mode, + const char *message, va_list ap) +{ + fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); + vfprintf (stderr, message, ap); + fprintf (stderr, ".\n"); + + if (exit_status >= 0) + exit (exit_status); +} + +void +lt_fatal (const char *file, int line, const char *message, ...) +{ + va_list ap; + va_start (ap, message); + lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); + va_end (ap); +} + +static const char * +nonnull (const char *s) +{ + return s ? s : "(null)"; +} + +static const char * +nonempty (const char *s) +{ + return (s && !*s) ? "(empty)" : nonnull (s); +} + +void +lt_setenv (const char *name, const char *value) +{ + lt_debugprintf (__FILE__, __LINE__, + "(lt_setenv) setting '%s' to '%s'\n", + nonnull (name), nonnull (value)); + { +#ifdef HAVE_SETENV + /* always make a copy, for consistency with !HAVE_SETENV */ + char *str = xstrdup (value); + setenv (name, str, 1); +#else + size_t len = strlen (name) + 1 + strlen (value) + 1; + char *str = XMALLOC (char, len); + sprintf (str, "%s=%s", name, value); + if (putenv (str) != EXIT_SUCCESS) + { + XFREE (str); + } +#endif + } +} + +char * +lt_extend_str (const char *orig_value, const char *add, int to_end) +{ + char *new_value; + if (orig_value && *orig_value) + { + size_t orig_value_len = strlen (orig_value); + size_t add_len = strlen (add); + new_value = XMALLOC (char, add_len + orig_value_len + 1); + if (to_end) + { + strcpy (new_value, orig_value); + strcpy (new_value + orig_value_len, add); + } + else + { + strcpy (new_value, add); + strcpy (new_value + add_len, orig_value); + } + } + else + { + new_value = xstrdup (add); + } + return new_value; +} + +void +lt_update_exe_path (const char *name, const char *value) +{ + lt_debugprintf (__FILE__, __LINE__, + "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", + nonnull (name), nonnull (value)); + + if (name && *name && value && *value) + { + char *new_value = lt_extend_str (getenv (name), value, 0); + /* some systems can't cope with a ':'-terminated path #' */ + size_t len = strlen (new_value); + while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) + { + new_value[--len] = '\0'; + } + lt_setenv (name, new_value); + XFREE (new_value); + } +} + +void +lt_update_lib_path (const char *name, const char *value) +{ + lt_debugprintf (__FILE__, __LINE__, + "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", + nonnull (name), nonnull (value)); + + if (name && *name && value && *value) + { + char *new_value = lt_extend_str (getenv (name), value, 0); + lt_setenv (name, new_value); + XFREE (new_value); + } +} + +EOF + case $host_os in + mingw*) + cat <<"EOF" + +/* Prepares an argument vector before calling spawn(). + Note that spawn() does not by itself call the command interpreter + (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : + ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&v); + v.dwPlatformId == VER_PLATFORM_WIN32_NT; + }) ? "cmd.exe" : "command.com"). + Instead it simply concatenates the arguments, separated by ' ', and calls + CreateProcess(). We must quote the arguments since Win32 CreateProcess() + interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a + special way: + - Space and tab are interpreted as delimiters. They are not treated as + delimiters if they are surrounded by double quotes: "...". + - Unescaped double quotes are removed from the input. Their only effect is + that within double quotes, space and tab are treated like normal + characters. + - Backslashes not followed by double quotes are not special. + - But 2*n+1 backslashes followed by a double quote become + n backslashes followed by a double quote (n >= 0): + \" -> " + \\\" -> \" + \\\\\" -> \\" + */ +#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" +#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" +char ** +prepare_spawn (char **argv) +{ + size_t argc; + char **new_argv; + size_t i; + + /* Count number of arguments. */ + for (argc = 0; argv[argc] != NULL; argc++) + ; + + /* Allocate new argument vector. */ + new_argv = XMALLOC (char *, argc + 1); + + /* Put quoted arguments into the new argument vector. */ + for (i = 0; i < argc; i++) + { + const char *string = argv[i]; + + if (string[0] == '\0') + new_argv[i] = xstrdup ("\"\""); + else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) + { + int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); + size_t length; + unsigned int backslashes; + const char *s; + char *quoted_string; + char *p; + + length = 0; + backslashes = 0; + if (quote_around) + length++; + for (s = string; *s != '\0'; s++) + { + char c = *s; + if (c == '"') + length += backslashes + 1; + length++; + if (c == '\\') + backslashes++; + else + backslashes = 0; + } + if (quote_around) + length += backslashes + 1; + + quoted_string = XMALLOC (char, length + 1); + + p = quoted_string; + backslashes = 0; + if (quote_around) + *p++ = '"'; + for (s = string; *s != '\0'; s++) + { + char c = *s; + if (c == '"') + { + unsigned int j; + for (j = backslashes + 1; j > 0; j--) + *p++ = '\\'; + } + *p++ = c; + if (c == '\\') + backslashes++; + else + backslashes = 0; + } + if (quote_around) + { + unsigned int j; + for (j = backslashes; j > 0; j--) + *p++ = '\\'; + *p++ = '"'; + } + *p = '\0'; + + new_argv[i] = quoted_string; + } + else + new_argv[i] = (char *) string; + } + new_argv[argc] = NULL; + + return new_argv; +} +EOF + ;; + esac + + cat <<"EOF" +void lt_dump_script (FILE* f) +{ +EOF + func_emit_wrapper yes | + $SED -n -e ' +s/^\(.\{79\}\)\(..*\)/\1\ +\2/ +h +s/\([\\"]\)/\\\1/g +s/$/\\n/ +s/\([^\n]*\).*/ fputs ("\1", f);/p +g +D' + cat <<"EOF" +} +EOF +} +# end: func_emit_cwrapperexe_src + +# func_win32_import_lib_p ARG +# True if ARG is an import lib, as indicated by $file_magic_cmd +func_win32_import_lib_p () +{ + $debug_cmd + + case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in + *import*) : ;; + *) false ;; + esac +} + +# func_suncc_cstd_abi +# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! +# Several compiler flags select an ABI that is incompatible with the +# Cstd library. Avoid specifying it if any are in CXXFLAGS. +func_suncc_cstd_abi () +{ + $debug_cmd + + case " $compile_command " in + *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) + suncc_use_cstd_abi=no + ;; + *) + suncc_use_cstd_abi=yes + ;; + esac +} + +# func_mode_link arg... +func_mode_link () +{ + $debug_cmd + + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + # It is impossible to link a dll without this setting, and + # we shouldn't force the makefile maintainer to figure out + # what system we are compiling for in order to pass an extra + # flag for every libtool invocation. + # allow_undefined=no + + # FIXME: Unfortunately, there are problems with the above when trying + # to make a dll that has undefined symbols, in which case not + # even a static library is built. For now, we need to specify + # -no-undefined on the libtool link line when we can be certain + # that all symbols are satisfied, otherwise we get a static library. + allow_undefined=yes + ;; + *) + allow_undefined=yes + ;; + esac + libtool_args=$nonopt + base_compile="$nonopt $@" + compile_command=$nonopt + finalize_command=$nonopt + + compile_rpath= + finalize_rpath= + compile_shlibpath= + finalize_shlibpath= + convenience= + old_convenience= + deplibs= + old_deplibs= + compiler_flags= + linker_flags= + dllsearchpath= + lib_search_path=`pwd` + inst_prefix_dir= + new_inherited_linker_flags= + + avoid_version=no + bindir= + dlfiles= + dlprefiles= + dlself=no + export_dynamic=no + export_symbols= + export_symbols_regex= + generated= + libobjs= + ltlibs= + module=no + no_install=no + objs= + os2dllname= + non_pic_objects= + precious_files_regex= + prefer_static_libs=no + preload=false + prev= + prevarg= + release= + rpath= + xrpath= + perm_rpath= + temp_rpath= + thread_safe=no + vinfo= + vinfo_number=no + weak_libs= + single_module=$wl-single_module + func_infer_tag $base_compile + + # We need to know -static, to get the right output filenames. + for arg + do + case $arg in + -shared) + test yes != "$build_libtool_libs" \ + && func_fatal_configuration "cannot build a shared library" + build_old_libs=no + break + ;; + -all-static | -static | -static-uninstalled-libs | -static-libtool-libs) + case $arg in + -all-static | -static) + if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then + func_warning "complete static linking is impossible in this configuration" + fi + if test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=yes + ;; + -static-uninstalled-libs) + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=built + ;; + -static-libtool-libs) + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=yes + ;; + esac + build_libtool_libs=no + build_old_libs=yes + break + ;; + esac + done + + # See if our shared archives depend on static archives. + test -n "$old_archive_from_new_cmds" && build_old_libs=yes + + # Go through the arguments, transforming them on the way. + while test "$#" -gt 0; do + arg=$1 + shift + func_quote_for_eval "$arg" + qarg=$func_quote_for_eval_unquoted_result + func_append libtool_args " $func_quote_for_eval_result" + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case $prev in + output) + func_append compile_command " @OUTPUT@" + func_append finalize_command " @OUTPUT@" + ;; + esac + + case $prev in + bindir) + bindir=$arg + prev= + continue + ;; + dlfiles|dlprefiles) + $preload || { + # Add the symbol object into the linking commands. + func_append compile_command " @SYMFILE@" + func_append finalize_command " @SYMFILE@" + preload=: + } + case $arg in + *.la | *.lo) ;; # We handle these cases below. + force) + if test no = "$dlself"; then + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + self) + if test dlprefiles = "$prev"; then + dlself=yes + elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then + dlself=yes + else + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + *) + if test dlfiles = "$prev"; then + func_append dlfiles " $arg" + else + func_append dlprefiles " $arg" + fi + prev= + continue + ;; + esac + ;; + expsyms) + export_symbols=$arg + test -f "$arg" \ + || func_fatal_error "symbol file '$arg' does not exist" + prev= + continue + ;; + expsyms_regex) + export_symbols_regex=$arg + prev= + continue + ;; + framework) + case $host in + *-*-darwin*) + case "$deplibs " in + *" $qarg.ltframework "*) ;; + *) func_append deplibs " $qarg.ltframework" # this is fixed later + ;; + esac + ;; + esac + prev= + continue + ;; + inst_prefix) + inst_prefix_dir=$arg + prev= + continue + ;; + mllvm) + # Clang does not use LLVM to link, so we can simply discard any + # '-mllvm $arg' options when doing the link step. + prev= + continue + ;; + objectlist) + if test -f "$arg"; then + save_arg=$arg + moreargs= + for fil in `cat "$save_arg"` + do +# func_append moreargs " $fil" + arg=$fil + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if func_lalib_unsafe_p "$arg"; then + pic_object= + non_pic_object= + + # Read the .lo file + func_source "$arg" + + if test -z "$pic_object" || + test -z "$non_pic_object" || + test none = "$pic_object" && + test none = "$non_pic_object"; then + func_fatal_error "cannot find name of object for '$arg'" + fi + + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir=$func_dirname_result + + if test none != "$pic_object"; then + # Prepend the subdirectory the object is found in. + pic_object=$xdir$pic_object + + if test dlfiles = "$prev"; then + if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then + func_append dlfiles " $pic_object" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + # CHECK ME: I think I busted this. -Ossama + if test dlprefiles = "$prev"; then + # Preload the old-style object. + func_append dlprefiles " $pic_object" + prev= + fi + + # A PIC object. + func_append libobjs " $pic_object" + arg=$pic_object + fi + + # Non-PIC object. + if test none != "$non_pic_object"; then + # Prepend the subdirectory the object is found in. + non_pic_object=$xdir$non_pic_object + + # A standard non-PIC object + func_append non_pic_objects " $non_pic_object" + if test -z "$pic_object" || test none = "$pic_object"; then + arg=$non_pic_object + fi + else + # If the PIC object exists, use it instead. + # $xdir was prepended to $pic_object above. + non_pic_object=$pic_object + func_append non_pic_objects " $non_pic_object" + fi + else + # Only an error if not doing a dry-run. + if $opt_dry_run; then + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir=$func_dirname_result + + func_lo2o "$arg" + pic_object=$xdir$objdir/$func_lo2o_result + non_pic_object=$xdir$func_lo2o_result + func_append libobjs " $pic_object" + func_append non_pic_objects " $non_pic_object" + else + func_fatal_error "'$arg' is not a valid libtool object" + fi + fi + done + else + func_fatal_error "link input file '$arg' does not exist" + fi + arg=$save_arg + prev= + continue + ;; + os2dllname) + os2dllname=$arg + prev= + continue + ;; + precious_regex) + precious_files_regex=$arg + prev= + continue + ;; + release) + release=-$arg + prev= + continue + ;; + rpath | xrpath) + # We need an absolute path. + case $arg in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + func_fatal_error "only absolute run-paths are allowed" + ;; + esac + if test rpath = "$prev"; then + case "$rpath " in + *" $arg "*) ;; + *) func_append rpath " $arg" ;; + esac + else + case "$xrpath " in + *" $arg "*) ;; + *) func_append xrpath " $arg" ;; + esac + fi + prev= + continue + ;; + shrext) + shrext_cmds=$arg + prev= + continue + ;; + weak) + func_append weak_libs " $arg" + prev= + continue + ;; + xcclinker) + func_append linker_flags " $qarg" + func_append compiler_flags " $qarg" + prev= + func_append compile_command " $qarg" + func_append finalize_command " $qarg" + continue + ;; + xcompiler) + func_append compiler_flags " $qarg" + prev= + func_append compile_command " $qarg" + func_append finalize_command " $qarg" + continue + ;; + xlinker) + func_append linker_flags " $qarg" + func_append compiler_flags " $wl$qarg" + prev= + func_append compile_command " $wl$qarg" + func_append finalize_command " $wl$qarg" + continue + ;; + *) + eval "$prev=\"\$arg\"" + prev= + continue + ;; + esac + fi # test -n "$prev" + + prevarg=$arg + + case $arg in + -all-static | -static) + if test -n "$link_static_flag"; then + # See comment for -static flag below, for more details. + func_append compile_command " $link_static_flag" + func_append finalize_command " $link_static_flag" + fi + continue + ;; + + -allow-undefined) + # FIXME: remove this flag sometime in the future. + func_fatal_error "'-allow-undefined' must not be used because it is the default" + ;; + + -avoid-version) + avoid_version=yes + continue + ;; + + -bindir) + prev=bindir + continue + ;; + + -dlopen) + prev=dlfiles + continue + ;; + + -dlpreopen) + prev=dlprefiles + continue + ;; + + -export-dynamic) + export_dynamic=yes + continue + ;; + + -export-symbols | -export-symbols-regex) + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + func_fatal_error "more than one -exported-symbols argument is not allowed" + fi + if test X-export-symbols = "X$arg"; then + prev=expsyms + else + prev=expsyms_regex + fi + continue + ;; + + -framework) + prev=framework + continue + ;; + + -inst-prefix-dir) + prev=inst_prefix + continue + ;; + + # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* + # so, if we see these flags be careful not to treat them like -L + -L[A-Z][A-Z]*:*) + case $with_gcc/$host in + no/*-*-irix* | /*-*-irix*) + func_append compile_command " $arg" + func_append finalize_command " $arg" + ;; + esac + continue + ;; + + -L*) + func_stripname "-L" '' "$arg" + if test -z "$func_stripname_result"; then + if test "$#" -gt 0; then + func_fatal_error "require no space between '-L' and '$1'" + else + func_fatal_error "need path for '-L' option" + fi + fi + func_resolve_sysroot "$func_stripname_result" + dir=$func_resolve_sysroot_result + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + absdir=`cd "$dir" && pwd` + test -z "$absdir" && \ + func_fatal_error "cannot determine absolute directory name of '$dir'" + dir=$absdir + ;; + esac + case "$deplibs " in + *" -L$dir "* | *" $arg "*) + # Will only happen for absolute or sysroot arguments + ;; + *) + # Preserve sysroot, but never include relative directories + case $dir in + [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; + *) func_append deplibs " -L$dir" ;; + esac + func_append lib_search_path " $dir" + ;; + esac + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` + case :$dllsearchpath: in + *":$dir:"*) ;; + ::) dllsearchpath=$dir;; + *) func_append dllsearchpath ":$dir";; + esac + case :$dllsearchpath: in + *":$testbindir:"*) ;; + ::) dllsearchpath=$testbindir;; + *) func_append dllsearchpath ":$testbindir";; + esac + ;; + esac + continue + ;; + + -l*) + if test X-lc = "X$arg" || test X-lm = "X$arg"; then + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) + # These systems don't actually have a C or math library (as such) + continue + ;; + *-*-os2*) + # These systems don't actually have a C library (as such) + test X-lc = "X$arg" && continue + ;; + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) + # Do not include libc due to us having libc/libc_r. + test X-lc = "X$arg" && continue + ;; + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C and math libraries are in the System framework + func_append deplibs " System.ltframework" + continue + ;; + *-*-sco3.2v5* | *-*-sco5v6*) + # Causes problems with __ctype + test X-lc = "X$arg" && continue + ;; + *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) + # Compiler inserts libc in the correct place for threads to work + test X-lc = "X$arg" && continue + ;; + esac + elif test X-lc_r = "X$arg"; then + case $host in + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) + # Do not include libc_r directly, use -pthread flag. + continue + ;; + esac + fi + func_append deplibs " $arg" + continue + ;; + + -mllvm) + prev=mllvm + continue + ;; + + -module) + module=yes + continue + ;; + + # Tru64 UNIX uses -model [arg] to determine the layout of C++ + # classes, name mangling, and exception handling. + # Darwin uses the -arch flag to determine output architecture. + -model|-arch|-isysroot|--sysroot) + func_append compiler_flags " $arg" + func_append compile_command " $arg" + func_append finalize_command " $arg" + prev=xcompiler + continue + ;; + + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ + |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) + func_append compiler_flags " $arg" + func_append compile_command " $arg" + func_append finalize_command " $arg" + case "$new_inherited_linker_flags " in + *" $arg "*) ;; + * ) func_append new_inherited_linker_flags " $arg" ;; + esac + continue + ;; + + -multi_module) + single_module=$wl-multi_module + continue + ;; + + -no-fast-install) + fast_install=no + continue + ;; + + -no-install) + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) + # The PATH hackery in wrapper scripts is required on Windows + # and Darwin in order for the loader to find any dlls it needs. + func_warning "'-no-install' is ignored for $host" + func_warning "assuming '-no-fast-install' instead" + fast_install=no + ;; + *) no_install=yes ;; + esac + continue + ;; + + -no-undefined) + allow_undefined=no + continue + ;; + + -objectlist) + prev=objectlist + continue + ;; + + -os2dllname) + prev=os2dllname + continue + ;; + + -o) prev=output ;; + + -precious-files-regex) + prev=precious_regex + continue + ;; + + -release) + prev=release + continue + ;; + + -rpath) + prev=rpath + continue + ;; + + -R) + prev=xrpath + continue + ;; + + -R*) + func_stripname '-R' '' "$arg" + dir=$func_stripname_result + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + =*) + func_stripname '=' '' "$dir" + dir=$lt_sysroot$func_stripname_result + ;; + *) + func_fatal_error "only absolute run-paths are allowed" + ;; + esac + case "$xrpath " in + *" $dir "*) ;; + *) func_append xrpath " $dir" ;; + esac + continue + ;; + + -shared) + # The effects of -shared are defined in a previous loop. + continue + ;; + + -shrext) + prev=shrext + continue + ;; + + -static-uninstalled-libs | -static-libtool-libs) + # The effects of -static-uninstalled-libs are defined in a previous + # loop. We used to do the same as -all-static on platforms that + # didn't have a PIC flag, but the assumption that the effects + # would be equivalent was wrong. It would break on at least + # Digital Unix and AIX. + continue + ;; + + -thread-safe) + thread_safe=yes + continue + ;; + + -version-info) + prev=vinfo + continue + ;; + + -version-number) + prev=vinfo + vinfo_number=yes + continue + ;; + + -weak) + prev=weak + continue + ;; + + -Wc,*) + func_stripname '-Wc,' '' "$arg" + args=$func_stripname_result + arg= + save_ifs=$IFS; IFS=, + for flag in $args; do + IFS=$save_ifs + func_quote_for_eval "$flag" + func_append arg " $func_quote_for_eval_result" + func_append compiler_flags " $func_quote_for_eval_result" + done + IFS=$save_ifs + func_stripname ' ' '' "$arg" + arg=$func_stripname_result + ;; + + -Wl,*) + func_stripname '-Wl,' '' "$arg" + args=$func_stripname_result + arg= + save_ifs=$IFS; IFS=, + for flag in $args; do + IFS=$save_ifs + func_quote_for_eval "$flag" + func_append arg " $wl$func_quote_for_eval_result" + func_append compiler_flags " $wl$func_quote_for_eval_result" + func_append linker_flags " $func_quote_for_eval_result" + done + IFS=$save_ifs + func_stripname ' ' '' "$arg" + arg=$func_stripname_result + ;; + + -Xcompiler) + prev=xcompiler + continue + ;; + + -Xlinker) + prev=xlinker + continue + ;; + + -XCClinker) + prev=xcclinker + continue + ;; + + # -msg_* for osf cc + -msg_*) + func_quote_for_eval "$arg" + arg=$func_quote_for_eval_result + ;; + + # Flags to be passed through unchanged, with rationale: + # -64, -mips[0-9] enable 64-bit mode for the SGI compiler + # -r[0-9][0-9]* specify processor for the SGI compiler + # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler + # +DA*, +DD* enable 64-bit mode for the HP compiler + # -q* compiler args for the IBM compiler + # -m*, -t[45]*, -txscale* architecture-specific flags for GCC + # -F/path path to uninstalled frameworks, gcc on darwin + # -p, -pg, --coverage, -fprofile-* profiling flags for GCC + # -fstack-protector* stack protector flags for GCC + # @file GCC response files + # -tp=* Portland pgcc target processor selection + # --sysroot=* for sysroot support + # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization + # -stdlib=* select c++ std lib with clang + -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ + -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ + -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*) + func_quote_for_eval "$arg" + arg=$func_quote_for_eval_result + func_append compile_command " $arg" + func_append finalize_command " $arg" + func_append compiler_flags " $arg" + continue + ;; + + -Z*) + if test os2 = "`expr $host : '.*\(os2\)'`"; then + # OS/2 uses -Zxxx to specify OS/2-specific options + compiler_flags="$compiler_flags $arg" + func_append compile_command " $arg" + func_append finalize_command " $arg" + case $arg in + -Zlinker | -Zstack) + prev=xcompiler + ;; + esac + continue + else + # Otherwise treat like 'Some other compiler flag' below + func_quote_for_eval "$arg" + arg=$func_quote_for_eval_result + fi + ;; + + # Some other compiler flag. + -* | +*) + func_quote_for_eval "$arg" + arg=$func_quote_for_eval_result + ;; + + *.$objext) + # A standard object. + func_append objs " $arg" + ;; + + *.lo) + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if func_lalib_unsafe_p "$arg"; then + pic_object= + non_pic_object= + + # Read the .lo file + func_source "$arg" + + if test -z "$pic_object" || + test -z "$non_pic_object" || + test none = "$pic_object" && + test none = "$non_pic_object"; then + func_fatal_error "cannot find name of object for '$arg'" + fi + + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir=$func_dirname_result + + test none = "$pic_object" || { + # Prepend the subdirectory the object is found in. + pic_object=$xdir$pic_object + + if test dlfiles = "$prev"; then + if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then + func_append dlfiles " $pic_object" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + # CHECK ME: I think I busted this. -Ossama + if test dlprefiles = "$prev"; then + # Preload the old-style object. + func_append dlprefiles " $pic_object" + prev= + fi + + # A PIC object. + func_append libobjs " $pic_object" + arg=$pic_object + } + + # Non-PIC object. + if test none != "$non_pic_object"; then + # Prepend the subdirectory the object is found in. + non_pic_object=$xdir$non_pic_object + + # A standard non-PIC object + func_append non_pic_objects " $non_pic_object" + if test -z "$pic_object" || test none = "$pic_object"; then + arg=$non_pic_object + fi + else + # If the PIC object exists, use it instead. + # $xdir was prepended to $pic_object above. + non_pic_object=$pic_object + func_append non_pic_objects " $non_pic_object" + fi + else + # Only an error if not doing a dry-run. + if $opt_dry_run; then + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir=$func_dirname_result + + func_lo2o "$arg" + pic_object=$xdir$objdir/$func_lo2o_result + non_pic_object=$xdir$func_lo2o_result + func_append libobjs " $pic_object" + func_append non_pic_objects " $non_pic_object" + else + func_fatal_error "'$arg' is not a valid libtool object" + fi + fi + ;; + + *.$libext) + # An archive. + func_append deplibs " $arg" + func_append old_deplibs " $arg" + continue + ;; + + *.la) + # A libtool-controlled library. + + func_resolve_sysroot "$arg" + if test dlfiles = "$prev"; then + # This library was specified with -dlopen. + func_append dlfiles " $func_resolve_sysroot_result" + prev= + elif test dlprefiles = "$prev"; then + # The library was specified with -dlpreopen. + func_append dlprefiles " $func_resolve_sysroot_result" + prev= + else + func_append deplibs " $func_resolve_sysroot_result" + fi + continue + ;; + + # Some other compiler argument. + *) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + func_quote_for_eval "$arg" + arg=$func_quote_for_eval_result + ;; + esac # arg + + # Now actually substitute the argument into the commands. + if test -n "$arg"; then + func_append compile_command " $arg" + func_append finalize_command " $arg" + fi + done # argument parsing loop + + test -n "$prev" && \ + func_fatal_help "the '$prevarg' option requires an argument" + + if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then + eval arg=\"$export_dynamic_flag_spec\" + func_append compile_command " $arg" + func_append finalize_command " $arg" + fi + + oldlibs= + # calculate the name of the file, without its directory + func_basename "$output" + outputname=$func_basename_result + libobjs_save=$libobjs + + if test -n "$shlibpath_var"; then + # get the directories listed in $shlibpath_var + eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` + else + shlib_search_path= + fi + eval sys_lib_search_path=\"$sys_lib_search_path_spec\" + eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" + + # Definition is injected by LT_CONFIG during libtool generation. + func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" + + func_dirname "$output" "/" "" + output_objdir=$func_dirname_result$objdir + func_to_tool_file "$output_objdir/" + tool_output_objdir=$func_to_tool_file_result + # Create the object directory. + func_mkdir_p "$output_objdir" + + # Determine the type of output + case $output in + "") + func_fatal_help "you must specify an output file" + ;; + *.$libext) linkmode=oldlib ;; + *.lo | *.$objext) linkmode=obj ;; + *.la) linkmode=lib ;; + *) linkmode=prog ;; # Anything else should be a program. + esac + + specialdeplibs= + + libs= + # Find all interdependent deplibs by searching for libraries + # that are linked more than once (e.g. -la -lb -la) + for deplib in $deplibs; do + if $opt_preserve_dup_deps; then + case "$libs " in + *" $deplib "*) func_append specialdeplibs " $deplib" ;; + esac + fi + func_append libs " $deplib" + done + + if test lib = "$linkmode"; then + libs="$predeps $libs $compiler_lib_search_path $postdeps" + + # Compute libraries that are listed more than once in $predeps + # $postdeps and mark them as special (i.e., whose duplicates are + # not to be eliminated). + pre_post_deps= + if $opt_duplicate_compiler_generated_deps; then + for pre_post_dep in $predeps $postdeps; do + case "$pre_post_deps " in + *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; + esac + func_append pre_post_deps " $pre_post_dep" + done + fi + pre_post_deps= + fi + + deplibs= + newdependency_libs= + newlib_search_path= + need_relink=no # whether we're linking any uninstalled libtool libraries + notinst_deplibs= # not-installed libtool libraries + notinst_path= # paths that contain not-installed libtool libraries + + case $linkmode in + lib) + passes="conv dlpreopen link" + for file in $dlfiles $dlprefiles; do + case $file in + *.la) ;; + *) + func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" + ;; + esac + done + ;; + prog) + compile_deplibs= + finalize_deplibs= + alldeplibs=false + newdlfiles= + newdlprefiles= + passes="conv scan dlopen dlpreopen link" + ;; + *) passes="conv" + ;; + esac + + for pass in $passes; do + # The preopen pass in lib mode reverses $deplibs; put it back here + # so that -L comes before libs that need it for instance... + if test lib,link = "$linkmode,$pass"; then + ## FIXME: Find the place where the list is rebuilt in the wrong + ## order, and fix it there properly + tmp_deplibs= + for deplib in $deplibs; do + tmp_deplibs="$deplib $tmp_deplibs" + done + deplibs=$tmp_deplibs + fi + + if test lib,link = "$linkmode,$pass" || + test prog,scan = "$linkmode,$pass"; then + libs=$deplibs + deplibs= + fi + if test prog = "$linkmode"; then + case $pass in + dlopen) libs=$dlfiles ;; + dlpreopen) libs=$dlprefiles ;; + link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; + esac + fi + if test lib,dlpreopen = "$linkmode,$pass"; then + # Collect and forward deplibs of preopened libtool libs + for lib in $dlprefiles; do + # Ignore non-libtool-libs + dependency_libs= + func_resolve_sysroot "$lib" + case $lib in + *.la) func_source "$func_resolve_sysroot_result" ;; + esac + + # Collect preopened libtool deplibs, except any this library + # has declared as weak libs + for deplib in $dependency_libs; do + func_basename "$deplib" + deplib_base=$func_basename_result + case " $weak_libs " in + *" $deplib_base "*) ;; + *) func_append deplibs " $deplib" ;; + esac + done + done + libs=$dlprefiles + fi + if test dlopen = "$pass"; then + # Collect dlpreopened libraries + save_deplibs=$deplibs + deplibs= + fi + + for deplib in $libs; do + lib= + found=false + case $deplib in + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ + |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) + if test prog,link = "$linkmode,$pass"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + func_append compiler_flags " $deplib" + if test lib = "$linkmode"; then + case "$new_inherited_linker_flags " in + *" $deplib "*) ;; + * ) func_append new_inherited_linker_flags " $deplib" ;; + esac + fi + fi + continue + ;; + -l*) + if test lib != "$linkmode" && test prog != "$linkmode"; then + func_warning "'-l' is ignored for archives/objects" + continue + fi + func_stripname '-l' '' "$deplib" + name=$func_stripname_result + if test lib = "$linkmode"; then + searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" + else + searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" + fi + for searchdir in $searchdirs; do + for search_ext in .la $std_shrext .so .a; do + # Search the libtool library + lib=$searchdir/lib$name$search_ext + if test -f "$lib"; then + if test .la = "$search_ext"; then + found=: + else + found=false + fi + break 2 + fi + done + done + if $found; then + # deplib is a libtool library + # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, + # We need to do some special things here, and not later. + if test yes = "$allow_libtool_libs_with_static_runtimes"; then + case " $predeps $postdeps " in + *" $deplib "*) + if func_lalib_p "$lib"; then + library_names= + old_library= + func_source "$lib" + for l in $old_library $library_names; do + ll=$l + done + if test "X$ll" = "X$old_library"; then # only static version available + found=false + func_dirname "$lib" "" "." + ladir=$func_dirname_result + lib=$ladir/$old_library + if test prog,link = "$linkmode,$pass"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" + fi + continue + fi + fi + ;; + *) ;; + esac + fi + else + # deplib doesn't seem to be a libtool library + if test prog,link = "$linkmode,$pass"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" + fi + continue + fi + ;; # -l + *.ltframework) + if test prog,link = "$linkmode,$pass"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + if test lib = "$linkmode"; then + case "$new_inherited_linker_flags " in + *" $deplib "*) ;; + * ) func_append new_inherited_linker_flags " $deplib" ;; + esac + fi + fi + continue + ;; + -L*) + case $linkmode in + lib) + deplibs="$deplib $deplibs" + test conv = "$pass" && continue + newdependency_libs="$deplib $newdependency_libs" + func_stripname '-L' '' "$deplib" + func_resolve_sysroot "$func_stripname_result" + func_append newlib_search_path " $func_resolve_sysroot_result" + ;; + prog) + if test conv = "$pass"; then + deplibs="$deplib $deplibs" + continue + fi + if test scan = "$pass"; then + deplibs="$deplib $deplibs" + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + func_stripname '-L' '' "$deplib" + func_resolve_sysroot "$func_stripname_result" + func_append newlib_search_path " $func_resolve_sysroot_result" + ;; + *) + func_warning "'-L' is ignored for archives/objects" + ;; + esac # linkmode + continue + ;; # -L + -R*) + if test link = "$pass"; then + func_stripname '-R' '' "$deplib" + func_resolve_sysroot "$func_stripname_result" + dir=$func_resolve_sysroot_result + # Make sure the xrpath contains only unique directories. + case "$xrpath " in + *" $dir "*) ;; + *) func_append xrpath " $dir" ;; + esac + fi + deplibs="$deplib $deplibs" + continue + ;; + *.la) + func_resolve_sysroot "$deplib" + lib=$func_resolve_sysroot_result + ;; + *.$libext) + if test conv = "$pass"; then + deplibs="$deplib $deplibs" + continue + fi + case $linkmode in + lib) + # Linking convenience modules into shared libraries is allowed, + # but linking other static libraries is non-portable. + case " $dlpreconveniencelibs " in + *" $deplib "*) ;; + *) + valid_a_lib=false + case $deplibs_check_method in + match_pattern*) + set dummy $deplibs_check_method; shift + match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` + if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ + | $EGREP "$match_pattern_regex" > /dev/null; then + valid_a_lib=: + fi + ;; + pass_all) + valid_a_lib=: + ;; + esac + if $valid_a_lib; then + echo + $ECHO "*** Warning: Linking the shared library $output against the" + $ECHO "*** static library $deplib is not portable!" + deplibs="$deplib $deplibs" + else + echo + $ECHO "*** Warning: Trying to link with static lib archive $deplib." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have" + echo "*** because the file extensions .$libext of this argument makes me believe" + echo "*** that it is just a static archive that I should not use here." + fi + ;; + esac + continue + ;; + prog) + if test link != "$pass"; then + deplibs="$deplib $deplibs" + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + continue + ;; + esac # linkmode + ;; # *.$libext + *.lo | *.$objext) + if test conv = "$pass"; then + deplibs="$deplib $deplibs" + elif test prog = "$linkmode"; then + if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then + # If there is no dlopen support or we're linking statically, + # we need to preload. + func_append newdlprefiles " $deplib" + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + func_append newdlfiles " $deplib" + fi + fi + continue + ;; + %DEPLIBS%) + alldeplibs=: + continue + ;; + esac # case $deplib + + $found || test -f "$lib" \ + || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" + + # Check to see that this really is a libtool archive. + func_lalib_unsafe_p "$lib" \ + || func_fatal_error "'$lib' is not a valid libtool archive" + + func_dirname "$lib" "" "." + ladir=$func_dirname_result + + dlname= + dlopen= + dlpreopen= + libdir= + library_names= + old_library= + inherited_linker_flags= + # If the library was installed with an old release of libtool, + # it will not redefine variables installed, or shouldnotlink + installed=yes + shouldnotlink=no + avoidtemprpath= + + + # Read the .la file + func_source "$lib" + + # Convert "-framework foo" to "foo.ltframework" + if test -n "$inherited_linker_flags"; then + tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` + for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do + case " $new_inherited_linker_flags " in + *" $tmp_inherited_linker_flag "*) ;; + *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; + esac + done + fi + dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + if test lib,link = "$linkmode,$pass" || + test prog,scan = "$linkmode,$pass" || + { test prog != "$linkmode" && test lib != "$linkmode"; }; then + test -n "$dlopen" && func_append dlfiles " $dlopen" + test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" + fi + + if test conv = "$pass"; then + # Only check for convenience libraries + deplibs="$lib $deplibs" + if test -z "$libdir"; then + if test -z "$old_library"; then + func_fatal_error "cannot find name of link library for '$lib'" + fi + # It is a libtool convenience library, so add in its objects. + func_append convenience " $ladir/$objdir/$old_library" + func_append old_convenience " $ladir/$objdir/$old_library" + elif test prog != "$linkmode" && test lib != "$linkmode"; then + func_fatal_error "'$lib' is not a convenience library" + fi + tmp_libs= + for deplib in $dependency_libs; do + deplibs="$deplib $deplibs" + if $opt_preserve_dup_deps; then + case "$tmp_libs " in + *" $deplib "*) func_append specialdeplibs " $deplib" ;; + esac + fi + func_append tmp_libs " $deplib" + done + continue + fi # $pass = conv + + + # Get the name of the library we link against. + linklib= + if test -n "$old_library" && + { test yes = "$prefer_static_libs" || + test built,no = "$prefer_static_libs,$installed"; }; then + linklib=$old_library + else + for l in $old_library $library_names; do + linklib=$l + done + fi + if test -z "$linklib"; then + func_fatal_error "cannot find name of link library for '$lib'" + fi + + # This library was specified with -dlopen. + if test dlopen = "$pass"; then + test -z "$libdir" \ + && func_fatal_error "cannot -dlopen a convenience library: '$lib'" + if test -z "$dlname" || + test yes != "$dlopen_support" || + test no = "$build_libtool_libs" + then + # If there is no dlname, no dlopen support or we're linking + # statically, we need to preload. We also need to preload any + # dependent libraries so libltdl's deplib preloader doesn't + # bomb out in the load deplibs phase. + func_append dlprefiles " $lib $dependency_libs" + else + func_append newdlfiles " $lib" + fi + continue + fi # $pass = dlopen + + # We need an absolute path. + case $ladir in + [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; + *) + abs_ladir=`cd "$ladir" && pwd` + if test -z "$abs_ladir"; then + func_warning "cannot determine absolute directory name of '$ladir'" + func_warning "passing it literally to the linker, although it might fail" + abs_ladir=$ladir + fi + ;; + esac + func_basename "$lib" + laname=$func_basename_result + + # Find the relevant object directory and library name. + if test yes = "$installed"; then + if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then + func_warning "library '$lib' was moved." + dir=$ladir + absdir=$abs_ladir + libdir=$abs_ladir + else + dir=$lt_sysroot$libdir + absdir=$lt_sysroot$libdir + fi + test yes = "$hardcode_automatic" && avoidtemprpath=yes + else + if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then + dir=$ladir + absdir=$abs_ladir + # Remove this search path later + func_append notinst_path " $abs_ladir" + else + dir=$ladir/$objdir + absdir=$abs_ladir/$objdir + # Remove this search path later + func_append notinst_path " $abs_ladir" + fi + fi # $installed = yes + func_stripname 'lib' '.la' "$laname" + name=$func_stripname_result + + # This library was specified with -dlpreopen. + if test dlpreopen = "$pass"; then + if test -z "$libdir" && test prog = "$linkmode"; then + func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" + fi + case $host in + # special handling for platforms with PE-DLLs. + *cygwin* | *mingw* | *cegcc* ) + # Linker will automatically link against shared library if both + # static and shared are present. Therefore, ensure we extract + # symbols from the import library if a shared library is present + # (otherwise, the dlopen module name will be incorrect). We do + # this by putting the import library name into $newdlprefiles. + # We recover the dlopen module name by 'saving' the la file + # name in a special purpose variable, and (later) extracting the + # dlname from the la file. + if test -n "$dlname"; then + func_tr_sh "$dir/$linklib" + eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" + func_append newdlprefiles " $dir/$linklib" + else + func_append newdlprefiles " $dir/$old_library" + # Keep a list of preopened convenience libraries to check + # that they are being used correctly in the link pass. + test -z "$libdir" && \ + func_append dlpreconveniencelibs " $dir/$old_library" + fi + ;; + * ) + # Prefer using a static library (so that no silly _DYNAMIC symbols + # are required to link). + if test -n "$old_library"; then + func_append newdlprefiles " $dir/$old_library" + # Keep a list of preopened convenience libraries to check + # that they are being used correctly in the link pass. + test -z "$libdir" && \ + func_append dlpreconveniencelibs " $dir/$old_library" + # Otherwise, use the dlname, so that lt_dlopen finds it. + elif test -n "$dlname"; then + func_append newdlprefiles " $dir/$dlname" + else + func_append newdlprefiles " $dir/$linklib" + fi + ;; + esac + fi # $pass = dlpreopen + + if test -z "$libdir"; then + # Link the convenience library + if test lib = "$linkmode"; then + deplibs="$dir/$old_library $deplibs" + elif test prog,link = "$linkmode,$pass"; then + compile_deplibs="$dir/$old_library $compile_deplibs" + finalize_deplibs="$dir/$old_library $finalize_deplibs" + else + deplibs="$lib $deplibs" # used for prog,scan pass + fi + continue + fi + + + if test prog = "$linkmode" && test link != "$pass"; then + func_append newlib_search_path " $ladir" + deplibs="$lib $deplibs" + + linkalldeplibs=false + if test no != "$link_all_deplibs" || test -z "$library_names" || + test no = "$build_libtool_libs"; then + linkalldeplibs=: + fi + + tmp_libs= + for deplib in $dependency_libs; do + case $deplib in + -L*) func_stripname '-L' '' "$deplib" + func_resolve_sysroot "$func_stripname_result" + func_append newlib_search_path " $func_resolve_sysroot_result" + ;; + esac + # Need to link against all dependency_libs? + if $linkalldeplibs; then + deplibs="$deplib $deplibs" + else + # Need to hardcode shared library paths + # or/and link against static libraries + newdependency_libs="$deplib $newdependency_libs" + fi + if $opt_preserve_dup_deps; then + case "$tmp_libs " in + *" $deplib "*) func_append specialdeplibs " $deplib" ;; + esac + fi + func_append tmp_libs " $deplib" + done # for deplib + continue + fi # $linkmode = prog... + + if test prog,link = "$linkmode,$pass"; then + if test -n "$library_names" && + { { test no = "$prefer_static_libs" || + test built,yes = "$prefer_static_libs,$installed"; } || + test -z "$old_library"; }; then + # We need to hardcode the library path + if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then + # Make sure the rpath contains only unique directories. + case $temp_rpath: in + *"$absdir:"*) ;; + *) func_append temp_rpath "$absdir:" ;; + esac + fi + + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) func_append compile_rpath " $absdir" ;; + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) func_append finalize_rpath " $libdir" ;; + esac + ;; + esac + fi # $linkmode,$pass = prog,link... + + if $alldeplibs && + { test pass_all = "$deplibs_check_method" || + { test yes = "$build_libtool_libs" && + test -n "$library_names"; }; }; then + # We only need to search for static libraries + continue + fi + fi + + link_static=no # Whether the deplib will be linked statically + use_static_libs=$prefer_static_libs + if test built = "$use_static_libs" && test yes = "$installed"; then + use_static_libs=no + fi + if test -n "$library_names" && + { test no = "$use_static_libs" || test -z "$old_library"; }; then + case $host in + *cygwin* | *mingw* | *cegcc* | *os2*) + # No point in relinking DLLs because paths are not encoded + func_append notinst_deplibs " $lib" + need_relink=no + ;; + *) + if test no = "$installed"; then + func_append notinst_deplibs " $lib" + need_relink=yes + fi + ;; + esac + # This is a shared library + + # Warn about portability, can't link against -module's on some + # systems (darwin). Don't bleat about dlopened modules though! + dlopenmodule= + for dlpremoduletest in $dlprefiles; do + if test "X$dlpremoduletest" = "X$lib"; then + dlopenmodule=$dlpremoduletest + break + fi + done + if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then + echo + if test prog = "$linkmode"; then + $ECHO "*** Warning: Linking the executable $output against the loadable module" + else + $ECHO "*** Warning: Linking the shared library $output against the loadable module" + fi + $ECHO "*** $linklib is not portable!" + fi + if test lib = "$linkmode" && + test yes = "$hardcode_into_libs"; then + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) func_append compile_rpath " $absdir" ;; + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) func_append finalize_rpath " $libdir" ;; + esac + ;; + esac + fi + + if test -n "$old_archive_from_expsyms_cmds"; then + # figure out the soname + set dummy $library_names + shift + realname=$1 + shift + libname=`eval "\\$ECHO \"$libname_spec\""` + # use dlname if we got it. it's perfectly good, no? + if test -n "$dlname"; then + soname=$dlname + elif test -n "$soname_spec"; then + # bleh windows + case $host in + *cygwin* | mingw* | *cegcc* | *os2*) + func_arith $current - $age + major=$func_arith_result + versuffix=-$major + ;; + esac + eval soname=\"$soname_spec\" + else + soname=$realname + fi + + # Make a new name for the extract_expsyms_cmds to use + soroot=$soname + func_basename "$soroot" + soname=$func_basename_result + func_stripname 'lib' '.dll' "$soname" + newlib=libimp-$func_stripname_result.a + + # If the library has no export list, then create one now + if test -f "$output_objdir/$soname-def"; then : + else + func_verbose "extracting exported symbol list from '$soname'" + func_execute_cmds "$extract_expsyms_cmds" 'exit $?' + fi + + # Create $newlib + if test -f "$output_objdir/$newlib"; then :; else + func_verbose "generating import library for '$soname'" + func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' + fi + # make sure the library variables are pointing to the new library + dir=$output_objdir + linklib=$newlib + fi # test -n "$old_archive_from_expsyms_cmds" + + if test prog = "$linkmode" || test relink != "$opt_mode"; then + add_shlibpath= + add_dir= + add= + lib_linked=yes + case $hardcode_action in + immediate | unsupported) + if test no = "$hardcode_direct"; then + add=$dir/$linklib + case $host in + *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; + *-*-sysv4*uw2*) add_dir=-L$dir ;; + *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ + *-*-unixware7*) add_dir=-L$dir ;; + *-*-darwin* ) + # if the lib is a (non-dlopened) module then we cannot + # link against it, someone is ignoring the earlier warnings + if /usr/bin/file -L $add 2> /dev/null | + $GREP ": [^:]* bundle" >/dev/null; then + if test "X$dlopenmodule" != "X$lib"; then + $ECHO "*** Warning: lib $linklib is a module, not a shared library" + if test -z "$old_library"; then + echo + echo "*** And there doesn't seem to be a static archive available" + echo "*** The link will probably fail, sorry" + else + add=$dir/$old_library + fi + elif test -n "$old_library"; then + add=$dir/$old_library + fi + fi + esac + elif test no = "$hardcode_minus_L"; then + case $host in + *-*-sunos*) add_shlibpath=$dir ;; + esac + add_dir=-L$dir + add=-l$name + elif test no = "$hardcode_shlibpath_var"; then + add_shlibpath=$dir + add=-l$name + else + lib_linked=no + fi + ;; + relink) + if test yes = "$hardcode_direct" && + test no = "$hardcode_direct_absolute"; then + add=$dir/$linklib + elif test yes = "$hardcode_minus_L"; then + add_dir=-L$absdir + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case $libdir in + [\\/]*) + func_append add_dir " -L$inst_prefix_dir$libdir" + ;; + esac + fi + add=-l$name + elif test yes = "$hardcode_shlibpath_var"; then + add_shlibpath=$dir + add=-l$name + else + lib_linked=no + fi + ;; + *) lib_linked=no ;; + esac + + if test yes != "$lib_linked"; then + func_fatal_configuration "unsupported hardcode properties" + fi + + if test -n "$add_shlibpath"; then + case :$compile_shlibpath: in + *":$add_shlibpath:"*) ;; + *) func_append compile_shlibpath "$add_shlibpath:" ;; + esac + fi + if test prog = "$linkmode"; then + test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" + test -n "$add" && compile_deplibs="$add $compile_deplibs" + else + test -n "$add_dir" && deplibs="$add_dir $deplibs" + test -n "$add" && deplibs="$add $deplibs" + if test yes != "$hardcode_direct" && + test yes != "$hardcode_minus_L" && + test yes = "$hardcode_shlibpath_var"; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) func_append finalize_shlibpath "$libdir:" ;; + esac + fi + fi + fi + + if test prog = "$linkmode" || test relink = "$opt_mode"; then + add_shlibpath= + add_dir= + add= + # Finalize command for both is simple: just hardcode it. + if test yes = "$hardcode_direct" && + test no = "$hardcode_direct_absolute"; then + add=$libdir/$linklib + elif test yes = "$hardcode_minus_L"; then + add_dir=-L$libdir + add=-l$name + elif test yes = "$hardcode_shlibpath_var"; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) func_append finalize_shlibpath "$libdir:" ;; + esac + add=-l$name + elif test yes = "$hardcode_automatic"; then + if test -n "$inst_prefix_dir" && + test -f "$inst_prefix_dir$libdir/$linklib"; then + add=$inst_prefix_dir$libdir/$linklib + else + add=$libdir/$linklib + fi + else + # We cannot seem to hardcode it, guess we'll fake it. + add_dir=-L$libdir + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case $libdir in + [\\/]*) + func_append add_dir " -L$inst_prefix_dir$libdir" + ;; + esac + fi + add=-l$name + fi + + if test prog = "$linkmode"; then + test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" + test -n "$add" && finalize_deplibs="$add $finalize_deplibs" + else + test -n "$add_dir" && deplibs="$add_dir $deplibs" + test -n "$add" && deplibs="$add $deplibs" + fi + fi + elif test prog = "$linkmode"; then + # Here we assume that one of hardcode_direct or hardcode_minus_L + # is not unsupported. This is valid on all known static and + # shared platforms. + if test unsupported != "$hardcode_direct"; then + test -n "$old_library" && linklib=$old_library + compile_deplibs="$dir/$linklib $compile_deplibs" + finalize_deplibs="$dir/$linklib $finalize_deplibs" + else + compile_deplibs="-l$name -L$dir $compile_deplibs" + finalize_deplibs="-l$name -L$dir $finalize_deplibs" + fi + elif test yes = "$build_libtool_libs"; then + # Not a shared library + if test pass_all != "$deplibs_check_method"; then + # We're trying link a shared library against a static one + # but the system doesn't support it. + + # Just print a warning and add the library to dependency_libs so + # that the program can be linked against the static library. + echo + $ECHO "*** Warning: This system cannot link to static lib archive $lib." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have." + if test yes = "$module"; then + echo "*** But as you try to build a module library, libtool will still create " + echo "*** a static module, that should work as long as the dlopening application" + echo "*** is linked with the -dlopen flag to resolve symbols at runtime." + if test -z "$global_symbol_pipe"; then + echo + echo "*** However, this would only work if libtool was able to extract symbol" + echo "*** lists from a program, using 'nm' or equivalent, but libtool could" + echo "*** not find such a program. So, this module is probably useless." + echo "*** 'nm' from GNU binutils and a full rebuild may help." + fi + if test no = "$build_old_libs"; then + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi + else + deplibs="$dir/$old_library $deplibs" + link_static=yes + fi + fi # link shared/static library? + + if test lib = "$linkmode"; then + if test -n "$dependency_libs" && + { test yes != "$hardcode_into_libs" || + test yes = "$build_old_libs" || + test yes = "$link_static"; }; then + # Extract -R from dependency_libs + temp_deplibs= + for libdir in $dependency_libs; do + case $libdir in + -R*) func_stripname '-R' '' "$libdir" + temp_xrpath=$func_stripname_result + case " $xrpath " in + *" $temp_xrpath "*) ;; + *) func_append xrpath " $temp_xrpath";; + esac;; + *) func_append temp_deplibs " $libdir";; + esac + done + dependency_libs=$temp_deplibs + fi + + func_append newlib_search_path " $absdir" + # Link against this library + test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" + # ... and its dependency_libs + tmp_libs= + for deplib in $dependency_libs; do + newdependency_libs="$deplib $newdependency_libs" + case $deplib in + -L*) func_stripname '-L' '' "$deplib" + func_resolve_sysroot "$func_stripname_result";; + *) func_resolve_sysroot "$deplib" ;; + esac + if $opt_preserve_dup_deps; then + case "$tmp_libs " in + *" $func_resolve_sysroot_result "*) + func_append specialdeplibs " $func_resolve_sysroot_result" ;; + esac + fi + func_append tmp_libs " $func_resolve_sysroot_result" + done + + if test no != "$link_all_deplibs"; then + # Add the search paths of all dependency libraries + for deplib in $dependency_libs; do + path= + case $deplib in + -L*) path=$deplib ;; + *.la) + func_resolve_sysroot "$deplib" + deplib=$func_resolve_sysroot_result + func_dirname "$deplib" "" "." + dir=$func_dirname_result + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + func_warning "cannot determine absolute directory name of '$dir'" + absdir=$dir + fi + ;; + esac + if $GREP "^installed=no" $deplib > /dev/null; then + case $host in + *-*-darwin*) + depdepl= + eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` + if test -n "$deplibrary_names"; then + for tmp in $deplibrary_names; do + depdepl=$tmp + done + if test -f "$absdir/$objdir/$depdepl"; then + depdepl=$absdir/$objdir/$depdepl + darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` + if test -z "$darwin_install_name"; then + darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` + fi + func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" + func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" + path= + fi + fi + ;; + *) + path=-L$absdir/$objdir + ;; + esac + else + eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + test -z "$libdir" && \ + func_fatal_error "'$deplib' is not a valid libtool archive" + test "$absdir" != "$libdir" && \ + func_warning "'$deplib' seems to be moved" + + path=-L$absdir + fi + ;; + esac + case " $deplibs " in + *" $path "*) ;; + *) deplibs="$path $deplibs" ;; + esac + done + fi # link_all_deplibs != no + fi # linkmode = lib + done # for deplib in $libs + if test link = "$pass"; then + if test prog = "$linkmode"; then + compile_deplibs="$new_inherited_linker_flags $compile_deplibs" + finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" + else + compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + fi + fi + dependency_libs=$newdependency_libs + if test dlpreopen = "$pass"; then + # Link the dlpreopened libraries before other libraries + for deplib in $save_deplibs; do + deplibs="$deplib $deplibs" + done + fi + if test dlopen != "$pass"; then + test conv = "$pass" || { + # Make sure lib_search_path contains only unique directories. + lib_search_path= + for dir in $newlib_search_path; do + case "$lib_search_path " in + *" $dir "*) ;; + *) func_append lib_search_path " $dir" ;; + esac + done + newlib_search_path= + } + + if test prog,link = "$linkmode,$pass"; then + vars="compile_deplibs finalize_deplibs" + else + vars=deplibs + fi + for var in $vars dependency_libs; do + # Add libraries to $var in reverse order + eval tmp_libs=\"\$$var\" + new_libs= + for deplib in $tmp_libs; do + # FIXME: Pedantically, this is the right thing to do, so + # that some nasty dependency loop isn't accidentally + # broken: + #new_libs="$deplib $new_libs" + # Pragmatically, this seems to cause very few problems in + # practice: + case $deplib in + -L*) new_libs="$deplib $new_libs" ;; + -R*) ;; + *) + # And here is the reason: when a library appears more + # than once as an explicit dependence of a library, or + # is implicitly linked in more than once by the + # compiler, it is considered special, and multiple + # occurrences thereof are not removed. Compare this + # with having the same library being listed as a + # dependency of multiple other libraries: in this case, + # we know (pedantically, we assume) the library does not + # need to be listed more than once, so we keep only the + # last copy. This is not always right, but it is rare + # enough that we require users that really mean to play + # such unportable linking tricks to link the library + # using -Wl,-lname, so that libtool does not consider it + # for duplicate removal. + case " $specialdeplibs " in + *" $deplib "*) new_libs="$deplib $new_libs" ;; + *) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$deplib $new_libs" ;; + esac + ;; + esac + ;; + esac + done + tmp_libs= + for deplib in $new_libs; do + case $deplib in + -L*) + case " $tmp_libs " in + *" $deplib "*) ;; + *) func_append tmp_libs " $deplib" ;; + esac + ;; + *) func_append tmp_libs " $deplib" ;; + esac + done + eval $var=\"$tmp_libs\" + done # for var + fi + + # Add Sun CC postdeps if required: + test CXX = "$tagname" && { + case $host_os in + linux*) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) # Sun C++ 5.9 + func_suncc_cstd_abi + + if test no != "$suncc_use_cstd_abi"; then + func_append postdeps ' -library=Cstd -library=Crun' + fi + ;; + esac + ;; + + solaris*) + func_cc_basename "$CC" + case $func_cc_basename_result in + CC* | sunCC*) + func_suncc_cstd_abi + + if test no != "$suncc_use_cstd_abi"; then + func_append postdeps ' -library=Cstd -library=Crun' + fi + ;; + esac + ;; + esac + } + + # Last step: remove runtime libs from dependency_libs + # (they stay in deplibs) + tmp_libs= + for i in $dependency_libs; do + case " $predeps $postdeps $compiler_lib_search_path " in + *" $i "*) + i= + ;; + esac + if test -n "$i"; then + func_append tmp_libs " $i" + fi + done + dependency_libs=$tmp_libs + done # for pass + if test prog = "$linkmode"; then + dlfiles=$newdlfiles + fi + if test prog = "$linkmode" || test lib = "$linkmode"; then + dlprefiles=$newdlprefiles + fi + + case $linkmode in + oldlib) + if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then + func_warning "'-dlopen' is ignored for archives" + fi + + case " $deplibs" in + *\ -l* | *\ -L*) + func_warning "'-l' and '-L' are ignored for archives" ;; + esac + + test -n "$rpath" && \ + func_warning "'-rpath' is ignored for archives" + + test -n "$xrpath" && \ + func_warning "'-R' is ignored for archives" + + test -n "$vinfo" && \ + func_warning "'-version-info/-version-number' is ignored for archives" + + test -n "$release" && \ + func_warning "'-release' is ignored for archives" + + test -n "$export_symbols$export_symbols_regex" && \ + func_warning "'-export-symbols' is ignored for archives" + + # Now set the variables for building old libraries. + build_libtool_libs=no + oldlibs=$output + func_append objs "$old_deplibs" + ;; + + lib) + # Make sure we only generate libraries of the form 'libNAME.la'. + case $outputname in + lib*) + func_stripname 'lib' '.la' "$outputname" + name=$func_stripname_result + eval shared_ext=\"$shrext_cmds\" + eval libname=\"$libname_spec\" + ;; + *) + test no = "$module" \ + && func_fatal_help "libtool library '$output' must begin with 'lib'" + + if test no != "$need_lib_prefix"; then + # Add the "lib" prefix for modules if required + func_stripname '' '.la' "$outputname" + name=$func_stripname_result + eval shared_ext=\"$shrext_cmds\" + eval libname=\"$libname_spec\" + else + func_stripname '' '.la' "$outputname" + libname=$func_stripname_result + fi + ;; + esac + + if test -n "$objs"; then + if test pass_all != "$deplibs_check_method"; then + func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" + else + echo + $ECHO "*** Warning: Linking the shared library $output against the non-libtool" + $ECHO "*** objects $objs is not portable!" + func_append libobjs " $objs" + fi + fi + + test no = "$dlself" \ + || func_warning "'-dlopen self' is ignored for libtool libraries" + + set dummy $rpath + shift + test 1 -lt "$#" \ + && func_warning "ignoring multiple '-rpath's for a libtool library" + + install_libdir=$1 + + oldlibs= + if test -z "$rpath"; then + if test yes = "$build_libtool_libs"; then + # Building a libtool convenience library. + # Some compilers have problems with a '.al' extension so + # convenience libraries should have the same extension an + # archive normally would. + oldlibs="$output_objdir/$libname.$libext $oldlibs" + build_libtool_libs=convenience + build_old_libs=yes + fi + + test -n "$vinfo" && \ + func_warning "'-version-info/-version-number' is ignored for convenience libraries" + + test -n "$release" && \ + func_warning "'-release' is ignored for convenience libraries" + else + + # Parse the version information argument. + save_ifs=$IFS; IFS=: + set dummy $vinfo 0 0 0 + shift + IFS=$save_ifs + + test -n "$7" && \ + func_fatal_help "too many parameters to '-version-info'" + + # convert absolute version numbers to libtool ages + # this retains compatibility with .la files and attempts + # to make the code below a bit more comprehensible + + case $vinfo_number in + yes) + number_major=$1 + number_minor=$2 + number_revision=$3 + # + # There are really only two kinds -- those that + # use the current revision as the major version + # and those that subtract age and use age as + # a minor version. But, then there is irix + # that has an extra 1 added just for fun + # + case $version_type in + # correct linux to gnu/linux during the next big refactor + darwin|freebsd-elf|linux|osf|windows|none) + func_arith $number_major + $number_minor + current=$func_arith_result + age=$number_minor + revision=$number_revision + ;; + freebsd-aout|qnx|sunos) + current=$number_major + revision=$number_minor + age=0 + ;; + irix|nonstopux) + func_arith $number_major + $number_minor + current=$func_arith_result + age=$number_minor + revision=$number_minor + lt_irix_increment=no + ;; + esac + ;; + no) + current=$1 + revision=$2 + age=$3 + ;; + esac + + # Check that each of the things are valid numbers. + case $current in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + func_error "CURRENT '$current' must be a nonnegative integer" + func_fatal_error "'$vinfo' is not valid version information" + ;; + esac + + case $revision in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + func_error "REVISION '$revision' must be a nonnegative integer" + func_fatal_error "'$vinfo' is not valid version information" + ;; + esac + + case $age in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + func_error "AGE '$age' must be a nonnegative integer" + func_fatal_error "'$vinfo' is not valid version information" + ;; + esac + + if test "$age" -gt "$current"; then + func_error "AGE '$age' is greater than the current interface number '$current'" + func_fatal_error "'$vinfo' is not valid version information" + fi + + # Calculate the version variables. + major= + versuffix= + verstring= + case $version_type in + none) ;; + + darwin) + # Like Linux, but with the current version available in + # verstring for coding it into the library header + func_arith $current - $age + major=.$func_arith_result + versuffix=$major.$age.$revision + # Darwin ld doesn't like 0 for these options... + func_arith $current + 1 + minor_current=$func_arith_result + xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" + verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" + # On Darwin other compilers + case $CC in + nagfor*) + verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" + ;; + *) + verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" + ;; + esac + ;; + + freebsd-aout) + major=.$current + versuffix=.$current.$revision + ;; + + freebsd-elf) + func_arith $current - $age + major=.$func_arith_result + versuffix=$major.$age.$revision + ;; + + irix | nonstopux) + if test no = "$lt_irix_increment"; then + func_arith $current - $age + else + func_arith $current - $age + 1 + fi + major=$func_arith_result + + case $version_type in + nonstopux) verstring_prefix=nonstopux ;; + *) verstring_prefix=sgi ;; + esac + verstring=$verstring_prefix$major.$revision + + # Add in all the interfaces that we are compatible with. + loop=$revision + while test 0 -ne "$loop"; do + func_arith $revision - $loop + iface=$func_arith_result + func_arith $loop - 1 + loop=$func_arith_result + verstring=$verstring_prefix$major.$iface:$verstring + done + + # Before this point, $major must not contain '.'. + major=.$major + versuffix=$major.$revision + ;; + + linux) # correct to gnu/linux during the next big refactor + func_arith $current - $age + major=.$func_arith_result + versuffix=$major.$age.$revision + ;; + + osf) + func_arith $current - $age + major=.$func_arith_result + versuffix=.$current.$age.$revision + verstring=$current.$age.$revision + + # Add in all the interfaces that we are compatible with. + loop=$age + while test 0 -ne "$loop"; do + func_arith $current - $loop + iface=$func_arith_result + func_arith $loop - 1 + loop=$func_arith_result + verstring=$verstring:$iface.0 + done + + # Make executables depend on our current version. + func_append verstring ":$current.0" + ;; + + qnx) + major=.$current + versuffix=.$current + ;; + + sco) + major=.$current + versuffix=.$current + ;; + + sunos) + major=.$current + versuffix=.$current.$revision + ;; + + windows) + # Use '-' rather than '.', since we only want one + # extension on DOS 8.3 file systems. + func_arith $current - $age + major=$func_arith_result + versuffix=-$major + ;; + + *) + func_fatal_configuration "unknown library version type '$version_type'" + ;; + esac + + # Clear the version info if we defaulted, and they specified a release. + if test -z "$vinfo" && test -n "$release"; then + major= + case $version_type in + darwin) + # we can't check for "0.0" in archive_cmds due to quoting + # problems, so we reset it completely + verstring= + ;; + *) + verstring=0.0 + ;; + esac + if test no = "$need_version"; then + versuffix= + else + versuffix=.0.0 + fi + fi + + # Remove version info from name if versioning should be avoided + if test yes,no = "$avoid_version,$need_version"; then + major= + versuffix= + verstring= + fi + + # Check to see if the archive will have undefined symbols. + if test yes = "$allow_undefined"; then + if test unsupported = "$allow_undefined_flag"; then + if test yes = "$build_old_libs"; then + func_warning "undefined symbols not allowed in $host shared libraries; building static only" + build_libtool_libs=no + else + func_fatal_error "can't build $host shared library unless -no-undefined is specified" + fi + fi + else + # Don't allow undefined symbols. + allow_undefined_flag=$no_undefined_flag + fi + + fi + + func_generate_dlsyms "$libname" "$libname" : + func_append libobjs " $symfileobj" + test " " = "$libobjs" && libobjs= + + if test relink != "$opt_mode"; then + # Remove our outputs, but don't remove object files since they + # may have been created when compiling PIC objects. + removelist= + tempremovelist=`$ECHO "$output_objdir/*"` + for p in $tempremovelist; do + case $p in + *.$objext | *.gcno) + ;; + $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) + if test -n "$precious_files_regex"; then + if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 + then + continue + fi + fi + func_append removelist " $p" + ;; + *) ;; + esac + done + test -n "$removelist" && \ + func_show_eval "${RM}r \$removelist" + fi + + # Now set the variables for building old libraries. + if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then + func_append oldlibs " $output_objdir/$libname.$libext" + + # Transform .lo files to .o files. + oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` + fi + + # Eliminate all temporary directories. + #for path in $notinst_path; do + # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` + # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` + # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` + #done + + if test -n "$xrpath"; then + # If the user specified any rpath flags, then add them. + temp_xrpath= + for libdir in $xrpath; do + func_replace_sysroot "$libdir" + func_append temp_xrpath " -R$func_replace_sysroot_result" + case "$finalize_rpath " in + *" $libdir "*) ;; + *) func_append finalize_rpath " $libdir" ;; + esac + done + if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then + dependency_libs="$temp_xrpath $dependency_libs" + fi + fi + + # Make sure dlfiles contains only unique files that won't be dlpreopened + old_dlfiles=$dlfiles + dlfiles= + for lib in $old_dlfiles; do + case " $dlprefiles $dlfiles " in + *" $lib "*) ;; + *) func_append dlfiles " $lib" ;; + esac + done + + # Make sure dlprefiles contains only unique files + old_dlprefiles=$dlprefiles + dlprefiles= + for lib in $old_dlprefiles; do + case "$dlprefiles " in + *" $lib "*) ;; + *) func_append dlprefiles " $lib" ;; + esac + done + + if test yes = "$build_libtool_libs"; then + if test -n "$rpath"; then + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) + # these systems don't actually have a c library (as such)! + ;; + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C library is in the System framework + func_append deplibs " System.ltframework" + ;; + *-*-netbsd*) + # Don't link with libc until the a.out ld.so is fixed. + ;; + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) + # Do not include libc due to us having libc/libc_r. + ;; + *-*-sco3.2v5* | *-*-sco5v6*) + # Causes problems with __ctype + ;; + *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) + # Compiler inserts libc in the correct place for threads to work + ;; + *) + # Add libc to deplibs on all other systems if necessary. + if test yes = "$build_libtool_need_lc"; then + func_append deplibs " -lc" + fi + ;; + esac + fi + + # Transform deplibs into only deplibs that can be linked in shared. + name_save=$name + libname_save=$libname + release_save=$release + versuffix_save=$versuffix + major_save=$major + # I'm not sure if I'm treating the release correctly. I think + # release should show up in the -l (ie -lgmp5) so we don't want to + # add it in twice. Is that correct? + release= + versuffix= + major= + newdeplibs= + droppeddeps=no + case $deplibs_check_method in + pass_all) + # Don't check for shared/static. Everything works. + # This might be a little naive. We might want to check + # whether the library exists or not. But this is on + # osf3 & osf4 and I'm not really sure... Just + # implementing what was already the behavior. + newdeplibs=$deplibs + ;; + test_compile) + # This code stresses the "libraries are programs" paradigm to its + # limits. Maybe even breaks it. We compile a program, linking it + # against the deplibs as a proxy for the library. Then we can check + # whether they linked in statically or dynamically with ldd. + $opt_dry_run || $RM conftest.c + cat > conftest.c </dev/null` + $nocaseglob + else + potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` + fi + for potent_lib in $potential_libs; do + # Follow soft links. + if ls -lLd "$potent_lib" 2>/dev/null | + $GREP " -> " >/dev/null; then + continue + fi + # The statement above tries to avoid entering an + # endless loop below, in case of cyclic links. + # We might still enter an endless loop, since a link + # loop can be closed while we follow links, + # but so what? + potlib=$potent_lib + while test -h "$potlib" 2>/dev/null; do + potliblink=`ls -ld $potlib | $SED 's/.* -> //'` + case $potliblink in + [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; + *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; + esac + done + if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | + $SED -e 10q | + $EGREP "$file_magic_regex" > /dev/null; then + func_append newdeplibs " $a_deplib" + a_deplib= + break 2 + fi + done + done + fi + if test -n "$a_deplib"; then + droppeddeps=yes + echo + $ECHO "*** Warning: linker path does not have real file for library $a_deplib." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have" + echo "*** because I did check the linker path looking for a file starting" + if test -z "$potlib"; then + $ECHO "*** with $libname but no candidates were found. (...for file magic test)" + else + $ECHO "*** with $libname and none of the candidates passed a file format test" + $ECHO "*** using a file magic. Last file checked: $potlib" + fi + fi + ;; + *) + # Add a -L argument. + func_append newdeplibs " $a_deplib" + ;; + esac + done # Gone through all deplibs. + ;; + match_pattern*) + set dummy $deplibs_check_method; shift + match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` + for a_deplib in $deplibs; do + case $a_deplib in + -l*) + func_stripname -l '' "$a_deplib" + name=$func_stripname_result + if test yes = "$allow_libtool_libs_with_static_runtimes"; then + case " $predeps $postdeps " in + *" $a_deplib "*) + func_append newdeplibs " $a_deplib" + a_deplib= + ;; + esac + fi + if test -n "$a_deplib"; then + libname=`eval "\\$ECHO \"$libname_spec\""` + for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do + potential_libs=`ls $i/$libname[.-]* 2>/dev/null` + for potent_lib in $potential_libs; do + potlib=$potent_lib # see symlink-check above in file_magic test + if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ + $EGREP "$match_pattern_regex" > /dev/null; then + func_append newdeplibs " $a_deplib" + a_deplib= + break 2 + fi + done + done + fi + if test -n "$a_deplib"; then + droppeddeps=yes + echo + $ECHO "*** Warning: linker path does not have real file for library $a_deplib." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have" + echo "*** because I did check the linker path looking for a file starting" + if test -z "$potlib"; then + $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" + else + $ECHO "*** with $libname and none of the candidates passed a file format test" + $ECHO "*** using a regex pattern. Last file checked: $potlib" + fi + fi + ;; + *) + # Add a -L argument. + func_append newdeplibs " $a_deplib" + ;; + esac + done # Gone through all deplibs. + ;; + none | unknown | *) + newdeplibs= + tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` + if test yes = "$allow_libtool_libs_with_static_runtimes"; then + for i in $predeps $postdeps; do + # can't use Xsed below, because $i might contain '/' + tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` + done + fi + case $tmp_deplibs in + *[!\ \ ]*) + echo + if test none = "$deplibs_check_method"; then + echo "*** Warning: inter-library dependencies are not supported in this platform." + else + echo "*** Warning: inter-library dependencies are not known to be supported." + fi + echo "*** All declared inter-library dependencies are being dropped." + droppeddeps=yes + ;; + esac + ;; + esac + versuffix=$versuffix_save + major=$major_save + release=$release_save + libname=$libname_save + name=$name_save + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library with the System framework + newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` + ;; + esac + + if test yes = "$droppeddeps"; then + if test yes = "$module"; then + echo + echo "*** Warning: libtool could not satisfy all declared inter-library" + $ECHO "*** dependencies of module $libname. Therefore, libtool will create" + echo "*** a static module, that should work as long as the dlopening" + echo "*** application is linked with the -dlopen flag." + if test -z "$global_symbol_pipe"; then + echo + echo "*** However, this would only work if libtool was able to extract symbol" + echo "*** lists from a program, using 'nm' or equivalent, but libtool could" + echo "*** not find such a program. So, this module is probably useless." + echo "*** 'nm' from GNU binutils and a full rebuild may help." + fi + if test no = "$build_old_libs"; then + oldlibs=$output_objdir/$libname.$libext + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + else + echo "*** The inter-library dependencies that have been dropped here will be" + echo "*** automatically added whenever a program is linked with this library" + echo "*** or is declared to -dlopen it." + + if test no = "$allow_undefined"; then + echo + echo "*** Since this library must not contain undefined symbols," + echo "*** because either the platform does not support them or" + echo "*** it was explicitly requested with -no-undefined," + echo "*** libtool will only create a static version of it." + if test no = "$build_old_libs"; then + oldlibs=$output_objdir/$libname.$libext + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi + fi + fi + # Done checking deplibs! + deplibs=$newdeplibs + fi + # Time to change all our "foo.ltframework" stuff back to "-framework foo" + case $host in + *-*-darwin*) + newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + ;; + esac + + # move library search paths that coincide with paths to not yet + # installed libraries to the beginning of the library search list + new_libs= + for path in $notinst_path; do + case " $new_libs " in + *" -L$path/$objdir "*) ;; + *) + case " $deplibs " in + *" -L$path/$objdir "*) + func_append new_libs " -L$path/$objdir" ;; + esac + ;; + esac + done + for deplib in $deplibs; do + case $deplib in + -L*) + case " $new_libs " in + *" $deplib "*) ;; + *) func_append new_libs " $deplib" ;; + esac + ;; + *) func_append new_libs " $deplib" ;; + esac + done + deplibs=$new_libs + + # All the library-specific variables (install_libdir is set above). + library_names= + old_library= + dlname= + + # Test again, we may have decided not to build it any more + if test yes = "$build_libtool_libs"; then + # Remove $wl instances when linking with ld. + # FIXME: should test the right _cmds variable. + case $archive_cmds in + *\$LD\ *) wl= ;; + esac + if test yes = "$hardcode_into_libs"; then + # Hardcode the library paths + hardcode_libdirs= + dep_rpath= + rpath=$finalize_rpath + test relink = "$opt_mode" || rpath=$compile_rpath$rpath + for libdir in $rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + func_replace_sysroot "$libdir" + libdir=$func_replace_sysroot_result + if test -z "$hardcode_libdirs"; then + hardcode_libdirs=$libdir + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + func_append dep_rpath " $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) func_append perm_rpath " $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir=$hardcode_libdirs + eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" + fi + if test -n "$runpath_var" && test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + func_append rpath "$dir:" + done + eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" + fi + test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" + fi + + shlibpath=$finalize_shlibpath + test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath + if test -n "$shlibpath"; then + eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" + fi + + # Get the real and link names of the library. + eval shared_ext=\"$shrext_cmds\" + eval library_names=\"$library_names_spec\" + set dummy $library_names + shift + realname=$1 + shift + + if test -n "$soname_spec"; then + eval soname=\"$soname_spec\" + else + soname=$realname + fi + if test -z "$dlname"; then + dlname=$soname + fi + + lib=$output_objdir/$realname + linknames= + for link + do + func_append linknames " $link" + done + + # Use standard objects if they are pic + test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` + test "X$libobjs" = "X " && libobjs= + + delfiles= + if test -n "$export_symbols" && test -n "$include_expsyms"; then + $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" + export_symbols=$output_objdir/$libname.uexp + func_append delfiles " $export_symbols" + fi + + orig_export_symbols= + case $host_os in + cygwin* | mingw* | cegcc*) + if test -n "$export_symbols" && test -z "$export_symbols_regex"; then + # exporting using user supplied symfile + func_dll_def_p "$export_symbols" || { + # and it's NOT already a .def file. Must figure out + # which of the given symbols are data symbols and tag + # them as such. So, trigger use of export_symbols_cmds. + # export_symbols gets reassigned inside the "prepare + # the list of exported symbols" if statement, so the + # include_expsyms logic still works. + orig_export_symbols=$export_symbols + export_symbols= + always_export_symbols=yes + } + fi + ;; + esac + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then + func_verbose "generating symbol list for '$libname.la'" + export_symbols=$output_objdir/$libname.exp + $opt_dry_run || $RM $export_symbols + cmds=$export_symbols_cmds + save_ifs=$IFS; IFS='~' + for cmd1 in $cmds; do + IFS=$save_ifs + # Take the normal branch if the nm_file_list_spec branch + # doesn't work or if tool conversion is not needed. + case $nm_file_list_spec~$to_tool_file_cmd in + *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) + try_normal_branch=yes + eval cmd=\"$cmd1\" + func_len " $cmd" + len=$func_len_result + ;; + *) + try_normal_branch=no + ;; + esac + if test yes = "$try_normal_branch" \ + && { test "$len" -lt "$max_cmd_len" \ + || test "$max_cmd_len" -le -1; } + then + func_show_eval "$cmd" 'exit $?' + skipped_export=false + elif test -n "$nm_file_list_spec"; then + func_basename "$output" + output_la=$func_basename_result + save_libobjs=$libobjs + save_output=$output + output=$output_objdir/$output_la.nm + func_to_tool_file "$output" + libobjs=$nm_file_list_spec$func_to_tool_file_result + func_append delfiles " $output" + func_verbose "creating $NM input file list: $output" + for obj in $save_libobjs; do + func_to_tool_file "$obj" + $ECHO "$func_to_tool_file_result" + done > "$output" + eval cmd=\"$cmd1\" + func_show_eval "$cmd" 'exit $?' + output=$save_output + libobjs=$save_libobjs + skipped_export=false + else + # The command line is too long to execute in one step. + func_verbose "using reloadable object file for export list..." + skipped_export=: + # Break out early, otherwise skipped_export may be + # set to false by a later but shorter cmd. + break + fi + done + IFS=$save_ifs + if test -n "$export_symbols_regex" && test : != "$skipped_export"; then + func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' + func_show_eval '$MV "${export_symbols}T" "$export_symbols"' + fi + fi + fi + + if test -n "$export_symbols" && test -n "$include_expsyms"; then + tmp_export_symbols=$export_symbols + test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols + $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' + fi + + if test : != "$skipped_export" && test -n "$orig_export_symbols"; then + # The given exports_symbols file has to be filtered, so filter it. + func_verbose "filter symbol list for '$libname.la' to tag DATA exports" + # FIXME: $output_objdir/$libname.filter potentially contains lots of + # 's' commands, which not all seds can handle. GNU sed should be fine + # though. Also, the filter scales superlinearly with the number of + # global variables. join(1) would be nice here, but unfortunately + # isn't a blessed tool. + $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter + func_append delfiles " $export_symbols $output_objdir/$libname.filter" + export_symbols=$output_objdir/$libname.def + $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols + fi + + tmp_deplibs= + for test_deplib in $deplibs; do + case " $convenience " in + *" $test_deplib "*) ;; + *) + func_append tmp_deplibs " $test_deplib" + ;; + esac + done + deplibs=$tmp_deplibs + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec" && + test yes = "$compiler_needs_object" && + test -z "$libobjs"; then + # extract the archives, so we have objects to list. + # TODO: could optimize this to just extract one archive. + whole_archive_flag_spec= + fi + if test -n "$whole_archive_flag_spec"; then + save_libobjs=$libobjs + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + test "X$libobjs" = "X " && libobjs= + else + gentop=$output_objdir/${outputname}x + func_append generated " $gentop" + + func_extract_archives $gentop $convenience + func_append libobjs " $func_extract_archives_result" + test "X$libobjs" = "X " && libobjs= + fi + fi + + if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then + eval flag=\"$thread_safe_flag_spec\" + func_append linker_flags " $flag" + fi + + # Make a backup of the uninstalled library when relinking + if test relink = "$opt_mode"; then + $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? + fi + + # Do each of the archive commands. + if test yes = "$module" && test -n "$module_cmds"; then + if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then + eval test_cmds=\"$module_expsym_cmds\" + cmds=$module_expsym_cmds + else + eval test_cmds=\"$module_cmds\" + cmds=$module_cmds + fi + else + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + eval test_cmds=\"$archive_expsym_cmds\" + cmds=$archive_expsym_cmds + else + eval test_cmds=\"$archive_cmds\" + cmds=$archive_cmds + fi + fi + + if test : != "$skipped_export" && + func_len " $test_cmds" && + len=$func_len_result && + test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then + : + else + # The command line is too long to link in one step, link piecewise + # or, if using GNU ld and skipped_export is not :, use a linker + # script. + + # Save the value of $output and $libobjs because we want to + # use them later. If we have whole_archive_flag_spec, we + # want to use save_libobjs as it was before + # whole_archive_flag_spec was expanded, because we can't + # assume the linker understands whole_archive_flag_spec. + # This may have to be revisited, in case too many + # convenience libraries get linked in and end up exceeding + # the spec. + if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then + save_libobjs=$libobjs + fi + save_output=$output + func_basename "$output" + output_la=$func_basename_result + + # Clear the reloadable object creation command queue and + # initialize k to one. + test_cmds= + concat_cmds= + objlist= + last_robj= + k=1 + + if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then + output=$output_objdir/$output_la.lnkscript + func_verbose "creating GNU ld script: $output" + echo 'INPUT (' > $output + for obj in $save_libobjs + do + func_to_tool_file "$obj" + $ECHO "$func_to_tool_file_result" >> $output + done + echo ')' >> $output + func_append delfiles " $output" + func_to_tool_file "$output" + output=$func_to_tool_file_result + elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then + output=$output_objdir/$output_la.lnk + func_verbose "creating linker input file list: $output" + : > $output + set x $save_libobjs + shift + firstobj= + if test yes = "$compiler_needs_object"; then + firstobj="$1 " + shift + fi + for obj + do + func_to_tool_file "$obj" + $ECHO "$func_to_tool_file_result" >> $output + done + func_append delfiles " $output" + func_to_tool_file "$output" + output=$firstobj\"$file_list_spec$func_to_tool_file_result\" + else + if test -n "$save_libobjs"; then + func_verbose "creating reloadable object files..." + output=$output_objdir/$output_la-$k.$objext + eval test_cmds=\"$reload_cmds\" + func_len " $test_cmds" + len0=$func_len_result + len=$len0 + + # Loop over the list of objects to be linked. + for obj in $save_libobjs + do + func_len " $obj" + func_arith $len + $func_len_result + len=$func_arith_result + if test -z "$objlist" || + test "$len" -lt "$max_cmd_len"; then + func_append objlist " $obj" + else + # The command $test_cmds is almost too long, add a + # command to the queue. + if test 1 -eq "$k"; then + # The first file doesn't have a previous command to add. + reload_objs=$objlist + eval concat_cmds=\"$reload_cmds\" + else + # All subsequent reloadable object files will link in + # the last one created. + reload_objs="$objlist $last_robj" + eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" + fi + last_robj=$output_objdir/$output_la-$k.$objext + func_arith $k + 1 + k=$func_arith_result + output=$output_objdir/$output_la-$k.$objext + objlist=" $obj" + func_len " $last_robj" + func_arith $len0 + $func_len_result + len=$func_arith_result + fi + done + # Handle the remaining objects by creating one last + # reloadable object file. All subsequent reloadable object + # files will link in the last one created. + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + reload_objs="$objlist $last_robj" + eval concat_cmds=\"\$concat_cmds$reload_cmds\" + if test -n "$last_robj"; then + eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" + fi + func_append delfiles " $output" + + else + output= + fi + + ${skipped_export-false} && { + func_verbose "generating symbol list for '$libname.la'" + export_symbols=$output_objdir/$libname.exp + $opt_dry_run || $RM $export_symbols + libobjs=$output + # Append the command to create the export file. + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" + if test -n "$last_robj"; then + eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" + fi + } + + test -n "$save_libobjs" && + func_verbose "creating a temporary reloadable object file: $output" + + # Loop through the commands generated above and execute them. + save_ifs=$IFS; IFS='~' + for cmd in $concat_cmds; do + IFS=$save_ifs + $opt_quiet || { + func_quote_for_expand "$cmd" + eval "func_echo $func_quote_for_expand_result" + } + $opt_dry_run || eval "$cmd" || { + lt_exit=$? + + # Restore the uninstalled library and exit + if test relink = "$opt_mode"; then + ( cd "$output_objdir" && \ + $RM "${realname}T" && \ + $MV "${realname}U" "$realname" ) + fi + + exit $lt_exit + } + done + IFS=$save_ifs + + if test -n "$export_symbols_regex" && ${skipped_export-false}; then + func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' + func_show_eval '$MV "${export_symbols}T" "$export_symbols"' + fi + fi + + ${skipped_export-false} && { + if test -n "$export_symbols" && test -n "$include_expsyms"; then + tmp_export_symbols=$export_symbols + test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols + $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' + fi + + if test -n "$orig_export_symbols"; then + # The given exports_symbols file has to be filtered, so filter it. + func_verbose "filter symbol list for '$libname.la' to tag DATA exports" + # FIXME: $output_objdir/$libname.filter potentially contains lots of + # 's' commands, which not all seds can handle. GNU sed should be fine + # though. Also, the filter scales superlinearly with the number of + # global variables. join(1) would be nice here, but unfortunately + # isn't a blessed tool. + $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter + func_append delfiles " $export_symbols $output_objdir/$libname.filter" + export_symbols=$output_objdir/$libname.def + $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols + fi + } + + libobjs=$output + # Restore the value of output. + output=$save_output + + if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + test "X$libobjs" = "X " && libobjs= + fi + # Expand the library linking commands again to reset the + # value of $libobjs for piecewise linking. + + # Do each of the archive commands. + if test yes = "$module" && test -n "$module_cmds"; then + if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then + cmds=$module_expsym_cmds + else + cmds=$module_cmds + fi + else + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + cmds=$archive_expsym_cmds + else + cmds=$archive_cmds + fi + fi + fi + + if test -n "$delfiles"; then + # Append the command to remove temporary files to $cmds. + eval cmds=\"\$cmds~\$RM $delfiles\" + fi + + # Add any objects from preloaded convenience libraries + if test -n "$dlprefiles"; then + gentop=$output_objdir/${outputname}x + func_append generated " $gentop" + + func_extract_archives $gentop $dlprefiles + func_append libobjs " $func_extract_archives_result" + test "X$libobjs" = "X " && libobjs= + fi + + save_ifs=$IFS; IFS='~' + for cmd in $cmds; do + IFS=$sp$nl + eval cmd=\"$cmd\" + IFS=$save_ifs + $opt_quiet || { + func_quote_for_expand "$cmd" + eval "func_echo $func_quote_for_expand_result" + } + $opt_dry_run || eval "$cmd" || { + lt_exit=$? + + # Restore the uninstalled library and exit + if test relink = "$opt_mode"; then + ( cd "$output_objdir" && \ + $RM "${realname}T" && \ + $MV "${realname}U" "$realname" ) + fi + + exit $lt_exit + } + done + IFS=$save_ifs + + # Restore the uninstalled library and exit + if test relink = "$opt_mode"; then + $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? + + if test -n "$convenience"; then + if test -z "$whole_archive_flag_spec"; then + func_show_eval '${RM}r "$gentop"' + fi + fi + + exit $EXIT_SUCCESS + fi + + # Create links to the real library. + for linkname in $linknames; do + if test "$realname" != "$linkname"; then + func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' + fi + done + + # If -module or -export-dynamic was specified, set the dlname. + if test yes = "$module" || test yes = "$export_dynamic"; then + # On all known operating systems, these are identical. + dlname=$soname + fi + fi + ;; + + obj) + if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then + func_warning "'-dlopen' is ignored for objects" + fi + + case " $deplibs" in + *\ -l* | *\ -L*) + func_warning "'-l' and '-L' are ignored for objects" ;; + esac + + test -n "$rpath" && \ + func_warning "'-rpath' is ignored for objects" + + test -n "$xrpath" && \ + func_warning "'-R' is ignored for objects" + + test -n "$vinfo" && \ + func_warning "'-version-info' is ignored for objects" + + test -n "$release" && \ + func_warning "'-release' is ignored for objects" + + case $output in + *.lo) + test -n "$objs$old_deplibs" && \ + func_fatal_error "cannot build library object '$output' from non-libtool objects" + + libobj=$output + func_lo2o "$libobj" + obj=$func_lo2o_result + ;; + *) + libobj= + obj=$output + ;; + esac + + # Delete the old objects. + $opt_dry_run || $RM $obj $libobj + + # Objects from convenience libraries. This assumes + # single-version convenience libraries. Whenever we create + # different ones for PIC/non-PIC, this we'll have to duplicate + # the extraction. + reload_conv_objs= + gentop= + # if reload_cmds runs $LD directly, get rid of -Wl from + # whole_archive_flag_spec and hope we can get by with turning comma + # into space. + case $reload_cmds in + *\$LD[\ \$]*) wl= ;; + esac + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" + test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` + reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags + else + gentop=$output_objdir/${obj}x + func_append generated " $gentop" + + func_extract_archives $gentop $convenience + reload_conv_objs="$reload_objs $func_extract_archives_result" + fi + fi + + # If we're not building shared, we need to use non_pic_objs + test yes = "$build_libtool_libs" || libobjs=$non_pic_objects + + # Create the old-style object. + reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs + + output=$obj + func_execute_cmds "$reload_cmds" 'exit $?' + + # Exit if we aren't doing a library object file. + if test -z "$libobj"; then + if test -n "$gentop"; then + func_show_eval '${RM}r "$gentop"' + fi + + exit $EXIT_SUCCESS + fi + + test yes = "$build_libtool_libs" || { + if test -n "$gentop"; then + func_show_eval '${RM}r "$gentop"' + fi + + # Create an invalid libtool object if no PIC, so that we don't + # accidentally link it into a program. + # $show "echo timestamp > $libobj" + # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? + exit $EXIT_SUCCESS + } + + if test -n "$pic_flag" || test default != "$pic_mode"; then + # Only do commands if we really have different PIC objects. + reload_objs="$libobjs $reload_conv_objs" + output=$libobj + func_execute_cmds "$reload_cmds" 'exit $?' + fi + + if test -n "$gentop"; then + func_show_eval '${RM}r "$gentop"' + fi + + exit $EXIT_SUCCESS + ;; + + prog) + case $host in + *cygwin*) func_stripname '' '.exe' "$output" + output=$func_stripname_result.exe;; + esac + test -n "$vinfo" && \ + func_warning "'-version-info' is ignored for programs" + + test -n "$release" && \ + func_warning "'-release' is ignored for programs" + + $preload \ + && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ + && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library is the System framework + compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` + finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` + ;; + esac + + case $host in + *-*-darwin*) + # Don't allow lazy linking, it breaks C++ global constructors + # But is supposedly fixed on 10.4 or later (yay!). + if test CXX = "$tagname"; then + case ${MACOSX_DEPLOYMENT_TARGET-10.0} in + 10.[0123]) + func_append compile_command " $wl-bind_at_load" + func_append finalize_command " $wl-bind_at_load" + ;; + esac + fi + # Time to change all our "foo.ltframework" stuff back to "-framework foo" + compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + ;; + esac + + + # move library search paths that coincide with paths to not yet + # installed libraries to the beginning of the library search list + new_libs= + for path in $notinst_path; do + case " $new_libs " in + *" -L$path/$objdir "*) ;; + *) + case " $compile_deplibs " in + *" -L$path/$objdir "*) + func_append new_libs " -L$path/$objdir" ;; + esac + ;; + esac + done + for deplib in $compile_deplibs; do + case $deplib in + -L*) + case " $new_libs " in + *" $deplib "*) ;; + *) func_append new_libs " $deplib" ;; + esac + ;; + *) func_append new_libs " $deplib" ;; + esac + done + compile_deplibs=$new_libs + + + func_append compile_command " $compile_deplibs" + func_append finalize_command " $finalize_deplibs" + + if test -n "$rpath$xrpath"; then + # If the user specified any rpath flags, then add them. + for libdir in $rpath $xrpath; do + # This is the magic to use -rpath. + case "$finalize_rpath " in + *" $libdir "*) ;; + *) func_append finalize_rpath " $libdir" ;; + esac + done + fi + + # Now hardcode the library paths + rpath= + hardcode_libdirs= + for libdir in $compile_rpath $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs=$libdir + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + func_append rpath " $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) func_append perm_rpath " $libdir" ;; + esac + fi + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` + case :$dllsearchpath: in + *":$libdir:"*) ;; + ::) dllsearchpath=$libdir;; + *) func_append dllsearchpath ":$libdir";; + esac + case :$dllsearchpath: in + *":$testbindir:"*) ;; + ::) dllsearchpath=$testbindir;; + *) func_append dllsearchpath ":$testbindir";; + esac + ;; + esac + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir=$hardcode_libdirs + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + compile_rpath=$rpath + + rpath= + hardcode_libdirs= + for libdir in $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs=$libdir + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + func_append rpath " $flag" + fi + elif test -n "$runpath_var"; then + case "$finalize_perm_rpath " in + *" $libdir "*) ;; + *) func_append finalize_perm_rpath " $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir=$hardcode_libdirs + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + finalize_rpath=$rpath + + if test -n "$libobjs" && test yes = "$build_old_libs"; then + # Transform all the library objects into standard objects. + compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` + finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` + fi + + func_generate_dlsyms "$outputname" "@PROGRAM@" false + + # template prelinking step + if test -n "$prelink_cmds"; then + func_execute_cmds "$prelink_cmds" 'exit $?' + fi + + wrappers_required=: + case $host in + *cegcc* | *mingw32ce*) + # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. + wrappers_required=false + ;; + *cygwin* | *mingw* ) + test yes = "$build_libtool_libs" || wrappers_required=false + ;; + *) + if test no = "$need_relink" || test yes != "$build_libtool_libs"; then + wrappers_required=false + fi + ;; + esac + $wrappers_required || { + # Replace the output file specification. + compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` + link_command=$compile_command$compile_rpath + + # We have no uninstalled library dependencies, so finalize right now. + exit_status=0 + func_show_eval "$link_command" 'exit_status=$?' + + if test -n "$postlink_cmds"; then + func_to_tool_file "$output" + postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` + func_execute_cmds "$postlink_cmds" 'exit $?' + fi + + # Delete the generated files. + if test -f "$output_objdir/${outputname}S.$objext"; then + func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' + fi + + exit $exit_status + } + + if test -n "$compile_shlibpath$finalize_shlibpath"; then + compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" + fi + if test -n "$finalize_shlibpath"; then + finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" + fi + + compile_var= + finalize_var= + if test -n "$runpath_var"; then + if test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + func_append rpath "$dir:" + done + compile_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + if test -n "$finalize_perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $finalize_perm_rpath; do + func_append rpath "$dir:" + done + finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + fi + + if test yes = "$no_install"; then + # We don't need to create a wrapper script. + link_command=$compile_var$compile_command$compile_rpath + # Replace the output file specification. + link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` + # Delete the old output file. + $opt_dry_run || $RM $output + # Link the executable and exit + func_show_eval "$link_command" 'exit $?' + + if test -n "$postlink_cmds"; then + func_to_tool_file "$output" + postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` + func_execute_cmds "$postlink_cmds" 'exit $?' + fi + + exit $EXIT_SUCCESS + fi + + case $hardcode_action,$fast_install in + relink,*) + # Fast installation is not supported + link_command=$compile_var$compile_command$compile_rpath + relink_command=$finalize_var$finalize_command$finalize_rpath + + func_warning "this platform does not like uninstalled shared libraries" + func_warning "'$output' will be relinked during installation" + ;; + *,yes) + link_command=$finalize_var$compile_command$finalize_rpath + relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` + ;; + *,no) + link_command=$compile_var$compile_command$compile_rpath + relink_command=$finalize_var$finalize_command$finalize_rpath + ;; + *,needless) + link_command=$finalize_var$compile_command$finalize_rpath + relink_command= + ;; + esac + + # Replace the output file specification. + link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` + + # Delete the old output files. + $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname + + func_show_eval "$link_command" 'exit $?' + + if test -n "$postlink_cmds"; then + func_to_tool_file "$output_objdir/$outputname" + postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` + func_execute_cmds "$postlink_cmds" 'exit $?' + fi + + # Now create the wrapper script. + func_verbose "creating $output" + + # Quote the relink command for shipping. + if test -n "$relink_command"; then + # Preserve any variables that may affect compiler behavior + for var in $variables_saved_for_relink; do + if eval test -z \"\${$var+set}\"; then + relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else + func_quote_for_eval "$var_value" + relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" + fi + done + relink_command="(cd `pwd`; $relink_command)" + relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` + fi + + # Only actually do things if not in dry run mode. + $opt_dry_run || { + # win32 will think the script is a binary if it has + # a .exe suffix, so we strip it off here. + case $output in + *.exe) func_stripname '' '.exe' "$output" + output=$func_stripname_result ;; + esac + # test for cygwin because mv fails w/o .exe extensions + case $host in + *cygwin*) + exeext=.exe + func_stripname '' '.exe' "$outputname" + outputname=$func_stripname_result ;; + *) exeext= ;; + esac + case $host in + *cygwin* | *mingw* ) + func_dirname_and_basename "$output" "" "." + output_name=$func_basename_result + output_path=$func_dirname_result + cwrappersource=$output_path/$objdir/lt-$output_name.c + cwrapper=$output_path/$output_name.exe + $RM $cwrappersource $cwrapper + trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 + + func_emit_cwrapperexe_src > $cwrappersource + + # The wrapper executable is built using the $host compiler, + # because it contains $host paths and files. If cross- + # compiling, it, like the target executable, must be + # executed on the $host or under an emulation environment. + $opt_dry_run || { + $LTCC $LTCFLAGS -o $cwrapper $cwrappersource + $STRIP $cwrapper + } + + # Now, create the wrapper script for func_source use: + func_ltwrapper_scriptname $cwrapper + $RM $func_ltwrapper_scriptname_result + trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 + $opt_dry_run || { + # note: this script will not be executed, so do not chmod. + if test "x$build" = "x$host"; then + $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result + else + func_emit_wrapper no > $func_ltwrapper_scriptname_result + fi + } + ;; + * ) + $RM $output + trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 + + func_emit_wrapper no > $output + chmod +x $output + ;; + esac + } + exit $EXIT_SUCCESS + ;; + esac + + # See if we need to build an old-fashioned archive. + for oldlib in $oldlibs; do + + case $build_libtool_libs in + convenience) + oldobjs="$libobjs_save $symfileobj" + addlibs=$convenience + build_libtool_libs=no + ;; + module) + oldobjs=$libobjs_save + addlibs=$old_convenience + build_libtool_libs=no + ;; + *) + oldobjs="$old_deplibs $non_pic_objects" + $preload && test -f "$symfileobj" \ + && func_append oldobjs " $symfileobj" + addlibs=$old_convenience + ;; + esac + + if test -n "$addlibs"; then + gentop=$output_objdir/${outputname}x + func_append generated " $gentop" + + func_extract_archives $gentop $addlibs + func_append oldobjs " $func_extract_archives_result" + fi + + # Do each command in the archive commands. + if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then + cmds=$old_archive_from_new_cmds + else + + # Add any objects from preloaded convenience libraries + if test -n "$dlprefiles"; then + gentop=$output_objdir/${outputname}x + func_append generated " $gentop" + + func_extract_archives $gentop $dlprefiles + func_append oldobjs " $func_extract_archives_result" + fi + + # POSIX demands no paths to be encoded in archives. We have + # to avoid creating archives with duplicate basenames if we + # might have to extract them afterwards, e.g., when creating a + # static archive out of a convenience library, or when linking + # the entirety of a libtool archive into another (currently + # not supported by libtool). + if (for obj in $oldobjs + do + func_basename "$obj" + $ECHO "$func_basename_result" + done | sort | sort -uc >/dev/null 2>&1); then + : + else + echo "copying selected object files to avoid basename conflicts..." + gentop=$output_objdir/${outputname}x + func_append generated " $gentop" + func_mkdir_p "$gentop" + save_oldobjs=$oldobjs + oldobjs= + counter=1 + for obj in $save_oldobjs + do + func_basename "$obj" + objbase=$func_basename_result + case " $oldobjs " in + " ") oldobjs=$obj ;; + *[\ /]"$objbase "*) + while :; do + # Make sure we don't pick an alternate name that also + # overlaps. + newobj=lt$counter-$objbase + func_arith $counter + 1 + counter=$func_arith_result + case " $oldobjs " in + *[\ /]"$newobj "*) ;; + *) if test ! -f "$gentop/$newobj"; then break; fi ;; + esac + done + func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" + func_append oldobjs " $gentop/$newobj" + ;; + *) func_append oldobjs " $obj" ;; + esac + done + fi + func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 + tool_oldlib=$func_to_tool_file_result + eval cmds=\"$old_archive_cmds\" + + func_len " $cmds" + len=$func_len_result + if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then + cmds=$old_archive_cmds + elif test -n "$archiver_list_spec"; then + func_verbose "using command file archive linking..." + for obj in $oldobjs + do + func_to_tool_file "$obj" + $ECHO "$func_to_tool_file_result" + done > $output_objdir/$libname.libcmd + func_to_tool_file "$output_objdir/$libname.libcmd" + oldobjs=" $archiver_list_spec$func_to_tool_file_result" + cmds=$old_archive_cmds + else + # the command line is too long to link in one step, link in parts + func_verbose "using piecewise archive linking..." + save_RANLIB=$RANLIB + RANLIB=: + objlist= + concat_cmds= + save_oldobjs=$oldobjs + oldobjs= + # Is there a better way of finding the last object in the list? + for obj in $save_oldobjs + do + last_oldobj=$obj + done + eval test_cmds=\"$old_archive_cmds\" + func_len " $test_cmds" + len0=$func_len_result + len=$len0 + for obj in $save_oldobjs + do + func_len " $obj" + func_arith $len + $func_len_result + len=$func_arith_result + func_append objlist " $obj" + if test "$len" -lt "$max_cmd_len"; then + : + else + # the above command should be used before it gets too long + oldobjs=$objlist + if test "$obj" = "$last_oldobj"; then + RANLIB=$save_RANLIB + fi + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" + objlist= + len=$len0 + fi + done + RANLIB=$save_RANLIB + oldobjs=$objlist + if test -z "$oldobjs"; then + eval cmds=\"\$concat_cmds\" + else + eval cmds=\"\$concat_cmds~\$old_archive_cmds\" + fi + fi + fi + func_execute_cmds "$cmds" 'exit $?' + done + + test -n "$generated" && \ + func_show_eval "${RM}r$generated" + + # Now create the libtool archive. + case $output in + *.la) + old_library= + test yes = "$build_old_libs" && old_library=$libname.$libext + func_verbose "creating $output" + + # Preserve any variables that may affect compiler behavior + for var in $variables_saved_for_relink; do + if eval test -z \"\${$var+set}\"; then + relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else + func_quote_for_eval "$var_value" + relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" + fi + done + # Quote the link command for shipping. + relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" + relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` + if test yes = "$hardcode_automatic"; then + relink_command= + fi + + # Only create the output if not a dry run. + $opt_dry_run || { + for installed in no yes; do + if test yes = "$installed"; then + if test -z "$install_libdir"; then + break + fi + output=$output_objdir/${outputname}i + # Replace all uninstalled libtool libraries with the installed ones + newdependency_libs= + for deplib in $dependency_libs; do + case $deplib in + *.la) + func_basename "$deplib" + name=$func_basename_result + func_resolve_sysroot "$deplib" + eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` + test -z "$libdir" && \ + func_fatal_error "'$deplib' is not a valid libtool archive" + func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" + ;; + -L*) + func_stripname -L '' "$deplib" + func_replace_sysroot "$func_stripname_result" + func_append newdependency_libs " -L$func_replace_sysroot_result" + ;; + -R*) + func_stripname -R '' "$deplib" + func_replace_sysroot "$func_stripname_result" + func_append newdependency_libs " -R$func_replace_sysroot_result" + ;; + *) func_append newdependency_libs " $deplib" ;; + esac + done + dependency_libs=$newdependency_libs + newdlfiles= + + for lib in $dlfiles; do + case $lib in + *.la) + func_basename "$lib" + name=$func_basename_result + eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + test -z "$libdir" && \ + func_fatal_error "'$lib' is not a valid libtool archive" + func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" + ;; + *) func_append newdlfiles " $lib" ;; + esac + done + dlfiles=$newdlfiles + newdlprefiles= + for lib in $dlprefiles; do + case $lib in + *.la) + # Only pass preopened files to the pseudo-archive (for + # eventual linking with the app. that links it) if we + # didn't already link the preopened objects directly into + # the library: + func_basename "$lib" + name=$func_basename_result + eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + test -z "$libdir" && \ + func_fatal_error "'$lib' is not a valid libtool archive" + func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" + ;; + esac + done + dlprefiles=$newdlprefiles + else + newdlfiles= + for lib in $dlfiles; do + case $lib in + [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; + *) abs=`pwd`"/$lib" ;; + esac + func_append newdlfiles " $abs" + done + dlfiles=$newdlfiles + newdlprefiles= + for lib in $dlprefiles; do + case $lib in + [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; + *) abs=`pwd`"/$lib" ;; + esac + func_append newdlprefiles " $abs" + done + dlprefiles=$newdlprefiles + fi + $RM $output + # place dlname in correct position for cygwin + # In fact, it would be nice if we could use this code for all target + # systems that can't hard-code library paths into their executables + # and that have no shared library path variable independent of PATH, + # but it turns out we can't easily determine that from inspecting + # libtool variables, so we have to hard-code the OSs to which it + # applies here; at the moment, that means platforms that use the PE + # object format with DLL files. See the long comment at the top of + # tests/bindir.at for full details. + tdlname=$dlname + case $host,$output,$installed,$module,$dlname in + *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) + # If a -bindir argument was supplied, place the dll there. + if test -n "$bindir"; then + func_relative_path "$install_libdir" "$bindir" + tdlname=$func_relative_path_result/$dlname + else + # Otherwise fall back on heuristic. + tdlname=../bin/$dlname + fi + ;; + esac + $ECHO > $output "\ +# $outputname - a libtool library file +# Generated by $PROGRAM (GNU $PACKAGE) $VERSION +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='$tdlname' + +# Names of this library. +library_names='$library_names' + +# The name of the static archive. +old_library='$old_library' + +# Linker flags that cannot go in dependency_libs. +inherited_linker_flags='$new_inherited_linker_flags' + +# Libraries that this one depends upon. +dependency_libs='$dependency_libs' + +# Names of additional weak libraries provided by this library +weak_library_names='$weak_libs' + +# Version information for $libname. +current=$current +age=$age +revision=$revision + +# Is this an already installed library? +installed=$installed + +# Should we warn about portability when linking against -modules? +shouldnotlink=$module + +# Files to dlopen/dlpreopen +dlopen='$dlfiles' +dlpreopen='$dlprefiles' + +# Directory that this library needs to be installed in: +libdir='$install_libdir'" + if test no,yes = "$installed,$need_relink"; then + $ECHO >> $output "\ +relink_command=\"$relink_command\"" + fi + done + } + + # Do a symbolic link so that the libtool archive can be found in + # LD_LIBRARY_PATH before the program is installed. + func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' + ;; + esac + exit $EXIT_SUCCESS +} + +if test link = "$opt_mode" || test relink = "$opt_mode"; then + func_mode_link ${1+"$@"} +fi + + +# func_mode_uninstall arg... +func_mode_uninstall () +{ + $debug_cmd + + RM=$nonopt + files= + rmforce=false + exit_status=0 + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic=$magic + + for arg + do + case $arg in + -f) func_append RM " $arg"; rmforce=: ;; + -*) func_append RM " $arg" ;; + *) func_append files " $arg" ;; + esac + done + + test -z "$RM" && \ + func_fatal_help "you must specify an RM program" + + rmdirs= + + for file in $files; do + func_dirname "$file" "" "." + dir=$func_dirname_result + if test . = "$dir"; then + odir=$objdir + else + odir=$dir/$objdir + fi + func_basename "$file" + name=$func_basename_result + test uninstall = "$opt_mode" && odir=$dir + + # Remember odir for removal later, being careful to avoid duplicates + if test clean = "$opt_mode"; then + case " $rmdirs " in + *" $odir "*) ;; + *) func_append rmdirs " $odir" ;; + esac + fi + + # Don't error if the file doesn't exist and rm -f was used. + if { test -L "$file"; } >/dev/null 2>&1 || + { test -h "$file"; } >/dev/null 2>&1 || + test -f "$file"; then + : + elif test -d "$file"; then + exit_status=1 + continue + elif $rmforce; then + continue + fi + + rmfiles=$file + + case $name in + *.la) + # Possibly a libtool archive, so verify it. + if func_lalib_p "$file"; then + func_source $dir/$name + + # Delete the libtool libraries and symlinks. + for n in $library_names; do + func_append rmfiles " $odir/$n" + done + test -n "$old_library" && func_append rmfiles " $odir/$old_library" + + case $opt_mode in + clean) + case " $library_names " in + *" $dlname "*) ;; + *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; + esac + test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" + ;; + uninstall) + if test -n "$library_names"; then + # Do each command in the postuninstall commands. + func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' + fi + + if test -n "$old_library"; then + # Do each command in the old_postuninstall commands. + func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' + fi + # FIXME: should reinstall the best remaining shared library. + ;; + esac + fi + ;; + + *.lo) + # Possibly a libtool object, so verify it. + if func_lalib_p "$file"; then + + # Read the .lo file + func_source $dir/$name + + # Add PIC object to the list of files to remove. + if test -n "$pic_object" && test none != "$pic_object"; then + func_append rmfiles " $dir/$pic_object" + fi + + # Add non-PIC object to the list of files to remove. + if test -n "$non_pic_object" && test none != "$non_pic_object"; then + func_append rmfiles " $dir/$non_pic_object" + fi + fi + ;; + + *) + if test clean = "$opt_mode"; then + noexename=$name + case $file in + *.exe) + func_stripname '' '.exe' "$file" + file=$func_stripname_result + func_stripname '' '.exe' "$name" + noexename=$func_stripname_result + # $file with .exe has already been added to rmfiles, + # add $file without .exe + func_append rmfiles " $file" + ;; + esac + # Do a test to see if this is a libtool program. + if func_ltwrapper_p "$file"; then + if func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + relink_command= + func_source $func_ltwrapper_scriptname_result + func_append rmfiles " $func_ltwrapper_scriptname_result" + else + relink_command= + func_source $dir/$noexename + fi + + # note $name still contains .exe if it was in $file originally + # as does the version of $file that was added into $rmfiles + func_append rmfiles " $odir/$name $odir/${name}S.$objext" + if test yes = "$fast_install" && test -n "$relink_command"; then + func_append rmfiles " $odir/lt-$name" + fi + if test "X$noexename" != "X$name"; then + func_append rmfiles " $odir/lt-$noexename.c" + fi + fi + fi + ;; + esac + func_show_eval "$RM $rmfiles" 'exit_status=1' + done + + # Try to remove the $objdir's in the directories where we deleted files + for dir in $rmdirs; do + if test -d "$dir"; then + func_show_eval "rmdir $dir >/dev/null 2>&1" + fi + done + + exit $exit_status +} + +if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then + func_mode_uninstall ${1+"$@"} +fi + +test -z "$opt_mode" && { + help=$generic_help + func_fatal_help "you must specify a MODE" +} + +test -z "$exec_cmd" && \ + func_fatal_help "invalid operation mode '$opt_mode'" + +if test -n "$exec_cmd"; then + eval exec "$exec_cmd" + exit $EXIT_FAILURE +fi + +exit $exit_status + + +# The TAGs below are defined such that we never get into a situation +# where we disable both kinds of libraries. Given conflicting +# choices, we go for a static library, that is the most portable, +# since we can't tell whether shared libraries were disabled because +# the user asked for that or because the platform doesn't support +# them. This is particularly important on AIX, because we don't +# support having both static and shared libraries enabled at the same +# time on that platform, so we default to a shared-only configuration. +# If a disable-shared tag is given, we'll fallback to a static-only +# configuration. But we'll never go from static-only to shared-only. + +# ### BEGIN LIBTOOL TAG CONFIG: disable-shared +build_libtool_libs=no +build_old_libs=yes +# ### END LIBTOOL TAG CONFIG: disable-shared + +# ### BEGIN LIBTOOL TAG CONFIG: disable-static +build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` +# ### END LIBTOOL TAG CONFIG: disable-static + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: diff --git a/build-aux/missing b/build-aux/missing new file mode 100755 index 0000000..c6e3795 --- /dev/null +++ b/build-aux/missing @@ -0,0 +1,215 @@ +#! /bin/sh +# Common wrapper for a few potentially missing GNU programs. + +scriptversion=2016-01-11.22; # UTC + +# Copyright (C) 1996-2017 Free Software Foundation, Inc. +# Originally written by Fran,cois Pinard , 1996. + +# 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, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +if test $# -eq 0; then + echo 1>&2 "Try '$0 --help' for more information" + exit 1 +fi + +case $1 in + + --is-lightweight) + # Used by our autoconf macros to check whether the available missing + # script is modern enough. + exit 0 + ;; + + --run) + # Back-compat with the calling convention used by older automake. + shift + ;; + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due +to PROGRAM being missing or too old. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + +Supported PROGRAM values: + aclocal autoconf autoheader autom4te automake makeinfo + bison yacc flex lex help2man + +Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and +'g' are ignored when checking the name. + +Send bug reports to ." + exit $? + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing $scriptversion (GNU Automake)" + exit $? + ;; + + -*) + echo 1>&2 "$0: unknown '$1' option" + echo 1>&2 "Try '$0 --help' for more information" + exit 1 + ;; + +esac + +# Run the given program, remember its exit status. +"$@"; st=$? + +# If it succeeded, we are done. +test $st -eq 0 && exit 0 + +# Also exit now if we it failed (or wasn't found), and '--version' was +# passed; such an option is passed most likely to detect whether the +# program is present and works. +case $2 in --version|--help) exit $st;; esac + +# Exit code 63 means version mismatch. This often happens when the user +# tries to use an ancient version of a tool on a file that requires a +# minimum version. +if test $st -eq 63; then + msg="probably too old" +elif test $st -eq 127; then + # Program was missing. + msg="missing on your system" +else + # Program was found and executed, but failed. Give up. + exit $st +fi + +perl_URL=http://www.perl.org/ +flex_URL=http://flex.sourceforge.net/ +gnu_software_URL=http://www.gnu.org/software + +program_details () +{ + case $1 in + aclocal|automake) + echo "The '$1' program is part of the GNU Automake package:" + echo "<$gnu_software_URL/automake>" + echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" + echo "<$gnu_software_URL/autoconf>" + echo "<$gnu_software_URL/m4/>" + echo "<$perl_URL>" + ;; + autoconf|autom4te|autoheader) + echo "The '$1' program is part of the GNU Autoconf package:" + echo "<$gnu_software_URL/autoconf/>" + echo "It also requires GNU m4 and Perl in order to run:" + echo "<$gnu_software_URL/m4/>" + echo "<$perl_URL>" + ;; + esac +} + +give_advice () +{ + # Normalize program name to check for. + normalized_program=`echo "$1" | sed ' + s/^gnu-//; t + s/^gnu//; t + s/^g//; t'` + + printf '%s\n' "'$1' is $msg." + + configure_deps="'configure.ac' or m4 files included by 'configure.ac'" + case $normalized_program in + autoconf*) + echo "You should only need it if you modified 'configure.ac'," + echo "or m4 files included by it." + program_details 'autoconf' + ;; + autoheader*) + echo "You should only need it if you modified 'acconfig.h' or" + echo "$configure_deps." + program_details 'autoheader' + ;; + automake*) + echo "You should only need it if you modified 'Makefile.am' or" + echo "$configure_deps." + program_details 'automake' + ;; + aclocal*) + echo "You should only need it if you modified 'acinclude.m4' or" + echo "$configure_deps." + program_details 'aclocal' + ;; + autom4te*) + echo "You might have modified some maintainer files that require" + echo "the 'autom4te' program to be rebuilt." + program_details 'autom4te' + ;; + bison*|yacc*) + echo "You should only need it if you modified a '.y' file." + echo "You may want to install the GNU Bison package:" + echo "<$gnu_software_URL/bison/>" + ;; + lex*|flex*) + echo "You should only need it if you modified a '.l' file." + echo "You may want to install the Fast Lexical Analyzer package:" + echo "<$flex_URL>" + ;; + help2man*) + echo "You should only need it if you modified a dependency" \ + "of a man page." + echo "You may want to install the GNU Help2man package:" + echo "<$gnu_software_URL/help2man/>" + ;; + makeinfo*) + echo "You should only need it if you modified a '.texi' file, or" + echo "any other file indirectly affecting the aspect of the manual." + echo "You might want to install the Texinfo package:" + echo "<$gnu_software_URL/texinfo/>" + echo "The spurious makeinfo call might also be the consequence of" + echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" + echo "want to install GNU make:" + echo "<$gnu_software_URL/make/>" + ;; + *) + echo "You might have modified some files without having the proper" + echo "tools for further handling them. Check the 'README' file, it" + echo "often tells you about the needed prerequisites for installing" + echo "this package. You may also peek at any GNU archive site, in" + echo "case some other package contains this missing '$1' program." + ;; + esac +} + +give_advice "$1" | sed -e '1s/^/WARNING: /' \ + -e '2,$s/^/ /' >&2 + +# Propagate the correct exit status (expected to be 127 for a program +# not found, 63 for a program that failed due to version mismatch). +exit $st + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC0" +# time-stamp-end: "; # UTC" +# End: diff --git a/callback/COPYING b/callback/COPYING new file mode 100644 index 0000000..a3d1815 --- /dev/null +++ b/callback/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, 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) + + 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/callback/MIGRATION b/callback/MIGRATION new file mode 100644 index 0000000..6ce7402 --- /dev/null +++ b/callback/MIGRATION @@ -0,0 +1,79 @@ +Migration Guide +=============== + +When switching from vacall+trampoline to callback, you need to make the +following changes to your code: + + vacall+trampoline callback + ----------------- -------- + + -- Include files -- + +#include "vacall/vacall.h" #include "callback/callback.h" +#include "trampoline/trampoline.h" + + -- Variable declarations -- + +static void* trampvar; + + -- Callback declaration -- + +static void static void +mycallback (va_alist args) mycallback (void* data, va_alist args) +{ { + void* data = trampvar; ... + ... + + -- Initialization -- + +vacall_function = &mycallback; + + -- Allocating a callback -- + +void* trampoline = void* trampoline = + alloc_trampoline( alloc_callback(&mycallback,data); + (__TR_function)&vacall, + &trampvar, + data); + + -- Testing for a callback -- + +if if +(is_trampoline(address) (is_callback(address) + && (trampoline_address(address) && (callback_address(address) + == (__TR_function)&vacall) == &mycallback) + && (trampoline_variable(address) ) + == &trampvar) +) + +void* data = trampoline_data(address); void* data = callback_data(address); + + -- Deallocating a callback -- + +free_trampoline(address); free_callback(address); + + -- Libraries -- + +libvacall.a libtrampoline.a libcallback.a + + +================================================================================ +Copyright (C) 1995-1998 Bruno Haible + +This manual is free documentation. It is dually licensed under the +GNU FDL and the GNU GPL. This means that you can redistribute this +manual under either of these two licenses, at your choice. + +This manual is covered by the GNU FDL. Permission is granted to copy, +distribute and/or modify this document under the terms of the +GNU Free Documentation License (FDL), either version 1.2 of the +License, or (at your option) any later version published by the +Free Software Foundation (FSF); with no Invariant Sections, with no +Front-Cover Text, and with no Back-Cover Texts. +A copy of the license is at . + +This manual is covered by the GNU GPL. You can redistribute it and/or +modify it under the terms of the GNU General Public License (GPL), either +version 2 of the License, or (at your option) any later version published +by the Free Software Foundation (FSF). +A copy of the license is at . diff --git a/callback/Makefile.in b/callback/Makefile.in new file mode 100644 index 0000000..06b8203 --- /dev/null +++ b/callback/Makefile.in @@ -0,0 +1,236 @@ +# Makefile for callback + +#### Start of system configuration section. #### + +HOST = @host@ +CPU = @HOST_CPU_C_ABI@ + +# Directories used by "make": +srcdir = @srcdir@ + +# Directories used by "make install": +prefix = @prefix@ +local_prefix = /usr/local +exec_prefix = @exec_prefix@ +libdir = @libdir@ +includedir = @includedir@ +mandir = @mandir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +htmldir = $(datadir)/html + +# Programs used by "make": +# C compiler +CC = @CC@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +# C++ compiler +CXX = @CXX@ +CXXFLAGS = @CXXFLAGS@ +# Both C and C++ compiler +CPPFLAGS = @CPPFLAGS@ +INCLUDES = -I. -I$(srcdir) -I.. -I$(srcdir)/.. -I$(srcdir)/vacall_r +LDFLAGS = @LDFLAGS@ +LIBTOOL = @LIBTOOL@ +LIBTOOL_COMPILE = $(LIBTOOL) --mode=compile +LIBTOOL_LINK = $(LIBTOOL) --mode=link +LIBTOOL_INSTALL = $(LIBTOOL) --mode=install +LIBTOOL_UNINSTALL = $(LIBTOOL) --mode=uninstall +AR = @AR@ +AR_FLAGS = rc +RANLIB = @RANLIB@ +RM = rm -f +@SET_MAKE@ + +# Programs used by "make install": +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ + +# Libtool options for linking with the thread library. +LTLIBTHREAD = @LTLIBTHREAD@ + +#### End of system configuration section. #### + +SHELL = /bin/sh + +# Needed by $(LIBTOOL). +top_builddir = .. + +# Limit the set of exported symbols, on those platforms where libtool supports it. +# Currently this excludes the symbols from gnulib modules. +LIBCALLBACK_EXPORTED_SYMBOLS_REGEX = '^callback_|_callback$$|^trampoline_r_data0$$' + +# Before making a release, change this according to the libtool documentation, +# section "Library interface versions". +LIBCALLBACK_VERSION_INFO = 1:2:0 + +all : all-subdirs libcallback.la $(srcdir)/callback.3 $(srcdir)/callback.html + +all-subdirs : force + cd @callback_subdir@ && $(MAKE) all + +callback-libapi.lo : $(srcdir)/callback-libapi.c $(srcdir)/callback.h $(srcdir)/trampoline_r/trampoline_r.h ../config.h + $(LIBTOOL_COMPILE) $(CC) $(INCLUDES) -I$(srcdir)/trampoline_r $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/callback-libapi.c + +callback-compat.lo : $(srcdir)/callback-compat.c ../config.h + $(LIBTOOL_COMPILE) $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/callback-compat.c + +libcallback.la : vacall_r/libvacall.la trampoline_r/libtrampoline.la callback-libapi.lo callback-compat.lo + $(LIBTOOL_LINK) $(CC) -o libcallback.la -rpath $(libdir) -no-undefined -export-symbols-regex $(LIBCALLBACK_EXPORTED_SYMBOLS_REGEX) -version-info $(LIBCALLBACK_VERSION_INFO) vacall_r/vacall.lo vacall_r/vacall-libapi.lo vacall_r/vacall-structcpy.lo trampoline_r/*.lo callback-libapi.lo callback-compat.lo ../gnulib-lib/libgnu.la $(LDFLAGS) $(LTLIBTHREAD) + +# Installs the library and include files only. Typically called with only +# $(libdir) and $(includedir) - don't use $(prefix) and $(exec_prefix) here. +install-lib : all force + cd vacall_r && $(MAKE) install-lib libdir='$(libdir)' includedir='$(includedir)' + mkdir -p $(libdir) + $(LIBTOOL_INSTALL) $(INSTALL_DATA) libcallback.la $(libdir)/libcallback.la + mkdir -p $(includedir) + $(INSTALL_DATA) $(srcdir)/callback.h $(includedir)/callback.h + +install : force + cd vacall_r && $(MAKE) install + mkdir -p $(DESTDIR)$(prefix) + mkdir -p $(DESTDIR)$(exec_prefix) + mkdir -p $(DESTDIR)$(libdir) + $(LIBTOOL_INSTALL) $(INSTALL_DATA) libcallback.la $(DESTDIR)$(libdir)/libcallback.la + mkdir -p $(DESTDIR)$(includedir) + $(INSTALL_DATA) $(srcdir)/callback.h $(DESTDIR)$(includedir)/callback.h + mkdir -p $(DESTDIR)$(mandir) + mkdir -p $(DESTDIR)$(mandir)/man3 + $(INSTALL_DATA) $(srcdir)/callback.3 $(DESTDIR)$(mandir)/man3/callback.3 + mkdir -p $(DESTDIR)$(datadir) + mkdir -p $(DESTDIR)$(htmldir) + $(INSTALL_DATA) $(srcdir)/callback.html $(DESTDIR)$(htmldir)/callback.html + +installdirs : force + cd vacall_r && $(MAKE) installdirs + mkdir -p $(DESTDIR)$(prefix) + mkdir -p $(DESTDIR)$(exec_prefix) + mkdir -p $(DESTDIR)$(libdir) + mkdir -p $(DESTDIR)$(includedir) + mkdir -p $(DESTDIR)$(mandir) + mkdir -p $(DESTDIR)$(mandir)/man3 + mkdir -p $(DESTDIR)$(datadir) + mkdir -p $(DESTDIR)$(htmldir) + +uninstall : force + cd vacall_r && $(MAKE) uninstall + $(LIBTOOL_UNINSTALL) $(RM) $(DESTDIR)$(libdir)/libcallback.la + $(RM) $(DESTDIR)$(includedir)/callback.h + $(RM) $(DESTDIR)$(mandir)/man3/callback.3 + $(RM) $(DESTDIR)$(htmldir)/callback.html + +test1.@OBJEXT@ : $(srcdir)/test1.c $(srcdir)/callback.h $(srcdir)/vacall_r/vacall_r.h + $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/test1.c + +test1 : test1.@OBJEXT@ libcallback.la + $(LIBTOOL_LINK) $(CC) $(CFLAGS) @GCC_X_NONE@ test1.@OBJEXT@ libcallback.la $(LDFLAGS) -o test1 + +minitests.@OBJEXT@ : $(srcdir)/minitests.c $(srcdir)/tests.c $(srcdir)/callback.h $(srcdir)/vacall_r/vacall_r.h + $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/minitests.c + +minitests.s : $(srcdir)/minitests.c $(srcdir)/tests.c $(srcdir)/callback.h $(srcdir)/vacall_r/vacall_r.h + $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -S $(srcdir)/minitests.c + +minitests : minitests.@OBJEXT@ libcallback.la + $(LIBTOOL_LINK) $(CC) $(CFLAGS) @GCC_X_NONE@ minitests.@OBJEXT@ libcallback.la $(LDFLAGS) -o minitests + +minitests-c++.@OBJEXT@ : $(srcdir)/minitests-c++.cc $(srcdir)/minitests.c $(srcdir)/tests.c $(srcdir)/callback.h $(srcdir)/vacall_r/vacall_r.h + $(CXX) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS) -c $(srcdir)/minitests-c++.cc + +minitests-c++ : minitests-c++.@OBJEXT@ libcallback.la + $(LIBTOOL_LINK) $(CXX) $(CXXFLAGS) @GCC_X_NONE@ minitests-c++.@OBJEXT@ libcallback.la $(LDFLAGS) -o minitests-c++ + +check-subdirs : force + cd @callback_subdir@ && $(MAKE) check + +check : all check-subdirs test1 minitests + ./test1 + ./minitests > minitests.out + LC_ALL=C uniq -u < minitests.out > minitests.output.$(HOST) + test '!' -s minitests.output.$(HOST) +@IF_CXX@ ./minitests-c++ > minitests-c++.out +@IF_CXX@ LC_ALL=C uniq -u < minitests-c++.out > minitests-c++.output.$(HOST) +@IF_CXX@ test '!' -s minitests-c++.output.$(HOST) +@IF_CXX@check : minitests-c++ + +tests.@OBJEXT@ : $(srcdir)/tests.c $(srcdir)/callback.h $(srcdir)/vacall_r/vacall_r.h + $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/tests.c + +tests.s : $(srcdir)/tests.c $(srcdir)/callback.h $(srcdir)/vacall_r/vacall_r.h + $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -S $(srcdir)/tests.c + +tests : tests.@OBJEXT@ libcallback.la + $(LIBTOOL_LINK) $(CC) $(CFLAGS) @GCC_X_NONE@ tests.@OBJEXT@ libcallback.la $(LDFLAGS) -o tests + +extracheck-subdirs : force + cd @callback_subdir@ && $(MAKE) extracheck + +extracheck : all extracheck-subdirs tests + ./tests > tests.out + LC_ALL=C uniq -u < tests.out > tests.output.$(HOST) + test '!' -s tests.output.$(HOST) + +MOSTLYCLEANDIRS = .libs _libs +MOSTLYCLEANFILES = \ + *.@OBJEXT@ *.lo core \ + libcallback.* \ + test1.@OBJEXT@ test1 \ + minitests.@OBJEXT@ minitests.s minitests minitests.out \ + minitests-c++.@OBJEXT@ minitests-c++ minitests-c++.out \ + tests.@OBJEXT@ tests.s tests tests.out + +mostlyclean : force + cd @callback_subdir@ && $(MAKE) mostlyclean + $(RM) -r $(MOSTLYCLEANDIRS) + $(RM) $(MOSTLYCLEANFILES) + +clean : force + cd @callback_subdir@ && $(MAKE) clean + $(RM) -r $(MOSTLYCLEANDIRS) + $(RM) $(MOSTLYCLEANFILES) + +DISTCLEANFILES = \ + Makefile \ + minitests.output.* minitests-c++.output.* tests.output.* + +distclean : force + cd @callback_subdir@ && if test -f Makefile; then $(MAKE) distclean; fi + $(RM) -r $(MOSTLYCLEANDIRS) + $(RM) $(MOSTLYCLEANFILES) + $(RM) $(DISTCLEANFILES) + +maintainer-clean : force + cd @callback_subdir@ && if test -f Makefile; then $(MAKE) maintainer-clean; fi + $(RM) -r $(MOSTLYCLEANDIRS) + $(RM) $(MOSTLYCLEANFILES) + $(RM) $(DISTCLEANFILES) + + +# List of source files (committed in version control). +SOURCE_FILES = \ + COPYING MIGRATION PLATFORMS README callback.3 callback.html elf-hack.txt \ + Makefile.maint \ + Makefile.in \ + callback.h \ + callback-libapi.c \ + callback-compat.c \ + test1.c \ + minitests.c minitests-c++.cc \ + tests.c +# List of distributed files generated by Makefile.maint. +GENERATED_FILES = \ + callback.man +# List of distributed files. +DISTFILES = $(SOURCE_FILES) $(GENERATED_FILES) + +distdir : $(DISTFILES) + for file in $(DISTFILES); do \ + if test -f $$file; then dir='.'; else dir='$(srcdir)'; fi; \ + cp -p "$$dir/$$file" '$(distdir)'/$$file || exit 1; \ + done + test -d '$(distdir)'/@callback_subdir@ || mkdir '$(distdir)'/@callback_subdir@; cd @callback_subdir@ && $(MAKE) distdir distdir='$(distdir)'/@callback_subdir@ + + +force : diff --git a/callback/Makefile.maint b/callback/Makefile.maint new file mode 100644 index 0000000..c60fbae --- /dev/null +++ b/callback/Makefile.maint @@ -0,0 +1,29 @@ +# maintainer -*-Makefile-*- + +SHELL = /bin/sh +MAKE = make + +# ==================== Easily regeneratable files ==================== + +ROFF_MAN = groff -Tutf8 -mandoc + +all : callback.man \ + vacall_r/vacall-i386-msvc.c \ + trampoline_r/trampoline_r.man + +callback.man : callback.3 + $(ROFF_MAN) callback.3 > callback.man + +vacall_r/vacall-i386-msvc.c : vacall_r/vacall-i386-macro.S + cd vacall_r && $(MAKE) -f Makefile.maint vacall-i386-msvc.c + +trampoline_r/trampoline_r.man : trampoline_r/trampoline_r.3 + cd trampoline_r && $(MAKE) -f Makefile.maint trampoline_r.man + +totally-clean : force + $(RM) callback.man + cd vacall_r && $(MAKE) -f Makefile.maint totally-clean + cd trampoline_r && $(MAKE) -f Makefile.maint totally-clean + + +force : diff --git a/callback/PLATFORMS b/callback/PLATFORMS new file mode 100644 index 0000000..ab8b5e6 --- /dev/null +++ b/callback/PLATFORMS @@ -0,0 +1,43 @@ +Supported CPUs: (Put the GNU config.guess values here.) + i386 i486-pc-linux (gcc), i686-unknown-gnu0.9 (gcc), + i386-pc-solaris2.6 (gcc), i386-pc-solaris2.10 (gcc, cc), + i386-w64-mingw32 (gcc, MSVC 14), + i586-unknown-freebsd11.0 (cc), i386-unknown-dragonfly3.8 (gcc), + i386-unknown-netbsdelf7.0 (gcc), i386-unknown-openbsd6.0 (gcc), + i586-pc-haiku (gcc-x86), i386-pc-minix (clang) + m68k m68k-unknown-linux (gcc) + mips mips-sgi-irix5.3 (gcc), mips-sgi-irix6.4 (cc -32, -n32, -64), + mips-sgi-irix6.5 (cc -32, -n32, gcc -mabi=n32), + mips-unknown-linux (gcc -mabi=32), + mips64-unknown-linux (gcc -mabi=n32, gcc -mabi=64) + sparc sparc-sun-sunos4.1.3_U1 (gcc), sparc-sun-solaris2.4 (gcc), + sparc-sun-solaris2.10 (gcc, cc), + sparc64-sun-solaris2.10 (gcc -m64, cc -xarch=generic64), + sparc-unknown-linux (gcc), sparc64-unknown-linux (gcc), + sparc-unknown-netbsdelf7.1 (gcc), + sparc64-unknown-netbsd8.0 (gcc) + alpha alpha-dec-osf3.2 (gcc), alpha-dec-osf4.0 (gcc, cc), + alphaev67-unknown-linux (gcc) + hppa hppa1.1-hp-hpux9.05 (cc), hppa1.1-hp-hpux10.01 (cc), + hppa2.0-hp-hpux10.20 (cc +DA1.1), hppa2.0w-hp-hpux11.31 (cc), + hppa-unknown-linux (gcc) + hppa64 hppa64-hp-hpux11.31 (cc +DD64) + arm armv5tejl-unknown-linux (gcc), armv6l-unknown-linux (gcc), + armv7l-unknown-linux (gcc) + arm64 aarch64-unknown-linux (gcc) + powerpc powerpc-ibm-aix7.1.3.0 (xlc, gcc), powerpc-unknown-linux (gcc), + powerpc-apple-darwin6.8 (gcc), powerpc-apple-darwin9.8.0 (gcc) + powerpc64 powerpc-ibm-aix7.1.3.0 (gcc -maix64, xlc -q64; AR="ar -X 64"), + powerpc64-unknown-linux (gcc -m64), + powerpc64le-unknown-linux (gcc) + ia64 ia64-unknown-linux (gcc) + x86_64 x86_64-suse-linux (gcc), x86_64-unknown-linux (gcc -mx32), + x86_64-pc-solaris2.10 (gcc -m64, cc -xarch=generic64), + x86_64-pc-cygwin (gcc), x86_64-w64-mingw32 (gcc, MSVC 14), + x86_64-unknown-freebsd11.0 (cc), x86_64-unknown-netbsd7.0 (gcc), + x86_64-unknown-openbsd6.0 (gcc) + s390 s390x-ibm-linux (gcc -m31) + s390x s390x-ibm-linux (gcc) + riscv32 riscv32-unknown-linux (gcc -mabi=ilp32d) + riscv64 riscv64-unknown-linux (gcc -mabi=lp64d) + diff --git a/callback/README b/callback/README new file mode 100644 index 0000000..3b655d9 --- /dev/null +++ b/callback/README @@ -0,0 +1,66 @@ +callback - closures with variable arguments as first-class C functions + +This library implements closures with variable arguments and variable return +values as first-class C functions. A closure consists of a regular C function +and a piece of data which gets passed to the C function when the closure is +called. + +This library is especially suited to the implementation of call-back functions +in embedded interpreters. + + +Installation instructions: + + Configure the parent directory. Then: + cd callback + make + make check + make install + + +Files in this package: + + Documentation: + + README this text + COPYING free software license + PLATFORMS list of supported platforms + MIGRATION migration guide from vacall+trampoline + callback.3 manual page in Unix man format + callback.man manual page + callback.html manual page in HTML format + + Source: + + callback.h include file + tests.c test program + vacall_r/* a reentrant version of the vacall package + trampoline_r/* a reentrant version of the trampoline package + + Building: + + Makefile.in Makefile master + + Porting: + + Makefile.devel developer's Makefile + call-used-registers.txt table of call-used registers on different CPUs + + +Copyright notice: + +Copyright 1995-2017 Bruno Haible + +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, see . + diff --git a/callback/callback-compat.c b/callback/callback-compat.c new file mode 100644 index 0000000..fd3fc64 --- /dev/null +++ b/callback/callback-compat.c @@ -0,0 +1,24 @@ +/* + * Copyright 2017 Bruno Haible + * + * 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, see . + */ + +#include "config.h" + +#include + +/* A dummy symbol, so that GNU clisp's autoconfiguration recognizes this + library. */ +void trampoline_r_data0 (void) { abort(); } diff --git a/callback/callback-libapi.c b/callback/callback-libapi.c new file mode 100644 index 0000000..f1384c5 --- /dev/null +++ b/callback/callback-libapi.c @@ -0,0 +1,53 @@ +/* + * Copyright 2017 Bruno Haible + * + * 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, see . + */ + +#include "config.h" + +#define __TR_function obsolete__TR_function +#include "callback.h" +#undef __TR_function +#include "trampoline_r.h" + +/* This is the implementation of the library API. + The symbols that the linker sees are all prefixed with 'callback_', + to avoid potential collisions with other libraries. */ + +callback_t alloc_callback (callback_function_t address, void* data) +{ + return alloc_trampoline_r((__TR_function)callback_get_receiver(),(void*)address,data); +} + +void free_callback (callback_t callback) +{ + free_trampoline_r (callback); +} + +int is_callback (void* callback) +{ + return is_trampoline_r(callback) + && trampoline_r_address((__TR_function)callback) == (__TR_function)callback_get_receiver(); +} + +callback_function_t callback_address (callback_t callback) +{ + return (callback_function_t)trampoline_r_data0(callback); +} + +void* callback_data (callback_t callback) +{ + return trampoline_r_data1(callback); +} diff --git a/callback/callback.3 b/callback/callback.3 new file mode 100644 index 0000000..5214077 --- /dev/null +++ b/callback/callback.3 @@ -0,0 +1,273 @@ +.\" Copyright (C) 1995-2017 Bruno Haible +.\" +.\" This manual is free documentation. It is dually licensed under the +.\" GNU FDL and the GNU GPL. This means that you can redistribute this +.\" manual under either of these two licenses, at your choice. +.\" +.\" This manual is covered by the GNU FDL. Permission is granted to copy, +.\" distribute and/or modify this document under the terms of the +.\" GNU Free Documentation License (FDL), either version 1.2 of the +.\" License, or (at your option) any later version published by the +.\" Free Software Foundation (FSF); with no Invariant Sections, with no +.\" Front-Cover Text, and with no Back-Cover Texts. +.\" A copy of the license is at . +.\" +.\" This manual is covered by the GNU GPL. You can redistribute it and/or +.\" modify it under the terms of the GNU General Public License (GPL), either +.\" version 2 of the License, or (at your option) any later version published +.\" by the Free Software Foundation (FSF). +.\" A copy of the license is at . +.\" +.TH CALLBACK 3 "1 January 2017" +.SH NAME +callback \- closures with variable arguments as first-class C functions +.SH SYNOPSIS +.B #include +.LP +.nf +.BI "void " function " (void* " data ", va_alist " alist ")" +.BI "{" +.BI " va_start_" type "(" alist "[, " return_type "]);" +.BI " " arg " = va_arg_" type "(" alist "[, " arg_type "]);" +.BI " va_return_" type "(" alist "[[, " return_type "], " return_value "]);" +.BI "}" +.fi +.LP +.IB callback " = alloc_callback(" "&function" ", " data ");" +.LP +.BI "free_callback(" callback ");" +.LP +.nf +.BI "is_callback(" callback ")" +.BI "callback_address(" callback ")" +.BI "callback_data(" callback ")" +.fi +.SH DESCRIPTION +.LP +These functions implement +.I closures +with variable arguments as first-class C functions. + +Closures as +.I first-class C functions +means that they fit into a function pointer and can be called exactly +like any other C function. Moreover, they can be called with variable +arguments and can return variable return values. + +.IB callback " = alloc_callback(" "&function" ", " data ")" +allocates a callback. When +.I callback +gets called, it arranges to call +.IR function "," +passing +.I data +as first argument and, as second argument, the entire sequence of arguments +passed to +.IR callback . + +Function calling conventions differ considerably on different machines, +therefore the arguments are accessed and the result value is stored +through the same macros as used by the +.I vacall +package, see below. + +The callbacks are functions with indefinite extent: +.I callback +is only deallocated when +.BI free_callback( callback ) +is called. + +.BI "is_callback(" callback ")" +checks whether the C function +.I callback +was produced by a call to +.IR alloc_callback . +If this returns true, the arguments given to +.I alloc_callback +can be retrieved: +.RS 4 +.LP +.BI "callback_address(" callback ")" +returns +.IR "&function" , +.LP +.BI "callback_data(" callback ")" +returns +.IR data . +.RE + +.SH VACALL MACROS + +Within +.IR function , +the following macros can be used to walk through the argument list and +specify a return value: +.RS 0 +.TP +.BI "va_start_" type "(" alist "[, " return_type "]);" +starts the walk through the argument list and specifies the return type. +.TP +.IB arg " = va_arg_" type "(" alist "[, " arg_type "]);" +fetches the next argument from the argument list. +.TP +.BI "va_return_" type "(" alist "[[, " return_type "], " return_value "]);" +ends the walk through the argument list and specifies the return value. +.RE + +The +.I type +in +.BI va_start_ type +and +.BI va_return_ type +shall be one of +.BR void ", " int ", " uint ", " long ", " ulong ", " longlong ", " ulonglong ", " double ", " struct ", " ptr +or (for ANSI C calling conventions only) +.BR char ", " schar ", " uchar ", " short ", " ushort ", " float , +depending on the class of +.IR return_type . + +The +.I type +specifiers in +.BI va_start_ type +and +.BI va_return_ type +must be the same. +The +.I return_type +specifiers passed to +.BI va_start_ type +and +.BI va_return_ type +must be the same. + +The +.I type +in +.BI va_arg_ type +shall be one of +.BR int ", " uint ", " long ", " ulong ", " longlong ", " ulonglong ", " double ", " struct ", " ptr +or (for ANSI C calling conventions only) +.BR char ", " schar ", " uchar ", " short ", " ushort ", " float , +depending on the class of +.IR arg_type . + +In +.BI "va_start_struct(" alist ", " return_type ", " splittable ); +the +.I splittable +flag specifies whether the struct +.I return_type +can be returned in registers such that every struct field fits entirely in +a single register. This needs to be specified for structs of size +2*sizeof(long). For structs of size <= sizeof(long), +.I splittable +is ignored and assumed to be 1. For structs of size > 2*sizeof(long), +.I splittable +is ignored and assumed to be 0. There are some handy macros for this: +.nf +.BI "va_word_splittable_1 (" type1 ) +.BI "va_word_splittable_2 (" type1 ", " type2 ) +.BI "va_word_splittable_3 (" type1 ", " type2 ", " type3 ) +.BI "va_word_splittable_4 (" type1 ", " type2 ", " type3 ", " type4 ) +.fi +For a struct with three slots +.nf +.BI "struct { " "type1 id1" "; " "type2 id2" "; " "type3 id3" "; }" +.fi +you can specify +.I splittable +as +.BI "va_word_splittable_3 (" type1 ", " type2 ", " type3 ) +.RB . + +.SH NOTES + +Functions which want to emulate Kernighan & Ritchie style functions (i.e., +in ANSI C, functions without a typed argument list) cannot use the +.I type +values +.BR char ", " schar ", " uchar ", " short ", " ushort ", " float . +As prescribed by the default K&R C expression promotions, they have +to use +.B int +instead of +.BR char ", " schar ", " uchar ", " short ", " ushort +and +.B double +instead of +.BR float . + +The macros +.BR va_start_longlong(\|) , +.BR va_start_ulonglong(\|) , +.BR va_return_longlong(\|) , +.BR va_return_ulonglong(\|) , +.B va_arg_longlong(\|) +and +.B va_arg_ulonglong(\|) +work only if the C compiler has a working +.B long long +64-bit integer type. + +The struct types used in +.B va_start_struct(\|) +and +.B va_struct(\|) +must only contain (signed or unsigned) int, long, long long or pointer fields. +Struct types containing (signed or unsigned) char, short, float, double or +other structs are not supported. + +.SH SEE ALSO +.BR vacall (3), +.BR trampoline (3). + +.SH BUGS + +The current implementations have been tested on a selection of common +cases but there are probably still many bugs. + +There are typically built-in limits on the size of the argument-list, +which may also include the size of any structure arguments. + +The decision whether a struct is to be returned in registers or in memory +considers only the struct's size and alignment. This is inaccurate: for +example, gcc on m68k-next returns +.B "struct { char a,b,c; }" +in registers and +.B "struct { char a[3]; }" +in memory, although both types have the same size and the same alignment. + +The argument list can only be walked once. + +.SH NON-BUGS + +All information is passed in CPU registers and the stack. The +.B callback +package is therefore multithread-safe. + +.SH PORTING + +Porting +.B callback +consists in first porting the +.B vacall +and +.B trampoline +packages, then choosing a CPU register for passing the closure from +.B trampoline +to +.BR vacall . +This register is normally the register designated by STATIC_CHAIN_REGNUM +in the gcc source, file +.RI gcc-2.7.2/config/ cpu / cpu .h. + +.SH AUTHOR + +Bruno Haible + +.SH ACKNOWLEDGEMENTS + +Many ideas were cribbed from the gcc source. + diff --git a/callback/callback.h b/callback/callback.h new file mode 100644 index 0000000..667b067 --- /dev/null +++ b/callback/callback.h @@ -0,0 +1,90 @@ +/* + * Copyright 1997-2017 Bruno Haible + * + * 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, see . + */ + +#ifndef _CALLBACK_H +#define _CALLBACK_H + +#include "ffcall-version.h" + +/* Defines the type 'va_alist' and the va_* macros. */ +#include "vacall_r.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* This type denotes an opaque function pointer. + You need to cast it to an actual function pointer type (with correct return + type) before you can actually invoke it. */ +#ifdef __cplusplus +typedef int (*callback_t) (...); +#else +typedef int (*callback_t) (); +#endif +/* A deprecated alias of this type. */ +typedef callback_t __TR_function; + +/* This type denotes a callback implementation. + DATA is the pointer that was passed to alloc_callback(). + ALIST allows to iterate over the argument list. */ +typedef void (*callback_function_t) (void* /* DATA */, va_alist /* ALIST */); + + +/* Allocates a callback. + It returns a function pointer whose signature depends on the behaviour + of ADDRESS. + When invoked, it passes DATA as first argument to ADDRESS and the actual + arguments as a va_alist to ADDRESS. It returns the value passed to a + va_return_* macro by ADDRESS. + The callback has indefinite extent. It can be accessed until a call to + free_callback(). + */ +extern callback_t alloc_callback (callback_function_t /* ADDRESS */, void* /* DATA */); + +/* Frees the memory used by a callback. + CALLBACK must be the result of an alloc_callback() invocation. + After this call, CALLBACK must not be used any more - neither invoked, + not used as an argument to other functions. + */ +extern void free_callback (callback_t /* CALLBACK */); + + +/* Tests whether a given pointer is a function pointer returned by + alloc_callback(). Returns 1 for yes, 0 for no. + If yes, it can be cast to callback_t. + */ +extern int is_callback (void* /* CALLBACK */); + +/* Returns the ADDRESS argument passed to the alloc_callback() invocation. + CALLBACK must be the result of an alloc_callback() invocation. + */ +extern callback_function_t callback_address (callback_t /* CALLBACK */); + +/* Returns the DATA argument passed to the alloc_callback() invocation. + CALLBACK must be the result of an alloc_callback() invocation. + */ +extern void* callback_data (callback_t /* CALLBACK */); + + +#ifdef __cplusplus +} +#endif + + +#endif /* _CALLBACK_H */ diff --git a/callback/callback.html b/callback/callback.html new file mode 100644 index 0000000..bc0c675 --- /dev/null +++ b/callback/callback.html @@ -0,0 +1,290 @@ + + + + CALLBACK manual page + + +

CALLBACK manual page

+ + +

+ +


+ + +

Name

+
+ +callback - closures with variable arguments as first-class +C functions + + +

Synopsis

+
+ +
+#include <callback.h>
+
+

+

+void function (void* data, va_alist alist)
+{
+  va_start_type(alist[, return_type]);
+  arg = va_arg_type(alist[, arg_type]);
+  va_return_type(alist[[, return_type], return_value]);
+}
+
+

+

+callback = alloc_callback(&function, data);
+
+

+

+free_callback(callback);
+
+

+

+is_callback(callback)
+callback_address(callback)
+callback_data(callback)
+
+ + +

Description

+
+ +These functions implement closures with variable arguments +as first-class C functions. +

+Closures as first-class C functions means that they fit +into a function pointer and can be called exactly like any +other C function. Moreover, they can be called with variable +arguments and can return variable return values. +

+callback = alloc_callback(&function, data) +allocates a +callback. When callback gets called, it arranges to call +function, passing data as first argument and, as second +argument, the entire sequence of arguments passed to callback. +

+Function calling conventions differ considerably on different +machines, therefore the arguments are accessed and +the result value is stored through the same macros as used +by the vacall package, see below. +

+The callbacks are functions with indefinite extent: callback +is only deallocated when free_callback(callback) is +called. +

+is_callback(callback) +checks whether the C function callback +was produced by a call to alloc_callback. If this +returns true, the arguments given to alloc_callback can be +retrieved: +

    +
  • callback_address(callback) returns &function, +
  • callback_data(callback) returns data. +
+ + +

VACALL macros

+
+ +Within function, the following macros can be used to walk +through the argument list and specify a return value: +

+

+va_start_type(alist[, return_type]);
+
+starts the walk through the argument list and specifies the return type. +

+

+arg = va_arg_type(alist[, arg_type]);
+
+fetches the next argument from the argument list. +

+

+va_return_type(alist[[, return_type], return_value]);
+
+ends the walk through the argument list and specifies the return value. +

+The type in va_start_type + and va_return_type shall be one +of void, int, uint, long, +ulong, longlong, ulonglong, +double, struct, ptr +or +(for ANSI C calling conventions only) +char, schar, uchar, +short, ushort, float, +depending on the class of return_type. +

+The type specifiers in +va_start_type and va_return_type + must be the same. +The return_type specifiers passed to +va_start_type and va_return_type + must be the same. +

+The type in va_arg_type +shall be one of int, uint, long, +ulong, longlong, ulonglong, +double, struct, ptr +or (for ANSI C calling conventions only) +char, schar, uchar, +short, ushort, float, +depending on the class of arg_type. +

+In va_start_struct(alist, return_type, splittable); the +splittable flag specifies whether the struct return_type can +be returned in registers such that every struct field fits +entirely in a single register. This needs to be specified +for structs of size 2*sizeof(long). For structs of size +<= sizeof(long), splittable is ignored and assumed to be 1. +For structs of size > 2*sizeof(long), splittable is +ignored and assumed to be 0. There are some handy macros +for this: +

+va_word_splittable_1 (type1)
+va_word_splittable_2 (type1, type2)
+va_word_splittable_3 (type1, type2, type3)
+va_word_splittable_4 (type1, type2, type3, type4)
+
+For a struct with three slots +
+struct { type1 id1; type2 id2; type3 id3; }
+
+you can specify splittable as +va_word_splittable_3 (type1, type2, type3). + + +

Notes

+
+ +
    +
  1. Functions which want to emulate Kernighan & Ritchie style +functions (i.e., in ANSI C, functions without a typed +argument list) cannot use the type values +char, schar, uchar, +short, ushort, float. +As prescribed by the default +K&R C expression promotions, they have to use int instead +of char, schar, uchar, +short, ushort and double instead of +float. +

    +

  2. The macros va_start_longlong(), +va_start_ulonglong(), va_return_longlong(), +va_return_ulonglong(), va_arg_longlong() and +va_arg_ulonglong() work only if the C compiler has a working +long long 64-bit integer type. +

    +

  3. The struct types used in va_start_struct() and +va_struct() must only contain (signed or unsigned) int, +long, long long or pointer fields. Struct types containing +(signed or unsigned) char, short, float, double or other +structs are not supported. +

    +

+ + +

See also

+
+ +vacall(3), trampoline(3). + + +

Bugs

+
+ +The current implementations have been tested on a selection +of common cases but there are probably still many +bugs. +

+There are typically built-in limits on the size of the +argument-list, which may also include the size of any +structure arguments. +

+The decision whether a struct is to be returned in registers or in memory +considers only the struct's size and alignment. This is inaccurate: for +example, gcc on m68k-next returns +struct { char a,b,c; } +in registers and +struct { char a[3]; } +in memory, although both types have the same size and the same alignment. +

+The argument list can only be walked once. + + +

Non-Bugs

+ + +All information is passed in CPU registers and the stack. +The callback package is therefore multithread-safe. + + +

Porting

+
+ +Porting callback consists in first porting the vacall and +trampoline packages, then choosing a CPU register for +passing the closure from trampoline to vacall. This +register is normally the register designated by +STATIC_CHAIN_REGNUM in the gcc source, file +gcc-2.7.2/config/cpu/cpu.h. + + +

Author

+
+ +Bruno Haible <bruno@clisp.org> + + +

Acknowledgements

+
+ +Many ideas were cribbed from the gcc source. +

+ +


+ +
CALLBACK manual page
+Bruno Haible <bruno@clisp.org> +
+

+Last modified: 1 January 2017. + + + diff --git a/callback/callback.man b/callback/callback.man new file mode 100644 index 0000000..8f3a81d --- /dev/null +++ b/callback/callback.man @@ -0,0 +1,164 @@ +CALLBACK(3) Library Functions Manual CALLBACK(3) + + + +NAME + callback - closures with variable arguments as first-class C functions + +SYNOPSIS + #include  + + void function (void* data, va_alist alist) + { + va_start_type(alist[, return_type]); + arg = va_arg_type(alist[, arg_type]); + va_return_type(alist[[, return_type], return_value]); + } + + callback = alloc_callback(&function, data); + + free_callback(callback); + + is_callback(callback) + callback_address(callback) + callback_data(callback) + +DESCRIPTION + These functions implement closures with variable arguments as first- + class C functions. + + Closures as first-class C functions means that they fit into a function + pointer and can be called exactly like any other C function. Moreover, + they can be called with variable arguments and can return variable + return values. + + callback = alloc_callback(&function, data) allocates a callback. When + callback gets called, it arranges to call function, passing data as + first argument and, as second argument, the entire sequence of argu‐ + ments passed to callback. + + Function calling conventions differ considerably on different machines, + therefore the arguments are accessed and the result value is stored + through the same macros as used by the vacall package, see below. + + The callbacks are functions with indefinite extent: callback is only + deallocated when free_callback(callback) is called. + + is_callback(callback) checks whether the C function callback was pro‐ + duced by a call to alloc_callback. If this returns true, the arguments + given to alloc_callback can be retrieved: + + callback_address(callback) returns &function, + + callback_data(callback) returns data. + + +VACALL MACROS + Within function, the following macros can be used to walk through the + argument list and specify a return value: + + va_start_type(alist[, return_type]); + starts the walk through the argument list and specifies the + return type. + + arg = va_arg_type(alist[, arg_type]); + fetches the next argument from the argument list. + + va_return_type(alist[[, return_type], return_value]); + ends the walk through the argument list and specifies the return + value. + + The type in va_start_type and va_return_type shall be one of void, int, + uint, long, ulong, longlong, ulonglong, double, struct, ptr or (for + ANSI C calling conventions only) char, schar, uchar, short, ushort, + float, depending on the class of return_type. + + The type specifiers in va_start_type and va_return_type must be the + same. The return_type specifiers passed to va_start_type and + va_return_type must be the same. + + The type in va_arg_type shall be one of int, uint, long, ulong, long‐ + long, ulonglong, double, struct, ptr or (for ANSI C calling conventions + only) char, schar, uchar, short, ushort, float, depending on the class + of arg_type. + + In va_start_struct(alist, return_type, splittable); the splittable flag + specifies whether the struct return_type can be returned in registers + such that every struct field fits entirely in a single register. This + needs to be specified for structs of size 2*sizeof(long). For structs + of size <= sizeof(long), splittable is ignored and assumed to be 1. For + structs of size > 2*sizeof(long), splittable is ignored and assumed to + be 0. There are some handy macros for this: + va_word_splittable_1 (type1) + va_word_splittable_2 (type1, type2) + va_word_splittable_3 (type1, type2, type3) + va_word_splittable_4 (type1, type2, type3, type4) + For a struct with three slots + struct { type1 id1; type2 id2; type3 id3; } + you can specify splittable as va_word_splittable_3 (type1, type2, + type3) . + + +NOTES + Functions which want to emulate Kernighan & Ritchie style functions + (i.e., in ANSI C, functions without a typed argument list) cannot use + the type values char, schar, uchar, short, ushort, float. As pre‐ + scribed by the default K&R C expression promotions, they have to use + int instead of char, schar, uchar, short, ushort and double instead of + float. + + The macros va_start_longlong(), va_start_ulonglong(), va_return_long‐ + long(), va_return_ulonglong(), va_arg_longlong() and va_arg_ulonglong() + work only if the C compiler has a working long long 64-bit integer + type. + + The struct types used in va_start_struct() and va_struct() must only + contain (signed or unsigned) int, long, long long or pointer fields. + Struct types containing (signed or unsigned) char, short, float, double + or other structs are not supported. + + +SEE ALSO + vacall(3), trampoline(3). + + +BUGS + The current implementations have been tested on a selection of common + cases but there are probably still many bugs. + + There are typically built-in limits on the size of the argument-list, + which may also include the size of any structure arguments. + + The decision whether a struct is to be returned in registers or in mem‐ + ory considers only the struct's size and alignment. This is inaccurate: + for example, gcc on m68k-next returns struct { char a,b,c; } in regis‐ + ters and struct { char a[3]; } in memory, although both types have the + same size and the same alignment. + + The argument list can only be walked once. + + +NON-BUGS + All information is passed in CPU registers and the stack. The callback + package is therefore multithread-safe. + + +PORTING + Porting callback consists in first porting the vacall and trampoline + packages, then choosing a CPU register for passing the closure from + trampoline to vacall. This register is normally the register desig‐ + nated by STATIC_CHAIN_REGNUM in the gcc source, file gcc-2.7.2/con‐ + fig/cpu/cpu.h. + + +AUTHOR + Bruno Haible + + +ACKNOWLEDGEMENTS + Many ideas were cribbed from the gcc source. + + + + + 1 January 2017 CALLBACK(3) diff --git a/callback/elf-hack.txt b/callback/elf-hack.txt new file mode 100644 index 0000000..9b5eee4 --- /dev/null +++ b/callback/elf-hack.txt @@ -0,0 +1,53 @@ +Workaround against the ELF symbol resolving routine +=================================================== + +On Solaris 2.6 / i386, when the function being jumped to is an external symbol +of a shared library, the jump actually points to an ELF indirect jump: + jmp *PTR +where PTR initially contains the address of some resolving routine which +will replace the PTR contents with the actual code address of the function +and then jump to the function. +Unfortunately, this resolving routine clobbers all three registers: +%eax, %edx, %ecx. But %ecx is the register in which we pass the env_t +(that points to function and data) to callback_receiver. + +The same effect is also seen on Linux / x86_64, where r10 is clobbered by the +resolving routine (called '_dl_runtime_resolve' in glibc). +See https://savannah.gnu.org/bugs/?32466 . + +The same thing can happen on all platforms that support ELF, since the +lexical closure register is always a call-used register (see file +call-used-registers.txt). + +On i386 (and m68k), it would be possible to solve this by passing the env_t +as an extra argument on the stack and restore it to the lexical closure +register at the beginning of callback_receiver. But this approach becomes too +complex for the other CPUs. + +It is not possible to make a first call to callback_receiver to "straighten +things out", because during this first call the lexical closure register gets +clobbered and callback_receiver then invokes undefined behaviour. + +It may be possible to fix this, on some platforms, + - by use of "ld -r" to combine object files, so that the code in + trampoline_r.o can access callback_receiver directly, or + - by use of symbol visibility control, so that callback_receiver is + not an external symbol of the shared library any more, or + - by an appropriate use of dlsym(). +But this is highly platform dependent (linker, compiler, libc) and there may +be some platforms for which none of these approaches works. + +A workaround that was implemented in January 2017 was to + 1) modify trampoline_r so that it produces a trampoline that pushes the + env_t on the stack (preserving correct stack alignment) instead of + putting it in the lexical closure register, + 2) insert a couple of instructions at the beginning of callback_receiver + that pops this value off the stack and puts in in the lexical closure + register. + +An even simpler workaround is to make callback_receiver a static function, +so that the ELF linker does not even see it. Instead introduce a function +callback_get_receiver that returns &callback_receiver. This function is global, +but since it has a normal calling convention, the ELF symbol resolving routine +does not cause trouble the first time callback_get_receiver() is invoked. + diff --git a/callback/minitests-c++.cc b/callback/minitests-c++.cc new file mode 100644 index 0000000..1738e11 --- /dev/null +++ b/callback/minitests-c++.cc @@ -0,0 +1,18 @@ +/* + * Copyright 2017 Bruno Haible + * + * 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, see . + */ + +#include "minitests.c" diff --git a/callback/minitests.c b/callback/minitests.c new file mode 100644 index 0000000..b0f50fe --- /dev/null +++ b/callback/minitests.c @@ -0,0 +1,19 @@ +/* + * Copyright 1999-2001 Bruno Haible + * + * 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, see . + */ + +#define SKIP_EXTRA_STRUCTS +#include "tests.c" diff --git a/callback/test1.c b/callback/test1.c new file mode 100644 index 0000000..16625f2 --- /dev/null +++ b/callback/test1.c @@ -0,0 +1,52 @@ +/* Trampoline test */ + +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +#include "config.h" /* Define __${host_cpu}__ */ + +#include +#include + +#include "callback.h" + +#define MAGIC1 0x9db9af42 +#define MAGIC2 0xa2f9d045 +#define MAGIC3 0x7aff3cb4 + +int f (int x) +{ + return x + MAGIC3; +} + +void vf (void* data, va_alist alist) +{ + if (data != (void*)MAGIC1) { printf("wrong data\n"); exit(1); } + va_start_int(alist); + {int a = va_arg_int(alist); + int r = f(a); + va_return_int(alist, r); +}} + +int main () +{ + callback_t cf = alloc_callback(&vf, (void*)MAGIC1); + if ((*cf)(MAGIC2) == MAGIC2+MAGIC3) + { free_callback(cf); printf("Works, test1 passed.\n"); exit(0); } + else + { printf("Doesn't work!\n"); exit(1); } +} diff --git a/callback/tests.c b/callback/tests.c new file mode 100644 index 0000000..4972c5b --- /dev/null +++ b/callback/tests.c @@ -0,0 +1,2386 @@ +/* Some random tests for vacall. */ + +/* + * Copyright 1993 Bill Triggs + * Copyright 1995-2019 Bruno Haible + * + * 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, see . + */ + +#include +#include +#include +#include "callback.h" + +#include "testcases.c" + +#if defined(__m68k__) && defined(__GNUC__) +/* "gcc-2.6.3 -freg-struct-return" returns T = struct { char c[3]; } (which + * has size 4 !) in memory, in contrast to struct { char a,b,c; } and + * struct { char c[4]; } and struct { char a,b,c,d; } which have the same + * size and the same alignment but are returned in registers. I don't know why. + */ +#define SKIP_T +#endif +#if defined(__sparc__) && defined(__sun) && defined(__SUNPRO_C) /* SUNWspro cc */ +/* SunPRO cc miscompiles the simulator function for X_BcdB: d.i[1] is + * temporarily stored in %l2 and put onto the stack from %l2, but in between + * the copy of X has used %l2 as a counter without saving and restoring its + * value. + */ +#define SKIP_X +#endif +#if defined(__mipsn32__) && !defined(__GNUC__) +/* The X test crashes for an unknown reason. */ +#define SKIP_X +#endif + + +/* These functions simulate the behaviour of the functions defined in testcases.c. */ + +/* void tests */ +void v_v_simulator (void* data, va_alist alist) +{ + if (data != (void*)&v_v) { fprintf(out,"wrong data for v_v\n"); exit(1); } + va_start_void(alist); + fprintf(out,"void f(void):\n"); + fflush(out); + va_return_void(alist); +} + +/* int tests */ +void i_v_simulator (void* data, va_alist alist) +{ + if (data != (void*)&i_v) { fprintf(out,"wrong data for i_v\n"); exit(1); } + va_start_int(alist); + {int r=99; + fprintf(out,"int f(void):"); + fflush(out); + va_return_int(alist, r); +}} +void i_i_simulator (void* data, va_alist alist) +{ + if (data != (void*)&i_i) { fprintf(out,"wrong data for i_i\n"); exit(1); } + va_start_int(alist); + {int a = va_arg_int(alist); + int r=a+1; + fprintf(out,"int f(int):(%d)",a); + fflush(out); + va_return_int(alist, r); +}} +void i_i2_simulator (void* data, va_alist alist) +{ + if (data != (void*)&i_i2) { fprintf(out,"wrong data for i_i2\n"); exit(1); } + va_start_int(alist); + {int a = va_arg_int(alist); + int b = va_arg_int(alist); + int r=a+b; + fprintf(out,"int f(2*int):(%d,%d)",a,b); + fflush(out); + va_return_int(alist, r); +}} +void i_i4_simulator (void* data, va_alist alist) +{ + if (data != (void*)&i_i4) { fprintf(out,"wrong data for i_i4\n"); exit(1); } + va_start_int(alist); + {int a = va_arg_int(alist); + int b = va_arg_int(alist); + int c = va_arg_int(alist); + int d = va_arg_int(alist); + int r=a+b+c+d; + fprintf(out,"int f(4*int):(%d,%d,%d,%d)",a,b,c,d); + fflush(out); + va_return_int(alist, r); +}} +void i_i8_simulator (void* data, va_alist alist) +{ + if (data != (void*)&i_i8) { fprintf(out,"wrong data for i_i8\n"); exit(1); } + va_start_int(alist); + {int a = va_arg_int(alist); + int b = va_arg_int(alist); + int c = va_arg_int(alist); + int d = va_arg_int(alist); + int e = va_arg_int(alist); + int f = va_arg_int(alist); + int g = va_arg_int(alist); + int h = va_arg_int(alist); + int r=a+b+c+d+e+f+g+h; + fprintf(out,"int f(8*int):(%d,%d,%d,%d,%d,%d,%d,%d)",a,b,c,d,e,f,g,h); + fflush(out); + va_return_int(alist, r); +}} +void i_i16_simulator (void* data, va_alist alist) +{ + if (data != (void*)&i_i16) { fprintf(out,"wrong data for i_i16\n"); exit(1); } + va_start_int(alist); + {int a = va_arg_int(alist); + int b = va_arg_int(alist); + int c = va_arg_int(alist); + int d = va_arg_int(alist); + int e = va_arg_int(alist); + int f = va_arg_int(alist); + int g = va_arg_int(alist); + int h = va_arg_int(alist); + int i = va_arg_int(alist); + int j = va_arg_int(alist); + int k = va_arg_int(alist); + int l = va_arg_int(alist); + int m = va_arg_int(alist); + int n = va_arg_int(alist); + int o = va_arg_int(alist); + int p = va_arg_int(alist); + int r=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p; + fprintf(out,"int f(16*int):(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)", + a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p); + fflush(out); + va_return_int(alist, r); +}} +void i_i32_simulator (void* data, va_alist alist) +{ + if (data != (void*)&i_i32) { fprintf(out,"wrong data for i_i32\n"); exit(1); } + va_start_int(alist); + {int a = va_arg_int(alist); + int b = va_arg_int(alist); + int c = va_arg_int(alist); + int d = va_arg_int(alist); + int e = va_arg_int(alist); + int f = va_arg_int(alist); + int g = va_arg_int(alist); + int h = va_arg_int(alist); + int i = va_arg_int(alist); + int j = va_arg_int(alist); + int k = va_arg_int(alist); + int l = va_arg_int(alist); + int m = va_arg_int(alist); + int n = va_arg_int(alist); + int o = va_arg_int(alist); + int p = va_arg_int(alist); + int aa = va_arg_int(alist); + int ab = va_arg_int(alist); + int ac = va_arg_int(alist); + int ad = va_arg_int(alist); + int ae = va_arg_int(alist); + int af = va_arg_int(alist); + int ag = va_arg_int(alist); + int ah = va_arg_int(alist); + int ai = va_arg_int(alist); + int aj = va_arg_int(alist); + int ak = va_arg_int(alist); + int al = va_arg_int(alist); + int am = va_arg_int(alist); + int an = va_arg_int(alist); + int ao = va_arg_int(alist); + int ap = va_arg_int(alist); + int r=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+aa+ab+ac+ad+ae+af+ag+ah+ai+aj+ak+al+am+an+ao+ap; + fprintf(out,"int f(32*int):(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)", + a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an,ao,ap); + fflush(out); + va_return_int(alist, r); +}} + +/* float tests */ +void f_f_simulator (void* data, va_alist alist) +{ + if (data != (void*)&f_f) { fprintf(out,"wrong data for f_f\n"); exit(1); } + va_start_float(alist); + {float a = va_arg_float(alist); + float r=a+1.0; + fprintf(out,"float f(float):(%g)",a); + fflush(out); + va_return_float(alist, r); +}} +void f_f2_simulator (void* data, va_alist alist) +{ + if (data != (void*)&f_f2) { fprintf(out,"wrong data for f_f2\n"); exit(1); } + va_start_float(alist); + {float a = va_arg_float(alist); + float b = va_arg_float(alist); + float r=a+b; + fprintf(out,"float f(2*float):(%g,%g)",a,b); + fflush(out); + va_return_float(alist, r); +}} +void f_f4_simulator (void* data, va_alist alist) +{ + if (data != (void*)&f_f4) { fprintf(out,"wrong data for f_f4\n"); exit(1); } + va_start_float(alist); + {float a = va_arg_float(alist); + float b = va_arg_float(alist); + float c = va_arg_float(alist); + float d = va_arg_float(alist); + float r=a+b+c+d; + fprintf(out,"float f(4*float):(%g,%g,%g,%g)",a,b,c,d); + fflush(out); + va_return_float(alist, r); +}} +void f_f8_simulator (void* data, va_alist alist) +{ + if (data != (void*)&f_f8) { fprintf(out,"wrong data for f_f8\n"); exit(1); } + va_start_float(alist); + {float a = va_arg_float(alist); + float b = va_arg_float(alist); + float c = va_arg_float(alist); + float d = va_arg_float(alist); + float e = va_arg_float(alist); + float f = va_arg_float(alist); + float g = va_arg_float(alist); + float h = va_arg_float(alist); + float r=a+b+c+d+e+f+g+h; + fprintf(out,"float f(8*float):(%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h); + fflush(out); + va_return_float(alist, r); +}} +void f_f16_simulator (void* data, va_alist alist) +{ + if (data != (void*)&f_f16) { fprintf(out,"wrong data for f_f16\n"); exit(1); } + va_start_float(alist); + {float a = va_arg_float(alist); + float b = va_arg_float(alist); + float c = va_arg_float(alist); + float d = va_arg_float(alist); + float e = va_arg_float(alist); + float f = va_arg_float(alist); + float g = va_arg_float(alist); + float h = va_arg_float(alist); + float i = va_arg_float(alist); + float j = va_arg_float(alist); + float k = va_arg_float(alist); + float l = va_arg_float(alist); + float m = va_arg_float(alist); + float n = va_arg_float(alist); + float o = va_arg_float(alist); + float p = va_arg_float(alist); + float r=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p; + fprintf(out,"float f(16*float):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p); + fflush(out); + va_return_float(alist, r); +}} +void f_f24_simulator (void* data, va_alist alist) +{ + if (data != (void*)&f_f24) { fprintf(out,"wrong data for f_f24\n"); exit(1); } + va_start_float(alist); + {float a = va_arg_float(alist); + float b = va_arg_float(alist); + float c = va_arg_float(alist); + float d = va_arg_float(alist); + float e = va_arg_float(alist); + float f = va_arg_float(alist); + float g = va_arg_float(alist); + float h = va_arg_float(alist); + float i = va_arg_float(alist); + float j = va_arg_float(alist); + float k = va_arg_float(alist); + float l = va_arg_float(alist); + float m = va_arg_float(alist); + float n = va_arg_float(alist); + float o = va_arg_float(alist); + float p = va_arg_float(alist); + float q = va_arg_float(alist); + float s = va_arg_float(alist); + float t = va_arg_float(alist); + float u = va_arg_float(alist); + float v = va_arg_float(alist); + float w = va_arg_float(alist); + float x = va_arg_float(alist); + float y = va_arg_float(alist); + float r=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+s+t+u+v+w+x+y; + fprintf(out,"float f(24*float):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,s,t,u,v,w,x,y); + fflush(out); + va_return_float(alist, r); +}} + +/* double tests */ +void d_d_simulator (void* data, va_alist alist) +{ + if (data != (void*)&d_d) { fprintf(out,"wrong data for d_d\n"); exit(1); } + va_start_double(alist); + {double a = va_arg_double(alist); + double r=a+1.0; + fprintf(out,"double f(double):(%g)",a); + fflush(out); + va_return_double(alist, r); +}} +void d_d2_simulator (void* data, va_alist alist) +{ + if (data != (void*)&d_d2) { fprintf(out,"wrong data for d_d2\n"); exit(1); } + va_start_double(alist); + {double a = va_arg_double(alist); + double b = va_arg_double(alist); + double r=a+b; + fprintf(out,"double f(2*double):(%g,%g)",a,b); + fflush(out); + va_return_double(alist, r); +}} +void d_d4_simulator (void* data, va_alist alist) +{ + if (data != (void*)&d_d4) { fprintf(out,"wrong data for d_d4\n"); exit(1); } + va_start_double(alist); + {double a = va_arg_double(alist); + double b = va_arg_double(alist); + double c = va_arg_double(alist); + double d = va_arg_double(alist); + double r=a+b+c+d; + fprintf(out,"double f(4*double):(%g,%g,%g,%g)",a,b,c,d); + fflush(out); + va_return_double(alist, r); +}} +void d_d8_simulator (void* data, va_alist alist) +{ + if (data != (void*)&d_d8) { fprintf(out,"wrong data for d_d8\n"); exit(1); } + va_start_double(alist); + {double a = va_arg_double(alist); + double b = va_arg_double(alist); + double c = va_arg_double(alist); + double d = va_arg_double(alist); + double e = va_arg_double(alist); + double f = va_arg_double(alist); + double g = va_arg_double(alist); + double h = va_arg_double(alist); + double r=a+b+c+d+e+f+g+h; + fprintf(out,"double f(8*double):(%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h); + fflush(out); + va_return_double(alist, r); +}} +void d_d16_simulator (void* data, va_alist alist) +{ + if (data != (void*)&d_d16) { fprintf(out,"wrong data for d_d16\n"); exit(1); } + va_start_double(alist); + {double a = va_arg_double(alist); + double b = va_arg_double(alist); + double c = va_arg_double(alist); + double d = va_arg_double(alist); + double e = va_arg_double(alist); + double f = va_arg_double(alist); + double g = va_arg_double(alist); + double h = va_arg_double(alist); + double i = va_arg_double(alist); + double j = va_arg_double(alist); + double k = va_arg_double(alist); + double l = va_arg_double(alist); + double m = va_arg_double(alist); + double n = va_arg_double(alist); + double o = va_arg_double(alist); + double p = va_arg_double(alist); + double r=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p; + fprintf(out,"double f(16*double):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p); + fflush(out); + va_return_double(alist, r); +}} + +/* pointer tests */ +void vp_vpdpcpsp_simulator (void* data, va_alist alist) +{ + if (data != (void*)&vp_vpdpcpsp) { fprintf(out,"wrong data for vp_vpdpcpsp\n"); exit(1); } + va_start_ptr(alist, void*); + {void* a = va_arg_ptr(alist, void*); + double* b = va_arg_ptr(alist, double*); + char* c = va_arg_ptr(alist, char*); + Int* d = va_arg_ptr(alist, Int*); + void* ret = (char*)b + 1; + fprintf(out,"void* f(void*,double*,char*,Int*):(0x%p,0x%p,0x%p,0x%p)",a,b,c,d); + fflush(out); + va_return_ptr(alist, void*, ret); +}} + +/* mixed number tests */ +void uc_ucsil_simulator (void* data, va_alist alist) +{ + if (data != (void*)&uc_ucsil) { fprintf(out,"wrong data for uc_ucsil\n"); exit(1); } + va_start_uchar(alist); + {uchar a = va_arg_uchar(alist); + ushort b = va_arg_ushort(alist); + uint c = va_arg_uint(alist); + ulong d = va_arg_ulong(alist); + uchar r = (uchar)-1; + fprintf(out,"uchar f(uchar,ushort,uint,ulong):(%u,%u,%u,%lu)",a,b,c,d); + fflush(out); + va_return_uchar(alist, r); +}} +void d_iidd_simulator (void* data, va_alist alist) +{ + if (data != (void*)&d_iidd) { fprintf(out,"wrong data for d_iidd\n"); exit(1); } + va_start_double(alist); + {int a = va_arg_int(alist); + int b = va_arg_int(alist); + double c = va_arg_double(alist); + double d = va_arg_double(alist); + double r=a+b+c+d; + fprintf(out,"double f(int,int,double,double):(%d,%d,%g,%g)",a,b,c,d); + fflush(out); + va_return_double(alist, r); +}} +void d_iiidi_simulator (void* data, va_alist alist) +{ + if (data != (void*)&d_iiidi) { fprintf(out,"wrong data for d_iiidi\n"); exit(1); } + va_start_double(alist); + {int a = va_arg_int(alist); + int b = va_arg_int(alist); + int c = va_arg_int(alist); + double d = va_arg_double(alist); + int e = va_arg_int(alist); + double r=a+b+c+d+e; + fprintf(out,"double f(int,int,int,double,int):(%d,%d,%d,%g,%d)",a,b,c,d,e); + fflush(out); + va_return_double(alist, r); +}} +void d_idid_simulator (void* data, va_alist alist) +{ + if (data != (void*)&d_idid) { fprintf(out,"wrong data for d_idid\n"); exit(1); } + va_start_double(alist); + {int a = va_arg_int(alist); + double b = va_arg_double(alist); + int c = va_arg_int(alist); + double d = va_arg_double(alist); + double r=a+b+c+d; + fprintf(out,"double f(int,double,int,double):(%d,%g,%d,%g)",a,b,c,d); + fflush(out); + va_return_double(alist, r); +}} +void d_fdi_simulator (void* data, va_alist alist) +{ + if (data != (void*)&d_fdi) { fprintf(out,"wrong data for d_fdi\n"); exit(1); } + va_start_double(alist); + {float a = va_arg_float(alist); + double b = va_arg_double(alist); + int c = va_arg_int(alist); + double r=a+b+c; + fprintf(out,"double f(float,double,int):(%g,%g,%d)",a,b,c); + fflush(out); + va_return_double(alist, r); +}} +void us_cdcd_simulator (void* data, va_alist alist) +{ + if (data != (void*)&us_cdcd) { fprintf(out,"wrong data for us_cdcd\n"); exit(1); } + va_start_ushort(alist); + {char a = va_arg_char(alist); + double b = va_arg_double(alist); + char c = va_arg_char(alist); + double d = va_arg_double(alist); + ushort r = (ushort)(a + b + c + d); + fprintf(out,"ushort f(char,double,char,double):('%c',%g,'%c',%g)",a,b,c,d); + fflush(out); + va_return_ushort(alist, r); +}} +void ll_iiilli_simulator (void* data, va_alist alist) +{ + if (data != (void*)&ll_iiilli) { fprintf(out,"wrong data for ll_iiilli\n"); exit(1); } + va_start_longlong(alist); + {int a = va_arg_int(alist); + int b = va_arg_int(alist); + int c = va_arg_int(alist); + long long d = va_arg_longlong(alist); + int e = va_arg_int(alist); + long long r = (long long)(int)a + (long long)(int)b + (long long)(int)c + d + (long long)e; + fprintf(out,"long long f(int,int,int,long long,int):(%d,%d,%d,0x%lx%08lx,%d)",a,b,c,(long)(d>>32),(long)(d&0xffffffff),e); + fflush(out); + va_return_longlong(alist, r); +}} +void ll_flli_simulator (void* data, va_alist alist) +{ + if (data != (void*)&ll_flli) { fprintf(out,"wrong data for ll_flli\n"); exit(1); } + va_start_longlong(alist); + {float a = va_arg_float(alist); + long long b = va_arg_longlong(alist); + int c = va_arg_int(alist); + long long r = (long long)(int)a + b + (long long)c; + fprintf(out,"long long f(float,long long,int):(%g,0x%lx%08lx,0x%lx)",a,(long)(b>>32),(long)(b&0xffffffff),(long)c); + fflush(out); + va_return_longlong(alist, r); +}} +void f_fi_simulator (void* data, va_alist alist) +{ + if (data != (void*)&f_fi) { fprintf(out,"wrong data for f_fi\n"); exit(1); } + va_start_float(alist); + {float a = va_arg_float(alist); + int z = va_arg_int(alist); + float r=a+z; + fprintf(out,"float f(float,int):(%g,%d)",a,z); + fflush(out); + va_return_float(alist, r); +}} +void f_f2i_simulator (void* data, va_alist alist) +{ + if (data != (void*)&f_f2i) { fprintf(out,"wrong data for f_f2i\n"); exit(1); } + va_start_float(alist); + {float a = va_arg_float(alist); + float b = va_arg_float(alist); + int z = va_arg_int(alist); + float r=a+b+z; + fprintf(out,"float f(2*float,int):(%g,%g,%d)",a,b,z); + fflush(out); + va_return_float(alist, r); +}} +void f_f3i_simulator (void* data, va_alist alist) +{ + if (data != (void*)&f_f3i) { fprintf(out,"wrong data for f_f3i\n"); exit(1); } + va_start_float(alist); + {float a = va_arg_float(alist); + float b = va_arg_float(alist); + float c = va_arg_float(alist); + int z = va_arg_int(alist); + float r=a+b+c+z; + fprintf(out,"float f(3*float,int):(%g,%g,%g,%d)",a,b,c,z); + fflush(out); + va_return_float(alist, r); +}} +void f_f4i_simulator (void* data, va_alist alist) +{ + if (data != (void*)&f_f4i) { fprintf(out,"wrong data for f_f4i\n"); exit(1); } + va_start_float(alist); + {float a = va_arg_float(alist); + float b = va_arg_float(alist); + float c = va_arg_float(alist); + float d = va_arg_float(alist); + int z = va_arg_int(alist); + float r=a+b+c+d+z; + fprintf(out,"float f(4*float,int):(%g,%g,%g,%g,%d)",a,b,c,d,z); + fflush(out); + va_return_float(alist, r); +}} +void f_f7i_simulator (void* data, va_alist alist) +{ + if (data != (void*)&f_f7i) { fprintf(out,"wrong data for f_f7i\n"); exit(1); } + va_start_float(alist); + {float a = va_arg_float(alist); + float b = va_arg_float(alist); + float c = va_arg_float(alist); + float d = va_arg_float(alist); + float e = va_arg_float(alist); + float f = va_arg_float(alist); + float g = va_arg_float(alist); + int z = va_arg_int(alist); + float r=a+b+c+d+e+f+g+z; + fprintf(out,"float f(7*float,int):(%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,z); + fflush(out); + va_return_float(alist, r); +}} +void f_f8i_simulator (void* data, va_alist alist) +{ + if (data != (void*)&f_f8i) { fprintf(out,"wrong data for f_f8i\n"); exit(1); } + va_start_float(alist); + {float a = va_arg_float(alist); + float b = va_arg_float(alist); + float c = va_arg_float(alist); + float d = va_arg_float(alist); + float e = va_arg_float(alist); + float f = va_arg_float(alist); + float g = va_arg_float(alist); + float h = va_arg_float(alist); + int z = va_arg_int(alist); + float r=a+b+c+d+e+f+g+h+z; + fprintf(out,"float f(8*float,int):(%g,%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,h,z); + fflush(out); + va_return_float(alist, r); +}} +void f_f12i_simulator (void* data, va_alist alist) +{ + if (data != (void*)&f_f12i) { fprintf(out,"wrong data for f_f12i\n"); exit(1); } + va_start_float(alist); + {float a = va_arg_float(alist); + float b = va_arg_float(alist); + float c = va_arg_float(alist); + float d = va_arg_float(alist); + float e = va_arg_float(alist); + float f = va_arg_float(alist); + float g = va_arg_float(alist); + float h = va_arg_float(alist); + float i = va_arg_float(alist); + float j = va_arg_float(alist); + float k = va_arg_float(alist); + float l = va_arg_float(alist); + int z = va_arg_int(alist); + float r=a+b+c+d+e+f+g+h+i+j+k+l+z; + fprintf(out,"float f(12*float,int):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,h,i,j,k,l,z); + fflush(out); + va_return_float(alist, r); +}} +void f_f13i_simulator (void* data, va_alist alist) +{ + if (data != (void*)&f_f13i) { fprintf(out,"wrong data for f_f13i\n"); exit(1); } + va_start_float(alist); + {float a = va_arg_float(alist); + float b = va_arg_float(alist); + float c = va_arg_float(alist); + float d = va_arg_float(alist); + float e = va_arg_float(alist); + float f = va_arg_float(alist); + float g = va_arg_float(alist); + float h = va_arg_float(alist); + float i = va_arg_float(alist); + float j = va_arg_float(alist); + float k = va_arg_float(alist); + float l = va_arg_float(alist); + float m = va_arg_float(alist); + int z = va_arg_int(alist); + float r=a+b+c+d+e+f+g+h+i+j+k+l+m+z; + fprintf(out,"float f(13*float,int):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,h,i,j,k,l,m,z); + fflush(out); + va_return_float(alist, r); +}} +void d_di_simulator (void* data, va_alist alist) +{ + if (data != (void*)&d_di) { fprintf(out,"wrong data for d_di\n"); exit(1); } + va_start_double(alist); + {double a = va_arg_double(alist); + int z = va_arg_int(alist); + double r=a+z; + fprintf(out,"double f(double,int):(%g,%d)",a,z); + fflush(out); + va_return_double(alist, r); +}} +void d_d2i_simulator (void* data, va_alist alist) +{ + if (data != (void*)&d_d2i) { fprintf(out,"wrong data for d_d2i\n"); exit(1); } + va_start_double(alist); + {double a = va_arg_double(alist); + double b = va_arg_double(alist); + int z = va_arg_int(alist); + double r=a+b+z; + fprintf(out,"double f(2*double,int):(%g,%g,%d)",a,b,z); + fflush(out); + va_return_double(alist, r); +}} +void d_d3i_simulator (void* data, va_alist alist) +{ + if (data != (void*)&d_d3i) { fprintf(out,"wrong data for d_d3i\n"); exit(1); } + va_start_double(alist); + {double a = va_arg_double(alist); + double b = va_arg_double(alist); + double c = va_arg_double(alist); + int z = va_arg_int(alist); + double r=a+b+c+z; + fprintf(out,"double f(3*double,int):(%g,%g,%g,%d)",a,b,c,z); + fflush(out); + va_return_double(alist, r); +}} +void d_d4i_simulator (void* data, va_alist alist) +{ + if (data != (void*)&d_d4i) { fprintf(out,"wrong data for d_d4i\n"); exit(1); } + va_start_double(alist); + {double a = va_arg_double(alist); + double b = va_arg_double(alist); + double c = va_arg_double(alist); + double d = va_arg_double(alist); + int z = va_arg_int(alist); + double r=a+b+c+d+z; + fprintf(out,"double f(4*double,int):(%g,%g,%g,%g,%d)",a,b,c,d,z); + fflush(out); + va_return_double(alist, r); +}} +void d_d7i_simulator (void* data, va_alist alist) +{ + if (data != (void*)&d_d7i) { fprintf(out,"wrong data for d_d7i\n"); exit(1); } + va_start_double(alist); + {double a = va_arg_double(alist); + double b = va_arg_double(alist); + double c = va_arg_double(alist); + double d = va_arg_double(alist); + double e = va_arg_double(alist); + double f = va_arg_double(alist); + double g = va_arg_double(alist); + int z = va_arg_int(alist); + double r=a+b+c+d+e+f+g+z; + fprintf(out,"double f(7*double,int):(%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,z); + fflush(out); + va_return_double(alist, r); +}} +void d_d8i_simulator (void* data, va_alist alist) +{ + if (data != (void*)&d_d8i) { fprintf(out,"wrong data for d_d8i\n"); exit(1); } + va_start_double(alist); + {double a = va_arg_double(alist); + double b = va_arg_double(alist); + double c = va_arg_double(alist); + double d = va_arg_double(alist); + double e = va_arg_double(alist); + double f = va_arg_double(alist); + double g = va_arg_double(alist); + double h = va_arg_double(alist); + int z = va_arg_int(alist); + double r=a+b+c+d+e+f+g+h+z; + fprintf(out,"double f(8*double,int):(%g,%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,h,z); + fflush(out); + va_return_double(alist, r); +}} +void d_d12i_simulator (void* data, va_alist alist) +{ + if (data != (void*)&d_d12i) { fprintf(out,"wrong data for d_d12i\n"); exit(1); } + va_start_double(alist); + {double a = va_arg_double(alist); + double b = va_arg_double(alist); + double c = va_arg_double(alist); + double d = va_arg_double(alist); + double e = va_arg_double(alist); + double f = va_arg_double(alist); + double g = va_arg_double(alist); + double h = va_arg_double(alist); + double i = va_arg_double(alist); + double j = va_arg_double(alist); + double k = va_arg_double(alist); + double l = va_arg_double(alist); + int z = va_arg_int(alist); + double r=a+b+c+d+e+f+g+h+i+j+k+l+z; + fprintf(out,"double f(12*double,int):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,h,i,j,k,l,z); + fflush(out); + va_return_double(alist, r); +}} +void d_d13i_simulator (void* data, va_alist alist) +{ + if (data != (void*)&d_d13i) { fprintf(out,"wrong data for d_d13i\n"); exit(1); } + va_start_double(alist); + {double a = va_arg_double(alist); + double b = va_arg_double(alist); + double c = va_arg_double(alist); + double d = va_arg_double(alist); + double e = va_arg_double(alist); + double f = va_arg_double(alist); + double g = va_arg_double(alist); + double h = va_arg_double(alist); + double i = va_arg_double(alist); + double j = va_arg_double(alist); + double k = va_arg_double(alist); + double l = va_arg_double(alist); + double m = va_arg_double(alist); + int z = va_arg_int(alist); + double r=a+b+c+d+e+f+g+h+i+j+k+l+m+z; + fprintf(out,"double f(13*double,int):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,h,i,j,k,l,m,z); + fflush(out); + va_return_double(alist, r); +}} + +/* small structure return tests */ +void S1_v_simulator (void* data, va_alist alist) +{ + if (data != (void*)&S1_v) { fprintf(out,"wrong data for S1_v\n"); exit(1); } + {Size1 r; + va_start_struct(alist, Size1, 1); + r = Size1_1; + fprintf(out,"Size1 f(void):"); + fflush(out); + va_return_struct(alist, Size1, r); +}} +void S2_v_simulator (void* data, va_alist alist) +{ + if (data != (void*)&S2_v) { fprintf(out,"wrong data for S2_v\n"); exit(1); } + {Size2 r; + va_start_struct(alist, Size2, 1); + r = Size2_1; + fprintf(out,"Size2 f(void):"); + fflush(out); + va_return_struct(alist, Size2, r); +}} +void S3_v_simulator (void* data, va_alist alist) +{ + if (data != (void*)&S3_v) { fprintf(out,"wrong data for S3_v\n"); exit(1); } + {Size3 r; + va_start_struct(alist, Size3, 1); + r = Size3_1; + fprintf(out,"Size3 f(void):"); + fflush(out); + va_return_struct(alist, Size3, r); +}} +void S4_v_simulator (void* data, va_alist alist) +{ + if (data != (void*)&S4_v) { fprintf(out,"wrong data for S4_v\n"); exit(1); } + {Size4 r; + va_start_struct(alist, Size4, 1); + r = Size4_1; + fprintf(out,"Size4 f(void):"); + fflush(out); + va_return_struct(alist, Size4, r); +}} +void S7_v_simulator (void* data, va_alist alist) +{ + if (data != (void*)&S7_v) { fprintf(out,"wrong data for S7_v\n"); exit(1); } + {Size7 r; + va_start_struct(alist, Size7, 1); + r = Size7_1; + fprintf(out,"Size7 f(void):"); + fflush(out); + va_return_struct(alist, Size7, r); +}} +void S8_v_simulator (void* data, va_alist alist) +{ + if (data != (void*)&S8_v) { fprintf(out,"wrong data for S8_v\n"); exit(1); } + {Size8 r; + va_start_struct(alist, Size8, 1); + r = Size8_1; + fprintf(out,"Size8 f(void):"); + fflush(out); + va_return_struct(alist, Size8, r); +}} +void S12_v_simulator (void* data, va_alist alist) +{ + if (data != (void*)&S12_v) { fprintf(out,"wrong data for S12_v\n"); exit(1); } + {Size12 r; + va_start_struct(alist, Size12, 1); + r = Size12_1; + fprintf(out,"Size12 f(void):"); + fflush(out); + va_return_struct(alist, Size12, r); +}} +void S15_v_simulator (void* data, va_alist alist) +{ + if (data != (void*)&S15_v) { fprintf(out,"wrong data for S15_v\n"); exit(1); } + {Size15 r; + va_start_struct(alist, Size15, 1); + r = Size15_1; + fprintf(out,"Size15 f(void):"); + fflush(out); + va_return_struct(alist, Size15, r); +}} +void S16_v_simulator (void* data, va_alist alist) +{ + if (data != (void*)&S16_v) { fprintf(out,"wrong data for S16_v\n"); exit(1); } + {Size16 r; + va_start_struct(alist, Size16, 1); + r = Size16_1; + fprintf(out,"Size16 f(void):"); + fflush(out); + va_return_struct(alist, Size16, r); +}} + +/* structure tests */ +void I_III_simulator (void* data, va_alist alist) +{ + if (data != (void*)&I_III) { fprintf(out,"wrong data for I_III\n"); exit(1); } + {Int a; + Int b; + Int c; + Int r; + va_start_struct(alist, Int, 1); + a = va_arg_struct(alist, Int); + b = va_arg_struct(alist, Int); + c = va_arg_struct(alist, Int); + r.x = a.x + b.x + c.x; + fprintf(out,"Int f(Int,Int,Int):({%d},{%d},{%d})",a.x,b.x,c.x); + fflush(out); + va_return_struct(alist, Int, r); +}} +#ifndef SKIP_EXTRA_STRUCTS +void C_CdC_simulator (void* data, va_alist alist) +{ + if (data != (void*)&C_CdC) { fprintf(out,"wrong data for C_CdC\n"); exit(1); } + {Char a; + double b; + Char c; + Char r; + va_start_struct(alist, Char, 1); + a = va_arg_struct(alist, Char); + b = va_arg_double(alist); + c = va_arg_struct(alist, Char); + r.x = (a.x + c.x)/2; + fprintf(out,"Char f(Char,double,Char):({'%c'},%g,{'%c'})",a.x,b,c.x); + fflush(out); + va_return_struct(alist, Char, r); +}} +void F_Ffd_simulator (void* data, va_alist alist) +{ + if (data != (void*)&F_Ffd) { fprintf(out,"wrong data for F_Ffd\n"); exit(1); } + {Float a; + float b; + double c; + Float r; + va_start_struct(alist, Float, va_word_splittable_1(float)); + a = va_arg_struct(alist, Float); + b = va_arg_float(alist); + c = va_arg_double(alist); + r.x = a.x + b + c; + fprintf(out,"Float f(Float,float,double):({%g},%g,%g)",a.x,b,c); + fflush(out); + va_return_struct(alist, Float, r); +}} +void D_fDd_simulator (void* data, va_alist alist) +{ + if (data != (void*)&D_fDd) { fprintf(out,"wrong data for D_fDd\n"); exit(1); } + {float a; + Double b; + double c; + Double r; + va_start_struct(alist, Double, va_word_splittable_1(double)); + a = va_arg_float(alist); + b = va_arg_struct(alist, Double); + c = va_arg_double(alist); + r.x = a + b.x + c; + fprintf(out,"Double f(float,Double,double):(%g,{%g},%g)",a,b.x,c); + fflush(out); + va_return_struct(alist, Double, r); +}} +void D_Dfd_simulator (void* data, va_alist alist) +{ + if (data != (void*)&D_Dfd) { fprintf(out,"wrong data for D_Dfd\n"); exit(1); } + {Double a; + float b; + double c; + Double r; + va_start_struct(alist, Double, va_word_splittable_1(double)); + a = va_arg_struct(alist, Double); + b = va_arg_float(alist); + c = va_arg_double(alist); + r.x = a.x + b + c; + fprintf(out,"Double f(Double,float,double):({%g},%g,%g)",a.x,b,c); + fflush(out); + va_return_struct(alist, Double, r); +}} +#endif +void J_JiJ_simulator (void* data, va_alist alist) +{ + if (data != (void*)&J_JiJ) { fprintf(out,"wrong data for J_JiJ\n"); exit(1); } + {J a; + int b; + J c; + J r; + va_start_struct(alist, J, va_word_splittable_2(long,long)); + a = va_arg_struct(alist, J); + b = va_arg_int(alist); + c = va_arg_struct(alist, J); + r.l1 = a.l1+c.l1; r.l2 = a.l2+b+c.l2; + fprintf(out,"J f(J,int,J):({%ld,%ld},%d,{%ld,%ld})",a.l1,a.l2,b,c.l1,c.l2); + fflush(out); + va_return_struct(alist, J, r); +}} +#ifndef SKIP_EXTRA_STRUCTS +void T_TcT_simulator (void* data, va_alist alist) +{ + if (data != (void*)&T_TcT) { fprintf(out,"wrong data for T_TcT\n"); exit(1); } + {T a; + char b; + T c; + T r; + va_start_struct(alist, T, 1); + a = va_arg_struct(alist, T); + b = va_arg_char(alist); + c = va_arg_struct(alist, T); + r.c[0]='b'; r.c[1]=c.c[1]; r.c[2]=c.c[2]; + fprintf(out,"T f(T,char,T):({\"%c%c%c\"},'%c',{\"%c%c%c\"})",a.c[0],a.c[1],a.c[2],b,c.c[0],c.c[1],c.c[2]); + fflush(out); + va_return_struct(alist, T, r); +}} +void X_BcdB_simulator (void* data, va_alist alist) +{ + if (data != (void*)&X_BcdB) { fprintf(out,"wrong data for X_BcdB\n"); exit(1); } + {B a; + char b; + double c; + B d; + static X xr={"return val",'R'}; + X r; + va_start_struct(alist, X, 0); + a = va_arg_struct(alist, B); + b = va_arg_char(alist); + c = va_arg_double(alist); + d = va_arg_struct(alist, B); + r = xr; + r.c1 = b; + fprintf(out,"X f(B,char,double,B):({%g,{%d,%d,%d}},'%c',%g,{%g,{%d,%d,%d}})", + a.d,a.i[0],a.i[1],a.i[2],b,c,d.d,d.i[0],d.i[1],d.i[2]); + fflush(out); + va_return_struct(alist, X, r); +}} +#endif + +/* gpargs boundary tests */ +void l_l0J_simulator (void* data, va_alist alist) +{ + if (data != (void*)&l_l0J) { fprintf(out,"wrong data for l_l0J\n"); exit(1); } + va_start_long(alist); + {J b = va_arg_struct(alist, J); + long c = va_arg_long(alist); + long r = b.l1 + b.l2 + c; + fprintf(out,"long f(J,long):(%ld,%ld,%ld)",b.l1,b.l2,c); + fflush(out); + va_return_long(alist, r); +}} +void l_l1J_simulator (void* data, va_alist alist) +{ + if (data != (void*)&l_l1J) { fprintf(out,"wrong data for l_l1J\n"); exit(1); } + va_start_long(alist); + {long a1 = va_arg_long(alist); + J b = va_arg_struct(alist, J); + long c = va_arg_long(alist); + long r = a1 + b.l1 + b.l2 + c; + fprintf(out,"long f(long,J,long):(%ld,%ld,%ld,%ld)",a1,b.l1,b.l2,c); + fflush(out); + va_return_long(alist, r); +}} +void l_l2J_simulator (void* data, va_alist alist) +{ + if (data != (void*)&l_l2J) { fprintf(out,"wrong data for l_l2J\n"); exit(1); } + va_start_long(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + J b = va_arg_struct(alist, J); + long c = va_arg_long(alist); + long r = a1 + a2 + b.l1 + b.l2 + c; + fprintf(out,"long f(2*long,J,long):(%ld,%ld,%ld,%ld,%ld)",a1,a2,b.l1,b.l2,c); + fflush(out); + va_return_long(alist, r); +}} +void l_l3J_simulator (void* data, va_alist alist) +{ + if (data != (void*)&l_l3J) { fprintf(out,"wrong data for l_l3J\n"); exit(1); } + va_start_long(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + J b = va_arg_struct(alist, J); + long c = va_arg_long(alist); + long r = a1 + a2 + a3 + b.l1 + b.l2 + c; + fprintf(out,"long f(3*long,J,long):(%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,b.l1,b.l2,c); + fflush(out); + va_return_long(alist, r); +}} +void l_l4J_simulator (void* data, va_alist alist) +{ + if (data != (void*)&l_l4J) { fprintf(out,"wrong data for l_l4J\n"); exit(1); } + va_start_long(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + J b = va_arg_struct(alist, J); + long c = va_arg_long(alist); + long r = a1 + a2 + a3 + a4 + b.l1 + b.l2 + c; + fprintf(out,"long f(4*long,J,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,a4,b.l1,b.l2,c); + fflush(out); + va_return_long(alist, r); +}} +void l_l5J_simulator (void* data, va_alist alist) +{ + if (data != (void*)&l_l5J) { fprintf(out,"wrong data for l_l5J\n"); exit(1); } + va_start_long(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + long a5 = va_arg_long(alist); + J b = va_arg_struct(alist, J); + long c = va_arg_long(alist); + long r = a1 + a2 + a3 + a4 + a5 + b.l1 + b.l2 + c; + fprintf(out,"long f(5*long,J,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,a4,a5,b.l1,b.l2,c); + fflush(out); + va_return_long(alist, r); +}} +void l_l6J_simulator (void* data, va_alist alist) +{ + if (data != (void*)&l_l6J) { fprintf(out,"wrong data for l_l6J\n"); exit(1); } + va_start_long(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + long a5 = va_arg_long(alist); + long a6 = va_arg_long(alist); + J b = va_arg_struct(alist, J); + long c = va_arg_long(alist); + long r = a1 + a2 + a3 + a4 + a5 + a6 + b.l1 + b.l2 + c; + fprintf(out,"long f(6*long,J,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,a4,a5,a6,b.l1,b.l2,c); + fflush(out); + va_return_long(alist, r); +}} +void l_l7J_simulator (void* data, va_alist alist) +{ + if (data != (void*)&l_l7J) { fprintf(out,"wrong data for l_l7J\n"); exit(1); } + va_start_long(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + long a5 = va_arg_long(alist); + long a6 = va_arg_long(alist); + long a7 = va_arg_long(alist); + J b = va_arg_struct(alist, J); + long c = va_arg_long(alist); + long r = a1 + a2 + a3 + a4 + a5 + a6 + a7 + b.l1 + b.l2 + c; + fprintf(out,"long f(7*long,J,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,a4,a5,a6,a7,b.l1,b.l2,c); + fflush(out); + va_return_long(alist, r); +}} +void l_l0K_simulator (void* data, va_alist alist) +{ + if (data != (void*)&l_l0K) { fprintf(out,"wrong data for l_l0K\n"); exit(1); } + va_start_long(alist); + {K b = va_arg_struct(alist, K); + long c = va_arg_long(alist); + long r = b.l1 + b.l2 + b.l3 + b.l4 + c; + fprintf(out,"long f(K,long):(%ld,%ld,%ld,%ld,%ld)",b.l1,b.l2,b.l3,b.l4,c); + fflush(out); + va_return_long(alist, r); +}} +void l_l1K_simulator (void* data, va_alist alist) +{ + if (data != (void*)&l_l1K) { fprintf(out,"wrong data for l_l1K\n"); exit(1); } + va_start_long(alist); + {long a1 = va_arg_long(alist); + K b = va_arg_struct(alist, K); + long c = va_arg_long(alist); + long r = a1 + b.l1 + b.l2 + b.l3 + b.l4 + c; + fprintf(out,"long f(long,K,long):(%ld,%ld,%ld,%ld,%ld,%ld)",a1,b.l1,b.l2,b.l3,b.l4,c); + fflush(out); + va_return_long(alist, r); +}} +void l_l2K_simulator (void* data, va_alist alist) +{ + if (data != (void*)&l_l2K) { fprintf(out,"wrong data for l_l2K\n"); exit(1); } + va_start_long(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + K b = va_arg_struct(alist, K); + long c = va_arg_long(alist); + long r = a1 + a2 + b.l1 + b.l2 + b.l3 + b.l4 + c; + fprintf(out,"long f(2*long,K,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,b.l1,b.l2,b.l3,b.l4,c); + fflush(out); + va_return_long(alist, r); +}} +void l_l3K_simulator (void* data, va_alist alist) +{ + if (data != (void*)&l_l3K) { fprintf(out,"wrong data for l_l3K\n"); exit(1); } + va_start_long(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + K b = va_arg_struct(alist, K); + long c = va_arg_long(alist); + long r = a1 + a2 + a3 + b.l1 + b.l2 + b.l3 + b.l4 + c; + fprintf(out,"long f(3*long,K,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,b.l1,b.l2,b.l3,b.l4,c); + fflush(out); + va_return_long(alist, r); +}} +void l_l4K_simulator (void* data, va_alist alist) +{ + if (data != (void*)&l_l4K) { fprintf(out,"wrong data for l_l4K\n"); exit(1); } + va_start_long(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + K b = va_arg_struct(alist, K); + long c = va_arg_long(alist); + long r = a1 + a2 + a3 + a4 + b.l1 + b.l2 + b.l3 + b.l4 + c; + fprintf(out,"long f(4*long,K,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,a4,b.l1,b.l2,b.l3,b.l4,c); + fflush(out); + va_return_long(alist, r); +}} +void l_l5K_simulator (void* data, va_alist alist) +{ + if (data != (void*)&l_l5K) { fprintf(out,"wrong data for l_l5K\n"); exit(1); } + va_start_long(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + long a5 = va_arg_long(alist); + K b = va_arg_struct(alist, K); + long c = va_arg_long(alist); + long r = a1 + a2 + a3 + a4 + a5 + b.l1 + b.l2 + b.l3 + b.l4 + c; + fprintf(out,"long f(5*long,K,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,a4,a5,b.l1,b.l2,b.l3,b.l4,c); + fflush(out); + va_return_long(alist, r); +}} +void l_l6K_simulator (void* data, va_alist alist) +{ + if (data != (void*)&l_l6K) { fprintf(out,"wrong data for l_l6K\n"); exit(1); } + va_start_long(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + long a5 = va_arg_long(alist); + long a6 = va_arg_long(alist); + K b = va_arg_struct(alist, K); + long c = va_arg_long(alist); + long r = a1 + a2 + a3 + a4 + a5 + a6 + b.l1 + b.l2 + b.l3 + b.l4 + c; + fprintf(out,"long f(6*long,K,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,a4,a5,a6,b.l1,b.l2,b.l3,b.l4,c); + fflush(out); + va_return_long(alist, r); +}} +void f_f17l3L_simulator (void* data, va_alist alist) +{ + if (data != (void*)&f_f17l3L) { fprintf(out,"wrong data for f_f17l3L\n"); exit(1); } + va_start_float(alist); + {float a = va_arg_float(alist); + float b = va_arg_float(alist); + float c = va_arg_float(alist); + float d = va_arg_float(alist); + float e = va_arg_float(alist); + float f = va_arg_float(alist); + float g = va_arg_float(alist); + float h = va_arg_float(alist); + float i = va_arg_float(alist); + float j = va_arg_float(alist); + float k = va_arg_float(alist); + float l = va_arg_float(alist); + float m = va_arg_float(alist); + float n = va_arg_float(alist); + float o = va_arg_float(alist); + float p = va_arg_float(alist); + float q = va_arg_float(alist); + long s = va_arg_long(alist); + long t = va_arg_long(alist); + long u = va_arg_long(alist); + L z = va_arg_struct(alist, L); + float r = a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+s+t+u+z.l1+z.l2+z.l3+z.l4+z.l5+z.l6; + fprintf(out,"float f(17*float,3*int,L):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,s,t,u,z.l1,z.l2,z.l3,z.l4,z.l5,z.l6); + fflush(out); + va_return_float(alist, r); +}} +void d_d17l3L_simulator (void* data, va_alist alist) +{ + if (data != (void*)&d_d17l3L) { fprintf(out,"wrong data for d_d17l3L\n"); exit(1); } + va_start_double(alist); + {double a = va_arg_double(alist); + double b = va_arg_double(alist); + double c = va_arg_double(alist); + double d = va_arg_double(alist); + double e = va_arg_double(alist); + double f = va_arg_double(alist); + double g = va_arg_double(alist); + double h = va_arg_double(alist); + double i = va_arg_double(alist); + double j = va_arg_double(alist); + double k = va_arg_double(alist); + double l = va_arg_double(alist); + double m = va_arg_double(alist); + double n = va_arg_double(alist); + double o = va_arg_double(alist); + double p = va_arg_double(alist); + double q = va_arg_double(alist); + long s = va_arg_long(alist); + long t = va_arg_long(alist); + long u = va_arg_long(alist); + L z = va_arg_struct(alist, L); + double r = a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+s+t+u+z.l1+z.l2+z.l3+z.l4+z.l5+z.l6; + fprintf(out,"double f(17*double,3*int,L):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,s,t,u,z.l1,z.l2,z.l3,z.l4,z.l5,z.l6); + fflush(out); + va_return_double(alist, r); +}} +void ll_l2ll_simulator (void* data, va_alist alist) +{ + if (data != (void*)&ll_l2ll) { fprintf(out,"wrong data for ll_l2ll\n"); exit(1); } + va_start_longlong(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long long b = va_arg_longlong(alist); + long c = va_arg_long(alist); + long long r = (long long) (a1 + a2) + b + c; + fprintf(out,"long long f(2*long,long long,long):(%ld,%ld,0x%lx%08lx,%ld)",a1,a2,(long)(b>>32),(long)(b&0xffffffff),c); + fflush(out); + va_return_longlong(alist, r); +}} +void ll_l3ll_simulator (void* data, va_alist alist) +{ + if (data != (void*)&ll_l3ll) { fprintf(out,"wrong data for ll_l3ll\n"); exit(1); } + va_start_longlong(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long long b = va_arg_longlong(alist); + long c = va_arg_long(alist); + long long r = (long long) (a1 + a2 + a3) + b + c; + fprintf(out,"long long f(3*long,long long,long):(%ld,%ld,%ld,0x%lx%08lx,%ld)",a1,a2,a3,(long)(b>>32),(long)(b&0xffffffff),c); + fflush(out); + va_return_longlong(alist, r); +}} +void ll_l4ll_simulator (void* data, va_alist alist) +{ + if (data != (void*)&ll_l4ll) { fprintf(out,"wrong data for ll_l4ll\n"); exit(1); } + va_start_longlong(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + long long b = va_arg_longlong(alist); + long c = va_arg_long(alist); + long long r = (long long) (a1 + a2 + a3 + a4) + b + c; + fprintf(out,"long long f(4*long,long long,long):(%ld,%ld,%ld,%ld,0x%lx%08lx,%ld)",a1,a2,a3,a4,(long)(b>>32),(long)(b&0xffffffff),c); + fflush(out); + va_return_longlong(alist, r); +}} +void ll_l5ll_simulator (void* data, va_alist alist) +{ + if (data != (void*)&ll_l5ll) { fprintf(out,"wrong data for ll_l5ll\n"); exit(1); } + va_start_longlong(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + long a5 = va_arg_long(alist); + long long b = va_arg_longlong(alist); + long c = va_arg_long(alist); + long long r = (long long) (a1 + a2 + a3 + a4 + a5) + b + c; + fprintf(out,"long long f(5*long,long long,long):(%ld,%ld,%ld,%ld,%ld,0x%lx%08lx,%ld)",a1,a2,a3,a4,a5,(long)(b>>32),(long)(b&0xffffffff),c); + fflush(out); + va_return_longlong(alist, r); +}} +void ll_l6ll_simulator (void* data, va_alist alist) +{ + if (data != (void*)&ll_l6ll) { fprintf(out,"wrong data for ll_l6ll\n"); exit(1); } + va_start_longlong(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + long a5 = va_arg_long(alist); + long a6 = va_arg_long(alist); + long long b = va_arg_longlong(alist); + long c = va_arg_long(alist); + long long r = (long long) (a1 + a2 + a3 + a4 + a5 + a6) + b + c; + fprintf(out,"long long f(6*long,long long,long):(%ld,%ld,%ld,%ld,%ld,%ld,0x%lx%08lx,%ld)",a1,a2,a3,a4,a5,a6,(long)(b>>32),(long)(b&0xffffffff),c); + fflush(out); + va_return_longlong(alist, r); +}} +void ll_l7ll_simulator (void* data, va_alist alist) +{ + if (data != (void*)&ll_l7ll) { fprintf(out,"wrong data for ll_l7ll\n"); exit(1); } + va_start_longlong(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + long a5 = va_arg_long(alist); + long a6 = va_arg_long(alist); + long a7 = va_arg_long(alist); + long long b = va_arg_longlong(alist); + long c = va_arg_long(alist); + long long r = (long long) (a1 + a2 + a3 + a4 + a5 + a6 + a7) + b + c; + fprintf(out,"long long f(7*long,long long,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,0x%lx%08lx,%ld)",a1,a2,a3,a4,a5,a6,a7,(long)(b>>32),(long)(b&0xffffffff),c); + fflush(out); + va_return_longlong(alist, r); +}} +void d_l2d_simulator (void* data, va_alist alist) +{ + if (data != (void*)&d_l2d) { fprintf(out,"wrong data for d_l2d\n"); exit(1); } + va_start_double(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + double b = va_arg_double(alist); + long c = va_arg_long(alist); + double r = (double) (a1 + a2) + b + c; + fprintf(out,"double f(2*long,double,long):(%ld,%ld,%g,%ld)",a1,a2,b,c); + fflush(out); + va_return_double(alist, r); +}} +void d_l3d_simulator (void* data, va_alist alist) +{ + if (data != (void*)&d_l3d) { fprintf(out,"wrong data for d_l3d\n"); exit(1); } + va_start_double(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + double b = va_arg_double(alist); + long c = va_arg_long(alist); + double r = (double) (a1 + a2 + a3) + b + c; + fprintf(out,"double f(3*long,double,long):(%ld,%ld,%ld,%g,%ld)",a1,a2,a3,b,c); + fflush(out); + va_return_double(alist, r); +}} +void d_l4d_simulator (void* data, va_alist alist) +{ + if (data != (void*)&d_l4d) { fprintf(out,"wrong data for d_l4d\n"); exit(1); } + va_start_double(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + double b = va_arg_double(alist); + long c = va_arg_long(alist); + double r = (double) (a1 + a2 + a3 + a4) + b + c; + fprintf(out,"double f(4*long,double,long):(%ld,%ld,%ld,%ld,%g,%ld)",a1,a2,a3,a4,b,c); + fflush(out); + va_return_double(alist, r); +}} +void d_l5d_simulator (void* data, va_alist alist) +{ + if (data != (void*)&d_l5d) { fprintf(out,"wrong data for d_l5d\n"); exit(1); } + va_start_double(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + long a5 = va_arg_long(alist); + double b = va_arg_double(alist); + long c = va_arg_long(alist); + double r = (double) (a1 + a2 + a3 + a4 + a5) + b + c; + fprintf(out,"double f(5*long,double,long):(%ld,%ld,%ld,%ld,%ld,%g,%ld)",a1,a2,a3,a4,a5,b,c); + fflush(out); + va_return_double(alist, r); +}} +void d_l6d_simulator (void* data, va_alist alist) +{ + if (data != (void*)&d_l6d) { fprintf(out,"wrong data for d_l6d\n"); exit(1); } + va_start_double(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + long a5 = va_arg_long(alist); + long a6 = va_arg_long(alist); + double b = va_arg_double(alist); + long c = va_arg_long(alist); + double r = (double) (a1 + a2 + a3 + a4 + a5 + a6) + b + c; + fprintf(out,"double f(6*long,double,long):(%ld,%ld,%ld,%ld,%ld,%ld,%g,%ld)",a1,a2,a3,a4,a5,a6,b,c); + fflush(out); + va_return_double(alist, r); +}} +void d_l7d_simulator (void* data, va_alist alist) +{ + if (data != (void*)&d_l7d) { fprintf(out,"wrong data for d_l7d\n"); exit(1); } + va_start_double(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + long a5 = va_arg_long(alist); + long a6 = va_arg_long(alist); + long a7 = va_arg_long(alist); + double b = va_arg_double(alist); + long c = va_arg_long(alist); + double r = (double) (a1 + a2 + a3 + a4 + a5 + a6 + a7) + b + c; + fprintf(out,"double f(7*long,double,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%g,%ld)",a1,a2,a3,a4,a5,a6,a7,b,c); + fflush(out); + va_return_double(alist, r); +}} +void v_clobber_K_simulator (void* data, va_alist alist) +{ + if (data != (void*)&v_clobber_K) { fprintf(out,"wrong data for v_clobber_K\n"); exit(1); } + va_start_void(alist); + {K k = va_arg_struct(alist, K); + k.l1 += 1; + k.l2 += 10; + k.l3 += 100; + k.l4 += 1000; + va_return_void(alist); +}} + + +/* + * The way we run these tests - first call the function directly, then + * through vacall() - there is the danger that arguments or results seem + * to be passed correctly, but what we are seeing are in fact the vestiges + * (traces) or the previous call. This may seriously fake the test. + * Avoid this by clearing the registers between the first and the second call. + */ +long clear_traces_i (long a, long b, long c, long d, long e, long f, long g, long h, + long i, long j, long k, long l, long m, long n, long o, long p) +{ return 0; } +float clear_traces_f (float a, float b, float c, float d, float e, float f, float g, + float h, float i, float j, float k, float l, float m, float n, + float o, float p) +{ return 0.0; } +double clear_traces_d (double a, double b, double c, double d, double e, double f, double g, + double h, double i, double j, double k, double l, double m, double n, + double o, double p) +{ return 0.0; } +J clear_traces_J (void) +{ J j; j.l1 = j.l2 = 0; return j; } +void clear_traces (void) +{ clear_traces_i(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); + clear_traces_f(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.0); + clear_traces_d(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.0); + clear_traces_J(); +} + +int main (void) +{ + callback_t callback; + + out = stdout; + + /* void tests */ + v_v(); + clear_traces(); + callback = alloc_callback(&v_v_simulator,(void*)&v_v); + ((void (*) (void)) callback) (); + + /* int tests */ + { int ir; + + ir = i_v(); + fprintf(out,"->%d\n",ir); + fflush(out); + ir = 0; clear_traces(); + callback = alloc_callback(&i_v_simulator,(void*)&i_v); + ir = ((int (*) (void)) callback) (); + fprintf(out,"->%d\n",ir); + fflush(out); + + ir = i_i(i1); + fprintf(out,"->%d\n",ir); + fflush(out); + ir = 0; clear_traces(); + callback = alloc_callback(&i_i_simulator,(void*)&i_i); + ir = ((int (*) (int)) callback) (i1); + fprintf(out,"->%d\n",ir); + fflush(out); + + ir = i_i2(i1,i2); + fprintf(out,"->%d\n",ir); + fflush(out); + ir = 0; clear_traces(); + callback = alloc_callback(&i_i2_simulator,(void*)&i_i2); + ir = ((int (*) (int,int)) callback) (i1,i2); + fprintf(out,"->%d\n",ir); + fflush(out); + + ir = i_i4(i1,i2,i3,i4); + fprintf(out,"->%d\n",ir); + fflush(out); + ir = 0; clear_traces(); + callback = alloc_callback(&i_i4_simulator,(void*)&i_i4); + ir = ((int (*) (int,int,int,int)) callback) (i1,i2,i3,i4); + fprintf(out,"->%d\n",ir); + fflush(out); + + ir = i_i8(i1,i2,i3,i4,i5,i6,i7,i8); + fprintf(out,"->%d\n",ir); + fflush(out); + ir = 0; clear_traces(); + callback = alloc_callback(&i_i8_simulator,(void*)&i_i8); + ir = ((int (*) (int,int,int,int,int,int,int,int)) callback) (i1,i2,i3,i4,i5,i6,i7,i8); + fprintf(out,"->%d\n",ir); + fflush(out); + + ir = i_i16(i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14,i15,i16); + fprintf(out,"->%d\n",ir); + fflush(out); + ir = 0; clear_traces(); + callback = alloc_callback(&i_i16_simulator,(void*)&i_i16); + ir = ((int (*) (int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int)) callback) (i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14,i15,i16); + fprintf(out,"->%d\n",ir); + fflush(out); + + ir = i_i32(i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14,i15,i16,i17,i18,i19,i20,i21,i22,i23,i24,i25,i26,i27,i28,i29,i30,i31,i32); + fprintf(out,"->%d\n",ir); + fflush(out); + ir = 0; clear_traces(); + callback = alloc_callback(&i_i32_simulator,(void*)&i_i32); + ir = ((int (*) (int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int)) callback) (i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14,i15,i16,i17,i18,i19,i20,i21,i22,i23,i24,i25,i26,i27,i28,i29,i30,i31,i32); + fprintf(out,"->%d\n",ir); + fflush(out); + } + + /* float tests */ + { float fr; + + fr = f_f(f1); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + callback = alloc_callback(&f_f_simulator,(void*)&f_f); + fr = ((float (*) (float)) callback) (f1); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f2(f1,f2); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + callback = alloc_callback(&f_f2_simulator,(void*)&f_f2); + fr = ((float (*) (float,float)) callback) (f1,f2); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f4(f1,f2,f3,f4); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + callback = alloc_callback(&f_f4_simulator,(void*)&f_f4); + fr = ((float (*) (float,float,float,float)) callback) (f1,f2,f3,f4); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f8(f1,f2,f3,f4,f5,f6,f7,f8); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + callback = alloc_callback(&f_f8_simulator,(void*)&f_f8); + fr = ((float (*) (float,float,float,float,float,float,float,float)) callback) (f1,f2,f3,f4,f5,f6,f7,f8); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f16(f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + callback = alloc_callback(&f_f16_simulator,(void*)&f_f16); + fr = ((float (*) (float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float)) callback) (f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f24(f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16,f17,f18,f19,f20,f21,f22,f23,f24); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + callback = alloc_callback(&f_f24_simulator,(void*)&f_f24); + fr = ((float (*) (float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float)) callback) (f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16,f17,f18,f19,f20,f21,f22,f23,f24); + fprintf(out,"->%g\n",fr); + fflush(out); + } + + /* double tests */ + { double dr; + + dr = d_d(d1); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + callback = alloc_callback(&d_d_simulator,(void*)&d_d); + dr = ((double (*) (double)) callback) (d1); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d2(d1,d2); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + callback = alloc_callback(&d_d2_simulator,(void*)&d_d2); + dr = ((double (*) (double,double)) callback) (d1,d2); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d4(d1,d2,d3,d4); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + callback = alloc_callback(&d_d4_simulator,(void*)&d_d4); + dr = ((double (*) (double,double,double,double)) callback) (d1,d2,d3,d4); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d8(d1,d2,d3,d4,d5,d6,d7,d8); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + callback = alloc_callback(&d_d8_simulator,(void*)&d_d8); + dr = ((double (*) (double,double,double,double,double,double,double,double)) callback) (d1,d2,d3,d4,d5,d6,d7,d8); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d16(d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,d14,d15,d16); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + callback = alloc_callback(&d_d16_simulator,(void*)&d_d16); + dr = ((double (*) (double,double,double,double,double,double,double,double,double,double,double,double,double,double,double,double)) callback) (d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,d14,d15,d16); + fprintf(out,"->%g\n",dr); + fflush(out); + } + + /* pointer tests */ + { void* vpr; + + vpr = vp_vpdpcpsp(&uc1,&d2,str3,&I4); + fprintf(out,"->0x%p\n",vpr); + fflush(out); + vpr = 0; clear_traces(); + callback = alloc_callback(&vp_vpdpcpsp_simulator,(void*)&vp_vpdpcpsp); + vpr = ((void* (*) (void*,double*,char*,Int*)) callback) (&uc1,&d2,str3,&I4); + fprintf(out,"->0x%p\n",vpr); + fflush(out); + } + + /* mixed number tests */ + { uchar ucr; + ushort usr; + float fr; + double dr; + long long llr; + + ucr = uc_ucsil(uc1,us2,ui3,ul4); + fprintf(out,"->%u\n",ucr); + fflush(out); + ucr = 0; clear_traces(); + callback = alloc_callback(&uc_ucsil_simulator,(void*)&uc_ucsil); + ucr = ((uchar (*) (uchar,ushort,uint,ulong)) callback) (uc1,us2,ui3,ul4); + fprintf(out,"->%u\n",ucr); + fflush(out); + + dr = d_iidd(i1,i2,d3,d4); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + callback = alloc_callback(&d_iidd_simulator,(void*)&d_iidd); + dr = ((double (*) (int,int,double,double)) callback) (i1,i2,d3,d4); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_iiidi(i1,i2,i3,d4,i5); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + callback = alloc_callback(&d_iiidi_simulator,(void*)&d_iiidi); + dr = ((double (*) (int,int,int,double,int)) callback) (i1,i2,i3,d4,i5); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_idid(i1,d2,i3,d4); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + callback = alloc_callback(&d_idid_simulator,(void*)&d_idid); + dr = ((double (*) (int,double,int,double)) callback) (i1,d2,i3,d4); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_fdi(f1,d2,i3); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + callback = alloc_callback(&d_fdi_simulator,(void*)&d_fdi); + dr = ((double (*) (float,double,int)) callback) (f1,d2,i3); + fprintf(out,"->%g\n",dr); + fflush(out); + + usr = us_cdcd(c1,d2,c3,d4); + fprintf(out,"->%u\n",usr); + fflush(out); + usr = 0; clear_traces(); + callback = alloc_callback(&us_cdcd_simulator,(void*)&us_cdcd); + usr = ((ushort (*) (char,double,char,double)) callback) (c1,d2,c3,d4); + fprintf(out,"->%u\n",usr); + fflush(out); + + llr = ll_iiilli(i1,i2,i3,ll1,i13); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + llr = 0; clear_traces(); + callback = alloc_callback(&ll_iiilli_simulator,(void*)&ll_iiilli); + llr = ((long long (*) (int,int,int,long long,int)) callback) (i1,i2,i3,ll1,i13); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + + llr = ll_flli(f13,ll1,i13); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + llr = 0; clear_traces(); + callback = alloc_callback(&ll_flli_simulator,(void*)&ll_flli); + llr = ((long long (*) (float,long long,int)) callback) (f13,ll1,i13); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + + fr = f_fi(f1,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + callback = alloc_callback(&f_fi_simulator,(void*)&f_fi); + fr = ((float (*) (float,int)) callback) (f1,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f2i(f1,f2,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + callback = alloc_callback(&f_f2i_simulator,(void*)&f_f2i); + fr = ((float (*) (float,float,int)) callback) (f1,f2,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f3i(f1,f2,f3,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + callback = alloc_callback(&f_f3i_simulator,(void*)&f_f3i); + fr = ((float (*) (float,float,float,int)) callback) (f1,f2,f3,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f4i(f1,f2,f3,f4,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + callback = alloc_callback(&f_f4i_simulator,(void*)&f_f4i); + fr = ((float (*) (float,float,float,float,int)) callback) (f1,f2,f3,f4,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f7i(f1,f2,f3,f4,f5,f6,f7,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + callback = alloc_callback(&f_f7i_simulator,(void*)&f_f7i); + fr = ((float (*) (float,float,float,float,float,float,float,int)) callback) (f1,f2,f3,f4,f5,f6,f7,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f8i(f1,f2,f3,f4,f5,f6,f7,f8,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + callback = alloc_callback(&f_f8i_simulator,(void*)&f_f8i); + fr = ((float (*) (float,float,float,float,float,float,float,float,int)) callback) (f1,f2,f3,f4,f5,f6,f7,f8,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f12i(f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + callback = alloc_callback(&f_f12i_simulator,(void*)&f_f12i); + fr = ((float (*) (float,float,float,float,float,float,float,float,float,float,float,float,int)) callback) (f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f13i(f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + callback = alloc_callback(&f_f13i_simulator,(void*)&f_f13i); + fr = ((float (*) (float,float,float,float,float,float,float,float,float,float,float,float,float,int)) callback) (f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + + dr = d_di(d1,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + callback = alloc_callback(&d_di_simulator,(void*)&d_di); + dr = ((double (*) (double,int)) callback) (d1,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d2i(d1,d2,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + callback = alloc_callback(&d_d2i_simulator,(void*)&d_d2i); + dr = ((double (*) (double,double,int)) callback) (d1,d2,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d3i(d1,d2,d3,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + callback = alloc_callback(&d_d3i_simulator,(void*)&d_d3i); + dr = ((double (*) (double,double,double,int)) callback) (d1,d2,d3,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d4i(d1,d2,d3,d4,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + callback = alloc_callback(&d_d4i_simulator,(void*)&d_d4i); + dr = ((double (*) (double,double,double,double,int)) callback) (d1,d2,d3,d4,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d7i(d1,d2,d3,d4,d5,d6,d7,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + callback = alloc_callback(&d_d7i_simulator,(void*)&d_d7i); + dr = ((double (*) (double,double,double,double,double,double,double,int)) callback) (d1,d2,d3,d4,d5,d6,d7,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d8i(d1,d2,d3,d4,d5,d6,d7,d8,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + callback = alloc_callback(&d_d8i_simulator,(void*)&d_d8i); + dr = ((double (*) (double,double,double,double,double,double,double,double,int)) callback) (d1,d2,d3,d4,d5,d6,d7,d8,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d12i(d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + callback = alloc_callback(&d_d12i_simulator,(void*)&d_d12i); + dr = ((double (*) (double,double,double,double,double,double,double,double,double,double,double,double,int)) callback) (d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d13i(d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + callback = alloc_callback(&d_d13i_simulator,(void*)&d_d13i); + dr = ((double (*) (double,double,double,double,double,double,double,double,double,double,double,double,double,int)) callback) (d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + } + + /* small structure return tests */ + { + Size1 r = S1_v(); + fprintf(out,"->{%c}\n",r.x1); + fflush(out); + memset(&r,0,sizeof(r)); clear_traces(); + callback = alloc_callback(&S1_v_simulator,(void*)&S1_v); + r = ((Size1 (*) (void)) callback) (); + fprintf(out,"->{%c}\n",r.x1); + fflush(out); + } + { + Size2 r = S2_v(); + fprintf(out,"->{%c%c}\n",r.x1,r.x2); + fflush(out); + memset(&r,0,sizeof(r)); clear_traces(); + callback = alloc_callback(&S2_v_simulator,(void*)&S2_v); + r = ((Size2 (*) (void)) callback) (); + fprintf(out,"->{%c%c}\n",r.x1,r.x2); + fflush(out); + } + { + Size3 r = S3_v(); + fprintf(out,"->{%c%c%c}\n",r.x1,r.x2,r.x3); + fflush(out); + memset(&r,0,sizeof(r)); clear_traces(); + callback = alloc_callback(&S3_v_simulator,(void*)&S3_v); + r = ((Size3 (*) (void)) callback) (); + fprintf(out,"->{%c%c%c}\n",r.x1,r.x2,r.x3); + fflush(out); + } + { + Size4 r = S4_v(); + fprintf(out,"->{%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4); + fflush(out); + memset(&r,0,sizeof(r)); clear_traces(); + callback = alloc_callback(&S4_v_simulator,(void*)&S4_v); + r = ((Size4 (*) (void)) callback) (); + fprintf(out,"->{%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4); + fflush(out); + } + { + Size7 r = S7_v(); + fprintf(out,"->{%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7); + fflush(out); + memset(&r,0,sizeof(r)); clear_traces(); + callback = alloc_callback(&S7_v_simulator,(void*)&S7_v); + r = ((Size7 (*) (void)) callback) (); + fprintf(out,"->{%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7); + fflush(out); + } + { + Size8 r = S8_v(); + fprintf(out,"->{%c%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7,r.x8); + fflush(out); + memset(&r,0,sizeof(r)); clear_traces(); + callback = alloc_callback(&S8_v_simulator,(void*)&S8_v); + r = ((Size8 (*) (void)) callback) (); + fprintf(out,"->{%c%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7,r.x8); + fflush(out); + } + { + Size12 r = S12_v(); + fprintf(out,"->{%c%c%c%c%c%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7,r.x8,r.x9,r.x10,r.x11,r.x12); + fflush(out); + memset(&r,0,sizeof(r)); clear_traces(); + callback = alloc_callback(&S12_v_simulator,(void*)&S12_v); + r = ((Size12 (*) (void)) callback) (); + fprintf(out,"->{%c%c%c%c%c%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7,r.x8,r.x9,r.x10,r.x11,r.x12); + fflush(out); + } + { + Size15 r = S15_v(); + fprintf(out,"->{%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7,r.x8,r.x9,r.x10,r.x11,r.x12,r.x13,r.x14,r.x15); + fflush(out); + memset(&r,0,sizeof(r)); clear_traces(); + callback = alloc_callback(&S15_v_simulator,(void*)&S15_v); + r = ((Size15 (*) (void)) callback) (); + fprintf(out,"->{%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7,r.x8,r.x9,r.x10,r.x11,r.x12,r.x13,r.x14,r.x15); + fflush(out); + } + { + Size16 r = S16_v(); + fprintf(out,"->{%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7,r.x8,r.x9,r.x10,r.x11,r.x12,r.x13,r.x14,r.x15,r.x16); + fflush(out); + memset(&r,0,sizeof(r)); clear_traces(); + callback = alloc_callback(&S16_v_simulator,(void*)&S16_v); + r = ((Size16 (*) (void)) callback) (); + fprintf(out,"->{%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7,r.x8,r.x9,r.x10,r.x11,r.x12,r.x13,r.x14,r.x15,r.x16); + fflush(out); + } + + /* structure tests */ + { Int Ir; + Char Cr; + Float Fr; + Double Dr; + J Jr; + T Tr; + X Xr; + + Ir = I_III(I1,I2,I3); + fprintf(out,"->{%d}\n",Ir.x); + fflush(out); + Ir.x = 0; clear_traces(); + callback = alloc_callback(&I_III_simulator,(void*)&I_III); + Ir = ((Int (*) (Int,Int,Int)) callback) (I1,I2,I3); + fprintf(out,"->{%d}\n",Ir.x); + fflush(out); + +#ifndef SKIP_EXTRA_STRUCTS + Cr = C_CdC(C1,d2,C3); + fprintf(out,"->{'%c'}\n",Cr.x); + fflush(out); + Cr.x = '\0'; clear_traces(); + callback = alloc_callback(&C_CdC_simulator,(void*)&C_CdC); + Cr = ((Char (*) (Char,double,Char)) callback) (C1,d2,C3); + fprintf(out,"->{'%c'}\n",Cr.x); + fflush(out); + + Fr = F_Ffd(F1,f2,d3); + fprintf(out,"->{%g}\n",Fr.x); + fflush(out); + Fr.x = 0.0; clear_traces(); + callback = alloc_callback(&F_Ffd_simulator,(void*)&F_Ffd); + Fr = ((Float (*) (Float,float,double)) callback) (F1,f2,d3); + fprintf(out,"->{%g}\n",Fr.x); + fflush(out); + + Dr = D_fDd(f1,D2,d3); + fprintf(out,"->{%g}\n",Dr.x); + fflush(out); + Dr.x = 0.0; clear_traces(); + callback = alloc_callback(&D_fDd_simulator,(void*)&D_fDd); + Dr = ((Double (*) (float,Double,double)) callback) (f1,D2,d3); + fprintf(out,"->{%g}\n",Dr.x); + fflush(out); + + Dr = D_Dfd(D1,f2,d3); + fprintf(out,"->{%g}\n",Dr.x); + fflush(out); + Dr.x = 0.0; clear_traces(); + callback = alloc_callback(&D_Dfd_simulator,(void*)&D_Dfd); + Dr = ((Double (*) (Double,float,double)) callback) (D1,f2,d3); + fprintf(out,"->{%g}\n",Dr.x); + fflush(out); +#endif + + Jr = J_JiJ(J1,i2,J2); + fprintf(out,"->{%ld,%ld}\n",Jr.l1,Jr.l2); + fflush(out); + Jr.l1 = Jr.l2 = 0; clear_traces(); + callback = alloc_callback(&J_JiJ_simulator,(void*)&J_JiJ); + Jr = ((J (*) (J,int,J)) callback) (J1,i2,J2); + fprintf(out,"->{%ld,%ld}\n",Jr.l1,Jr.l2); + fflush(out); + +#ifndef SKIP_EXTRA_STRUCTS +#ifndef SKIP_T + Tr = T_TcT(T1,' ',T2); + fprintf(out,"->{\"%c%c%c\"}\n",Tr.c[0],Tr.c[1],Tr.c[2]); + fflush(out); + Tr.c[0] = Tr.c[1] = Tr.c[2] = 0; clear_traces(); + callback = alloc_callback(&T_TcT_simulator,(void*)&T_TcT); + Tr = ((T (*) (T,char,T)) callback) (T1,' ',T2); + fprintf(out,"->{\"%c%c%c\"}\n",Tr.c[0],Tr.c[1],Tr.c[2]); + fflush(out); +#endif + +#ifndef SKIP_X + Xr = X_BcdB(B1,c2,d3,B2); + fprintf(out,"->{\"%s\",'%c'}\n",Xr.c,Xr.c1); + fflush(out); + Xr.c[0]=Xr.c1='\0'; clear_traces(); + callback = alloc_callback(&X_BcdB_simulator,(void*)&X_BcdB); + Xr = ((X (*) (B,char,double,B)) callback) (B1,c2,d3,B2); + fprintf(out,"->{\"%s\",'%c'}\n",Xr.c,Xr.c1); + fflush(out); +#endif +#endif + } + + /* gpargs boundary tests */ + { long lr; + long long llr; + float fr; + double dr; + + lr = l_l0J(J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + callback = alloc_callback(&l_l0J_simulator,(void*)l_l0J); + lr = ((long (*) (J,long)) callback) (J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l1J(l1,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + callback = alloc_callback(&l_l1J_simulator,(void*)l_l1J); + lr = ((long (*) (long,J,long)) callback) (l1,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l2J(l1,l2,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + callback = alloc_callback(&l_l2J_simulator,(void*)l_l2J); + lr = ((long (*) (long,long,J,long)) callback) (l1,l2,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l3J(l1,l2,l3,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + callback = alloc_callback(&l_l3J_simulator,(void*)l_l3J); + lr = ((long (*) (long,long,long,J,long)) callback) (l1,l2,l3,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l4J(l1,l2,l3,l4,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + callback = alloc_callback(&l_l4J_simulator,(void*)l_l4J); + lr = ((long (*) (long,long,long,long,J,long)) callback) (l1,l2,l3,l4,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l5J(l1,l2,l3,l4,l5,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + callback = alloc_callback(&l_l5J_simulator,(void*)l_l5J); + lr = ((long (*) (long,long,long,long,long,J,long)) callback) (l1,l2,l3,l4,l5,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l6J(l1,l2,l3,l4,l5,l6,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + callback = alloc_callback(&l_l6J_simulator,(void*)l_l6J); + lr = ((long (*) (long,long,long,long,long,long,J,long)) callback) (l1,l2,l3,l4,l5,l6,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l7J(l1,l2,l3,l4,l5,l6,l7,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + callback = alloc_callback(&l_l7J_simulator,(void*)l_l7J); + lr = ((long (*) (long,long,long,long,long,long,long,J,long)) callback) (l1,l2,l3,l4,l5,l6,l7,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l0K(K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + callback = alloc_callback(&l_l0K_simulator,(void*)l_l0K); + lr = ((long (*) (K,long)) callback) (K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l1K(l1,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + callback = alloc_callback(&l_l1K_simulator,(void*)l_l1K); + lr = ((long (*) (long,K,long)) callback) (l1,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l2K(l1,l2,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + callback = alloc_callback(&l_l2K_simulator,(void*)l_l2K); + lr = ((long (*) (long,long,K,long)) callback) (l1,l2,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l3K(l1,l2,l3,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + callback = alloc_callback(&l_l3K_simulator,(void*)l_l3K); + lr = ((long (*) (long,long,long,K,long)) callback) (l1,l2,l3,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l4K(l1,l2,l3,l4,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + callback = alloc_callback(&l_l4K_simulator,(void*)l_l4K); + lr = ((long (*) (long,long,long,long,K,long)) callback) (l1,l2,l3,l4,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l5K(l1,l2,l3,l4,l5,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + callback = alloc_callback(&l_l5K_simulator,(void*)l_l5K); + lr = ((long (*) (long,long,long,long,long,K,long)) callback) (l1,l2,l3,l4,l5,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l6K(l1,l2,l3,l4,l5,l6,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + callback = alloc_callback(&l_l6K_simulator,(void*)l_l6K); + lr = ((long (*) (long,long,long,long,long,long,K,long)) callback) (l1,l2,l3,l4,l5,l6,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + fr = f_f17l3L(f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16,f17,l6,l7,l8,L1); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + callback = alloc_callback(&f_f17l3L_simulator,(void*)&f_f17l3L); + fr = ((float (*) (float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,long,long,long,L)) callback) (f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16,f17,l6,l7,l8,L1); + fprintf(out,"->%g\n",fr); + fflush(out); + + dr = d_d17l3L(d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,d14,d15,d16,d17,l6,l7,l8,L1); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + callback = alloc_callback(&d_d17l3L_simulator,(void*)&d_d17l3L); + dr = ((double (*) (double,double,double,double,double,double,double,double,double,double,double,double,double,double,double,double,double,long,long,long,L)) callback) (d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,d14,d15,d16,d17,l6,l7,l8,L1); + fprintf(out,"->%g\n",dr); + fflush(out); + + llr = ll_l2ll(l1,l2,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + llr = 0; clear_traces(); + callback = alloc_callback(&ll_l2ll_simulator,(void*)ll_l2ll); + llr = ((long long (*) (long,long,long long,long)) callback) (l1,l2,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + + llr = ll_l3ll(l1,l2,l3,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + llr = 0; clear_traces(); + callback = alloc_callback(&ll_l3ll_simulator,(void*)ll_l3ll); + llr = ((long long (*) (long,long,long,long long,long)) callback) (l1,l2,l3,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + + llr = ll_l4ll(l1,l2,l3,l4,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + llr = 0; clear_traces(); + callback = alloc_callback(&ll_l4ll_simulator,(void*)ll_l4ll); + llr = ((long long (*) (long,long,long,long,long long,long)) callback) (l1,l2,l3,l4,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + + llr = ll_l5ll(l1,l2,l3,l4,l5,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + llr = 0; clear_traces(); + callback = alloc_callback(&ll_l5ll_simulator,(void*)ll_l5ll); + llr = ((long long (*) (long,long,long,long,long,long long,long)) callback) (l1,l2,l3,l4,l5,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + + llr = ll_l6ll(l1,l2,l3,l4,l5,l6,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + llr = 0; clear_traces(); + callback = alloc_callback(&ll_l6ll_simulator,(void*)ll_l6ll); + llr = ((long long (*) (long,long,long,long,long,long,long long,long)) callback) (l1,l2,l3,l4,l5,l6,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + + llr = ll_l7ll(l1,l2,l3,l4,l5,l6,l7,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + llr = 0; clear_traces(); + callback = alloc_callback(&ll_l7ll_simulator,(void*)ll_l7ll); + llr = ((long long (*) (long,long,long,long,long,long,long,long long,long)) callback) (l1,l2,l3,l4,l5,l6,l7,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + + dr = d_l2d(l1,l2,ll1,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + callback = alloc_callback(&d_l2d_simulator,(void*)d_l2d); + dr = ((double (*) (long,long,double,long)) callback) (l1,l2,ll1,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_l3d(l1,l2,l3,ll1,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + callback = alloc_callback(&d_l3d_simulator,(void*)d_l3d); + dr = ((double (*) (long,long,long,double,long)) callback) (l1,l2,l3,ll1,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_l4d(l1,l2,l3,l4,ll1,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + callback = alloc_callback(&d_l4d_simulator,(void*)d_l4d); + dr = ((double (*) (long,long,long,long,double,long)) callback) (l1,l2,l3,l4,ll1,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_l5d(l1,l2,l3,l4,l5,ll1,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + callback = alloc_callback(&d_l5d_simulator,(void*)d_l5d); + dr = ((double (*) (long,long,long,long,long,double,long)) callback) (l1,l2,l3,l4,l5,ll1,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_l6d(l1,l2,l3,l4,l5,l6,ll1,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + callback = alloc_callback(&d_l6d_simulator,(void*)d_l6d); + dr = ((double (*) (long,long,long,long,long,long,double,long)) callback) (l1,l2,l3,l4,l5,l6,ll1,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_l7d(l1,l2,l3,l4,l5,l6,l7,ll1,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + callback = alloc_callback(&d_l7d_simulator,(void*)d_l7d); + dr = ((double (*) (long,long,long,long,long,long,long,double,long)) callback) (l1,l2,l3,l4,l5,l6,l7,ll1,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + } + + /* by-value tests */ + /* This test is trivial, since a copy of k is allocated on the callee's stack. + But anyway... */ + { K k; + + k.l1 = l1; + k.l2 = l2; + k.l3 = l3; + k.l4 = l4; + fprintf(out,"by_value:%ld,%ld,%ld,%ld\n",k.l1,k.l2,k.l3,k.l4); + fflush(out); + clear_traces(); + callback = alloc_callback(&v_clobber_K_simulator,(void*)v_clobber_K); + ((void (*) (K)) callback) (k); + fprintf(out,"by_value:%ld,%ld,%ld,%ld\n",k.l1,k.l2,k.l3,k.l4); + fflush(out); + } + + exit(0); +} diff --git a/callback/trampoline_r/COPYING b/callback/trampoline_r/COPYING new file mode 100644 index 0000000..a3d1815 --- /dev/null +++ b/callback/trampoline_r/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, 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) + + 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/callback/trampoline_r/Makefile.devel b/callback/trampoline_r/Makefile.devel new file mode 100644 index 0000000..7abb351 --- /dev/null +++ b/callback/trampoline_r/Makefile.devel @@ -0,0 +1,217 @@ +# This is the developer's -*-Makefile-*-, not the user's makefile. +# Do not use it unless you know exactly what you do! + +THISFILE = Makefile.devel +RM = rm -f + +# ============ Rules that require cross-compilation tools ============ + +GCC = gcc +GCCFLAGS = -O2 -fomit-frame-pointer -fPIC +CPP = $(GCC) -E +CROSS_TOOL = cross + +precompiled : \ + cache-sparc-macro.S cache-sparc64-macro.S \ + cache-alpha-macro.S \ + cache-hppa-macro.S cache-hppa64-macro.S \ + cache-powerpc-linux-macro.S cache-powerpc-macos.s \ + cache-powerpc64-elfv2-macro.S + + +cache-sparc-linux.s : cache-sparc.c $(THISFILE) + $(CROSS_TOOL) sparc-linux gcc -V 3.1 $(GCCFLAGS) -D__sparc__ -S cache-sparc.c -o cache-sparc-linux.s + +cache-sparc-macro.S : cache-sparc-linux.s ../../common/asm-sparc.sh ../../common/noexecstack.h $(THISFILE) + (echo '#include "asm-sparc.h"' ; ../../common/asm-sparc.sh < cache-sparc-linux.s ; cat ../../common/noexecstack.h) > cache-sparc-macro.S + +cache-sparc64-linux.s : cache-sparc.c $(THISFILE) + $(CROSS_TOOL) sparc64-linux gcc -V 4.0.2 $(GCCFLAGS) -D__sparc64__ -S cache-sparc.c -o cache-sparc64-linux.s + +cache-sparc64-macro.S : cache-sparc64-linux.s ../../common/asm-sparc.sh ../../common/noexecstack.h $(THISFILE) + (echo '#include "asm-sparc.h"' ; ../../common/asm-sparc.sh < cache-sparc64-linux.s ; cat ../../common/noexecstack.h) > cache-sparc64-macro.S + + +cache-alpha-linux.s : cache-alpha.c $(THISFILE) + $(CROSS_TOOL) alpha-linux gcc -V 4.0.2 $(GCCFLAGS) -D__alpha__ -S cache-alpha.c -o cache-alpha-linux.s + +cache-alpha-macro.S : cache-alpha-linux.s ../../common/asm-alpha.sh ../../common/noexecstack.h $(THISFILE) + (../../common/asm-alpha.sh < cache-alpha-linux.s ; cat ../../common/noexecstack.h) > cache-alpha-macro.S + + +cache-hppa-linux.s : cache-hppa.c $(THISFILE) + $(CROSS_TOOL) hppa-linux gcc -V 3.1 $(GCCFLAGS) -D__hppa__ -S cache-hppa.c -o cache-hppa-linux.s + +cache-hppa-macro.S : cache-hppa-linux.s ../../common/asm-hppa.sh ../../common/noexecstack.h $(THISFILE) + (echo '#include "asm-hppa.h"' ; ../../common/asm-hppa.sh < cache-hppa-linux.s ; cat ../../common/noexecstack.h) > cache-hppa-macro.S + + +cache-hppa64-linux.s : cache-hppa.c $(THISFILE) + $(CROSS_TOOL) hppa64-linux gcc -V 3.1 $(GCCFLAGS) -D__hppa64__ -S cache-hppa.c -o cache-hppa64-linux.s + +cache-hppa64-macro.S : cache-hppa64-linux.s ../../common/asm-hppa64.sh ../../common/noexecstack.h $(THISFILE) + (echo '#include "asm-hppa64.h"' ; ../../common/asm-hppa64.sh < cache-hppa64-linux.s ; cat ../../common/noexecstack.h) > cache-hppa64-macro.S + + +cache-powerpc-linux.s : cache-powerpc.c $(THISFILE) + $(CROSS_TOOL) powerpc-linux gcc -V 3.3.6 -mno-power -mno-power2 -mno-powerpc $(GCCFLAGS) -D__powerpc__ -S cache-powerpc.c -o cache-powerpc-linux.s + +cache-powerpc-linux-macro.S : cache-powerpc-linux.s ../../common/asm-powerpc.sh ../../common/noexecstack.h $(THISFILE) + (../../common/asm-powerpc.sh < cache-powerpc-linux.s ; cat ../../common/noexecstack.h) > cache-powerpc-linux-macro.S + +cache-powerpc-macos.s : cache-powerpc.c $(THISFILE) + $(CROSS_TOOL) powerpc-darwin gcc -V 3.3.6 $(GCCFLAGS) -D__powerpc__ -S cache-powerpc.c -o cache-powerpc-macos.s + + +cache-powerpc64-elfv2-linux.s : cache-powerpc64.c $(THISFILE) + $(CROSS_TOOL) powerpc64le-linux gcc-5.4.0 -mabi=elfv2 -mcpu=power4 -mlittle-endian $(GCCFLAGS) -D__powerpc64__ -S cache-powerpc64.c -o cache-powerpc64-elfv2-linux-le.s + $(CROSS_TOOL) powerpc64le-linux gcc-5.4.0 -mabi=elfv2 -mcpu=power4 -mbig-endian $(GCCFLAGS) -D__powerpc64__ -S cache-powerpc64.c -o cache-powerpc64-elfv2-linux-be.s + cmp cache-powerpc64-elfv2-linux-le.s cache-powerpc64-elfv2-linux-be.s > /dev/null + mv cache-powerpc64-elfv2-linux-le.s cache-powerpc64-elfv2-linux.s + $(RM) cache-powerpc64-elfv2-linux-be.s + +cache-powerpc64-elfv2-macro.S : cache-powerpc64-elfv2-linux.s ../../common/asm-powerpc.sh ../../common/noexecstack.h $(THISFILE) + (../../common/asm-powerpc.sh < cache-powerpc64-elfv2-linux.s ; cat ../../common/noexecstack.h) > cache-powerpc64-elfv2-macro.S + + +# --------------- Older rules --------------- + +OLDGCCFLAGS = -O2 -fomit-frame-pointer +ASPREFIX = /usr1/gnu/lib + +proto-precompiled : proto-i386.s proto-m68k.s proto-mips.s proto-mipsn32.s proto-mips64.s proto-sparc.s proto-sparc64.s proto-alpha.s proto-hppa.s proto-hppa64.s proto-arm.s proto-arm64.s proto-powerpc-aix.s proto-powerpc-sysv4.s proto-powerpc-macos.s proto-powerpc64-aix.s proto-powerpc64-elfv2.s proto-ia64.c proto-x86_64.c proto-x86_64-x32.s proto-s390.s proto-s390x.s proto-riscv32.s proto-riscv64.s + +proto-i386.s : proto.c + $(GCC) -V 2.7.2 -b i486-linuxaout $(OLDGCCFLAGS) -D__i386__ -S proto.c -o $@ + +proto-m68k.s : proto.c + $(GCC) -V egcs-2.91.57 -b m68k-sun $(OLDGCCFLAGS) -D__m68k__ -S proto.c -o $@ + +proto-mips.s : proto.c + $(GCC) -V 2.95.2 -b mips-sgi $(OLDGCCFLAGS) -D__mips__ -S proto.c -o $@ -mabicalls + +proto-mipsn32.s : proto.c + $(GCC) -V 2.95.2 -b mips-sgi-irix6 $(OLDGCCFLAGS) -D__mipsn32__ -S proto.c -o $@ -mabicalls + +proto-mips64.s : proto64.c + $(GCC) -V 2.95.2 -b mips-sgi -mips3 -mlong64 $(OLDGCCFLAGS) -D__mips64__ -S proto64.c -o $@ -mabicalls + +proto-sparc.s : proto.c + $(GCC) -V 2.95.2 -b sparc-sun $(OLDGCCFLAGS) -D__sparc__ -S proto.c -o $@ + +proto-sparc64.s : proto64.c + sparc64-linux-gcc -V 2.95.2 -b sparc64-linux $(OLDGCCFLAGS) -D__sparc64__ -S proto64.c -o $@ + +proto-alpha.s : proto64.c + $(GCC) -V 2.7.2 -b alpha-dec-osf $(OLDGCCFLAGS) -D__alpha__ -S proto64.c -o $@ + +proto-hppa.s : proto.c + $(GCC) -V 2.6.3 -b hppa1.0-hpux $(OLDGCCFLAGS) -D__hppa__ -S proto.c -o $@ + +proto-hppa64.s : proto64.c + $(CROSS_TOOL) hppa64-linux gcc -V 3.1 $(OLDGCCFLAGS) -D__hppa64__ -S proto64.c -o $@ + +proto-arm.s : proto.c + $(CROSS_TOOL) arm-linux gcc -V 3.1 $(OLDGCCFLAGS) -fno-omit-frame-pointer -D__arm__ -S proto.c -o $@ + +proto-arm64.s : proto64.c + $(CROSS_TOOL) aarch64-linux gcc-5.4.0 $(OLDGCCFLAGS) -D__arm64__ -S proto64.c -o $@ + +proto-powerpc-aix.s : proto.c + $(GCC) -V 2.95.2 -b rs6000 -mno-power -mno-power2 -mno-powerpc -mnew-mnemonics $(OLDGCCFLAGS) -D__powerpc__ -S proto.c -o $@ + +proto-powerpc-sysv4.s : proto.c + $(GCC) -V 2.95.2 -b ppc-linux -mno-power -mno-power2 -mno-powerpc $(OLDGCCFLAGS) -D__powerpc__ -S proto.c -o $@ + +proto-powerpc-macos.s : proto.c + $(GCC) -V 3.3.2 -b powerpc-darwin $(OLDGCCFLAGS) -D__powerpc__ -S proto.c -o $@ + +proto-powerpc64-aix.s : proto64.c + $(CROSS_TOOL) powerpc64-linux gcc $(OLDGCCFLAGS) -D__powerpc64__ -S proto64.c -o $@ + +proto-powerpc64-elfv2.s : proto64.c + $(CROSS_TOOL) powerpc64le-linux gcc -mabi=elfv2 $(OLDGCCFLAGS) -D__powerpc64__ -S proto64.c -o $@ + +proto-ia64.s : proto64.c + $(GCC) -V 2.9-ia64-000216 -b ia64-hp-linux $(OLDGCCFLAGS) -D__ia64__ -S proto64.c -o $@ + +proto-x86_64.s : proto64.c + $(GCC) -V 3.2.2 -b x86_64-suse-linux $(OLDGCCFLAGS) -D__x86_64__ -S proto64.c -o $@ + +proto-x86_64-x32.s : proto.c + $(CROSS_TOOL) x86_64-linux gcc-5.4.0 -mx32 $(OLDGCCFLAGS) -fno-asynchronous-unwind-tables -D__x86_64__ -D__x86_64_x32__ -S proto.c -o $@ + +proto-s390.s : proto.c + $(CROSS_TOOL) s390-linux gcc -V 3.1 $(OLDGCCFLAGS) -D__s390__ -S proto.c -o $@ + +proto-s390x.s : proto64.c + $(CROSS_TOOL) s390x-linux gcc-5.4.0 $(OLDGCCFLAGS) -D__s390x__ -S proto64.c -o $@ + +proto-riscv32.s : proto.c + $(CROSS_TOOL) riscv32-linux gcc-7.3.0 $(OLDGCCFLAGS) -D__riscv32__ -S proto.c -o $@ + +proto-riscv64.s : proto64.c + $(CROSS_TOOL) riscv64-linux gcc-7.3.0 $(OLDGCCFLAGS) -D__riscv64__ -S proto64.c -o $@ + +tramp-i386.o : tramp-i386.s + $(ASPREFIX)/i486-linux/bin/as tramp-i386.s -o $@ + +tramp-m68k.o : tramp-m68k.s + $(ASPREFIX)/m68k-linux/bin/as tramp-m68k.s -o $@ + +tramp-mips.o : tramp-mips.s + $(ASPREFIX)/mips-linux/bin/as tramp-mips.s -o $@ + +tramp-mips64.o : tramp-mips64.s + $(ASPREFIX)/mips-linux/bin/as -mips64 -mabi=64 tramp-mips64.s -o $@ + +tramp-sparc.o : tramp-sparc.s + $(ASPREFIX)/sparc-sun/bin/as tramp-sparc.s -o $@ + +tramp-sparc64.o : tramp-sparc64.s + $(ASPREFIX)/sparc64-linux/bin/as tramp-sparc64.s -o $@ + +tramp-alpha.o : tramp-alpha.s + $(ASPREFIX)/alpha-linux/bin/as tramp-alpha.s -o $@ + +tramp-hppa.o : tramp-hppa.s + $(ASPREFIX)/hppa1.0-hpux/bin/as tramp-hppa.s -o $@ + +tramp-hppa64.o : tramp-hppa64.s + $(CROSS_TOOL) hppa64-linux as tramp-hppa64.s -o $@ + +tramp-arm.o : tramp-arm.s + $(CROSS_TOOL) arm-linux as tramp-arm.s -o $@ + +tramp-arm64.o : tramp-arm64.s + $(CROSS_TOOL) aarch64-linux as tramp-arm64.s -o $@ + +tramp-powerpc-old.o : tramp-powerpc-old.s + $(ASPREFIX)/rs6000/bin/as tramp-powerpc-old.s -o $@ + +tramp-powerpc-sysv4.o : tramp-powerpc-sysv4.s + $(ASPREFIX)/ppc-linux/bin/as tramp-powerpc-sysv4.s -o $@ + +tramp-powerpc64-elfv2.o : tramp-powerpc64-elfv2.s + $(CROSS_TOOL) powerpc64le-linux as tramp-powerpc64-elfv2.s -o $@ + +tramp-ia64.o : tramp-ia64.s + /nue/usr/ia64-hp-linux/bin/as tramp-ia64.s -o $@ + +tramp-x86_64.o : tramp-x86_64.s + $(ASPREFIX)/x86_64-linux/bin/as tramp-x86_64.s -o $@ + +tramp-x86_64-x32.o : tramp-x86_64-x32.s + $(CROSS_TOOL) x86_64-linux as tramp-x86_64-x32.s -o $@ + +tramp-s390.o : tramp-s390.s + $(CROSS_TOOL) s390-linux as tramp-s390.s -o $@ + +tramp-s390x.o : tramp-s390x.s + $(CROSS_TOOL) s390x-linux as tramp-s390x.s -o $@ + +tramp-riscv32.o : tramp-riscv32.s + $(CROSS_TOOL) riscv32-linux as tramp-riscv32.s -o $@ + +tramp-riscv64.o : tramp-riscv64.s + $(CROSS_TOOL) riscv64-linux as tramp-riscv64.s -o $@ diff --git a/callback/trampoline_r/Makefile.in b/callback/trampoline_r/Makefile.in new file mode 100644 index 0000000..ee88507 --- /dev/null +++ b/callback/trampoline_r/Makefile.in @@ -0,0 +1,257 @@ +# Makefile for trampoline + +#### Start of system configuration section. #### + +HOST = @host@ +CPU = @HOST_CPU_C_ABI@ +OS = @host_os@ + +# Directories used by "make": +srcdir = @srcdir@ + +# Directories used by "make install": +prefix = @prefix@ +local_prefix = /usr/local +exec_prefix = @exec_prefix@ +libdir = @libdir@ +includedir = @includedir@ +mandir = @mandir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +htmldir = $(datadir)/html + +# Programs used by "make": +CC = @CC@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +CPP = @CPP@ +INCLUDES = -I. -I$(srcdir) -I../.. -I$(srcdir)/../.. +INCLUDES_WITH_GNULIB = $(INCLUDES) -I../../gnulib-lib -I$(srcdir)/../../gnulib-lib +ASPFLAGS = `if test @AS_UNDERSCORE@ = true; then echo '-DASM_UNDERSCORE'; fi` +LDFLAGS = @LDFLAGS@ +LIBTOOL = @LIBTOOL@ +LIBTOOL_COMPILE = $(LIBTOOL) --mode=compile +LIBTOOL_LINK = $(LIBTOOL) --mode=link +LIBTOOL_INSTALL = $(LIBTOOL) --mode=install +LIBTOOL_UNINSTALL = $(LIBTOOL) --mode=uninstall +AR = @AR@ +AR_FLAGS = rc +RANLIB = @RANLIB@ +RM = rm -f +@SET_MAKE@ + +# Programs used by "make install": +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ + +# Libtool options for linking with the thread library. +LTLIBTHREAD = @LTLIBTHREAD@ + +#### End of system configuration section. #### + +SHELL = /bin/sh + +# Needed by $(LIBTOOL). +top_builddir = ../.. + +OBJECTS = trampoline.lo @CPU_OBJECTS@ + +all : $(OBJECTS) libtrampoline.la $(srcdir)/trampoline_r.3 $(srcdir)/trampoline_r.html + +trampoline.lo : $(srcdir)/trampoline.c $(srcdir)/trampoline_r.h + $(LIBTOOL_COMPILE) $(CC) $(INCLUDES_WITH_GNULIB) $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/trampoline.c + +tramp-hppa.lo : tramp-hppa.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c tramp-hppa.s + +tramp-hppa.s : $(srcdir)/tramp-hppa-macro.S $(srcdir)/../../common/noexecstack.h + $(CPP) $(ASPFLAGS) -I$(srcdir)/../../common $(srcdir)/tramp-hppa-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e "s,!,',g" > tramp-hppa.s + +tramp-hppa64.lo : tramp-hppa64.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c tramp-hppa64.s + +tramp-hppa64.s : $(srcdir)/tramp-hppa64-macro.S $(srcdir)/../../common/noexecstack.h + $(CPP) $(ASPFLAGS) -I$(srcdir)/../../common $(srcdir)/tramp-hppa64-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e "s,!,',g" > tramp-hppa64.s + +tramp-powerpc.lo : tramp-powerpc.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c tramp-powerpc.s + +tramp-powerpc.s : $(srcdir)/tramp-powerpc-aix.S + $(CPP) $(srcdir)/tramp-powerpc-aix.S > tramp-powerpc.s + +tramp-powerpc64.lo : tramp-powerpc64.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c tramp-powerpc64.s + +tramp-powerpc64.s : $(srcdir)/tramp-powerpc64-aix.S $(srcdir)/../../common/noexecstack.h + $(CPP) -I$(srcdir)/../../common $(srcdir)/tramp-powerpc64-aix.S > tramp-powerpc64.s + +tramp-ia64.lo : tramp-ia64.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c tramp-ia64.s + +tramp-ia64.s : $(srcdir)/tramp-ia64-macro.S $(srcdir)/../../common/noexecstack.h + $(CPP) $(ASPFLAGS) -I$(srcdir)/../../common $(srcdir)/tramp-ia64-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > tramp-ia64.s + +cache-sparc.lo : cache-sparc.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c cache-sparc.s + +cache-sparc.s : $(srcdir)/cache-sparc-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../../common - < $(srcdir)/cache-sparc-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,\. ,.,g' -e 's,//.*$$,,' -e 's,\$$,#,g' -e 's,# ,#,g' > cache-sparc.s + +cache-sparc64.lo : cache-sparc64.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c cache-sparc64.s + +cache-sparc64.s : $(srcdir)/cache-sparc64-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../../common - < $(srcdir)/cache-sparc64-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,\. ,.,g' -e 's,//.*$$,,' -e 's,\$$,#,g' -e 's,# ,#,g' > cache-sparc64.s + +cache-alpha.lo : cache-alpha.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c cache-alpha.s + +cache-alpha.s : $(srcdir)/cache-alpha-macro.S + $(CPP) $(ASPFLAGS) $(srcdir)/cache-alpha-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > cache-alpha.s + +cache-hppa.lo : cache-hppa.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c cache-hppa.s + +cache-hppa.s : $(srcdir)/cache-hppa-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../../common $(srcdir)/cache-hppa-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e "s,!,',g" > cache-hppa.s + +cache-hppa64.lo : cache-hppa64.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c cache-hppa64.s + +cache-hppa64.s : $(srcdir)/cache-hppa64-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../../common $(srcdir)/cache-hppa64-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e "s,!,',g" > cache-hppa64.s + +cache-powerpc.lo : cache-powerpc.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c cache-powerpc.s + +cache-powerpc.s : $(srcdir)/cache-powerpc-linux-macro.S $(srcdir)/cache-powerpc-macos.s + case "$(OS)" in \ + macos* | darwin*) syntax=macos;; \ + *) syntax=linux;; \ + esac; \ + case $${syntax} in \ + macos) \ + grep -v '\.machine' $(srcdir)/cache-powerpc-$${syntax}.s > cache-powerpc.s || exit 1 ;; \ + linux) \ + $(CPP) $(ASPFLAGS) $(srcdir)/cache-powerpc-$${syntax}-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > cache-powerpc.s || exit 1 ;; \ + *) \ + cp $(srcdir)/cache-powerpc-$${syntax}.s cache-powerpc.s || exit 1 ;; \ + esac + +cache-powerpc64-elfv2.lo : cache-powerpc64-elfv2.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c cache-powerpc64-elfv2.s + +cache-powerpc64-elfv2.s : $(srcdir)/cache-powerpc64-elfv2-macro.S + $(CPP) $(ASPFLAGS) $(srcdir)/cache-powerpc64-elfv2-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > cache-powerpc64-elfv2.s + +libtrampoline.la : $(OBJECTS) ../../gnulib-lib/libgnu.la + $(LIBTOOL_LINK) $(CC) -o libtrampoline.la -rpath $(libdir) -no-undefined $(OBJECTS) ../../gnulib-lib/libgnu.la $(LDFLAGS) $(LTLIBTHREAD) + +# Installs the library and include files only. Typically called with only +# $(libdir) and $(includedir) - don't use $(prefix) and $(exec_prefix) here. +install-lib : all force + mkdir -p $(includedir) + $(INSTALL_DATA) $(srcdir)/trampoline_r.h $(includedir)/trampoline_r.h + +install : all force + mkdir -p $(DESTDIR)$(prefix) + mkdir -p $(DESTDIR)$(exec_prefix) +# mkdir -p $(DESTDIR)$(libdir) +# $(LIBTOOL_INSTALL) $(INSTALL_DATA) libtrampoline.la $(DESTDIR)$(libdir)/libtrampoline.la + mkdir -p $(DESTDIR)$(includedir) + $(INSTALL_DATA) $(srcdir)/trampoline_r.h $(DESTDIR)$(includedir)/trampoline_r.h + mkdir -p $(DESTDIR)$(mandir) + mkdir -p $(DESTDIR)$(mandir)/man3 + $(INSTALL_DATA) $(srcdir)/trampoline_r.3 $(DESTDIR)$(mandir)/man3/trampoline_r.3 + mkdir -p $(DESTDIR)$(datadir) + mkdir -p $(DESTDIR)$(htmldir) + $(INSTALL_DATA) $(srcdir)/trampoline_r.html $(DESTDIR)$(htmldir)/trampoline_r.html + +installdirs : force + mkdir -p $(DESTDIR)$(prefix) + mkdir -p $(DESTDIR)$(exec_prefix) +# mkdir -p $(DESTDIR)$(libdir) + mkdir -p $(DESTDIR)$(includedir) + mkdir -p $(DESTDIR)$(mandir) + mkdir -p $(DESTDIR)$(mandir)/man3 + mkdir -p $(DESTDIR)$(datadir) + mkdir -p $(DESTDIR)$(htmldir) + +uninstall : force +# $(LIBTOOL_UNINSTALL) $(RM) $(DESTDIR)$(libdir)/libtrampoline.la + $(RM) $(DESTDIR)$(includedir)/trampoline_r.h + $(RM) $(DESTDIR)$(mandir)/man3/trampoline_r.3 + $(RM) $(DESTDIR)$(htmldir)/trampoline_r.html + +test1.@OBJEXT@ : $(srcdir)/test1.c $(srcdir)/trampoline_r.h + $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/test1.c + +test1 : test1.@OBJEXT@ libtrampoline.la + $(LIBTOOL_LINK) $(CC) $(CFLAGS) @GCC_X_NONE@ test1.@OBJEXT@ libtrampoline.la $(LDFLAGS) -o test1 + +test2.@OBJEXT@ : $(srcdir)/test2.c $(srcdir)/trampoline_r.h + $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/test2.c + +test2 : test2.@OBJEXT@ libtrampoline.la + $(LIBTOOL_LINK) $(CC) $(CFLAGS) @GCC_X_NONE@ test2.@OBJEXT@ libtrampoline.la $(LDFLAGS) -o test2 + +check1 : all test1 + ./test1 + +check : all test1 test2 + ./test1 + ./test2 + touch tests.passed.$(HOST) + +extracheck : check + +mostlyclean : clean + +clean : force + $(RM) $(OBJECTS) `echo $(OBJECTS) | sed -e 's/\.lo/.@OBJEXT@/g'` tramp-hppa.s tramp-hppa64.s tramp-powerpc.s tramp-powerpc64.s tramp-ia64.s cache-sparc.s cache-sparc64.s cache-alpha.s cache-hppa.s cache-hppa64.s cache-powerpc.s cache-powerpc64-elfv2.s libtrampoline.* core + $(RM) -r .libs _libs + $(RM) test1.@OBJEXT@ test1 test2.@OBJEXT@ test2 + +distclean : clean + $(RM) Makefile tests.passed.* + +maintainer-clean : distclean + + +# List of source files (committed in version control or generated by Makefile.devel). +SOURCE_FILES = \ + COPYING \ + PORTING README trampoline_r.3 trampoline_r.html \ + Makefile.devel \ + Makefile.maint \ + Makefile.in \ + trampoline_r.h \ + trampoline.c \ + tramp-hppa-macro.S \ + tramp-hppa64-macro.S \ + tramp-powerpc-aix.S \ + tramp-powerpc64-aix.S \ + tramp-ia64-macro.S \ + cache.c \ + cache-alpha.c cache-alpha-linux.s cache-alpha-macro.S \ + cache-hppa.c cache-hppa-linux.s cache-hppa-macro.S cache-hppa64-linux.s cache-hppa64-macro.S \ + cache-powerpc.c cache-powerpc-linux.s cache-powerpc-linux-macro.S cache-powerpc-macos.s \ + cache-powerpc64.c cache-powerpc64-elfv2-linux.s cache-powerpc64-elfv2-macro.S \ + cache-sparc.c cache-sparc-linux.s cache-sparc-macro.S cache-sparc64-linux.s cache-sparc64-macro.S \ + test1.c \ + test2.c +# List of distributed files generated by Makefile.maint. +GENERATED_FILES = \ + trampoline_r.man +# List of distributed files. +DISTFILES = $(SOURCE_FILES) $(GENERATED_FILES) + +distdir : $(DISTFILES) + for file in $(DISTFILES); do \ + if test -f $$file; then dir='.'; else dir='$(srcdir)'; fi; \ + cp -p "$$dir/$$file" '$(distdir)'/$$file || exit 1; \ + done + + +force : diff --git a/callback/trampoline_r/Makefile.maint b/callback/trampoline_r/Makefile.maint new file mode 100644 index 0000000..bc9c542 --- /dev/null +++ b/callback/trampoline_r/Makefile.maint @@ -0,0 +1,30 @@ +# maintainer -*-Makefile-*- + +RM = rm -f + +# ==================== Easily regeneratable files ==================== + +ROFF_MAN = groff -Tutf8 -mandoc + +all : trampoline_r.man + +trampoline_r.man : trampoline_r.3 + $(ROFF_MAN) trampoline_r.3 > trampoline_r.man + +totally-clean : force + $(RM) trampoline_r.man + + +# Files copied from other directories + +COPIED_FILES = \ + PORTING \ + cache.c \ + cache-alpha.c \ + cache-hppa.c +copied-files : $(COPIED_FILES) +$(COPIED_FILES) : % : ../../trampoline/% + cp $< $@ + + +force : diff --git a/callback/trampoline_r/PORTING b/callback/trampoline_r/PORTING new file mode 100644 index 0000000..46b6042 --- /dev/null +++ b/callback/trampoline_r/PORTING @@ -0,0 +1,95 @@ +The list of CPUs and platforms TRAMPOLINE has been ported to can be found +at the top of file trampoline.c. + +To port TRAMPOLINE to a new platform, three issues may have to be resolved: +A. a new CPU - how to build the trampoline? +B. a new OS - how to make code in malloc'ed memory executable? +C. a new CPU or OS - how to flush the instruction cache? + + +A. a new CPU - how to build the trampoline? + + The trampoline is a short sequence of machine instructions which puts + the constant into , then jumps to

. The only + registers that are allowed to be modified are call-used registers. No + stack manipulations are allowed since the trampoline has to pass its + arguments along to the function at
. + + 1. To find out which instructions are available for "move"/"store" and + "jump", compile proto.c for your CPU: + + make -f Makefile.devel proto-${CPU}.s + or + gcc -O2 -fomit-frame-pointer -S proto.c -o proto-${CPU}.s + + 2. Write down the instructions for the trampoline in a file tramp-${CPU}.s, + using constants for , ,
. Assemble it: + + gcc -c tramp-${CPU}.s + + Verify that the jump actually goes to
. (Beware: Some CPUs have + program-counter relative jumps.) + + gdb tramp-${CPU}.o + disassemble tramp + + 3. Take a hex dump of tramp-${CPU}.o + + hexdump -e '"%06.6_ax " 16/1 " %02X" "\n"' < tramp-${CPU}.o + or + od -tx1 -Ax < tramp-${CPU}.o + or + od -x +x < tramp-${CPU}.o + + Look out for the magic numbers you used for , and +
. + + 4. Write the code which builds up a trampoline in memory, in trampoline.c. + + 5. Try it: + + make + make check1 + + 6. Write the is_tramp() macro and the tramp_xxx() accessor macros + in trampoline.c. + + 7. Try it: + + make + make check + + +B. a new OS - how to make code in malloc'ed memory executable? + + ‘configure’ will find out whether code stored in malloc'ed memory is + executable, or whether virtual memory protections have to be set in order + to allow this. (The test is pretty simple: it copies a small function + to malloc'ed memory and tries to executed it. The test could also fail + because the compiler produced non-position-independent code or because + of alignment issues.) + + To set virtual memory protections on a page of memory, your system should + provide the mprotect() and getpagesize() functions. If it does not, find + a substitute. + + +C. a new CPU or OS - how to flush the instruction cache? + + CPUs which have separate data and instruction caches need to flush + (part of) the instruction cache when alloc_trampoline() is called. + (There may have been an old trampoline at the same location, and the + instruction cache is not updated when the new trampoline is built. + The effect can be that when the new trampoline is called, the old one + will still be executed.) + + To flush the instruction cache, some CPUs have special instruction which + can be put into gcc "asm" statements. On some CPUs these instructions are + privileged, you therefore need to call some system or library function. + On other CPUs, the only way to flush the instruction cache is to execute + a long sequence of "nop" or "jump" instructions. This is hairy. + + +When you are done with porting to a new platform, or even if TRAMPOLINE +passes the "make check" out of the box without modifications, please report +your results to the author of TRAMPOLINE, for inclusion in the next release. diff --git a/callback/trampoline_r/README b/callback/trampoline_r/README new file mode 100644 index 0000000..486839e --- /dev/null +++ b/callback/trampoline_r/README @@ -0,0 +1,12 @@ +This directory contains a reentrant version of the trampoline package. + +Instead of clobbering a global variable, a pointer to data0,data1,... +is passed to the called function in a special CPU register. + +The number of supported data words (data0,data1) is arbitrary; 3 or 4 +or more would work as well if trampoline.c was modified appropriately. +Two words are needed, however, for passing closures through vacall_r +without an additional malloc() call per closure. + +The include file is renamed to . + diff --git a/callback/trampoline_r/cache-alpha-linux.s b/callback/trampoline_r/cache-alpha-linux.s new file mode 100644 index 0000000..6754a16 --- /dev/null +++ b/callback/trampoline_r/cache-alpha-linux.s @@ -0,0 +1,20 @@ + .set noreorder + .set volatile + .set noat + .set nomacro + .text + .align 2 + .align 4 + .globl __TR_clear_cache + .ent __TR_clear_cache +$__TR_clear_cache..ng: +__TR_clear_cache: + .frame $30,0,$26,0 + .prologue 0 + .set macro + call_pal 0x86 + .set nomacro + ret $31,($26),1 + .end __TR_clear_cache + .ident "GCC: (GNU) 4.0.2" + .section .note.GNU-stack,"",@progbits diff --git a/callback/trampoline_r/cache-alpha-macro.S b/callback/trampoline_r/cache-alpha-macro.S new file mode 100644 index 0000000..e350f4c --- /dev/null +++ b/callback/trampoline_r/cache-alpha-macro.S @@ -0,0 +1,21 @@ + .set noreorder + .set volatile + .set noat + .set nomacro + .text + .align 2 + .align 4 + .globl __TR_clear_cache + .ent __TR_clear_cache +$__TR_clear_cache..ng: +__TR_clear_cache: + .frame $30,0,$26,0 + .prologue 0 + .set macro + call_pal 0x86 + .set nomacro + ret $31,($26),1 + .end __TR_clear_cache +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/callback/trampoline_r/cache-alpha.c b/callback/trampoline_r/cache-alpha.c new file mode 100644 index 0000000..ad20947 --- /dev/null +++ b/callback/trampoline_r/cache-alpha.c @@ -0,0 +1,24 @@ +/* Instruction cache flushing for alpha */ + +/* + * Copyright 1997 Bruno Haible + * + * 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, see . + */ + +void __TR_clear_cache (void) +{ + /* Taken from gforth-0.3.0. */ + asm volatile ("call_pal 0x86"); /* imb (instruction-memory barrier) */ +} diff --git a/callback/trampoline_r/cache-hppa-linux.s b/callback/trampoline_r/cache-hppa-linux.s new file mode 100644 index 0000000..b9c9a6d --- /dev/null +++ b/callback/trampoline_r/cache-hppa-linux.s @@ -0,0 +1,33 @@ + .LEVEL 1.1 + .text + .align 4 +.globl __TR_clear_cache + .type __TR_clear_cache,@function +__TR_clear_cache: + .PROC + .CALLINFO FRAME=0,NO_CALLS + .ENTRY +#APP + fdc 0(0,%r26) + fdc 0(0,%r25) + sync + mfsp %sr0,%r20 + ldsid (0,%r26),%r26 + mtsp %r26,%sr0 + fic 0(%sr0,%r26) + fic 0(%sr0,%r25) + sync + mtsp %r20,%sr0 + nop + nop + nop + nop + nop + nop +#NO_APP + bv,n %r0(%r2) + .EXIT + .PROCEND +.Lfe1: + .size __TR_clear_cache,.Lfe1-__TR_clear_cache + .ident "GCC: (GNU) 3.1" diff --git a/callback/trampoline_r/cache-hppa-macro.S b/callback/trampoline_r/cache-hppa-macro.S new file mode 100644 index 0000000..7c39646 --- /dev/null +++ b/callback/trampoline_r/cache-hppa-macro.S @@ -0,0 +1,36 @@ +#include "asm-hppa.h" + .LEVEL 1.1 + IMPORT_MILLICODE($$dyncall) + TEXT1() + TEXT2() + .align 4 +GLOBL(__TR_clear_cache) + DECLARE_FUNCTION(__TR_clear_cache) +DEF(__TR_clear_cache) + .PROC + .CALLINFO FRAME=0,NO_CALLS + .ENTRY + fdc 0(0,%r26) + fdc 0(0,%r25) + sync + mfsp %sr0,%r20 + ldsid (0,%r26),%r26 + mtsp %r26,%sr0 + fic 0(%sr0,%r26) + fic 0(%sr0,%r25) + sync + mtsp %r20,%sr0 + nop + nop + nop + nop + nop + nop + bv,n %r0(%r2) + .EXIT + .PROCEND +DEF(L(fe1)) + FUNEND(__TR_clear_cache) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/callback/trampoline_r/cache-hppa.c b/callback/trampoline_r/cache-hppa.c new file mode 100644 index 0000000..2174716 --- /dev/null +++ b/callback/trampoline_r/cache-hppa.c @@ -0,0 +1,65 @@ +/* Instruction cache flushing for hppa */ + +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +#ifdef __hppa64__ +/* Tell GCC not to clobber the registers that are call-saved in the HP C + calling convention. */ +register long arg0 __asm__("r26"); +register long arg1 __asm__("r25"); +register long arg2 __asm__("r24"); +register long arg3 __asm__("r23"); +register long arg4 __asm__("r22"); +register long arg5 __asm__("r21"); +register long arg6 __asm__("r20"); +register long arg7 __asm__("r19"); +#endif + +/* + * This assumes that the range [first_addr..last_addr] lies in at most two + * cache lines. + */ +void __TR_clear_cache (char* first_addr, char* last_addr) +{ + register int tmp1; + register int tmp2; + /* Flush the relevant data cache lines. (Yes, this is needed. I tried it.) */ + asm volatile ("fdc 0(0,%0)" + "\n\t" "fdc 0(0,%1)" + "\n\t" "sync" + : + : "r" (first_addr), "r" (last_addr) + ); + /* Flush the relevant instruction cache lines. */ + asm volatile ("mfsp %%sr0,%1" + "\n\t" "ldsid (0,%4),%0" + "\n\t" "mtsp %0,%%sr0" + "\n\t" "fic 0(%%sr0,%2)" + "\n\t" "fic 0(%%sr0,%3)" + "\n\t" "sync" + "\n\t" "mtsp %1,%%sr0" + "\n\t" "nop" + "\n\t" "nop" + "\n\t" "nop" + "\n\t" "nop" + "\n\t" "nop" + "\n\t" "nop" + : "=r" (tmp1), "=r" (tmp2) + : "r" (first_addr), "r" (last_addr), "r" (first_addr) + ); +} diff --git a/callback/trampoline_r/cache-hppa64-linux.s b/callback/trampoline_r/cache-hppa64-linux.s new file mode 100644 index 0000000..928f35f --- /dev/null +++ b/callback/trampoline_r/cache-hppa64-linux.s @@ -0,0 +1,35 @@ + .LEVEL 2.0w + .text + .align 8 +.globl __TR_clear_cache + .type __TR_clear_cache,@function +__TR_clear_cache: + .PROC + .CALLINFO FRAME=128,NO_CALLS + .ENTRY + ldo 128(%r30),%r30 +#APP + fdc 0(0,%r26) + fdc 0(0,%r25) + sync + mfsp %sr0,%r31 + ldsid (0,%r26),%r28 + mtsp %r28,%sr0 + fic 0(%sr0,%r26) + fic 0(%sr0,%r25) + sync + mtsp %r31,%sr0 + nop + nop + nop + nop + nop + nop +#NO_APP + bve (%r2) + ldo -128(%r30),%r30 + .EXIT + .PROCEND +.Lfe1: + .size __TR_clear_cache,.Lfe1-__TR_clear_cache + .ident "GCC: (GNU) 3.1" diff --git a/callback/trampoline_r/cache-hppa64-macro.S b/callback/trampoline_r/cache-hppa64-macro.S new file mode 100644 index 0000000..e5344ae --- /dev/null +++ b/callback/trampoline_r/cache-hppa64-macro.S @@ -0,0 +1,37 @@ +#include "asm-hppa64.h" + .LEVEL 2.0w + TEXT1() + TEXT2() + .align 8 +GLOBL(__TR_clear_cache) + DECLARE_FUNCTION(__TR_clear_cache) +DEF(__TR_clear_cache) + .PROC + .CALLINFO FRAME=128,NO_CALLS + .ENTRY + ldo 128(%r30),%r30 + fdc 0(0,%r26) + fdc 0(0,%r25) + sync + mfsp %sr0,%r31 + ldsid (0,%r26),%r28 + mtsp %r28,%sr0 + fic 0(%sr0,%r26) + fic 0(%sr0,%r25) + sync + mtsp %r31,%sr0 + nop + nop + nop + nop + nop + nop + bve (%r2) + ldo -128(%r30),%r30 + .EXIT + .PROCEND +DEF(L(fe1)) + FUNEND(__TR_clear_cache) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/callback/trampoline_r/cache-powerpc-linux-macro.S b/callback/trampoline_r/cache-powerpc-linux-macro.S new file mode 100644 index 0000000..9fb39b2 --- /dev/null +++ b/callback/trampoline_r/cache-powerpc-linux-macro.S @@ -0,0 +1,31 @@ + .file "cache-powerpc.c" + .section ".text" + .align 2 + .globl __TR_clear_cache + .type __TR_clear_cache, @function +__TR_clear_cache: + .extern __mulh + .extern __mull + .extern __divss + .extern __divus + .extern __quoss + .extern __quous + stwu 1,-32(1) + icbi 0,3; dcbf 0,3 + addi 0,3,4 + icbi 0,0; dcbf 0,0 + addi 9,3,8 + icbi 0,9; dcbf 0,9 + addi 0,3,12 + icbi 0,0; dcbf 0,0 + addi 9,3,16 + icbi 0,9; dcbf 0,9 + addi 3,3,20 + icbi 0,3; dcbf 0,3 + sync; isync + addi 1,1,32 + blr + .size __TR_clear_cache, .-__TR_clear_cache +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/callback/trampoline_r/cache-powerpc-linux.s b/callback/trampoline_r/cache-powerpc-linux.s new file mode 100644 index 0000000..11788b3 --- /dev/null +++ b/callback/trampoline_r/cache-powerpc-linux.s @@ -0,0 +1,42 @@ + .file "cache-powerpc.c" + .section ".text" + .align 2 + .globl __TR_clear_cache + .type __TR_clear_cache, @function +__TR_clear_cache: + .extern __mulh + .extern __mull + .extern __divss + .extern __divus + .extern __quoss + .extern __quous + stwu 1,-32(1) +#APP + icbi 0,3; dcbf 0,3 +#NO_APP + addi 0,3,4 +#APP + icbi 0,0; dcbf 0,0 +#NO_APP + addi 9,3,8 +#APP + icbi 0,9; dcbf 0,9 +#NO_APP + addi 0,3,12 +#APP + icbi 0,0; dcbf 0,0 +#NO_APP + addi 9,3,16 +#APP + icbi 0,9; dcbf 0,9 +#NO_APP + addi 3,3,20 +#APP + icbi 0,3; dcbf 0,3 + sync; isync +#NO_APP + addi 1,1,32 + blr + .size __TR_clear_cache, .-__TR_clear_cache + .section .note.GNU-stack,"",@progbits + .ident "GCC: (GNU) 3.3.6" diff --git a/callback/trampoline_r/cache-powerpc-macos.s b/callback/trampoline_r/cache-powerpc-macos.s new file mode 100644 index 0000000..c468cf3 --- /dev/null +++ b/callback/trampoline_r/cache-powerpc-macos.s @@ -0,0 +1,17 @@ +.text + .align 2 + .globl ___TR_clear_cache +___TR_clear_cache: + icbi 0,r3; dcbf 0,r3 + addi r0,r3,4 + icbi 0,r0; dcbf 0,r0 + addi r9,r3,8 + icbi 0,r9; dcbf 0,r9 + addi r0,r3,12 + icbi 0,r0; dcbf 0,r0 + addi r9,r3,16 + icbi 0,r9; dcbf 0,r9 + addi r3,r3,20 + icbi 0,r3; dcbf 0,r3 + sync; isync + blr diff --git a/callback/trampoline_r/cache-powerpc.c b/callback/trampoline_r/cache-powerpc.c new file mode 100644 index 0000000..88dbb0b --- /dev/null +++ b/callback/trampoline_r/cache-powerpc.c @@ -0,0 +1,32 @@ +/* Instruction cache flushing for powerpc, not on AIX */ + +/* + * Copyright 1997-2017 Bruno Haible + * + * 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, see . + */ + +void __TR_clear_cache (char* first_addr) +{ + /* Taken from egcs-1.1.2/gcc/config/rs6000/tramp.asm. */ + /* The number of asm statements here depends on the value of TRAMP_LENGTH + for __powerpcsysv4__. */ + asm volatile ("icbi 0,%0; dcbf 0,%0" : : "r" (first_addr)); + asm volatile ("icbi 0,%0; dcbf 0,%0" : : "r" (first_addr+4)); + asm volatile ("icbi 0,%0; dcbf 0,%0" : : "r" (first_addr+8)); + asm volatile ("icbi 0,%0; dcbf 0,%0" : : "r" (first_addr+12)); + asm volatile ("icbi 0,%0; dcbf 0,%0" : : "r" (first_addr+16)); + asm volatile ("icbi 0,%0; dcbf 0,%0" : : "r" (first_addr+20)); + asm volatile ("sync; isync"); +} diff --git a/callback/trampoline_r/cache-powerpc64-elfv2-linux.s b/callback/trampoline_r/cache-powerpc64-elfv2-linux.s new file mode 100644 index 0000000..e51aef5 --- /dev/null +++ b/callback/trampoline_r/cache-powerpc64-elfv2-linux.s @@ -0,0 +1,42 @@ + .file "cache-powerpc64.c" + .machine power4 + .abiversion 2 + .section ".toc","aw" + .section ".text" + .align 2 + .p2align 4,,15 + .globl __TR_clear_cache + .type __TR_clear_cache, @function +__TR_clear_cache: +#APP + # 25 "cache-powerpc64.c" 1 + icbi 0,3; dcbf 0,3 + # 0 "" 2 +#NO_APP + addi 9,3,4 +#APP + # 26 "cache-powerpc64.c" 1 + icbi 0,9; dcbf 0,9 + # 0 "" 2 +#NO_APP + addi 9,3,8 +#APP + # 27 "cache-powerpc64.c" 1 + icbi 0,9; dcbf 0,9 + # 0 "" 2 +#NO_APP + addi 3,3,12 +#APP + # 28 "cache-powerpc64.c" 1 + icbi 0,3; dcbf 0,3 + # 0 "" 2 + # 29 "cache-powerpc64.c" 1 + sync; isync + # 0 "" 2 +#NO_APP + blr + .long 0 + .byte 0,0,0,0,0,0,0,0 + .size __TR_clear_cache,.-__TR_clear_cache + .ident "GCC: (GNU) 5.4.0" + .section .note.GNU-stack,"",@progbits diff --git a/callback/trampoline_r/cache-powerpc64-elfv2-macro.S b/callback/trampoline_r/cache-powerpc64-elfv2-macro.S new file mode 100644 index 0000000..81c43d0 --- /dev/null +++ b/callback/trampoline_r/cache-powerpc64-elfv2-macro.S @@ -0,0 +1,35 @@ + .file "cache-powerpc64.c" + .machine power4 + .abiversion 2 + .section ".toc","aw" + .section ".text" + .align 2 + .p2align 4,,15 + .globl __TR_clear_cache + .type __TR_clear_cache, @function +__TR_clear_cache: + # 25 "cache-powerpc64.c" 1 + icbi 0,3; dcbf 0,3 + # 0 "" 2 + addi 9,3,4 + # 26 "cache-powerpc64.c" 1 + icbi 0,9; dcbf 0,9 + # 0 "" 2 + addi 9,3,8 + # 27 "cache-powerpc64.c" 1 + icbi 0,9; dcbf 0,9 + # 0 "" 2 + addi 3,3,12 + # 28 "cache-powerpc64.c" 1 + icbi 0,3; dcbf 0,3 + # 0 "" 2 + # 29 "cache-powerpc64.c" 1 + sync; isync + # 0 "" 2 + blr + .long 0 + .byte 0,0,0,0,0,0,0,0 + .size __TR_clear_cache,.-__TR_clear_cache +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/callback/trampoline_r/cache-powerpc64.c b/callback/trampoline_r/cache-powerpc64.c new file mode 100644 index 0000000..76a2b72 --- /dev/null +++ b/callback/trampoline_r/cache-powerpc64.c @@ -0,0 +1,30 @@ +/* Instruction cache flushing for powerpc64, not the AIX ABI */ + +/* + * Copyright 1997-2017 Bruno Haible + * + * 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, see . + */ + +void __TR_clear_cache (char* first_addr) +{ + /* Taken from egcs-1.1.2/gcc/config/rs6000/tramp.asm. */ + /* The number of asm statements here depends on the value of TRAMP_LENGTH-2*8 + for __powerpc64_elfv2__. */ + asm volatile ("icbi 0,%0; dcbf 0,%0" : : "r" (first_addr)); + asm volatile ("icbi 0,%0; dcbf 0,%0" : : "r" (first_addr+4)); + asm volatile ("icbi 0,%0; dcbf 0,%0" : : "r" (first_addr+8)); + asm volatile ("icbi 0,%0; dcbf 0,%0" : : "r" (first_addr+12)); + asm volatile ("sync; isync"); +} diff --git a/callback/trampoline_r/cache-sparc-linux.s b/callback/trampoline_r/cache-sparc-linux.s new file mode 100644 index 0000000..2fa77f5 --- /dev/null +++ b/callback/trampoline_r/cache-sparc-linux.s @@ -0,0 +1,15 @@ + .file "cache-sparc.c" + .section ".text" + .align 4 + .global __TR_clear_cache_2 + .type __TR_clear_cache_2,#function + .proc 020 +__TR_clear_cache_2: + !#PROLOGUE# 0 + iflush %o0+0;iflush %o0+8 + nop + retl + nop +.LLfe1: + .size __TR_clear_cache_2,.LLfe1-__TR_clear_cache_2 + .ident "GCC: (GNU) 3.1" diff --git a/callback/trampoline_r/cache-sparc-macro.S b/callback/trampoline_r/cache-sparc-macro.S new file mode 100644 index 0000000..b633dc5 --- /dev/null +++ b/callback/trampoline_r/cache-sparc-macro.S @@ -0,0 +1,17 @@ +#include "asm-sparc.h" + .section ".text" + .align 4 + .global C(__TR_clear_cache_2) + DECLARE_FUNCTION(__TR_clear_cache_2) + .proc 020 +FUNBEGIN(__TR_clear_cache_2) + !$PROLOGUE$ 0 + iflush %o0+0;iflush %o0+8 + nop + retl + nop +L(Lfe1): + FUNEND(__TR_clear_cache_2) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/callback/trampoline_r/cache-sparc.c b/callback/trampoline_r/cache-sparc.c new file mode 100644 index 0000000..81bc434 --- /dev/null +++ b/callback/trampoline_r/cache-sparc.c @@ -0,0 +1,29 @@ +/* Instruction cache flushing for sparc */ + +/* + * Copyright 1996-1999 Bruno Haible + * + * 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, see . + */ + +/* + * This assumes that the range [first_addr..last_addr] lies in at most two + * cache lines. + */ +void __TR_clear_cache_2 (char* first_addr, char* last_addr) +{ + asm volatile ("iflush %0+0;" /* the +0 is needed by gas, says gforth-0.3.0 */ + "iflush %0+8" + : : "r" (first_addr)); +} diff --git a/callback/trampoline_r/cache-sparc64-linux.s b/callback/trampoline_r/cache-sparc64-linux.s new file mode 100644 index 0000000..eb13421 --- /dev/null +++ b/callback/trampoline_r/cache-sparc64-linux.s @@ -0,0 +1,13 @@ + .file "cache-sparc.c" + .section ".text" + .align 4 + .global __TR_clear_cache_2 + .type __TR_clear_cache_2, #function + .proc 020 +__TR_clear_cache_2: + iflush %o0+0;iflush %o0+8 + jmp %o7+8 + nop + .size __TR_clear_cache_2, .-__TR_clear_cache_2 + .ident "GCC: (GNU) 4.0.2" + .section ".note.GNU-stack" diff --git a/callback/trampoline_r/cache-sparc64-macro.S b/callback/trampoline_r/cache-sparc64-macro.S new file mode 100644 index 0000000..039fd8e --- /dev/null +++ b/callback/trampoline_r/cache-sparc64-macro.S @@ -0,0 +1,14 @@ +#include "asm-sparc.h" + .section ".text" + .align 4 + .global C(__TR_clear_cache_2) + DECLARE_FUNCTION(__TR_clear_cache_2) + .proc 020 +FUNBEGIN(__TR_clear_cache_2) + iflush %o0+0;iflush %o0+8 + jmp %o7+8 + nop + FUNEND(__TR_clear_cache_2) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/callback/trampoline_r/cache.c b/callback/trampoline_r/cache.c new file mode 100644 index 0000000..7d34af9 --- /dev/null +++ b/callback/trampoline_r/cache.c @@ -0,0 +1,143 @@ +/* This file is derived from gcc-2.6.3/libgcc2.c, section L_clear_cache */ + +/* Copyright (C) 1989-2017 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 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, see . */ + + +/* Clear part of an instruction cache. */ + +/* Our emphasis here is _not_ to clear as few cache lines as possible + * or with as few machine instructions as possible, but to do it _right_. + */ + + + +/* This code is apparently untested!! */ + +/* This is from Andreas Stolcke . */ +#if defined(__mips__) || defined(__mips64__) +#include +#define CLEAR_INSN_CACHE(BEG, END) \ + cacheflush (BEG, END - BEG, BCACHE) +#endif + +void +__TR_clear_cache (beg, end) + char *beg, *end; +{ +#ifdef CLEAR_INSN_CACHE + CLEAR_INSN_CACHE (beg, end); +#else +#ifdef INSN_CACHE_SIZE /* This is actually dead code!! */ +#define INSN_CACHE_PLANE_SIZE (INSN_CACHE_SIZE / INSN_CACHE_DEPTH) + static char array[INSN_CACHE_SIZE + INSN_CACHE_PLANE_SIZE + INSN_CACHE_LINE_WIDTH]; + static int initialized = 0; + int offset; + void *start_addr; + void *end_addr; + typedef (*function_ptr) (); + +#if (INSN_CACHE_SIZE / INSN_CACHE_LINE_WIDTH) < 16 + /* It's cheaper to clear the whole cache. + Put in a series of jump instructions so that calling the beginning + of the cache will clear the whole thing. */ + + if (! initialized) + { + int ptr = (((int) array + INSN_CACHE_LINE_WIDTH - 1) + & -INSN_CACHE_LINE_WIDTH); + int end_ptr = ptr + INSN_CACHE_SIZE; + + while (ptr < end_ptr) + { + *(INSTRUCTION_TYPE *)ptr + = JUMP_AHEAD_INSTRUCTION + INSN_CACHE_LINE_WIDTH; + ptr += INSN_CACHE_LINE_WIDTH; + } + *(INSTRUCTION_TYPE *)(ptr - INSN_CACHE_LINE_WIDTH) = RETURN_INSTRUCTION; + + initialized = 1; + } + + /* Call the beginning of the sequence. */ + (((function_ptr) (((int) array + INSN_CACHE_LINE_WIDTH - 1) + & -INSN_CACHE_LINE_WIDTH)) + ()); + +#else /* Cache is large. */ + + if (! initialized) + { + int ptr = (((int) array + INSN_CACHE_LINE_WIDTH - 1) + & -INSN_CACHE_LINE_WIDTH); + + while (ptr < (int) array + sizeof array) + { + *(INSTRUCTION_TYPE *)ptr = RETURN_INSTRUCTION; + ptr += INSN_CACHE_LINE_WIDTH; + } + + initialized = 1; + } + + /* Find the location in array that occupies the same cache line as BEG. */ + + offset = ((int) beg & -INSN_CACHE_LINE_WIDTH) & (INSN_CACHE_PLANE_SIZE - 1); + start_addr = (((int) (array + INSN_CACHE_PLANE_SIZE - 1) + & -INSN_CACHE_PLANE_SIZE) + + offset); + + /* Compute the cache alignment of the place to stop clearing. */ +#if 0 /* This is not needed for gcc's purposes. */ + /* If the block to clear is bigger than a cache plane, + we clear the entire cache, and OFFSET is already correct. */ + if (end < beg + INSN_CACHE_PLANE_SIZE) +#endif + offset = (((int) (end + INSN_CACHE_LINE_WIDTH - 1) + & -INSN_CACHE_LINE_WIDTH) + & (INSN_CACHE_PLANE_SIZE - 1)); + +#if INSN_CACHE_DEPTH > 1 + end_addr = (start_addr & -INSN_CACHE_PLANE_SIZE) + offset; + if (end_addr <= start_addr) + end_addr += INSN_CACHE_PLANE_SIZE; + + for (plane = 0; plane < INSN_CACHE_DEPTH; plane++) + { + int addr = start_addr + plane * INSN_CACHE_PLANE_SIZE; + int stop = end_addr + plane * INSN_CACHE_PLANE_SIZE; + + while (addr != stop) + { + /* Call the return instruction at ADDR. */ + ((function_ptr) addr) (); + + addr += INSN_CACHE_LINE_WIDTH; + } + } +#else /* just one plane */ + do + { + /* Call the return instruction at START_ADDR. */ + ((function_ptr) start_addr) (); + + start_addr += INSN_CACHE_LINE_WIDTH; + } + while ((start_addr % INSN_CACHE_SIZE) != offset); +#endif /* just one plane */ +#endif /* Cache is large */ +#endif /* Cache exists */ +#endif /* CLEAR_INSN_CACHE */ +} diff --git a/callback/trampoline_r/test1.c b/callback/trampoline_r/test1.c new file mode 100644 index 0000000..cb1bfdf --- /dev/null +++ b/callback/trampoline_r/test1.c @@ -0,0 +1,105 @@ +/* Trampoline test */ + +/* + * Copyright 1995-2019 Bruno Haible + * + * 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, see . + */ + +#include +#include + +#include "trampoline_r.h" +#include "ffcall-abi.h" /* Define __${host_cpu}__ */ + +/* Set when we can check that the env register is being passed correctly. */ +#if defined __GNUC__ && !defined __clang__ && !defined(__arm__) +#define CHECK_ENV_REGISTER +#endif + +#define MAGIC1 0x9db9af42 +#define MAGIC2 0x614a13c9 +#define MAGIC3 0x7aff3cb4 +#define MAGIC4 0xa2f9d045 + +#ifdef __cplusplus +typedef int (*function)(...); +#else +typedef int (*function)(); +#endif + +int f (int x) +{ +#ifdef CHECK_ENV_REGISTER +#ifdef __i386__ +register void* env __asm__("%ecx"); +#endif +#ifdef __m68k__ +register void* env __asm__("a0"); +#endif +#if defined(__mips__) || defined(__mipsn32__) || defined(__mips64__) +register void* env __asm__("$2"); +#endif +#if defined(__sparc__) && !defined(__sparc64__) +register void* env __asm__("%g2"); +#endif +#ifdef __sparc64__ +register void* env __asm__("%g5"); +#endif +#ifdef __alpha__ +register void* env __asm__("$1"); +#endif +#if defined(__hppa__) && !defined(__hppa64__) +register void* env __asm__("%r29"); +#endif +#ifdef __hppa64__ +register void* env __asm__("%r31"); +#endif +#ifdef __arm64__ +register void* env __asm__("x18"); +#endif +#ifdef __powerpc__ +register void* env __asm__("r11"); +#endif +#ifdef __ia64__ +register void* env __asm__("r15"); +#endif +#ifdef __x86_64__ +register void* env __asm__("r10"); +#endif +#if defined(__s390__) || defined(__s390x__) +register void* env __asm__("r0"); +#endif +#if defined(__riscv32__) || defined(__riscv64__) +register void* env __asm__("t2"); +#endif + + return x + (int)(long)((void**)env)[0] + (int)(long)((void**)env)[1] + MAGIC3; +#else + return x + MAGIC3; +#endif +} + +int main () +{ + function cf = alloc_trampoline_r((function)&f, (void*)MAGIC1, (void*)MAGIC2); +#ifdef CHECK_ENV_REGISTER + if ((*cf)(MAGIC4) == MAGIC1+MAGIC2+MAGIC3+MAGIC4) +#else + if ((*cf)(MAGIC4) == MAGIC3+MAGIC4) +#endif + { free_trampoline_r(cf); printf("Works, test1 passed.\n"); exit(0); } + else + { printf("Doesn't work!\n"); exit(1); } +} diff --git a/callback/trampoline_r/test2.c b/callback/trampoline_r/test2.c new file mode 100644 index 0000000..cd4bd1f --- /dev/null +++ b/callback/trampoline_r/test2.c @@ -0,0 +1,52 @@ +/* Trampoline accessor test */ + +/* + * Copyright 1995-2005 Bruno Haible + * + * 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, see . + */ + +#include +#include + +#include "trampoline_r.h" + +#ifdef __cplusplus +typedef int (*function)(...); +#else +typedef int (*function)(); +#endif + +int f (int x) +{ return x; } + +#define MAGIC1 0x9db9af42 +#define MAGIC2 0x614a13c9 + +int main () +{ + function cf = alloc_trampoline_r((function)&f, (void*)MAGIC1, (void*)MAGIC2); + if (is_trampoline_r((void*)&main)) + { printf("is_trampoline_r(&main) returns true!\n"); exit(1); } + if (!is_trampoline_r((void*)cf)) + { printf("is_trampoline_r() returns false!\n"); exit(1); } + if (trampoline_r_address(cf) != (function)&f) + { printf("trampoline_r_address() doesn't work!\n"); exit(1); } + if (trampoline_r_data0(cf) != (void*)MAGIC1) + { printf("trampoline_r_data0() doesn't work!\n"); exit(1); } + if (trampoline_r_data1(cf) != (void*)MAGIC2) + { printf("trampoline_r_data1() doesn't work!\n"); exit(1); } + printf("test2 passed.\n"); + exit(0); +} diff --git a/callback/trampoline_r/tramp-hppa-macro.S b/callback/trampoline_r/tramp-hppa-macro.S new file mode 100644 index 0000000..f223283 --- /dev/null +++ b/callback/trampoline_r/tramp-hppa-macro.S @@ -0,0 +1,49 @@ +; Trampoline for hppa CPU + +; Copyright 1997-2017 Bruno Haible +; +; 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, see . + +; Available registers: %r1, %r19, %r20, %r21, %r22, %r29, %r31. + + .code + .IMPORT $global$,DATA + .IMPORT $$dyncall,MILLICODE + .code + + .align 4 + .EXPORT tramp_r,ENTRY,PRIV_LEV=3,ARGW0=GR,ARGW1=GR + .label tramp_r + .PROC + .CALLINFO FRAME=0,NO_CALLS + .ENTRY +; The closure pointer is already in register %r19. +; Move into register %r29 + ldw 0(0,%r19),%r29 +; Move
into register %r21. + ldw 4(0,%r19),%r21 +; Jump to it. + bb,>=,n %r21,30,tramp_r_2 + depi 0,31,2,%r21 + ldw 4(0,%r21),%r19 + ldw 0(0,%r21),%r21 + .label tramp_r_2 + ldsid (0,%r21),%r1 + mtsp %r1,%sr0 + be,n 0(%sr0,%r21) + nop + .EXIT + .PROCEND + +#include "noexecstack.h" diff --git a/callback/trampoline_r/tramp-hppa64-macro.S b/callback/trampoline_r/tramp-hppa64-macro.S new file mode 100644 index 0000000..62eb419 --- /dev/null +++ b/callback/trampoline_r/tramp-hppa64-macro.S @@ -0,0 +1,48 @@ +; Trampoline for hppa64 CPU + +; Copyright 2017 Bruno Haible +; +; 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, see . + +; Available registers: %r1, %r27, %r31. +; %r27 has a fixed meaning at function calls: pic_base (a.k.a. gp or dp). +; %r31 has a fixed meaning as millicode return pointer (mrp). + +#include "asm-hppa64.h" + + .LEVEL 2.0w + TEXT1() + TEXT2() + .align 8 + GLOBL(tramp_r) + DECLARE_FUNCTION(tramp_r) +DEF(tramp_r) + .PROC + .CALLINFO FRAME=0,NO_CALLS + .ENTRY +; The closure pointer is already in register %r27. +; Move into register %r31. + ldd 0(%r27),%r31 ; get +; Jump to . + ldd 8(%r27),%r27 ; get + ldd 16(%r27),%r1 + ldd 24(%r27),%r27 + bve (%r1) ; jump to + nop + .EXIT + .PROCEND +DEF(L(fe1)) + FUNEND(tramp_r) + +#include "noexecstack.h" diff --git a/callback/trampoline_r/tramp-ia64-macro.S b/callback/trampoline_r/tramp-ia64-macro.S new file mode 100644 index 0000000..f2deeec --- /dev/null +++ b/callback/trampoline_r/tramp-ia64-macro.S @@ -0,0 +1,43 @@ +/* Trampoline for ia64 CPU */ + +/* + * Copyright 2001-2017 Bruno Haible + * + * 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, see . + */ + +/* Available registers: r14 ... r31, r9 ... r11, r2 ... r3. */ + + .text + .align 16 + .global tramp_r# + .proc tramp_r# +tramp_r: + /* The closure pointer is already in register r1. */ + ld8 r14 = [r1] /* Move
into register r14. */ + adds r15 = 8, r1 + ;; + ld8 r15 = [r15] /* Move into register r15. */ + /* Jump to r14. */ + ld8 r17 = [r14] + adds r16 = 8, r14 + ;; + ld8 r1 = [r16] + mov b6 = r17 + ;; + br b6 + ;; + .endp tramp_r# + +#include "noexecstack.h" diff --git a/callback/trampoline_r/tramp-powerpc-aix.S b/callback/trampoline_r/tramp-powerpc-aix.S new file mode 100644 index 0000000..2ed1eca --- /dev/null +++ b/callback/trampoline_r/tramp-powerpc-aix.S @@ -0,0 +1,49 @@ +/* Trampoline for powerpc CPU with AIX calling convention */ + +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +/* Available registers: r0, r11, r12. */ +/* However, r0 is special in that it cannot be used as a base register. */ + + .globl tramp_r + .globl .tramp_r +.csect tramp_r[DS] +tramp_r: + .long .tramp_r, 0, 0 +.csect .text[PR] +.tramp_r: +/* Move into register r11 */ + lwz 11,0(2) /* get */ +/* Get */ + lwz 12,4(2) +/* + * gcc-2.6.3 source says: + * A function pointer is a pointer to a data area whose first word contains + * the actual address of the function, whose second word contains a pointer + * to its TOC, and whose third word contains a value to place in the static + * chain register (r11). But we have already placed our information in r11. + */ +/* lwz 11,8(12) pass static chain in r11 */ + lwz 2,4(12) /* pass TOC in r2 */ + lwz 0,0(12) /* actual code address */ + mtctr 0 + bctr + +_section_.text: +.csect .data[RW] + .long _section_.text diff --git a/callback/trampoline_r/tramp-powerpc64-aix.S b/callback/trampoline_r/tramp-powerpc64-aix.S new file mode 100644 index 0000000..2221dda --- /dev/null +++ b/callback/trampoline_r/tramp-powerpc64-aix.S @@ -0,0 +1,55 @@ +/* Trampoline for powerpc64 CPU with AIX calling convention */ + +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +/* Available registers: r0, r11, r12. */ +/* However, r0 is special in that it cannot be used as a base register. */ + + .machine "ppc64" + +#ifdef _AIX + .rename H.4.NO_SYMBOL{PR},"" + .lglobl H.4.NO_SYMBOL{PR} + + .globl .tramp_r + .csect H.4.NO_SYMBOL{PR},7 +#else + .globl tramp_r + .globl .tramp_r +tramp_r: + .quad .tramp_r +#endif +.tramp_r: +/* Move into register r11 */ + ld 11,0(2) /* get */ +/* Get */ + ld 12,8(2) +/* + * gcc-2.6.3 source says: + * A function pointer is a pointer to a data area whose first word contains + * the actual address of the function, whose second word contains a pointer + * to its TOC, and whose third word contains a value to place in the static + * chain register (r11). But we have already placed our information in r11. + */ +/* ld 11,16(12) pass static chain in r11 */ + ld 2,8(12) /* pass TOC in r2 */ + ld 0,0(12) /* actual code address */ + mtctr 0 + bctr + +#include "noexecstack.h" diff --git a/callback/trampoline_r/trampoline.c b/callback/trampoline_r/trampoline.c new file mode 100644 index 0000000..175eb42 --- /dev/null +++ b/callback/trampoline_r/trampoline.c @@ -0,0 +1,1505 @@ +/* Trampoline construction */ + +/* + * Copyright 1995-2019 Bruno Haible + * + * 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, see . + */ + + +#include "config.h" +#include "trampoline_r.h" + +#if defined(__hppa__) && !defined(__hppa64__) +#if 0 +#define __hppaold__ /* Old trampoline, real machine code. */ +#else +#define __hppanew__ /* New trampoline, just a closure. */ +#endif +#endif +#if defined(__hppa64__) +#if 0 +#define __hppa64old__ /* Old trampoline, real machine code. */ +#else +#define __hppa64new__ /* New trampoline, just a closure. */ +#endif +#endif +#if defined(__powerpc__) && !defined(__powerpc64__) +#if !defined(_AIX) +#define __powerpcsysv4__ /* SysV.4 ABI, real machine code. */ +#else +#define __powerpcaix__ /* AIX ABI, just a closure. */ +#endif +#endif +#if defined(__powerpc64__) && !defined(__powerpc64_elfv2__) +#define __powerpc64aix__ /* AIX ABI, just a closure. */ +#endif +#if defined(__hppanew__) || defined(__hppa64new__) +/* + * A function pointer is a biased pointer to a data area whose first word + * (hppa) or third word (hppa64) contains the actual address of the function. + */ +extern void tramp_r (); /* trampoline prototype */ +/* We don't need to take any special measures to make the code executable + * since the actual instructions are in the text segment. + */ +#ifndef CODE_EXECUTABLE +#define CODE_EXECUTABLE +#endif +#endif +#if defined(__powerpcaix__) || defined(__powerpc64aix__) || defined(__ia64__) +/* + * A function pointer is a pointer to a data area whose first word contains + * the actual address of the function. + */ +extern void (*tramp_r) (); /* trampoline prototype */ +/* We don't need to take any special measures to make the code executable + * since the actual instructions are in the text segment. + */ +#ifndef CODE_EXECUTABLE +#define CODE_EXECUTABLE +#endif +#endif + +#ifndef CODE_EXECUTABLE + /* How do we make the trampoline's code executable? */ + #if defined(HAVE_MACH_VM) || defined(HAVE_WORKING_MPROTECT) + #if HAVE_MPROTECT_AFTER_MALLOC_CAN_EXEC > 0 + /* mprotect() [or equivalent] the malloc'ed area. */ + #define EXECUTABLE_VIA_MALLOC_THEN_MPROTECT + #elif HAVE_MPROTECT_AFTER_MMAP_CAN_EXEC > 0 + /* mprotect() [or equivalent] the mmap'ed area. */ + #define EXECUTABLE_VIA_MMAP_THEN_MPROTECT + #elif defined(HAVE_MMAP_SHARED_CAN_EXEC) + #define EXECUTABLE_VIA_MMAP_FILE_SHARED + #else + #error "Don't know how to make memory pages executable." + #endif + #else + #ifdef HAVE_MMAP + /* Use an mmap'ed page. */ + #define EXECUTABLE_VIA_MMAP + #else + #ifdef HAVE_SHM + /* Use an shmat'ed page. */ + #define EXECUTABLE_VIA_SHM + #else + #if defined(_WIN32) && ! defined(__CYGWIN__) /* native Windows */ + #define EXECUTABLE_VIA_VIRTUALALLOC + #else + ?? + #endif + #endif + #endif + #endif +#endif + +#include /* declares fprintf() */ + +#include +#include /* declares abort(), malloc(), free() */ +#ifdef HAVE_UNISTD_H +#include +#endif + +/* Define intptr_t, uintptr_t. */ +#include + +/* Declare getpagesize(). */ +#ifdef HAVE_GETPAGESIZE +#ifdef __cplusplus +extern "C" RETGETPAGESIZETYPE getpagesize (void); +#else +extern RETGETPAGESIZETYPE getpagesize (void); +#endif +#else +#ifdef HAVE_SYS_PARAM_H +#include +#else +/* Not Unix, e.g. mingw32 */ +#define PAGESIZE 4096 +#endif +#define getpagesize() PAGESIZE +#endif + +/* Declare mprotect() or equivalent. */ +#if defined(EXECUTABLE_VIA_MALLOC_THEN_MPROTECT) || defined(EXECUTABLE_VIA_MMAP_THEN_MPROTECT) +#ifdef HAVE_MACH_VM +#include +#include +#ifdef __osf__ +#include +#endif +#include +#else +#include +#include +#endif +#endif + +/* Declare mmap(). */ +#if defined(EXECUTABLE_VIA_MMAP) || defined(EXECUTABLE_VIA_MMAP_FILE_SHARED) +#include +#include +#if !defined(PROT_EXEC) && defined(PROT_EXECUTE) /* Irix 4.0.5 needs this */ +#define PROT_EXEC PROT_EXECUTE +#endif +#endif + +/* Declare open(). */ +#if defined(EXECUTABLE_VIA_MMAP_DEVZERO) || defined(EXECUTABLE_VIA_MMAP_FILE_SHARED) +#include +#include +#include +#endif + +/* Declare shmget(), shmat(), shmctl(). */ +#ifdef EXECUTABLE_VIA_SHM +#include +#include +#include +#ifdef HAVE_SYS_SYSMACROS_H +#include +#endif +#endif + +/* Declare VirtualAlloc(), GetSystemInfo. */ +#ifdef EXECUTABLE_VIA_VIRTUALALLOC +#define WIN32_LEAN_AND_MEAN +#define WIN32_EXTRA_LEAN +#include +#endif + +/* Some old mmap() implementations require the flag MAP_FILE whenever you pass + an fd >= 0. */ +#ifndef MAP_FILE +#define MAP_FILE 0 +#endif +/* Some old mmap() implementations require the flag MAP_VARIABLE whenever you + pass an addr == NULL. */ +#ifndef MAP_VARIABLE +#define MAP_VARIABLE 0 +#endif + +/* Support for instruction cache flush. */ +#ifdef __i386__ +#if defined(_WIN32) && ! defined(__CYGWIN__) /* native Windows */ +#define WIN32_LEAN_AND_MEAN +#define WIN32_EXTRA_LEAN +#include +#endif +#endif +#if defined(__mips__) || defined(__mipsn32__) || defined(__mips64__) || defined(__riscv32__) || defined(__riscv64__) +#ifdef HAVE_SYS_CACHECTL_H /* IRIX, Linux */ +#include +#else +#ifdef __OpenBSD__ +#include +#endif +#endif +#endif +/* Inline assembly function for instruction cache flush. */ +#if defined(__sparc__) || defined(__sparc64__) || defined(__alpha__) || defined(__hppaold__) || defined(__hppa64old__) || defined(__powerpcsysv4__) || defined(__powerpc64_elfv2__) +#if defined(__sparc__) || defined(__sparc64__) +extern void __TR_clear_cache_2(); +#else +extern void __TR_clear_cache(); +#endif +#endif + +/* Support for multithread-safe coding. */ +#include "glthread/lock.h" + +#if !defined(CODE_EXECUTABLE) && defined(EXECUTABLE_VIA_MMAP_FILE_SHARED) +/* Opens a file descriptor and attempts to make it non-inheritable. */ +static int open_noinherit (const char *filename, int flags, int mode) +{ +# if O_CLOEXEC + return open (filename, flags | O_CLOEXEC, mode); +# else + int fd = open (filename, flags, mode); +# ifdef F_SETFD + if (fd >= 0) + { + int flags = fcntl (fd, F_GETFD, 0); + if (flags >= 0) + fcntl (fd, F_SETFD, flags | FD_CLOEXEC); + } +# endif + return fd; +# endif +} +#endif + +/* Length and alignment of trampoline */ +#ifdef __i386__ +#define TRAMP_LENGTH 12 +#define TRAMP_ALIGN 16 /* 4 for a i386, 16 for a i486 */ +#endif +#ifdef __m68k__ +#define TRAMP_LENGTH 14 +#define TRAMP_ALIGN 16 +#endif +#if (defined(__mips__) || defined(__mipsn32__)) && !defined(__mips64__) +#define TRAMP_LENGTH 24 +#define TRAMP_ALIGN 4 +#endif +#ifdef __mips64old__ +#define TRAMP_LENGTH 56 +#define TRAMP_ALIGN 4 +#endif +#ifdef __mips64__ +#define TRAMP_LENGTH 32 +#define TRAMP_ALIGN 8 +#endif +#if defined(__sparc__) && !defined(__sparc64__) +#define TRAMP_LENGTH 16 +#define TRAMP_ALIGN 16 +#endif +#ifdef __sparc64__ +#define TRAMP_LENGTH 32 +#define TRAMP_ALIGN 16 +#endif +#ifdef __alpha__ +#define TRAMP_LENGTH 32 +#define TRAMP_ALIGN 8 +#endif +#ifdef __hppaold__ +#define TRAMP_LENGTH 48 +#define TRAMP_ALIGN 16 +#endif +#ifdef __hppanew__ +#define TRAMP_LENGTH 16 +#define TRAMP_ALIGN 16 +#define TRAMP_BIAS 2 +#endif +#ifdef __hppa64old__ +#define TRAMP_LENGTH 80 +#define TRAMP_ALIGN 8 +#define TRAMP_BIAS 48 +#endif +#ifdef __hppa64new__ +#define TRAMP_LENGTH 48 +#define TRAMP_ALIGN 8 +#endif +#if defined(__arm__) || defined(__armhf__) +#define TRAMP_LENGTH 48 +#define TRAMP_ALIGN 4 +#endif +#ifdef __arm64__ +#define TRAMP_LENGTH 32 +#define TRAMP_ALIGN 8 +#endif +#ifdef __powerpcsysv4__ +#define TRAMP_LENGTH 24 +#define TRAMP_ALIGN 4 +#endif +#ifdef __powerpcaix__ +#define TRAMP_LENGTH 20 +#define TRAMP_ALIGN 4 +#endif +#ifdef __powerpc64_elfv2__ +#define TRAMP_LENGTH 32 +#define TRAMP_ALIGN 8 +#endif +#ifdef __powerpc64aix__ +#define TRAMP_LENGTH 40 +#define TRAMP_ALIGN 8 +#endif +#ifdef __ia64__ +#define TRAMP_LENGTH 32 +#define TRAMP_ALIGN 16 +#endif +#ifdef __x86_64__ +#ifdef __x86_64_x32__ +#define TRAMP_LENGTH 13 +#define TRAMP_ALIGN 4 +#else +#define TRAMP_LENGTH 22 +#define TRAMP_ALIGN 16 +#endif +#endif +#if defined(__s390__) && !defined(__s390x__) +#define TRAMP_LENGTH 20 +#define TRAMP_ALIGN 4 +#endif +#ifdef __s390x__ +#define TRAMP_LENGTH 32 +#define TRAMP_ALIGN 8 +#endif +#ifdef __riscv32__ +#define TRAMP_LENGTH 24 +#define TRAMP_ALIGN 4 +#endif +#ifdef __riscv64__ +#define TRAMP_LENGTH 32 +#define TRAMP_ALIGN 8 +#endif + +#ifndef TRAMP_BIAS +#define TRAMP_BIAS 0 +#endif + +#define TRAMP_TOTAL_LENGTH (TRAMP_LENGTH + 2*sizeof(void*)) + +#if !defined(CODE_EXECUTABLE) +static long pagesize = 0; +#endif + +#if !defined(CODE_EXECUTABLE) && (defined(EXECUTABLE_VIA_MMAP_DEVZERO) || defined(EXECUTABLE_VIA_MMAP_FILE_SHARED)) + +/* Variables needed for obtaining memory pages via mmap(). */ +#if defined(EXECUTABLE_VIA_MMAP_DEVZERO) +static int zero_fd; +#endif +#if defined(EXECUTABLE_VIA_MMAP_FILE_SHARED) +static int file_fd; +static long file_length; +#endif + +/* Initialization of these variables. */ +static void for_mmap_init (void) +{ +#if defined(EXECUTABLE_VIA_MMAP_DEVZERO) + zero_fd = open("/dev/zero",O_RDONLY,0644); + if (zero_fd < 0) + { fprintf(stderr,"trampoline: Cannot open /dev/zero!\n"); abort(); } +#endif +#if defined(EXECUTABLE_VIA_MMAP_FILE_SHARED) + { + char filename[100]; + sprintf(filename, "%s/trampdata-%d-%ld", "/tmp", getpid (), random ()); + file_fd = open_noinherit (filename, O_CREAT | O_RDWR | O_TRUNC, 0700); + if (file_fd < 0) + { fprintf(stderr,"trampoline: Cannot open %s!\n",filename); abort(); } + /* Remove the file from the file system as soon as possible, to make + sure there is no leftover after this process terminates or crashes. */ + unlink(filename); + } + file_length = 0; +#endif +} + +/* Once-only initializer for these variables. */ +gl_once_define(static, for_mmap_once) + +#endif + +#if !defined(CODE_EXECUTABLE) && !defined(EXECUTABLE_VIA_MALLOC_THEN_MPROTECT) +/* AIX doesn't support mprotect() in malloc'ed memory. Must get pages of + * memory with execute permission via mmap(). Then keep a free list of + * free trampolines. + */ +static char* freelist = NULL; +/* Lock that protects the freelist from simultaneous access from multiple + threads. */ +gl_lock_define_initialized(static, freelist_lock) +#endif + +__TR_function alloc_trampoline_r (__TR_function address, void* data0, void* data1) +{ + char* function; + char* function_x; + char* data; + +#if !defined(CODE_EXECUTABLE) + /* First, get the page size once and for all. */ + if (!pagesize) + { + /* Simultaneous execution of this initialization in multiple threads + is OK. */ +#if defined(EXECUTABLE_VIA_VIRTUALALLOC) + /* GetSystemInfo + + */ + SYSTEM_INFO info; + GetSystemInfo(&info); + pagesize = info.dwPageSize; +#elif defined(HAVE_MACH_VM) + pagesize = vm_page_size; +#else + pagesize = getpagesize(); +#endif +#if defined(EXECUTABLE_VIA_MMAP_DEVZERO) || defined(EXECUTABLE_VIA_MMAP_FILE_SHARED) + /* Use a once-only initializer here, since simultaneous execution of + for_mmap_init() in multiple threads must be avoided. */ + gl_once (for_mmap_once, for_mmap_init); +#endif + } +#endif + + /* 1. Allocate room */ + +#if !defined(CODE_EXECUTABLE) && !defined(EXECUTABLE_VIA_MALLOC_THEN_MPROTECT) + gl_lock_lock(freelist_lock); + if (freelist == NULL) + { /* Get a new page. */ + char* page; + char* page_end; +#ifdef EXECUTABLE_VIA_VIRTUALALLOC + /* VirtualAlloc + + */ + page = VirtualAlloc(NULL,pagesize,MEM_COMMIT,PAGE_EXECUTE_READWRITE); + if (page == NULL) + { fprintf(stderr,"trampoline: Out of virtual memory!\n"); abort(); } + page_end = page + pagesize; +#else +#ifdef EXECUTABLE_VIA_MMAP_FILE_SHARED + char* page_x; + /* Extend the file by one page. */ + long new_file_length = file_length + pagesize; + if (ftruncate(file_fd,new_file_length) < 0) + { fprintf(stderr,"trampoline: Cannot extend backing file!\n"); abort(); } + /* Create separate mappings for writing and for executing. */ + page = (char*)mmap(NULL,pagesize,PROT_READ|PROT_WRITE,MAP_SHARED,file_fd,file_length); + page_x = (char*)mmap(NULL,pagesize,PROT_READ|PROT_EXEC,MAP_SHARED,file_fd,file_length); + if (page == (char*)(-1) || page_x == (char*)(-1)) + { fprintf(stderr,"trampoline: Out of virtual memory!\n"); abort(); } + file_length = new_file_length; + page_end = page + pagesize; + /* Link the two pages together. */ + ((intptr_t*)page)[0] = page_x - page; + page = (char*)(((uintptr_t)page + sizeof(intptr_t) + TRAMP_ALIGN-1) & -TRAMP_ALIGN); +#else +#ifdef EXECUTABLE_VIA_MMAP_THEN_MPROTECT +#ifdef HAVE_MMAP_ANONYMOUS + /* Use mmap with the MAP_ANONYMOUS or MAP_ANON flag. */ + page = mmap(NULL, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_VARIABLE, -1, 0); +#else + /* Use mmap on /dev/zero. */ + page = mmap(NULL, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FILE | MAP_VARIABLE, zero_fd, 0); +#endif +#endif +#ifdef EXECUTABLE_VIA_MMAP +#ifdef HAVE_MMAP_ANONYMOUS + /* Use mmap with the MAP_ANONYMOUS or MAP_ANON flag. */ + page = mmap(NULL, pagesize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS | MAP_VARIABLE, -1, 0); +#else + /* Use mmap on /dev/zero. */ + page = mmap(NULL, pagesize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_FILE | MAP_VARIABLE, zero_fd, 0); +#endif +#endif +#ifdef EXECUTABLE_VIA_SHM + int shmid = shmget(IPC_PRIVATE, pagesize, 0700|IPC_CREAT); + if (shmid<0) + { page = (char*)(-1); } + else + { page = shmat(shmid, 0, 0); shmctl(shmid, IPC_RMID, 0); } +#endif + if (page == (char*)(-1)) + { fprintf(stderr,"trampoline: Out of virtual memory!\n"); abort(); } + page_end = page + pagesize; +#endif +#endif + /* Fill it with free trampolines. */ + { char** last = &freelist; + while (page+TRAMP_TOTAL_LENGTH <= page_end) + { *last = page; last = (char**)page; + page = (char*)(((uintptr_t)page + TRAMP_TOTAL_LENGTH + TRAMP_ALIGN-1) & -TRAMP_ALIGN); + } + *last = NULL; + } } + function = freelist; freelist = *(char**)freelist; + gl_lock_unlock(freelist_lock); +#else + { char* room = (char*) malloc(sizeof(void*) + TRAMP_TOTAL_LENGTH + TRAMP_ALIGN-1); + if (!room) + { fprintf(stderr,"trampoline: Out of virtual memory!\n"); abort(); } + function = (char*)(((uintptr_t)room + sizeof(void*) + TRAMP_ALIGN-1) & -TRAMP_ALIGN); + ((char**)function)[-1] = room; /* backpointer for free_trampoline() */ + } +#endif + +#if !defined(CODE_EXECUTABLE) && defined(EXECUTABLE_VIA_MMAP_FILE_SHARED) + /* Find the executable address corresponding to the writable address. */ + { uintptr_t page = (uintptr_t) function & -(intptr_t)pagesize; + function_x = function + ((intptr_t*)page)[0]; + } +#else + function_x = function; +#endif + + /* 2. Fill out the trampoline */ + data = function + TRAMP_LENGTH; + /* Knowing that data = function + TRAMP_LENGTH, we could certainly optimize + * the trampolines a little bit more, using PC relative addressing modes. + * But I doubt it's really worth it. + */ +#ifdef __i386__ + /* function: + * movl $,%ecx B9 + * jmp
E9
- + * here: + * nop 90 + * nop 90 + */ + *(char *) (function + 0) = 0xB9; + *(long *) (function + 1) = (long) data; + *(char *) (function + 5) = 0xE9; + *(long *) (function + 6) = (long) address - (long) (function_x + 10); + *(short *) (function +10) = 0x9090; /* nop nop, for alignment */ +#define is_tramp(function) \ + *(unsigned char *) (function + 0) == 0xB9 && \ + *(unsigned char *) (function + 5) == 0xE9 +#define tramp_address(function) \ + *(long *) (function + 6) + (long) (function + 10) +#define tramp_data(function) \ + *(long *) (function + 1) +#endif +#ifdef __m68k__ + /* function: + * movel #,a0 20 7C + * jmp
4E F9
+ * nop 4E 71 + */ + *(short *) (function + 0) = 0x207C; + *(long *) (function + 2) = (long) data; + *(short *) (function + 6) = 0x4EF9; + *(long *) (function + 8) = (long) address; + *(short *) (function +12) = 0x4E71; +#define is_tramp(function) \ + *(unsigned short *) (function + 0) == 0x207C && \ + *(unsigned short *) (function + 6) == 0x4EF9 && \ + *(unsigned short *) (function +12) == 0x4E71 +#define tramp_address(function) \ + *(long *) (function + 8) +#define tramp_data(function) \ + *(long *) (function + 2) +#endif +#if (defined(__mips__) || defined(__mipsn32__)) && !defined(__mips64__) + /* function: + * lw $2,16($25) 8F 22 00 10 + * lw $25,20($25) 8F 39 00 14 + * j $25 03 20 00 08 + * nop 00 00 00 00 + * .word + * .word
+ */ + *(unsigned int *) (function + 0) = 0x8F220010; + *(unsigned int *) (function + 4) = 0x8F390014; + *(unsigned int *) (function + 8) = 0x03200008; + *(unsigned int *) (function +12) = 0x00000000; + *(unsigned int *) (function +16) = (unsigned int) data; + *(unsigned int *) (function +20) = (unsigned int) address; +#define TRAMP_CODE_LENGTH 16 +#define is_tramp(function) \ + *(unsigned int *) (function + 0) == 0x8F220010 && \ + *(unsigned int *) (function + 4) == 0x8F390014 && \ + *(unsigned int *) (function + 8) == 0x03200008 && \ + *(unsigned int *) (function +12) == 0x00000000 +#define tramp_address(function) \ + *(unsigned int *) (function +20) +#define tramp_data(function) \ + *(unsigned int *) (function +16) +#endif +#ifdef __mips64old__ + /* function: + * dli $2, 3C 02 hi16(hi32()) + * 34 42 lo16(hi32()) + * 00 02 14 38 + * 34 42 hi16(lo32()) + * 00 02 14 38 + * 34 42 lo16(lo32()) + * dli $25,
3C 19 hi16(hi32(
)) + * 37 39 lo16(hi32(
)) + * 00 19 CC 38 + * 37 39 hi16(lo32(
)) + * 00 19 CC 38 + * 37 39 lo16(lo32(
)) + * j $25 03 20 00 08 + * nop 00 00 00 00 + */ + /* What about big endian / little endian ?? */ + *(short *) (function + 0) = 0x3C02; + *(short *) (function + 2) = (unsigned long) data >> 48; + *(short *) (function + 4) = 0x3442; + *(short *) (function + 6) = ((unsigned long) data >> 32) & 0xffff; + *(int *) (function + 8) = 0x00021438; + *(short *) (function +12) = 0x3442; + *(short *) (function +14) = ((unsigned long) data >> 16) & 0xffff; + *(int *) (function +16) = 0x00021438; + *(short *) (function +20) = 0x3442; + *(short *) (function +22) = (unsigned long) data & 0xffff; + *(short *) (function +24) = 0x3C19; + *(short *) (function +26) = (unsigned long) address >> 48; + *(short *) (function +28) = 0x3739; + *(short *) (function +30) = ((unsigned long) address >> 32) & 0xffff; + *(int *) (function +32) = 0x0019CC38; + *(short *) (function +36) = 0x3739; + *(short *) (function +38) = ((unsigned long) address >> 16) & 0xffff; + *(int *) (function +40) = 0x0019CC38; + *(short *) (function +44) = 0x3739; + *(short *) (function +46) = (unsigned long) address & 0xffff; + *(int *) (function +48) = 0x03200008; + *(int *) (function +52) = 0x00000000; +#define is_tramp(function) \ + *(unsigned short *) (function + 0) == 0x3C02 && \ + *(unsigned short *) (function + 4) == 0x3442 && \ + *(unsigned int *) (function + 8) == 0x00021438 && \ + *(unsigned short *) (function +12) == 0x3442 && \ + *(unsigned int *) (function +16) == 0x00021438 && \ + *(unsigned short *) (function +20) == 0x3442 && \ + *(unsigned short *) (function +24) == 0x3C19 && \ + *(unsigned short *) (function +28) == 0x3739 && \ + *(unsigned int *) (function +32) == 0x0019CC38 && \ + *(unsigned short *) (function +36) == 0x3739 && \ + *(unsigned int *) (function +40) == 0x0019CC38 && \ + *(unsigned short *) (function +44) == 0x3739 && \ + *(unsigned int *) (function +48) == 0x03200008 && \ + *(unsigned int *) (function +52) == 0x00000000 +#define hilo(word3,word2,word1,word0) \ + (((unsigned long) (word3) << 48) | ((unsigned long) (word2) << 32) | \ + ((unsigned long) (word1) << 16) | (unsigned long) (word0)) +#define tramp_address(function) \ + hilo(*(unsigned short *) (function +26), \ + *(unsigned short *) (function +30), \ + *(unsigned short *) (function +38), \ + *(unsigned short *) (function +46)) +#define tramp_data(function) \ + hilo(*(unsigned short *) (function + 2), \ + *(unsigned short *) (function + 6), \ + *(unsigned short *) (function +14), \ + *(unsigned short *) (function +22)) +#endif +#ifdef __mips64__ + /* function: + * ld $2,16($25) DF 22 00 10 + * ld $25,24($25) DF 39 00 18 + * j $25 03 20 00 08 + * nop 00 00 00 00 + * .dword + * .dword
+ */ + *(unsigned int *) (function + 0) = 0xDF220010; + *(unsigned int *) (function + 4) = 0xDF390018; + *(unsigned int *) (function + 8) = 0x03200008; + *(unsigned int *) (function +12) = 0x00000000; + *(unsigned long *) (function +16) = (unsigned long) data; + *(unsigned long *) (function +24) = (unsigned long) address; +#define TRAMP_CODE_LENGTH 16 +#define is_tramp(function) \ + *(unsigned int *) (function + 0) == 0xDF220010 && \ + *(unsigned int *) (function + 4) == 0xDF390018 && \ + *(unsigned int *) (function + 8) == 0x03200008 && \ + *(unsigned int *) (function +12) == 0x00000000 +#define tramp_address(function) \ + *(unsigned long *) (function +24) +#define tramp_data(function) \ + *(unsigned long *) (function +16) +#endif +#if defined(__sparc__) && !defined(__sparc64__) + /* function: + * sethi %hi(),%g2 05000000 | ( >> 10) + * sethi %hi(
),%g1 03000000 | (
>> 10) + * jmp %g1+%lo(
) 81C06000 | (
& 0x3ff) + * or %g2,%lo(),%g2 8410A000 | ( & 0x3ff) + */ +#define hi(word) ((unsigned long) (word) >> 10) +#define lo(word) ((unsigned long) (word) & 0x3ff) + *(long *) (function + 0) = 0x05000000 | hi(data); + *(long *) (function + 4) = 0x03000000 | hi(address); + *(long *) (function + 8) = 0x81C06000 | lo(address); + *(long *) (function +12) = 0x8410A000 | lo(data); +#define is_tramp(function) \ + (*(long *) (function + 0) & 0xffc00000) == 0x05000000 && \ + (*(long *) (function + 4) & 0xffc00000) == 0x03000000 && \ + (*(long *) (function + 8) & 0xfffffc00) == 0x81C06000 && \ + (*(long *) (function +12) & 0xfffffc00) == 0x8410A000 +#define hilo(hiword,loword) (((hiword) << 10) | ((loword) & 0x3ff)) +#define tramp_address(function) \ + hilo(*(long *) (function + 4), *(long *) (function + 8)) +#define tramp_data(function) \ + hilo(*(long *) (function + 0), *(long *) (function +12)) +#endif +#ifdef __sparc64__ + /* function: + * rd %pc,%g1 83414000 + * ldx [%g1+24],%g2 C4586018 + * jmp %g2 81C08000 + * ldx [%g1+16],%g5 CA586010 + * .long high32() >> 32 + * .long low32() & 0xffffffff + * .long high32(
)
>> 32 + * .long low32(
)
& 0xffffffff + */ + *(int *) (function + 0) = 0x83414000; + *(int *) (function + 4) = 0xC4586018; + *(int *) (function + 8) = 0x81C08000; + *(int *) (function +12) = 0xCA586010; + *(long *) (function +16) = (long) data; + *(long *) (function +24) = (long) address; +#define TRAMP_CODE_LENGTH 16 +#define is_tramp(function) \ + *(int *) (function + 0) == 0x83414000 && \ + *(int *) (function + 4) == 0xC4586018 && \ + *(int *) (function + 8) == 0x81C08000 && \ + *(int *) (function +12) == 0xCA586010 +#define tramp_address(function) \ + *(long *) (function +24) +#define tramp_data(function) \ + *(long *) (function +16) +#endif +#ifdef __alpha__ + /* function: + * br $1,function..ng 00 00 20 C0 + * function..ng: + * ldq $27,20($1) 14 00 61 A7 + * ldq $1,12($1) 0C 00 21 A4 + * jmp $31,($27),0 00 00 FB 6B + * .quad + * .quad
+ */ + { static int code [4] = + { 0xC0200000, 0xA7610014, 0xA421000C, 0x6BFB0000 }; + int i; + for (i=0; i<4; i++) { ((int *) function)[i] = code[i]; } + ((long *) function)[2] = (long) data; + ((long *) function)[3] = (long) address; + } +#define TRAMP_CODE_LENGTH 16 +#define is_tramp(function) \ + ((int *) function)[0] == 0xC0200000 && \ + ((int *) function)[1] == 0xA7610014 && \ + ((int *) function)[2] == 0xA421000C && \ + ((int *) function)[3] == 0x6BFB0000 +#define tramp_address(function) \ + ((long *) function)[3] +#define tramp_data(function) \ + ((long *) function)[2] +#endif +#ifdef __hppaold__ + /* function: + * ldil L',%r29 23A00000 | hi() + * ldil L'
,%r21 22A00000 | hi(
) + * ldo R'(%r29),%r29 37BD0000 | lo() + * ldo R'
(%r21),%r21 36B50000 | lo(
) + * bb,>=,n %r21,30,function2 C7D5C012 + * depi 0,31,2,%r21 D6A01C1E + * ldw 4(0,%r21),%r19 4AB30008 + * ldw 0(0,%r21),%r21 4AB50000 + * function2: + * ldsid (0,%r21),%r1 02A010A1 + * mtsp %r1,%sr0 00011820 + * be,n 0(%sr0,%r21) E2A00002 + * nop 08000240 + */ + /* When decoding a 21-bit argument in an instruction, the hppa performs + * the following bit manipulation: + * assemble21: x[20]...x[0] + * --> x[0] x[11]...x[1] x[15]..x[14] x[20]...x[16] x[13]..x[12] + * When encoding a 21-bit argument into an instruction, we need the + * to perform the reverse permutation: + * permute21: y[20]...y[0] + * --> y[6]...y[2] y[8]..y[7] y[1]..y[0] y[19]...y[9] y[20] + */ +#define assemble21(x) \ + ((((x) & 0x1) << 20) | (((x) & 0xFFE) << 8) | \ + (((x) & 0xC000) >> 7) | (((x) & 0x1F0000) >> 14) | (((x) & 0x3000) >> 12)) +#define permute21(y) \ + ((((y) & 0x7C) << 14) | (((y) & 0x180) << 7) | (((y) & 0x3) << 12) | \ + (((y) & 0xFFE00) >> 8) | (((y) & 0x100000) >> 20)) +#define hi(word) permute21((unsigned long) (word) >> 11) +#define lo(word) (((unsigned long) (word) & 0x7FF) << 1) + *(long *) (function + 0) = 0x23A00000 | hi(data); + *(long *) (function + 4) = 0x22A00000 | hi(address); + *(long *) (function + 8) = 0x37BD0000 | lo(data); + *(long *) (function +12) = 0x36B50000 | lo(address); + *(long *) (function +16) = 0xC7D5C012; + *(long *) (function +20) = 0xD6A01C1E; + *(long *) (function +24) = 0x4AB30008; + *(long *) (function +28) = 0x4AB50000; + *(long *) (function +32) = 0x02A010A1; + *(long *) (function +36) = 0x00011820; + *(long *) (function +40) = 0xE2A00002; + *(long *) (function +44) = 0x08000240; +#define is_tramp(function) \ + ((long) function & 3) == 0 && \ + (*(long *) (function + 0) & 0xffe00000) == 0x23A00000 && \ + (*(long *) (function + 4) & 0xffe00000) == 0x22A00000 && \ + (*(long *) (function + 8) & 0xfffff000) == 0x37BD0000 && \ + (*(long *) (function +12) & 0xfffff000) == 0x36B50000 && \ + *(long *) (function +16) == 0xC7D5C012 && \ + *(long *) (function +20) == 0xD6A01C1E && \ + *(long *) (function +24) == 0x4AB30008 && \ + *(long *) (function +28) == 0x4AB50000 && \ + *(long *) (function +32) == 0x02A010A1 && \ + *(long *) (function +36) == 0x00011820 && \ + *(long *) (function +40) == 0xE2A00002 && \ + *(long *) (function +44) == 0x08000240 +#define hilo(hiword,loword) \ + ((assemble21((unsigned long) (hiword)) << 11) | \ + (((unsigned long) (loword) & 0xFFE) >> 1) \ + ) +#define tramp_address(function) \ + hilo(*(long *) (function + 4), *(long *) (function +12)) +#define tramp_data(function) \ + hilo(*(long *) (function + 0), *(long *) (function + 8)) +#endif +#ifdef __hppanew__ + /* function: + * .long tramp_r + * .long closure + * closure: + * .long + * .long
+ */ + { /* work around a bug in gcc 3.* */ + void* tramp_r_address = &tramp_r; + *(long *) (function + 0) = ((long *) ((char*)tramp_r_address-2))[0]; + *(long *) (function + 4) = (long) (function + 8); + *(long *) (function + 8) = (long) data; + *(long *) (function +12) = (long) address; + } +#define TRAMP_CODE_LENGTH 0 +#define is_tramp(function) \ + ((long *) function)[0] == ((long *) ((char*)tramp_r_address-2))[0] +#define tramp_address(function) \ + ((long *) function)[3] +#define tramp_data(function) \ + ((long *) function)[2] +#endif +#ifdef __hppa64old__ + /* function: + * mfia %r27 000014BB + * ldd 32(%r27),%r31 537F0040 + * ldd 40(%r27),%r27 537B0050 + * ldd 16(%r27),%r1 53610020 + * ldd 24(%r27),%r27 537B0030 + * bve (%r1) E820D000 + * nop 08000240 + * .align 8 + * .dword + * .dword
+ * function_pointer: + * .dword 0 + * .dword 0 + * .dword function + * .dword 0 + */ + *(int *) (function + 0) = 0x000014BB; + *(int *) (function + 4) = 0x537F0040; + *(int *) (function + 8) = 0x537B0050; + *(int *) (function +12) = 0x53610020; + *(int *) (function +16) = 0x537B0030; + *(int *) (function +20) = 0xE820D000; + *(int *) (function +24) = 0x08000240; + *(long *) (function +32) = (long)data; + *(long *) (function +40) = (long)address; + *(long *) (function +48) = (long)0; + *(long *) (function +56) = (long)0; + *(long *) (function +64) = (long)function; + *(long *) (function +72) = (long)0; +#define TRAMP_CODE_LENGTH 28 +#define is_tramp(function) \ + *(int *) (function + 0) == 0x000014BB && \ + *(int *) (function + 4) == 0x537F0040 && \ + *(int *) (function + 8) == 0x537B0050 && \ + *(int *) (function +12) == 0x53610020 && \ + *(int *) (function +16) == 0x537B0030 && \ + *(int *) (function +20) == 0xE820D000 && \ + *(int *) (function +24) == 0x08000240 +#define tramp_address(function) \ + (*(unsigned long *) (function +40)) +#define tramp_data(function) \ + (*(unsigned long *) (function +32)) +#endif +#ifdef __hppa64new__ + /* function: + * .dword 0 + * .dword 0 + * .dword tramp + * .dword closure + * closure: + * .dword + * .dword
+ */ + *(long *) (function + 0) = 0; + *(long *) (function + 8) = 0; + *(long *) (function +16) = ((long *) (void*) &tramp_r)[2]; + *(long *) (function +24) = (long) (function + 32); + *(long *) (function +32) = (long) data; + *(long *) (function +40) = (long) address; +#define TRAMP_CODE_LENGTH 0 +#define is_tramp(function) \ + ((long *) function)[2] == ((long *) (void*) &tramp_r)[2] && \ + ((long *) function)[3] == (long) (function + 32) +#define tramp_address(function) \ + ((long *) function)[5] +#define tramp_data(function) \ + ((long *) function)[4] +#endif +#if defined(__arm__) || defined(__armhf__) + /* function: + * mov ip,sp E1A0C00D + * stmdb sp!,{r0,r1,r2,r3} E92D000F + * stmfd sp!,{fp,ip,lr,pc} E92DD800 + * sub fp,ip,#20 E24CB014 + * sub sp,sp,#8 E24DD008 + * ldr ip,[pc,#12] E59FC00C @ Get + * str ip,[sp,#0] E58DC000 @ Put on stack + * mov lr,pc E1A0E00F @ Prepare call (put return address in lr) + * ldr pc,[pc,#4] E59FF004 @ Call
with the same args in registers + * ldmea fp,{fp,sp,pc} E91BA800 @ Restore fp and sp, and return to return address. + * _data: + * .word + * _address: + * .word
+ */ + { + ((long *) function)[0] = 0xE1A0C00D; + ((long *) function)[1] = 0xE92D000F; + ((long *) function)[2] = 0xE92DD800; + ((long *) function)[3] = 0xE24CB014; + ((long *) function)[4] = 0xE24DD008; + ((long *) function)[5] = 0xE59FC00C; + ((long *) function)[6] = 0xE58DC000; + ((long *) function)[7] = 0xE1A0E00F; + ((long *) function)[8] = 0xE59FF004; + ((long *) function)[9] = 0xE91BA800; + ((long *) function)[10] = (long) data; + ((long *) function)[11] = (long) address; + } +#define TRAMP_CODE_LENGTH 40 +#define is_tramp(function) \ + ((long *) function)[0] == 0xE1A0C00D && \ + ((long *) function)[1] == 0xE92D000F && \ + ((long *) function)[2] == 0xE92DD800 && \ + ((long *) function)[3] == 0xE24CB014 && \ + ((long *) function)[4] == 0xE24DD008 && \ + ((long *) function)[5] == 0xE59FC00C && \ + ((long *) function)[6] == 0xE58DC000 && \ + ((long *) function)[7] == 0xE1A0E00F && \ + ((long *) function)[8] == 0xE59FF004 && \ + ((long *) function)[9] == 0xE91BA800 +#define tramp_address(function) \ + ((long *) function)[11] +#define tramp_data(function) \ + ((long *) function)[10] +#endif +#ifdef __arm64__ + /* function: + * ldr x17,.+24 580000D1 + * ldr x18,.+12 58000072 + * br x17 D61F0220 + * nop D503201F + * .xword + * .xword
+ */ + *(int *) (function + 0) = 0x580000D1; + *(int *) (function + 4) = 0x58000072; + *(int *) (function + 8) = 0xD61F0220; + *(int *) (function +12) = 0xD503201F; + *(long *) (function +16) = (unsigned long) data; + *(long *) (function +24) = (unsigned long) address; +#define TRAMP_CODE_LENGTH 16 +#define is_tramp(function) \ + *(unsigned int *) (function + 0) == 0x580000D1 && \ + *(unsigned int *) (function + 4) == 0x58000072 && \ + *(unsigned int *) (function + 8) == 0xD61F0220 && \ + *(unsigned int *) (function +12) == 0xD503201F +#define tramp_address(function) \ + (*(unsigned long *) (function +24)) +#define tramp_data(function) \ + (*(unsigned long *) (function +16)) +#endif +#ifdef __powerpcsysv4__ + /* function: + * {liu|lis} 11,hi16() 3D 60 hi16() + * {oril|ori} 11,11,lo16() 61 6B lo16() + * {liu|lis} 0,hi16(
) 3C 00 hi16(
) + * {oril|ori} 0,0,lo16(
) 60 00 lo16(
) + * mtctr 0 7C 09 03 A6 + * bctr 4E 80 04 20 + */ + *(short *) (function + 0) = 0x3D60; + *(short *) (function + 2) = (unsigned long) data >> 16; + *(short *) (function + 4) = 0x616B; + *(short *) (function + 6) = (unsigned long) data & 0xffff; + *(short *) (function + 8) = 0x3C00; + *(short *) (function +10) = (unsigned long) address >> 16; + *(short *) (function +12) = 0x6000; + *(short *) (function +14) = (unsigned long) address & 0xffff; + *(long *) (function +16) = 0x7C0903A6; + *(long *) (function +20) = 0x4E800420; +#define is_tramp(function) \ + *(unsigned short *) (function + 0) == 0x3D60 && \ + *(unsigned short *) (function + 4) == 0x616B && \ + *(unsigned short *) (function + 8) == 0x3C00 && \ + *(unsigned short *) (function +12) == 0x6000 && \ + *(unsigned long *) (function +16) == 0x7C0903A6 && \ + *(unsigned long *) (function +20) == 0x4E800420 +#define hilo(hiword,loword) \ + (((unsigned long) (hiword) << 16) | (unsigned long) (loword)) +#define tramp_address(function) \ + hilo(*(unsigned short *) (function +10), *(unsigned short *) (function +14)) +#define tramp_data(function) \ + hilo(*(unsigned short *) (function + 2), *(unsigned short *) (function + 6)) +#endif +#ifdef __powerpcaix__ + /* function: + * .long .tramp_r + * .long .mytoc + * .long 0 + * .mytoc: + * .long + * .long
+ */ + *(long *) (function + 0) = ((long *) &tramp_r)[0]; + *(long *) (function + 4) = (long) (function + 12); + *(long *) (function + 8) = 0; + *(long *) (function +12) = (long) data; + *(long *) (function +16) = (long) address; +#define TRAMP_CODE_LENGTH 0 +#define is_tramp(function) \ + ((long *) function)[0] == ((long *) &tramp_r)[0] +#define tramp_address(function) \ + ((long *) function)[4] +#define tramp_data(function) \ + ((long *) function)[3] +#endif +#ifdef __powerpc64_elfv2__ + /* function: + * ld 11,16(12) 10 00 6C E9 + * ld 12,24(12) 18 00 8C E9 + * mtctr 12 A6 03 89 7D + * bctr 20 04 80 4E + * .quad + * .quad
+ */ + *(int *) (function + 0) = 0xE96C0010; + *(int *) (function + 4) = 0xE98C0018; + *(int *) (function + 8) = 0x7D8903A6; + *(int *) (function +12) = 0x4E800420; + *(long *) (function +16) = (unsigned long) data; + *(long *) (function +24) = (unsigned long) address; +#define TRAMP_CODE_LENGTH 16 +#define is_tramp(function) \ + *(unsigned int *) (function + 0) == 0xE96C0010 && \ + *(unsigned int *) (function + 4) == 0xE98C0018 && \ + *(unsigned int *) (function + 8) == 0x7D8903A6 && \ + *(unsigned int *) (function +12) == 0x4E800420 +#define tramp_address(function) \ + (*(unsigned long *) (function +24)) +#define tramp_data(function) \ + (*(unsigned long *) (function +16)) +#endif +#ifdef __powerpc64aix__ + /* function: + * .quad .tramp_r + * .quad .mytoc + * .quad 0 + * .mytoc: + * .quad + * .quad
+ */ + *(long *) (function + 0) = ((long *) &tramp_r)[0]; + *(long *) (function + 8) = (long) (function + 24); + *(long *) (function +16) = 0; + *(long *) (function +24) = (long) data; + *(long *) (function +32) = (long) address; +#define TRAMP_CODE_LENGTH 0 +#define is_tramp(function) \ + ((long *) function)[0] == ((long *) &tramp_r)[0] +#define tramp_address(function) \ + ((long *) function)[4] +#define tramp_data(function) \ + ((long *) function)[3] +#endif +#ifdef __ia64__ + /* function: + * data8 tramp_r + * data8 closure + * closure: + * data8
+ * data8 + */ + *(long *) (function + 0) = (long) &tramp_r; + *(long *) (function + 8) = (long) (function + 16); + *(long *) (function +16) = (long) address; + *(long *) (function +24) = (long) data; +#define TRAMP_CODE_LENGTH 0 +#define is_tramp(function) \ + ((long *) function)[0] == (long) &tramp_r && \ + ((long *) function)[1] == (long) (function + 16) +#define tramp_address(function) \ + ((long *) function)[2] +#define tramp_data(function) \ + ((long *) function)[3] +#endif +#ifdef __x86_64__ +#ifdef __x86_64_x32__ + /* function: + * movl $,%r10d 41 BA + * movl $
,%rax B8
+ * jmp *%rax FF E0 + */ + *(int *) (function + 0) = ((unsigned long) data << 16) | 0xBA41; + *(int *) (function + 4) = ((unsigned long) address << 24) | 0xB80000 | ((unsigned long) data >> 16); + *(int *) (function + 8) = 0xFF000000 | ((unsigned long) address >> 8); + *(int *) (function +12) = 0xE0; +#define is_tramp(function) \ + (*(unsigned long *) (function + 0) & 0x0000FFFF) == 0xBA41 && \ + (*(unsigned long *) (function + 4) & 0x00FF0000) == 0xB80000 && \ + (*(unsigned long *) (function + 8) & 0xFF000000) == 0xFF000000 && \ + *(unsigned char *) (function +12) == 0xE0 +#define tramp_address(function) \ + ((*(unsigned long *) (function + 4) >> 24) | \ + (*(unsigned long *) (function + 8) << 8)) +#define tramp_data(function) \ + ((*(unsigned long *) (function + 0) >> 16) | \ + (*(unsigned long *) (function + 4) << 16)) +#else + /* function: + * movabsq $,%r10 49 BA + * movabsq $
,%rax 48 B8
+ * jmp *%rax FF E0 + */ + *(short *) (function + 0) = 0xBA49; + *(short *) (function + 2) = (unsigned long long) data & 0xffff; + *(int *) (function + 4) = ((unsigned long long) data >> 16) & 0xffffffff; + *(short *) (function + 8) = ((unsigned long long) data >> 48) & 0xffff; + *(short *) (function +10) = 0xB848; + *(int *) (function +12) = (unsigned long long) address & 0xffffffff; + *(int *) (function +16) = ((unsigned long long) address >> 32) & 0xffffffff; + *(short *) (function +20) = 0xE0FF; +#define is_tramp(function) \ + *(unsigned short *) (function + 0) == 0xBA49 && \ + *(unsigned short *) (function +10) == 0xB848 && \ + *(unsigned short *) (function +20) == 0xE0FF +#define hilo(hiword,loword) \ + (((unsigned long long) (hiword) << 32) | (unsigned long long) (loword)) +#define himidlo(hishort,midword,loshort) \ + (((unsigned long long) (hishort) << 48) | (unsigned long long) (midword) << 16 \ + | (unsigned long long) (loshort)) +#define tramp_address(function) \ + hilo(*(unsigned int *) (function +16), *(unsigned int *) (function +12)) +#define tramp_data(function) \ + himidlo(*(unsigned short *) (function + 8), \ + *(unsigned int *) (function + 4), \ + *(unsigned short *) (function + 2)) +#endif +#endif +#if defined(__s390__) && !defined(__s390x__) + /* function: + * bras %r1,.L1 A7150002 + * .L1: + * lm %r0,%r1,data-.L1(%r1) 98011008 + * br %r1 07F1 + * nop 0707 + * data: .long + * address: .long
+ */ + *(int *) (function + 0) = 0xA7150002; + *(int *) (function + 4) = 0x98011008; + *(int *) (function + 8) = 0x07F10707; + *(int *) (function +12) = (unsigned int) data; + *(int *) (function +16) = (unsigned int) address; +#define TRAMP_CODE_LENGTH 12 +#define is_tramp(function) \ + *(unsigned int *) (function + 0) == 0xA7150002 && \ + *(unsigned int *) (function + 4) == 0x98011008 && \ + *(unsigned int *) (function + 8) == 0x07F10707 +#define tramp_address(function) \ + *(unsigned int *) (function +16) +#define tramp_data(function) \ + *(unsigned int *) (function +12) +#endif +#ifdef __s390x__ + /* function: + * larl %r1,.L1 C01000000003 + * .L1: + * lmg %r0,%r1,data-.L1(%r1) EB01100A0004 + * br %r1 07F1 + * nop 0707 + * data: .quad + * address: .quad
+ */ + *(int *) (function + 0) = 0xC0100000; + *(int *) (function + 4) = 0x0003EB01; + *(int *) (function + 8) = 0x100A0004; + *(int *) (function +12) = 0x07F10707; + *(long *) (function +16) = (unsigned long) data; + *(long *) (function +24) = (unsigned long) address; +#define TRAMP_CODE_LENGTH 16 +#define is_tramp(function) \ + *(unsigned int *) (function + 0) == 0xC0100000 && \ + *(unsigned int *) (function + 4) == 0x0003EB01 && \ + *(unsigned int *) (function + 8) == 0x100A0004 && \ + *(unsigned int *) (function +12) == 0x07F10707 +#define tramp_address(function) \ + (*(unsigned long *) (function +24)) +#define tramp_data(function) \ + (*(unsigned long *) (function +16)) +#endif +#ifdef __riscv32__ + /* function: + * auipc t0,0 00000297 + * lw t1,20(t0) 0142A303 + * lw t2,16(t0) 0102A383 + * jr t1 00030067 + * data: .quad + * address: .quad
+ */ + *(int *) (function + 0) = 0x00000297; + *(int *) (function + 4) = 0x0142A303; + *(int *) (function + 8) = 0x0102A383; + *(int *) (function +12) = 0x00030067; + *(int *) (function +16) = (unsigned int) data; + *(int *) (function +24) = (unsigned int) address; +#define TRAMP_CODE_LENGTH 16 +#define is_tramp(function) \ + *(unsigned int *) (function + 0) == 0x00000297 && \ + *(unsigned int *) (function + 4) == 0x0142A303 && \ + *(unsigned int *) (function + 8) == 0x0102A383 && \ + *(unsigned int *) (function +12) == 0x00030067 +#define tramp_address(function) \ + (*(unsigned int *) (function +20)) +#define tramp_data(function) \ + (*(unsigned int *) (function +16)) +#endif +#ifdef __riscv64__ + /* function: + * auipc t0,0 00000297 + * ld t1,24(t0) 0182B303 + * ld t2,16(t0) 0102B383 + * jr t1 00030067 + * data: .quad + * address: .quad
+ */ + *(int *) (function + 0) = 0x00000297; + *(int *) (function + 4) = 0x0182B303; + *(int *) (function + 8) = 0x0102B383; + *(int *) (function +12) = 0x00030067; + *(long *) (function +16) = (unsigned long) data; + *(long *) (function +24) = (unsigned long) address; +#define TRAMP_CODE_LENGTH 16 +#define is_tramp(function) \ + *(unsigned int *) (function + 0) == 0x00000297 && \ + *(unsigned int *) (function + 4) == 0x0182B303 && \ + *(unsigned int *) (function + 8) == 0x0102B383 && \ + *(unsigned int *) (function +12) == 0x00030067 +#define tramp_address(function) \ + (*(unsigned long *) (function +24)) +#define tramp_data(function) \ + (*(unsigned long *) (function +16)) +#endif + /* + * data: + * + * + */ + *(void* *) (data + 0*sizeof(void*)) = data0; + *(void* *) (data + 1*sizeof(void*)) = data1; + + /* 3. Set memory protection to "executable" */ + +#if !defined(CODE_EXECUTABLE) +#if defined(EXECUTABLE_VIA_MALLOC_THEN_MPROTECT) || defined(EXECUTABLE_VIA_MMAP_THEN_MPROTECT) + /* Call mprotect on the pages that contain the range. */ + { uintptr_t start_addr = (uintptr_t) function; + uintptr_t end_addr = (uintptr_t) (function + TRAMP_LENGTH); + start_addr = start_addr & -pagesize; + end_addr = (end_addr + pagesize-1) & -pagesize; + {uintptr_t len = end_addr - start_addr; +#if defined(HAVE_MACH_VM) + if (vm_protect(task_self(),start_addr,len,0,VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE) != KERN_SUCCESS) +#else + if (mprotect((void*)start_addr, len, PROT_READ|PROT_WRITE|PROT_EXEC) < 0) +#endif + { fprintf(stderr,"trampoline: cannot make memory executable\n"); abort(); } + }} +#endif +#endif + + /* 4. Flush instruction cache */ + /* We need this because some CPUs have separate data cache and instruction + * cache. The freshly built trampoline is visible to the data cache, but not + * maybe not to the instruction cache. This is hairy. + */ + /* TRAMP_CODE_LENGTH = length of the machine instructions. */ +#ifndef TRAMP_CODE_LENGTH +#define TRAMP_CODE_LENGTH TRAMP_LENGTH +#endif +#if !(defined(__hppanew__) || defined(__hppa64new__) || defined(__powerpcaix__) || defined(__powerpc64aix__) || defined(__ia64__)) + /* Only needed if we really set up machine instructions. */ +#ifdef __i386__ +#if defined(_WIN32) + while (!FlushInstructionCache(GetCurrentProcess(),function_x,TRAMP_CODE_LENGTH)) + continue; +#endif +#endif +#ifdef __m68k__ +#if defined(__NetBSD__) && defined(__GNUC__) + { register uintptr_t _beg __asm__ ("%a1") = (uintptr_t) function_x; + register uintptr_t _len __asm__ ("%d1") = TRAMP_CODE_LENGTH; + __asm__ __volatile__ ( + "move%.l %#0x80000004,%/d0\n\t" /* CC_EXTPURGE | C_IPURGE */ + "trap #12" /* kernel call ‘cachectl’ */ + : + : "a" (_beg), "d" (_len) + : "%a0", "%a1", "%d0", "%d1" /* call-used registers */ + ); + } +#endif +#if defined(__linux__) && defined(__GNUC__) + { register uintptr_t _beg __asm__ ("%d1") = (uintptr_t) function_x; + register uintptr_t _len __asm__ ("%d4") = TRAMP_CODE_LENGTH + 32; + __asm__ __volatile__ ( + "move%.l %#123,%/d0\n\t" + "move%.l %#1,%/d2\n\t" + "move%.l %#3,%/d3\n\t" + "trap %#0" + : + : "d" (_beg), "d" (_len) + : "%d0", "%d2", "%d3" + ); + } +#endif +#if defined(AUX) && defined(__GNUC__) + /* sysm68k(105, addr, scope, cache, len) */ + __asm__ __volatile__ ( + "move%.l %1,%/sp@-\n\t" + "move%.l %#3,%/sp@-\n\t" + "move%.l %#1,%/sp@-\n\t" + "move%.l %0,%/sp@-\n\t" + "move%.l %#105,%/sp@-\n\t" + "move%.l %#0,%/sp@-\n\t" + "move%.l %#38,%/sp@-\n\t" + "trap %#0\n\t" + "add%.l %#24,%/sp" + : + : "r" (function_x), "g" ((int)TRAMP_CODE_LENGTH) + : "%d0" + ); +#endif +#endif +#if defined(__mips__) || defined(__mipsn32__) || defined(__mips64__) + cacheflush(function_x,TRAMP_CODE_LENGTH,ICACHE); + /* gforth-0.3.0 uses BCACHE instead of ICACHE. Why?? */ +#endif +#if defined(__sparc__) || defined(__sparc64__) + /* This assumes that the trampoline fits in at most two cache lines. */ + __TR_clear_cache_2(function_x,function_x+TRAMP_CODE_LENGTH-1); +#endif +#ifdef __alpha__ + __TR_clear_cache(); +#endif +#if defined(__hppa__) || defined(__hppa64__) + /* This assumes that the trampoline fits in at most two cache lines. */ + __TR_clear_cache(function_x,function_x+TRAMP_CODE_LENGTH-1); +#endif +#if defined(__arm__) || defined(__armhf__) || defined(__arm64__) + /* On ARM, cache flushing can only be done through a system call. + GCC implements it for Linux with EABI, through an "swi 0" with code + 0xf0002. For other systems, it may be an "swi 0x9f0002", + an "swi 0xf00000", or similar. */ + /* On ARM64, cache flushing is done through special instructions, + and the length of the cache lines must be determined at runtime. + See gcc/libgcc/config/aarch64/sync-cache.c. */ +#if defined(__GNUC__) + /* Use the GCC built-in. */ + __clear_cache((void*)function_x,(void*)(function_x+TRAMP_CODE_LENGTH)); +#else + #error "Don't know how to implement clear_cache on this platform." +#endif +#endif +#if defined(__powerpc__) || defined(__powerpc64__) + __TR_clear_cache(function_x); +#endif +#if defined(__riscv32__) || defined(__riscv64__) +#if defined(__linux__) + /* Use the libc function. */ + __riscv_flush_icache((void*)function_x,(void*)(function_x+TRAMP_CODE_LENGTH),0); +#elif defined(__GNUC__) + __asm__ __volatile__ ("fence.i"); +#endif +#endif +#endif + + /* 5. Return. */ + return (__TR_function) (function_x + TRAMP_BIAS); +} + +void free_trampoline_r (__TR_function function) +{ +#if TRAMP_BIAS + function = (__TR_function)((char*)function - TRAMP_BIAS); +#endif +#if !defined(CODE_EXECUTABLE) && !defined(EXECUTABLE_VIA_MALLOC_THEN_MPROTECT) +#ifdef EXECUTABLE_VIA_MMAP_FILE_SHARED + /* Find the writable address corresponding to the executable address. */ + { uintptr_t page_x = (uintptr_t) function & -(intptr_t)pagesize; + function -= ((intptr_t*)page_x)[0]; + } +#endif + *(char**)function = freelist; freelist = (char*)function; + /* It is probably not worth calling munmap() for entirely freed pages. */ +#else + free(((char**)function)[-1]); +#endif +} + +int is_trampoline_r (void* function) +{ +#if defined(is_tramp) && defined(tramp_data) +#ifdef __hppanew__ + void* tramp_r_address = &tramp_r; + if (!(((uintptr_t)function & 3) == (TRAMP_BIAS & 3))) return 0; +#endif + if (is_tramp(((char*)function - TRAMP_BIAS))) + { + char* function_w; +#ifdef EXECUTABLE_VIA_MMAP_FILE_SHARED + /* Find the writable address corresponding to the executable address. */ + { uintptr_t page_x = (uintptr_t) function & -(intptr_t)pagesize; + function_w = function - ((intptr_t*)page_x)[0]; + } +#else + function_w = function; +#endif + return (tramp_data(((char*)function - TRAMP_BIAS))) == (uintptr_t)((char*)function_w - TRAMP_BIAS + TRAMP_LENGTH); + } + return 0; +#else + abort(); +#endif +} + +__TR_function trampoline_r_address (__TR_function function) +{ +#ifdef tramp_address + return (__TR_function)(tramp_address(((char*)function - TRAMP_BIAS))); +#else + abort(); +#endif +} + +void* trampoline_r_data0 (__TR_function function) +{ +#ifdef tramp_data + return ((void**)((char*)function-TRAMP_BIAS+TRAMP_LENGTH))[0]; +#else + abort(); +#endif +} + +void* trampoline_r_data1 (__TR_function function) +{ +#ifdef tramp_data + return ((void**)((char*)function-TRAMP_BIAS+TRAMP_LENGTH))[1]; +#else + abort(); +#endif +} diff --git a/callback/trampoline_r/trampoline_r.3 b/callback/trampoline_r/trampoline_r.3 new file mode 100644 index 0000000..f58cfe6 --- /dev/null +++ b/callback/trampoline_r/trampoline_r.3 @@ -0,0 +1,120 @@ +.\" Copyright (C) 1995-2017 Bruno Haible +.\" +.\" This manual is free documentation. It is dually licensed under the +.\" GNU FDL and the GNU GPL. This means that you can redistribute this +.\" manual under either of these two licenses, at your choice. +.\" +.\" This manual is covered by the GNU FDL. Permission is granted to copy, +.\" distribute and/or modify this document under the terms of the +.\" GNU Free Documentation License (FDL), either version 1.2 of the +.\" License, or (at your option) any later version published by the +.\" Free Software Foundation (FSF); with no Invariant Sections, with no +.\" Front-Cover Text, and with no Back-Cover Texts. +.\" A copy of the license is at . +.\" +.\" This manual is covered by the GNU GPL. You can redistribute it and/or +.\" modify it under the terms of the GNU General Public License (GPL), either +.\" version 2 of the License, or (at your option) any later version published +.\" by the Free Software Foundation (FSF). +.\" A copy of the license is at . +.\" +.TH TRAMPOLINE 3 "1 January 2017" +.SH NAME +trampoline \- closures as first-class C functions +.SH SYNOPSIS +.B #include +.LP +.B function = alloc_trampoline_r(address, data0, data1); +.LP +.B free_trampoline_r(function); +.LP +.nf +.B is_trampoline_r(function) +.B trampoline_r_address(function) +.B trampoline_r_data0(function) +.B trampoline_r_data1(function) +.fi +.SH DESCRIPTION +.LP +These functions implement +.I closures +as first-class C functions. +A closure consists of a regular C function and a piece of data +which gets passed to the C function when the closure is called. + +Closures as +.I first-class C functions +means that they fit into a function +pointer and can be called exactly like any other C function. +.IB function " = alloc_trampoline_r(" address ", " data0 ", " data1 ")" +allocates a closure. When +.I function +gets called, it stores in a special "lexical chain register" a pointer to a +storage area containing +.I data0 +in its first word and +.I data1 +in its second word and calls the C function at +.IR address . +The function at +.I address +is responsible for fetching +.I data0 +and +.I data1 +off the pointer. Note that the "lexical chain register" is a call-used +register, i.e. is clobbered by function calls. + +This is much like +.BR gcc "'s" +local functions, except that the GNU C local functions have dynamic extent +(i.e. are deallocated when the creating function returns), while +.I trampoline +provides functions with indefinite extent: +.I function +is only deallocated when +.BI free_trampoline_r( function ) +is called. + +.BI "is_trampoline_r(" function ")" +checks whether the C function +.I function +was produced by a call to +.IR alloc_trampoline_r . +If this returns true, the arguments given to +.I alloc_trampoline_r +can be retrieved: +.RS 4 +.LP +.BI "trampoline_r_address(" function ")" +returns +.IR address , +.LP +.BI "trampoline_r_data0(" function ")" +returns +.IR data0 , +.LP +.BI "trampoline_r_data1(" function ")" +returns +.IR data1 . +.RE + +.SH SEE ALSO +.BR trampoline (3), +.BR gcc (1), +.BR stdarg (3) + +.SH PORTING +The way +.B gcc +builds local functions is described in the gcc source, file +.RI gcc-2.6.3/config/ cpu / cpu .h. + +.SH AUTHOR + +Bruno Haible + +.SH ACKNOWLEDGEMENTS + +Many ideas were cribbed from the gcc source. + diff --git a/callback/trampoline_r/trampoline_r.h b/callback/trampoline_r/trampoline_r.h new file mode 100644 index 0000000..42bb221 --- /dev/null +++ b/callback/trampoline_r/trampoline_r.h @@ -0,0 +1,41 @@ +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +#ifndef _TRAMPOLINE_R_H +#define _TRAMPOLINE_R_H + +/* Use a consistent prefix for all symbols in libcallback. */ +#define alloc_trampoline_r callback_trampoline_alloc +#define free_trampoline_r callback_trampoline_free +#define is_trampoline_r callback_trampoline_is +#define trampoline_r_address callback_trampoline_address +#define trampoline_r_data0 callback_trampoline_data0 +#define trampoline_r_data1 callback_trampoline_data1 + +#ifdef __cplusplus +typedef int (*__TR_function) (...); +#else +typedef int (*__TR_function) (); +#endif +extern __TR_function alloc_trampoline_r (__TR_function, void*, void*); +extern void free_trampoline_r (__TR_function); +extern int is_trampoline_r (void*); +extern __TR_function trampoline_r_address (__TR_function); +extern void* trampoline_r_data0 (__TR_function); +extern void* trampoline_r_data1 (__TR_function); + +#endif /* _TRAMPOLINE_R_H */ diff --git a/callback/trampoline_r/trampoline_r.html b/callback/trampoline_r/trampoline_r.html new file mode 100644 index 0000000..e7fb770 --- /dev/null +++ b/callback/trampoline_r/trampoline_r.html @@ -0,0 +1,135 @@ + + + + TRAMPOLINE_R manual page + + +

TRAMPOLINE_R manual page

+ + +

+ +


+ + +

Name

+
+ +trampoline_r - closures as first-class C functions + + +

Synopsis

+
+ +
+#include <trampoline_r.h>
+function = alloc_trampoline_r(address, data0, data1);
+free_trampoline_r(function);
+is_trampoline_r(function)
+trampoline_r_address(function)
+trampoline_r_data0(function)
+trampoline_r_data1(function)
+
+ + +

Description

+
+ +These functions implement closures as first-class +C functions. A closure consists of a regular C function and a +piece of data which gets passed to the C function when the +closure is called. +

+Closures as first-class C functions means that they fit +into a function pointer and can be called exactly like any +other C function. function = alloc_trampoline_r(address, data0, data1) +allocates a closure. When function gets +called, it stores in a special "lexical chain register" a +pointer to a storage area containing data0 in its first +word and data1 in its second word and calls the C function +at address. The function at address is responsible for +fetching data0 and data1 off the pointer. Note that the +"lexical chain register" is a call-used register, i.e. is +clobbered by function calls. +

+This is much like gcc's local functions, except that the +GNU C local functions have dynamic extent (i.e. are +deallocated when the creating function returns), while trampoline + provides functions with indefinite extent: function +is only deallocated when free_trampoline_r(function) is +called. +

+is_trampoline_r(function) +checks whether the C function function +was produced by a call to alloc_trampoline_r. +If this returns true, the arguments given to alloc_trampoline_r +can be retrieved: +

    +
  • trampoline_r_address(function) returns address, +
  • trampoline_r_data0(function) returns data0, +
  • trampoline_r_data1(function) returns data1. +
+ + +

See also

+
+trampoline(3), gcc(1), stdarg(3) + + +

Porting

+
+ +The way gcc builds local functions is described in the gcc +source, file gcc-2.6.3/config/cpu/cpu.h. + + +

Author

+
+ +Bruno Haible <bruno@clisp.org> + + +

Acknowledgements

+
+ +Many ideas were cribbed from the gcc source. +

+ +


+ +
TRAMPOLINE_R manual page
+Bruno Haible <bruno@clisp.org> +
+

+Last modified: 1 January 2017. + + + diff --git a/callback/trampoline_r/trampoline_r.man b/callback/trampoline_r/trampoline_r.man new file mode 100644 index 0000000..4580171 --- /dev/null +++ b/callback/trampoline_r/trampoline_r.man @@ -0,0 +1,71 @@ +TRAMPOLINE(3) Library Functions Manual TRAMPOLINE(3) + + + +NAME + trampoline - closures as first-class C functions + +SYNOPSIS + #include  + + function = alloc_trampoline_r(address, data0, data1); + + free_trampoline_r(function); + + is_trampoline_r(function) + trampoline_r_address(function) + trampoline_r_data0(function) + trampoline_r_data1(function) + +DESCRIPTION + These functions implement closures as first-class C functions. A clo‐ + sure consists of a regular C function and a piece of data which gets + passed to the C function when the closure is called. + + Closures as first-class C functions means that they fit into a function + pointer and can be called exactly like any other C function. function + = alloc_trampoline_r(address, data0, data1) allocates a closure. When + function gets called, it stores in a special "lexical chain register" a + pointer to a storage area containing data0 in its first word and data1 + in its second word and calls the C function at address. The function + at address is responsible for fetching data0 and data1 off the pointer. + Note that the "lexical chain register" is a call-used register, i.e. is + clobbered by function calls. + + This is much like gcc's local functions, except that the GNU C local + functions have dynamic extent (i.e. are deallocated when the creating + function returns), while trampoline provides functions with indefinite + extent: function is only deallocated when free_trampoline_r(function) + is called. + + is_trampoline_r(function) checks whether the C function function was + produced by a call to alloc_trampoline_r. If this returns true, the + arguments given to alloc_trampoline_r can be retrieved: + + trampoline_r_address(function) returns address, + + trampoline_r_data0(function) returns data0, + + trampoline_r_data1(function) returns data1. + + +SEE ALSO + trampoline(3), gcc(1), stdarg(3) + + +PORTING + The way gcc builds local functions is described in the gcc source, file + gcc-2.6.3/config/cpu/cpu.h. + + +AUTHOR + Bruno Haible + + +ACKNOWLEDGEMENTS + Many ideas were cribbed from the gcc source. + + + + + 1 January 2017 TRAMPOLINE(3) diff --git a/callback/vacall_r/COPYING b/callback/vacall_r/COPYING new file mode 100644 index 0000000..a3d1815 --- /dev/null +++ b/callback/vacall_r/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, 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) + + 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/callback/vacall_r/Makefile.devel b/callback/vacall_r/Makefile.devel new file mode 100644 index 0000000..6f3653d --- /dev/null +++ b/callback/vacall_r/Makefile.devel @@ -0,0 +1,229 @@ +# This is the developer's -*-Makefile-*-, not the user's makefile. +# Do not use it unless you know exactly what you do! + +THISFILE = Makefile.devel +LN = ln -s +RM = rm -f + +# ============ Rules that require cross-compilation tools ============ + +GCC = gcc +GCCFLAGS = -I../.. -I../../dummy -O2 -fno-omit-frame-pointer -fPIC -DREENTRANT +SED = sed +CROSS_TOOL = cross + +precompiled : \ + vacall-i386-macro.S \ + vacall-m68k.mit.S vacall-m68k.motorola.S \ + vacall-mipseb-macro.S vacall-mipsel-macro.S vacall-mipsn32eb-macro.S vacall-mipsn32el-macro.S vacall-mips64eb-macro.S vacall-mips64el-macro.S \ + vacall-sparc-macro.S vacall-sparc64-macro.S \ + vacall-alpha-macro.S \ + vacall-hppa-macro.S vacall-hppa64-macro.S \ + vacall-arm-macro.S vacall-armhf-macro.S \ + vacall-arm64-macro.S \ + vacall-powerpc-aix.s vacall-powerpc-linux-macro.S vacall-powerpc-sysv4-macro.S vacall-powerpc-macos.s vacall-powerpc64-aix.s vacall-powerpc64-linux.S vacall-powerpc64-elfv2-linux.S \ + vacall-ia64-macro.S \ + vacall-x86_64-macro.S vacall-x86_64-x32-linux.s vacall-x86_64-windows-macro.S \ + vacall-s390-macro.S vacall-s390x-macro.S \ + vacall-riscv32-ilp32d-macro.S vacall-riscv64-lp64d-macro.S + + +vacall-i386-linux.s : ../../vacall/vacall-i386.c ../../vacall/vacall-internal.h vacall_r.h $(THISFILE) + $(CROSS_TOOL) i386-linux gcc -V 3.1 $(GCCFLAGS) -D__i386__ -S ../../vacall/vacall-i386.c -I../../vacall -I. -o vacall-i386-linux.s + +vacall-i386-macro.S : vacall-i386-linux.s ../../common/asm-i386.sh ../../common/noexecstack.h $(THISFILE) + (echo '#include "asm-i386.h"' ; sed -e '/\.align.*,0x90$$/d' < vacall-i386-linux.s | ../../common/asm-i386.sh ; cat ../../common/noexecstack.h) > vacall-i386-macro.S + + +vacall-m68k-linux.s : ../../vacall/vacall-m68k.c ../../vacall/vacall-internal.h vacall_r.h $(THISFILE) + $(CROSS_TOOL) m68k-linux gcc -V 3.1 $(GCCFLAGS) -D__m68k__ -S ../../vacall/vacall-m68k.c -I../../vacall -I. -o vacall-m68k-linux.s + +vacall-m68k-sun.s : ../../vacall/vacall-m68k.c ../../vacall/vacall-internal.h vacall_r.h $(THISFILE) + $(CROSS_TOOL) m68k-sun gcc -V 3.1 $(GCCFLAGS) -D__m68k__ -S ../../vacall/vacall-m68k.c -I../../vacall -I. -o vacall-m68k-sun.s + +vacall-m68k.mit.S : vacall-m68k-sun.s ../../common/asm-m68k.sh ../../common/noexecstack.h $(THISFILE) + (echo '#include "asm-m68k.h"' ; ../../common/asm-m68k.sh mit < vacall-m68k-sun.s ; cat ../../common/noexecstack.h) > vacall-m68k.mit.S + +vacall-m68k.motorola.S : vacall-m68k-linux.s ../../common/asm-m68k.sh ../../common/noexecstack.h $(THISFILE) + (echo '#include "asm-m68k.h"' ; ../../common/asm-m68k.sh motorola < vacall-m68k-linux.s ; cat ../../common/noexecstack.h) > vacall-m68k.motorola.S + + +vacall-mipseb-linux.s : ../../vacall/vacall-mips.c ../../vacall/vacall-internal.h vacall_r.h $(THISFILE) +# For references to symbols: -mno-explicit-relocs ensures a syntax that the IRIX assembler understands. + $(CROSS_TOOL) mips64-linux gcc-5.4.0 -mabi=32 -mfpxx -march=mips2 -meb -mno-explicit-relocs $(GCCFLAGS) -D__mips__ -S ../../vacall/vacall-mips.c -I../../vacall -I. -o vacall-mipseb-linux.s + +vacall-mipseb-macro.S : vacall-mipseb-linux.s ../../common/asm-mips.sh $(THISFILE) + (echo '#include "asm-mips.h"' ; ../../common/asm-mips.sh < vacall-mipseb-linux.s) > vacall-mipseb-macro.S + +vacall-mipsel-linux.s : ../../vacall/vacall-mips.c ../../vacall/vacall-internal.h vacall_r.h $(THISFILE) + $(CROSS_TOOL) mips64-linux gcc-5.4.0 -mabi=32 -mfpxx -march=mips2 -mel -mno-explicit-relocs $(GCCFLAGS) -D__mips__ -S ../../vacall/vacall-mips.c -I../../vacall -I. -o vacall-mipsel-linux.s + +vacall-mipsel-macro.S : vacall-mipsel-linux.s ../../common/asm-mips.sh $(THISFILE) + (echo '#include "asm-mips.h"' ; ../../common/asm-mips.sh < vacall-mipsel-linux.s) > vacall-mipsel-macro.S + +vacall-mipsn32eb-linux.s : ../../vacall/vacall-mipsn32.c ../../vacall/vacall-internal.h vacall_r.h $(THISFILE) + $(CROSS_TOOL) mips64-linux gcc-5.4.0 -mabi=n32 -meb $(GCCFLAGS) -D__mipsn32__ -S ../../vacall/vacall-mipsn32.c -I../../vacall -I. -o vacall-mipsn32eb-linux.s + +vacall-mipsn32eb-macro.S : vacall-mipsn32eb-linux.s ../../common/asm-mips.sh $(THISFILE) + (echo '#include "asm-mips.h"' ; ../../common/asm-mips.sh < vacall-mipsn32eb-linux.s) > vacall-mipsn32eb-macro.S + +vacall-mipsn32el-linux.s : ../../vacall/vacall-mipsn32.c ../../vacall/vacall-internal.h vacall_r.h $(THISFILE) + $(CROSS_TOOL) mips64-linux gcc-5.4.0 -mabi=n32 -mel $(GCCFLAGS) -D__mipsn32__ -S ../../vacall/vacall-mipsn32.c -I../../vacall -I. -o vacall-mipsn32el-linux.s + +vacall-mipsn32el-macro.S : vacall-mipsn32el-linux.s ../../common/asm-mips.sh $(THISFILE) + (echo '#include "asm-mips.h"' ; ../../common/asm-mips.sh < vacall-mipsn32el-linux.s) > vacall-mipsn32el-macro.S + +vacall-mips64eb-linux.s : ../../vacall/vacall-mips64.c ../../vacall/vacall-internal.h vacall_r.h $(THISFILE) + $(CROSS_TOOL) mips64-linux gcc-5.4.0 -mabi=64 -meb $(GCCFLAGS) -D__mips64__ -S ../../vacall/vacall-mips64.c -I../../vacall -I. -o vacall-mips64eb-linux.s + +vacall-mips64eb-macro.S : vacall-mips64eb-linux.s ../../common/asm-mips.sh $(THISFILE) + (echo '#include "asm-mips.h"' ; ../../common/asm-mips.sh < vacall-mips64eb-linux.s) > vacall-mips64eb-macro.S + +vacall-mips64el-linux.s : ../../vacall/vacall-mips64.c ../../vacall/vacall-internal.h vacall_r.h $(THISFILE) + $(CROSS_TOOL) mips64-linux gcc-5.4.0 -mabi=64 -mel $(GCCFLAGS) -D__mips64__ -S ../../vacall/vacall-mips64.c -I../../vacall -I. -o vacall-mips64el-linux.s + +vacall-mips64el-macro.S : vacall-mips64el-linux.s ../../common/asm-mips.sh $(THISFILE) + (echo '#include "asm-mips.h"' ; ../../common/asm-mips.sh < vacall-mips64el-linux.s) > vacall-mips64el-macro.S + + +vacall-sparc-linux.s : ../../vacall/vacall-sparc.c ../../vacall/vacall-internal.h vacall_r.h $(THISFILE) + $(CROSS_TOOL) sparc-linux gcc -V 3.1 $(GCCFLAGS) -D__sparc__ -S ../../vacall/vacall-sparc.c -I../../vacall -I. -o vacall-sparc-linux.s + +vacall-sparc-macro.S : vacall-sparc-linux.s ../../common/asm-sparc.sh ../../common/noexecstack.h $(THISFILE) + (echo '#include "asm-sparc.h"' ; ../../common/asm-sparc.sh < vacall-sparc-linux.s ; cat ../../common/noexecstack.h) > vacall-sparc-macro.S + +vacall-sparc64-linux.s : ../../vacall/vacall-sparc64.c ../../vacall/vacall-internal.h vacall_r.h $(THISFILE) + $(CROSS_TOOL) sparc64-linux gcc -V 4.0.2 $(GCCFLAGS) -D__sparc64__ -S ../../vacall/vacall-sparc64.c -I../../vacall -I. -o vacall-sparc64-linux.s + +vacall-sparc64-macro.S : vacall-sparc64-linux.s ../../common/asm-sparc.sh ../../common/noexecstack.h $(THISFILE) + (echo '#include "asm-sparc.h"' ; ../../common/asm-sparc.sh < vacall-sparc64-linux.s ; cat ../../common/noexecstack.h) > vacall-sparc64-macro.S + + +vacall-alpha-linux.s : ../../vacall/vacall-alpha.c ../../vacall/vacall-internal.h vacall_r.h $(THISFILE) + $(CROSS_TOOL) alpha-linux gcc -V 4.0.2 $(GCCFLAGS) -D__alpha__ -S ../../vacall/vacall-alpha.c -I../../vacall -I. -o vacall-alpha-linux.s + +vacall-alpha-macro.S : vacall-alpha-linux.s ../../common/asm-alpha.sh ../../common/noexecstack.h $(THISFILE) + (../../common/asm-alpha.sh < vacall-alpha-linux.s ; cat ../../common/noexecstack.h) > vacall-alpha-macro.S + + +vacall-hppa-linux.s : ../../vacall/vacall-hppa.c ../../vacall/vacall-internal.h vacall_r.h $(THISFILE) + $(CROSS_TOOL) hppa-linux gcc -V 3.1 $(GCCFLAGS) -D__hppa__ -S ../../vacall/vacall-hppa.c -I../../vacall -I. -o vacall-hppa-linux.s + +vacall-hppa-macro.S : vacall-hppa-linux.s ../../common/asm-hppa.sh ../../common/noexecstack.h $(THISFILE) + (echo '#include "asm-hppa.h"' ; ../../common/asm-hppa.sh < vacall-hppa-linux.s ; cat ../../common/noexecstack.h) > vacall-hppa-macro.S + +vacall-hppa64-linux.s : ../../vacall/vacall-hppa64.c ../../vacall/vacall-internal.h vacall_r.h $(THISFILE) + $(CROSS_TOOL) hppa64-linux gcc -V 3.1 $(GCCFLAGS) -D__hppa64__ -S ../../vacall/vacall-hppa64.c -I../../vacall -I. -o vacall-hppa64-linux.s + +vacall-hppa64-macro.S : vacall-hppa64-linux.s ../../common/asm-hppa64.sh ../../common/noexecstack.h $(THISFILE) + (echo '#include "asm-hppa64.h"' ; ../../common/asm-hppa64.sh < vacall-hppa64-linux.s ; cat ../../common/noexecstack.h) > vacall-hppa64-macro.S + + +vacall-arm-macro.S : ../../vacall/vacall-arm.c ../../vacall/vacall-internal.h vacall_r.h ../../common/asm-arm.sh ../../common/noexecstack-arm.h $(THISFILE) + $(CROSS_TOOL) arm-linux gcc -V 3.1 -mlittle-endian $(GCCFLAGS) -D__arm__ -S ../../vacall/vacall-arm.c -I../../vacall -I. -o vacall-armel.s + $(CROSS_TOOL) arm-linux gcc -V 3.1 -mbig-endian $(GCCFLAGS) -D__arm__ -S ../../vacall/vacall-arm.c -I../../vacall -I. -o vacall-armeb.s + cmp vacall-armel.s vacall-armeb.s > /dev/null + (echo '#include "asm-arm.h"' ; ../../common/asm-arm.sh < vacall-armel.s ; cat ../../common/noexecstack-arm.h) > vacall-arm-macro.S + $(RM) vacall-armel.s vacall-armeb.s + +vacall-armhf-macro.S : ../../vacall/vacall-armhf.c ../../vacall/vacall-internal.h vacall_r.h ../../common/asm-arm.sh ../../common/noexecstack-arm.h $(THISFILE) +# The option -mabi=aapcs ensures an 8-bytes-aligned stack pointer. + $(CROSS_TOOL) armv7l-linux-gnueabihf gcc-6.3.0 -march=armv6 -mabi=aapcs -mfloat-abi=hard -mlittle-endian $(GCCFLAGS) -D__armhf__ -S ../../vacall/vacall-armhf.c -I../../vacall -I. -o vacall-armhfel.s + $(CROSS_TOOL) armv7l-linux-gnueabihf gcc-6.3.0 -march=armv6 -mabi=aapcs -mfloat-abi=hard -mbig-endian $(GCCFLAGS) -D__armhf__ -S ../../vacall/vacall-armhf.c -I../../vacall -I. -o vacall-armhfeb.s + cmp vacall-armhfel.s vacall-armhfeb.s > /dev/null + (echo '#include "asm-arm.h"' ; ../../common/asm-arm.sh < vacall-armhfel.s ; cat ../../common/noexecstack-arm.h) > vacall-armhf-macro.S + $(RM) vacall-armhfel.s vacall-armhfeb.s + + +vacall-arm64-macro.S : ../../vacall/vacall-arm64.c ../../vacall/vacall-internal.h vacall_r.h ../../common/asm-arm.sh ../../common/noexecstack-arm.h $(THISFILE) + $(CROSS_TOOL) aarch64-linux gcc-5.4.0 -mlittle-endian $(GCCFLAGS) -D__arm64__ -S ../../vacall/vacall-arm64.c -I../../vacall -I. -o vacall-arm64el.s + $(CROSS_TOOL) aarch64-linux gcc-5.4.0 -mbig-endian $(GCCFLAGS) -D__arm64__ -S ../../vacall/vacall-arm64.c -I../../vacall -I. -o vacall-arm64eb.s + cmp vacall-arm64el.s vacall-arm64eb.s > /dev/null + (echo '#include "asm-arm.h"' ; ../../common/asm-arm.sh < vacall-arm64el.s ; cat ../../common/noexecstack-arm.h) > vacall-arm64-macro.S + $(RM) vacall-arm64el.s vacall-arm64eb.s + + +vacall-powerpc-aix.s : ../../vacall/vacall-powerpc.c ../../vacall/vacall-internal.h vacall_r.h $(THISFILE) + $(CROSS_TOOL) rs6000-aix gcc -V 3.3.6 -mno-power -mno-power2 -mno-powerpc -mnew-mnemonics $(GCCFLAGS) -D__powerpc__ -S ../../vacall/vacall-powerpc.c -I../../vacall -I. -o vacall-powerpc-aix.s + +vacall-powerpc-linux.s : ../../vacall/vacall-powerpc.c ../../vacall/vacall-internal.h vacall_r.h $(THISFILE) + $(CROSS_TOOL) powerpc-linux gcc -V 3.3.6 -mno-power -mno-power2 -mno-powerpc $(GCCFLAGS) -D__powerpc__ -S ../../vacall/vacall-powerpc.c -I../../vacall -I. -o vacall-powerpc-linux.s + +vacall-powerpc-linux-macro.S : vacall-powerpc-linux.s ../../common/asm-powerpc.sh ../../common/noexecstack.h $(THISFILE) + (../../common/asm-powerpc.sh < vacall-powerpc-linux.s ; cat ../../common/noexecstack.h) > vacall-powerpc-linux-macro.S + +vacall-powerpc-sysv4-macro.S : ../../vacall/vacall-powerpc.c ../../vacall/vacall-internal.h vacall_r.h ../../common/asm-powerpc.sh ../../common/noexecstack.h $(THISFILE) + $(CROSS_TOOL) powerpc-linux gcc -V 3.3.6 -mno-power -mno-power2 -mno-powerpc $(GCCFLAGS) -D__powerpc__ -S ../../vacall/vacall-powerpc.c -I../../vacall -I. -o vacall-powerpc-sysv4.s + (../../common/asm-powerpc.sh < vacall-powerpc-sysv4.s ; cat ../../common/noexecstack.h) > vacall-powerpc-sysv4-macro.S + $(RM) vacall-powerpc-sysv4.s + +vacall-powerpc-macos.s : ../../vacall/vacall-powerpc.c ../../vacall/vacall-internal.h vacall_r.h $(THISFILE) + $(CROSS_TOOL) powerpc-darwin gcc -V 3.3.6 $(GCCFLAGS) -D__powerpc__ -S ../../vacall/vacall-powerpc.c -I../../vacall -I. -o vacall-powerpc-macos.s + +vacall-powerpc64-aix.s : ../../vacall/vacall-powerpc64.c ../../vacall/vacall-internal.h vacall_r.h $(THISFILE) + $(CROSS_TOOL) rs6000-aix6.1 gcc-5.4.0 -maix64 $(GCCFLAGS) -D__powerpc64__ -S ../../vacall/vacall-powerpc64.c -I../../vacall -I. -o vacall-powerpc64-aix.s + +vacall-powerpc64-linux.S : ../../vacall/vacall-powerpc64.c ../../vacall/vacall-internal.h vacall_r.h ../../common/asm-powerpc.sh ../../common/noexecstack.h $(THISFILE) + $(CROSS_TOOL) powerpc64le-linux gcc-5.4.0 -mabi=elfv1 -mcpu=power4 -mlittle-endian $(GCCFLAGS) -D__powerpc64__ -S ../../vacall/vacall-powerpc64.c -I../../vacall -I. -o vacall-powerpc64-linux-le.s + $(CROSS_TOOL) powerpc64le-linux gcc-5.4.0 -mabi=elfv1 -mcpu=power4 -mbig-endian $(GCCFLAGS) -D__powerpc64__ -S ../../vacall/vacall-powerpc64.c -I../../vacall -I. -o vacall-powerpc64-linux-be.s + cmp vacall-powerpc64-linux-le.s vacall-powerpc64-linux-be.s > /dev/null + (../../common/asm-powerpc.sh < vacall-powerpc64-linux-be.s ; cat ../../common/noexecstack.h) > vacall-powerpc64-linux.S + $(RM) vacall-powerpc64-linux-le.s vacall-powerpc64-linux-be.s + +vacall-powerpc64-elfv2-linux.S : ../../vacall/vacall-powerpc64.c ../../vacall/vacall-internal.h vacall_r.h ../../common/asm-powerpc.sh ../../common/noexecstack.h $(THISFILE) + $(CROSS_TOOL) powerpc64le-linux gcc-5.4.0 -mabi=elfv2 -mcpu=power4 -mlittle-endian $(GCCFLAGS) -D__powerpc64__ -D__powerpc64_elfv2__ -S ../../vacall/vacall-powerpc64.c -I../../vacall -I. -o vacall-powerpc64-elfv2-linux-le.s + $(CROSS_TOOL) powerpc64le-linux gcc-5.4.0 -mabi=elfv2 -mcpu=power4 -mbig-endian $(GCCFLAGS) -D__powerpc64__ -D__powerpc64_elfv2__ -S ../../vacall/vacall-powerpc64.c -I../../vacall -I. -o vacall-powerpc64-elfv2-linux-be.s +# vacall-powerpc64-linux-be.s contains endianness specific optimizations. + (../../common/asm-powerpc.sh < vacall-powerpc64-elfv2-linux-le.s ; cat ../../common/noexecstack.h) > vacall-powerpc64-elfv2-linux.S + $(RM) vacall-powerpc64-elfv2-linux-le.s vacall-powerpc64-elfv2-linux-be.s + + +vacall-ia64-linux.s : ../../vacall/vacall-ia64.c ../../vacall/vacall-internal.h vacall_r.h $(THISFILE) + $(CROSS_TOOL) ia64-linux gcc -V 4.0.1 $(GCCFLAGS) -D__ia64__ -S ../../vacall/vacall-ia64.c -I../../vacall -I. -o vacall-ia64-linux.s + +vacall-ia64-macro.S : vacall-ia64-linux.s ../../common/noexecstack.h $(THISFILE) + cat vacall-ia64-linux.s ../../common/noexecstack.h > vacall-ia64-macro.S + + +vacall-x86_64-linux.s : ../../vacall/vacall-x86_64.c ../../vacall/vacall-internal.h vacall_r.h $(THISFILE) + $(CROSS_TOOL) x86_64-linux gcc-4.0.2 $(GCCFLAGS) -D__x86_64__ -S ../../vacall/vacall-x86_64.c -I../../vacall -I. -o vacall-x86_64-linux.s + +vacall-x86_64-macro.S : vacall-x86_64-linux.s ../../common/asm-x86_64.sh ../../common/noexecstack.h $(THISFILE) + (echo '#include "asm-x86_64.h"' ; ../../common/asm-x86_64.sh < vacall-x86_64-linux.s ; cat ../../common/noexecstack.h) > vacall-x86_64-macro.S + +vacall-x86_64-x32-linux.s : ../../vacall/vacall-x86_64.c ../../vacall/vacall-internal.h vacall_r.h $(THISFILE) + $(CROSS_TOOL) x86_64-linux gcc-5.4.0 -mx32 $(GCCFLAGS) -D__x86_64__ -D__x86_64_x32__ -S ../../vacall/vacall-x86_64.c -I../../vacall -I. -o vacall-x86_64-x32-linux.s + +vacall-x86_64-windows.s : ../../vacall/vacall-x86_64-windows.c ../../vacall/vacall-internal.h vacall_r.h $(THISFILE) + $(CROSS_TOOL) x86_64-linux gcc-5.4.0 -mabi=ms $(GCCFLAGS) -fno-reorder-blocks-and-partition -D__x86_64__ -D_WIN32 -S ../../vacall/vacall-x86_64-windows.c -I../../vacall -I. -o vacall-x86_64-windows.s + +vacall-x86_64-windows-macro.S : vacall-x86_64-windows.s ../../common/asm-x86_64.sh ../../common/noexecstack.h $(THISFILE) + (echo '#include "asm-x86_64.h"' ; ../../common/asm-x86_64.sh < vacall-x86_64-windows.s ; cat ../../common/noexecstack.h) > vacall-x86_64-windows-macro.S + + +vacall-s390-linux.s : ../../vacall/vacall-s390.c ../../vacall/vacall-internal.h vacall_r.h $(THISFILE) + $(CROSS_TOOL) s390-linux gcc -V 3.1 $(GCCFLAGS) -D__s390__ -S ../../vacall/vacall-s390.c -I../../vacall -I. -o vacall-s390-linux.s + +vacall-s390-macro.S : vacall-s390-linux.s ../../common/asm-s390.sh ../../common/noexecstack.h $(THISFILE) + (../../common/asm-s390.sh < vacall-s390-linux.s ; cat ../../common/noexecstack.h) > vacall-s390-macro.S + + +vacall-s390x-linux.s : ../../vacall/vacall-s390x.c ../../vacall/vacall-internal.h vacall_r.h $(THISFILE) + $(CROSS_TOOL) s390x-linux gcc-5.4.0 $(GCCFLAGS) -D__s390x__ -S ../../vacall/vacall-s390x.c -I../../vacall -I. -o vacall-s390x-linux.s + +vacall-s390x-macro.S : vacall-s390x-linux.s ../../common/asm-s390.sh ../../common/noexecstack.h $(THISFILE) + (../../common/asm-s390.sh < vacall-s390x-linux.s ; cat ../../common/noexecstack.h) > vacall-s390x-macro.S + + +vacall-riscv32-ilp32d-linux.s : ../../vacall/vacall-riscv32.c ../../vacall/vacall-internal.h vacall_r.h $(THISFILE) + $(CROSS_TOOL) riscv32-linux gcc-7.3.0 $(GCCFLAGS) -D__riscv32__ -S ../../vacall/vacall-riscv32.c -I../../vacall -I. -o vacall-riscv32-ilp32d-linux.s + +vacall-riscv32-ilp32d-macro.S : vacall-riscv32-ilp32d-linux.s ../../common/asm-riscv.sh ../../common/noexecstack.h $(THISFILE) + (../../common/asm-riscv.sh < vacall-riscv32-ilp32d-linux.s ; cat ../../common/noexecstack.h) > vacall-riscv32-ilp32d-macro.S + + +vacall-riscv64-lp64d-linux.s : ../../vacall/vacall-riscv64.c ../../vacall/vacall-internal.h vacall_r.h $(THISFILE) + $(CROSS_TOOL) riscv64-linux gcc-7.3.0 $(GCCFLAGS) -D__riscv64__ -S ../../vacall/vacall-riscv64.c -I../../vacall -I. -o vacall-riscv64-lp64d-linux.s + +vacall-riscv64-lp64d-macro.S : vacall-riscv64-lp64d-linux.s ../../common/asm-riscv.sh ../../common/noexecstack.h $(THISFILE) + (../../common/asm-riscv.sh < vacall-riscv64-lp64d-linux.s ; cat ../../common/noexecstack.h) > vacall-riscv64-lp64d-macro.S diff --git a/callback/vacall_r/Makefile.in b/callback/vacall_r/Makefile.in new file mode 100644 index 0000000..9d52db5 --- /dev/null +++ b/callback/vacall_r/Makefile.in @@ -0,0 +1,351 @@ +# Makefile for vacall + +#### Start of system configuration section. #### + +HOST = @host@ +CPU = @HOST_CPU_C_ABI@ +OS = @host_os@ + +# Directories used by "make": +srcdir = @srcdir@ + +# Directories used by "make install": +prefix = @prefix@ +local_prefix = /usr/local +exec_prefix = @exec_prefix@ +libdir = @libdir@ +includedir = @includedir@ +mandir = @mandir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +htmldir = $(datadir)/html + +# Programs used by "make": +CC = @CC@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +CPP = @CPP@ +INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../../vacall -I../.. -I$(srcdir)/../.. +INCLUDES_WITH_GNULIB = $(INCLUDES) -I../../gnulib-lib -I$(srcdir)/../../gnulib-lib +ASPFLAGS = `if test @AS_UNDERSCORE@ = true; then echo '-DASM_UNDERSCORE'; fi` +LDFLAGS = @LDFLAGS@ +LIBTOOL = @LIBTOOL@ +LIBTOOL_COMPILE = $(LIBTOOL) --mode=compile +LIBTOOL_LINK = $(LIBTOOL) --mode=link +LIBTOOL_INSTALL = $(LIBTOOL) --mode=install +LIBTOOL_UNINSTALL = $(LIBTOOL) --mode=uninstall +AR = @AR@ +AR_FLAGS = rc +RANLIB = @RANLIB@ +MV = mv +LN = @LN@ +RM = rm -f +@SET_MAKE@ + +# Programs used by "make install": +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ + +#### End of system configuration section. #### + +SHELL = /bin/sh + +# Needed by $(LIBTOOL). +top_builddir = ../.. + +OBJECTS = vacall.lo vacall-libapi.lo vacall-structcpy.lo + +all : $(OBJECTS) libvacall.la + +vacall.lo : vacall-$(CPU).lo + $(RM) vacall.lo vacall.@OBJEXT@ + $(LN) vacall-$(CPU).lo vacall.lo + if test -f vacall-$(CPU).@OBJEXT@; then $(LN) vacall-$(CPU).@OBJEXT@ vacall.@OBJEXT@; fi + +@IFNOT_MSVC@vacall-i386.lo : vacall-i386.s +@IFNOT_MSVC@ $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c vacall-i386.s + +@IFNOT_MSVC@vacall-i386.s : $(srcdir)/vacall-i386-macro.S +@IFNOT_MSVC@ $(CPP) $(ASPFLAGS) -I$(srcdir) -I$(srcdir)/../../common - < $(srcdir)/vacall-i386-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,\. ,.,g' -e 's,@ ,@,g' -e 's,//.*$$,,' -e 's/##//g' > vacall-i386.s + +@IF_MSVC@vacall-i386.lo : $(srcdir)/vacall-i386-msvc.c +@IF_MSVC@ $(LIBTOOL_COMPILE) $(CC) $(INCLUDES) -I$(srcdir)/../../common $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/vacall-i386-msvc.c -o vacall-i386.lo + +vacall-sparc.lo : vacall-sparc.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c vacall-sparc.s + +vacall-sparc.s : $(srcdir)/vacall-sparc-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../../common - < $(srcdir)/vacall-sparc-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,\. ,.,g' -e 's,//.*$$,,' -e 's,\$$,#,g' -e 's,# ,#,g' > vacall-sparc.s + +vacall-sparc64.lo : vacall-sparc64.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c vacall-sparc64.s + +vacall-sparc64.s : $(srcdir)/vacall-sparc64-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../../common - < $(srcdir)/vacall-sparc64-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,\. ,.,g' -e 's,//.*$$,,' -e 's,\$$,#,g' -e 's,# ,#,g' > vacall-sparc64.s + +vacall-m68k.lo : vacall-m68k.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c vacall-m68k.s + +vacall-m68k.s : $(srcdir)/vacall-m68k.mit.S $(srcdir)/vacall-m68k.motorola.S + $(CPP) $(ASPFLAGS) -I$(srcdir) -I$(srcdir)/../../common $(srcdir)/vacall-m68k.motorola.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' | if test @AS_UNDERSCORE@ = true; then sed -e 's/\$$//g'; else sed -e 's/\$$/%/g'; fi > vacall-m68k.s + +vacall-mips.lo : vacall-mips.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c vacall-mips.s + +vacall-mips.s : $(srcdir)/vacall-mips@ENDIANNESS@-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir) -I$(srcdir)/../../common $(srcdir)/vacall-mips@ENDIANNESS@-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > vacall-mips.s + +vacall-mipsn32.lo : vacall-mipsn32.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c vacall-mipsn32.s + +vacall-mipsn32.s : $(srcdir)/vacall-mipsn32@ENDIANNESS@-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir) -I$(srcdir)/../../common $(srcdir)/vacall-mipsn32@ENDIANNESS@-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > vacall-mipsn32.s + +vacall-mips64.lo : vacall-mips64.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c vacall-mips64.s + +vacall-mips64.s : $(srcdir)/vacall-mips64@ENDIANNESS@-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir) -I$(srcdir)/../../common $(srcdir)/vacall-mips64@ENDIANNESS@-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > vacall-mips64.s + +vacall-alpha.lo : vacall-alpha.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c vacall-alpha.s + +vacall-alpha.s : $(srcdir)/vacall-alpha-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir) -I$(srcdir)/../../common $(srcdir)/vacall-alpha-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > vacall-alpha.s + +vacall-hppa.lo : vacall-hppa.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c vacall-hppa.s + +vacall-hppa.s : $(srcdir)/vacall-hppa-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../../common $(srcdir)/vacall-hppa-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e "s,!,',g" > vacall-hppa.s + +vacall-hppa64.lo : vacall-hppa64.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c vacall-hppa64.s + +vacall-hppa64.s : $(srcdir)/vacall-hppa64-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../../common $(srcdir)/vacall-hppa64-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e "s,!,',g" > vacall-hppa64.s + +vacall-arm.lo : vacall-arm.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c vacall-arm.s + +vacall-arm.s : $(srcdir)/vacall-arm-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir) -I$(srcdir)/../../common $(srcdir)/vacall-arm-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//,@,g' -e 's,\$$,#,g' > vacall-arm.s + +vacall-armhf.lo : vacall-armhf.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c vacall-armhf.s + +vacall-armhf.s : $(srcdir)/vacall-armhf-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir) -I$(srcdir)/../../common $(srcdir)/vacall-armhf-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//,@,g' -e 's,\$$,#,g' > vacall-armhf.s + +vacall-arm64.lo : vacall-arm64.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c vacall-arm64.s + +vacall-arm64.s : $(srcdir)/vacall-arm64-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir) -I$(srcdir)/../../common $(srcdir)/vacall-arm64-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//,@,g' -e 's,\$$,#,g' > vacall-arm64.s + +vacall-powerpc.lo : vacall-powerpc.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c vacall-powerpc.s + +vacall-powerpc.s : $(srcdir)/vacall-powerpc-aix.s $(srcdir)/vacall-powerpc-linux-macro.S $(srcdir)/vacall-powerpc-macos.s $(srcdir)/vacall-powerpc-sysv4-macro.S + case "$(OS)" in \ + aix*) syntax=aix;; \ + linux* | netbsd* | openbsd*) syntax=linux;; \ + macos* | darwin*) syntax=macos;; \ + *) syntax=sysv4;; \ + esac; \ + case $${syntax} in \ + linux | netbsd | sysv4) \ + $(CPP) $(ASPFLAGS) -I$(srcdir) $(srcdir)/vacall-powerpc-$${syntax}-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//,@,g' -e 's,\$$,#,g' > vacall-powerpc.s || exit 1 ;; \ + macos) \ + grep -v '\.machine' $(srcdir)/vacall-powerpc-$${syntax}.s > vacall-powerpc.s || exit 1 ;; \ + *) \ + cp $(srcdir)/vacall-powerpc-$${syntax}.s vacall-powerpc.s || exit 1 ;; \ + esac + +vacall-powerpc64.lo : vacall-powerpc64.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c vacall-powerpc64.s + +vacall-powerpc64.s : $(srcdir)/vacall-powerpc64-aix.s $(srcdir)/vacall-powerpc64-linux.S + case "$(OS)" in \ + aix*) syntax=aix;; \ + *) syntax=linux;; \ + esac; \ + case $${syntax} in \ + linux) \ + $(CPP) $(ASPFLAGS) $(srcdir)/vacall-powerpc64-$${syntax}.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > vacall-powerpc64.s || exit 1 ;; \ + *) \ + cp $(srcdir)/vacall-powerpc64-$${syntax}.s vacall-powerpc64.s || exit 1 ;; \ + esac + +vacall-powerpc64-elfv2.lo : vacall-powerpc64-elfv2.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c vacall-powerpc64-elfv2.s + +vacall-powerpc64-elfv2.s : $(srcdir)/vacall-powerpc64-elfv2-linux.S + $(CPP) $(ASPFLAGS) $(srcdir)/vacall-powerpc64-elfv2-linux.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > vacall-powerpc64-elfv2.s + +vacall-ia64.lo : vacall-ia64.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c vacall-ia64.s + +vacall-ia64.s : $(srcdir)/vacall-ia64-macro.S + $(CPP) $(ASPFLAGS) $(srcdir)/vacall-ia64-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > vacall-ia64.s + +@IFNOT_MSVC@vacall-x86_64.lo : vacall-x86_64.s +@IFNOT_MSVC@ $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c vacall-x86_64.s + +@IFNOT_MSVC@vacall-x86_64.s : $(srcdir)/vacall-x86_64-macro.S $(srcdir)/vacall-x86_64-windows-macro.S +@IFNOT_MSVC@ case "$(OS)" in \ +@IFNOT_MSVC@ cygwin* | mingw*) variant='-windows';; \ +@IFNOT_MSVC@ *) variant='';; \ +@IFNOT_MSVC@ esac; \ +@IFNOT_MSVC@ $(CPP) $(ASPFLAGS) -I$(srcdir) -I$(srcdir)/../../common - < $(srcdir)/vacall-x86_64$${variant}-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,\. ,.,g' -e 's,@ ,@,g' -e 's,//.*$$,,' -e 's/##//g' > vacall-x86_64.s + +@IF_MSVC@vacall-x86_64.lo : vacall-x86_64.asm +@IF_MSVC@ $(LIBTOOL_COMPILE) ml64 -c -nologo vacall-x86_64.asm +@IF_MSVC@ mkdir -p .libs; cp vacall-x86_64.@OBJEXT@ .libs/vacall-x86_64.@OBJEXT@ + +@IF_MSVC@vacall-x86_64.asm : $(srcdir)/vacall-x86_64-windows-macro.S +@IF_MSVC@ { $(CPP) $(ASPFLAGS) -I$(srcdir)/../../common $(srcdir)/vacall-x86_64-windows-macro.S | grep -v '^#'; echo 'END'; } > vacall-x86_64.asm + +vacall-x86_64-x32.lo : vacall-x86_64-x32.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c vacall-x86_64-x32.s + +vacall-x86_64-x32.s : $(srcdir)/vacall-x86_64-x32-linux.s + cp $(srcdir)/vacall-x86_64-x32-linux.s vacall-x86_64-x32.s + +vacall-s390.lo : vacall-s390.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c vacall-s390.s + +vacall-s390.s : $(srcdir)/vacall-s390-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir) $(srcdir)/vacall-s390-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > vacall-s390.s + +vacall-s390x.lo : vacall-s390x.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c vacall-s390x.s + +vacall-s390x.s : $(srcdir)/vacall-s390x-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir) $(srcdir)/vacall-s390x-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > vacall-s390x.s + +vacall-riscv32-ilp32d.lo : vacall-riscv32-ilp32d.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c vacall-riscv32-ilp32d.s + +vacall-riscv32-ilp32d.s : $(srcdir)/vacall-riscv32-ilp32d-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir) $(srcdir)/vacall-riscv32-ilp32d-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > vacall-riscv32-ilp32d.s + +vacall-riscv64-lp64d.lo : vacall-riscv64-lp64d.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c vacall-riscv64-lp64d.s + +vacall-riscv64-lp64d.s : $(srcdir)/vacall-riscv64-lp64d-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir) $(srcdir)/vacall-riscv64-lp64d-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > vacall-riscv64-lp64d.s + +vacall-libapi.lo : $(srcdir)/vacall-libapi.c $(srcdir)/../../vacall/vacall-internal.h $(srcdir)/vacall_r.h ../../config.h + $(LIBTOOL_COMPILE) $(CC) $(INCLUDES_WITH_GNULIB) $(CPPFLAGS) $(CFLAGS) @DISABLE_TYPE_BASED_ALIASING@ -DREENTRANT -c $(srcdir)/vacall-libapi.c + +vacall-structcpy.lo : $(srcdir)/vacall-structcpy.c $(srcdir)/../../common/structcpy.c + $(LIBTOOL_COMPILE) $(CC) -I$(srcdir)/../../common $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/vacall-structcpy.c + +libvacall.la : $(OBJECTS) + $(LIBTOOL_LINK) $(CC) -o libvacall.la -rpath $(libdir) -no-undefined $(OBJECTS) $(LDFLAGS) + +# Installs the library and include files only. Typically called with only +# $(libdir) and $(includedir) - don't use $(prefix) and $(exec_prefix) here. +install-lib : all force + mkdir -p $(includedir) + $(INSTALL_DATA) $(srcdir)/vacall_r.h $(includedir)/vacall_r.h + +install : all force + mkdir -p $(DESTDIR)$(prefix) +# mkdir -p $(DESTDIR)$(exec_prefix) +# mkdir -p $(DESTDIR)$(libdir) +# $(LIBTOOL_INSTALL) $(INSTALL_DATA) libvacall.la $(DESTDIR)$(libdir)/libvacall.la + mkdir -p $(DESTDIR)$(includedir) + $(INSTALL_DATA) $(srcdir)/vacall_r.h $(DESTDIR)$(includedir)/vacall_r.h +# mkdir -p $(DESTDIR)$(mandir) +# mkdir -p $(DESTDIR)$(mandir)/man3 +# $(INSTALL_DATA) $(srcdir)/vacall_r.3 $(DESTDIR)$(mandir)/man3/vacall_r.3 +# mkdir -p $(DESTDIR)$(datadir) +# mkdir -p $(DESTDIR)$(htmldir) +# $(INSTALL_DATA) $(srcdir)/vacall_r.html $(DESTDIR)$(htmldir)/vacall_r.html + +installdirs : force + mkdir -p $(DESTDIR)$(prefix) +# mkdir -p $(DESTDIR)$(exec_prefix) +# mkdir -p $(DESTDIR)$(libdir) + mkdir -p $(DESTDIR)$(includedir) +# mkdir -p $(DESTDIR)$(mandir) +# mkdir -p $(DESTDIR)$(mandir)/man3 +# mkdir -p $(DESTDIR)$(datadir) +# mkdir -p $(DESTDIR)$(htmldir) + +uninstall : force +# $(LIBTOOL_UNINSTALL) $(RM) $(DESTDIR)$(libdir)/libvacall.la + $(RM) $(DESTDIR)$(includedir)/vacall_r.h +# $(RM) $(DESTDIR)$(mandir)/man3/vacall_r.3 +# $(RM) $(DESTDIR)$(htmldir)/vacall_r.html + +check : all + +extracheck : all + +mostlyclean : clean + +clean : force + $(RM) *.@OBJEXT@ *.lo *.a libvacall.* core + $(RM) vacall-i386.s vacall-sparc.s vacall-sparc64.s vacall-m68k.s vacall-mips.s vacall-mipsn32.s vacall-mips64.s vacall-alpha.s vacall-hppa.s vacall-hppa64.s vacall-arm.s vacall-armhf.s vacall-arm64.s vacall-powerpc.s vacall-powerpc64.s vacall-powerpc64-elfv2.s vacall-ia64.s vacall-x86_64.s vacall-x86_64.asm vacall-x86_64-x32.s vacall-s390.s vacall-s390x.s vacall-riscv32-ilp32d.s vacall-riscv64-lp64d.s + $(RM) -r .libs _libs + +distclean : clean + $(RM) Makefile + +maintainer-clean : distclean + + +# List of source files (committed in version control or generated by Makefile.devel). +SOURCE_FILES = \ + COPYING \ + README \ + Makefile.devel \ + Makefile.maint \ + Makefile.in \ + vacall_r.h \ + get_receiver.c \ + vacall-alpha-linux.s vacall-alpha-macro.S \ + vacall-arm-macro.S \ + vacall-armhf-macro.S \ + vacall-arm64-macro.S \ + vacall-hppa-linux.s vacall-hppa-macro.S \ + vacall-hppa64-linux.s vacall-hppa64-macro.S \ + vacall-i386-linux.s vacall-i386-macro.S \ + vacall-ia64-linux.s vacall-ia64-macro.S \ + vacall-m68k-linux.s vacall-m68k-sun.s vacall-m68k.mit.S vacall-m68k.motorola.S \ + vacall-mipseb-linux.s vacall-mipsel-linux.s vacall-mipseb-macro.S vacall-mipsel-macro.S \ + vacall-mipsn32eb-linux.s vacall-mipsn32el-linux.s vacall-mipsn32eb-macro.S vacall-mipsn32el-macro.S \ + vacall-mips64eb-linux.s vacall-mips64el-linux.s vacall-mips64eb-macro.S vacall-mips64el-macro.S \ + vacall-powerpc-aix.s \ + vacall-powerpc-linux.s vacall-powerpc-linux-macro.S \ + vacall-powerpc-macos.s \ + vacall-powerpc-sysv4-macro.S \ + vacall-powerpc64-aix.s vacall-powerpc64-linux.S vacall-powerpc64-elfv2-linux.S \ + vacall-riscv32-ilp32d-linux.s vacall-riscv32-ilp32d-macro.S \ + vacall-riscv64-lp64d-linux.s vacall-riscv64-lp64d-macro.S \ + vacall-s390-linux.s vacall-s390-macro.S \ + vacall-s390x-linux.s vacall-s390x-macro.S \ + vacall-sparc-linux.s vacall-sparc-macro.S \ + vacall-sparc64-linux.s vacall-sparc64-macro.S \ + vacall-x86_64-linux.s vacall-x86_64-macro.S vacall-x86_64-x32-linux.s \ + vacall-x86_64-windows.s vacall-x86_64-windows-macro.S \ + vacall-libapi.c \ + vacall-structcpy.c +# List of distributed files generated by Makefile.maint. +GENERATED_FILES = \ + vacall-i386-msvc.c +# List of distributed files. +DISTFILES = $(SOURCE_FILES) $(GENERATED_FILES) + +distdir : $(DISTFILES) + for file in $(DISTFILES); do \ + if test -f $$file; then dir='.'; else dir='$(srcdir)'; fi; \ + cp -p "$$dir/$$file" '$(distdir)'/$$file || exit 1; \ + done + + +force : diff --git a/callback/vacall_r/Makefile.maint b/callback/vacall_r/Makefile.maint new file mode 100644 index 0000000..c9074f4 --- /dev/null +++ b/callback/vacall_r/Makefile.maint @@ -0,0 +1,17 @@ +# maintainer -*-Makefile-*- + +LN = ln -s +RM = rm -f + +# ==================== Easily regeneratable files ==================== + +all : vacall-i386-msvc.c + +vacall-i386-msvc.c : vacall-i386-macro.S + (echo '#ifdef _MSC_VER' ; echo '#include "vacall_r.h"' ; echo '#endif' ; sed -e '/FUNEND(callback_receiver,/q' < vacall-i386-macro.S ; cat get_receiver.c) > vacall-i386-msvc.c + +totally-clean : force + $(RM) vacall-i386-msvc.c + + +force : diff --git a/callback/vacall_r/README b/callback/vacall_r/README new file mode 100644 index 0000000..801a9b9 --- /dev/null +++ b/callback/vacall_r/README @@ -0,0 +1,9 @@ +This directory contains a reentrant version of the vacall package. + +Instead of using a global variable for the function to be called, +a pointer is passed in a special CPU register, pointing to: + - a function code pointer in the first word, + - a data word in the second word, to be passed before the va_alist. + +The include file is renamed to . + diff --git a/callback/vacall_r/get_receiver.c b/callback/vacall_r/get_receiver.c new file mode 100644 index 0000000..5394019 --- /dev/null +++ b/callback/vacall_r/get_receiver.c @@ -0,0 +1,24 @@ +/* Implementation of callback_get_receiver */ + +/* + * Copyright 2017 Bruno Haible + * + * 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, see . + */ + +__vacall_r_t +callback_get_receiver (void) +{ + return (__vacall_r_t)(void*)&callback_receiver; +} diff --git a/callback/vacall_r/vacall-alpha-linux.s b/callback/vacall_r/vacall-alpha-linux.s new file mode 100644 index 0000000..75fbe8f --- /dev/null +++ b/callback/vacall_r/vacall-alpha-linux.s @@ -0,0 +1,196 @@ + .set noreorder + .set volatile + .set noat + .set nomacro + .text + .align 2 + .align 4 + .ent callback_receiver +callback_receiver: + .frame $15,192,$26,48 + .mask 0x4008000,-192 + ldah $29,0($27) !gpdisp!1 + lda $29,0($29) !gpdisp!1 +$callback_receiver..ng: + lda $30,-192($30) + ldq $27,0($1) + stq $15,8($30) + mov $30,$15 + lda $3,144($15) + stq $26,0($30) + .prologue 1 + stq $31,48($15) + lda $2,88($15) + stq $16,144($15) + subq $2,$3,$2 + ldq $16,8($1) + stq $17,152($15) + lda $3,192($15) + stq $2,80($15) + lda $17,16($15) + lda $2,144($15) + stq $3,72($15) + stq $18,160($15) + stq $19,168($15) + stq $20,176($15) + stq $21,184($15) + stt $f16,88($15) + stt $f17,96($15) + stt $f18,104($15) + stt $f19,112($15) + stt $f20,120($15) + stt $f21,128($15) + stl $31,16($15) + stq $2,40($15) + stl $31,56($15) + jsr $26,($27),0 + ldah $29,0($26) !gpdisp!2 + lda $29,0($29) !gpdisp!2 + ldl $2,56($15) + beq $2,$L43 + zapnot $2,15,$3 + cmpeq $3,1,$2 + bne $2,$L44 + cmpeq $3,2,$2 + bne $2,$L44 + cmpeq $3,3,$2 + bne $2,$L50 + cmpeq $3,4,$2 + bne $2,$L51 + cmpeq $3,5,$2 + bne $2,$L52 + cmpeq $3,6,$2 + bne $2,$L53 + cmpeq $3,7,$2 + bne $2,$L54 + cmpeq $3,8,$2 + bne $2,$L48 + cmpeq $3,9,$2 + bne $2,$L48 + cmpeq $3,10,$2 + bne $2,$L48 + cmpeq $3,11,$2 + bne $2,$L48 + cmpeq $3,12,$2 + bne $2,$L55 + cmpeq $3,13,$2 + bne $2,$L56 + cmpeq $3,14,$2 + bne $2,$L48 + cmpeq $3,15,$2 + beq $2,$L43 + lda $2,1024($31) + ldl $3,16($15) + and $2,$3,$2 + beq $2,$L43 + ldq $3,64($15) + cmpeq $3,1,$2 + bne $2,$L57 + cmpeq $3,2,$2 + bne $2,$L58 + cmpeq $3,4,$2 + bne $2,$L59 + cmpeq $3,8,$2 + bne $2,$L60 + cmpeq $3,16,$2 + beq $2,$L43 + ldq $2,48($15) + ldq $1,8($2) + ldq $0,0($2) + .align 4 +$L43: + mov $15,$30 + ldq $26,0($30) + ldq $15,8($30) + lda $30,192($30) + ret $31,($26),1 + .align 4 +$L44: + mov $15,$30 + ldl $2,24($15) + ldq $26,0($30) + sll $2,56,$2 + sra $2,56,$0 + ldq $15,8($30) + lda $30,192($30) + ret $31,($26),1 +$L51: + ldl $2,24($15) + sll $2,48,$2 + sra $2,48,$0 + br $31,$L43 +$L50: + ldl $2,24($15) + bis $31,$31,$31 + and $2,0xff,$0 + br $31,$L43 +$L48: + ldq $0,24($15) + br $31,$L43 +$L52: + ldl $2,24($15) + bis $31,$31,$31 + zapnot $2,3,$0 + br $31,$L43 +$L53: + ldl $3,24($15) + bis $31,$31,$31 + mov $3,$0 + br $31,$L43 +$L54: + ldl $2,24($15) + bis $31,$31,$31 + zapnot $2,15,$0 + br $31,$L43 +$L55: + lds $f0,24($15) + br $31,$L43 +$L56: + ldt $f0,24($15) + br $31,$L43 +$L57: + ldq $3,48($15) + ldq_u $2,0($3) + extbl $2,$3,$0 + br $31,$L43 +$L58: + ldq $3,48($15) + ldq_u $2,0($3) + extwl $2,$3,$0 + br $31,$L43 +$L60: + ldq $2,48($15) + bis $31,$31,$31 + ldq $0,0($2) + br $31,$L43 +$L59: + ldq $2,48($15) + ldl $3,0($2) + zapnot $3,15,$0 + br $31,$L43 + .end callback_receiver + .align 2 + .align 4 + .globl callback_get_receiver + .ent callback_get_receiver +callback_get_receiver: + .frame $15,16,$26,0 + .mask 0x4008000,-16 + ldah $29,0($27) !gpdisp!3 + lda $29,0($29) !gpdisp!3 +$callback_get_receiver..ng: + lda $30,-16($30) + ldah $2,callback_receiver($29) !gprelhigh + stq $15,8($30) + mov $30,$15 + stq $26,0($30) + .prologue 1 + mov $15,$30 + lda $0,callback_receiver($2) !gprellow + ldq $26,0($30) + ldq $15,8($30) + lda $30,16($30) + ret $31,($26),1 + .end callback_get_receiver + .ident "GCC: (GNU) 4.0.2" + .section .note.GNU-stack,"",@progbits diff --git a/callback/vacall_r/vacall-alpha-macro.S b/callback/vacall_r/vacall-alpha-macro.S new file mode 100644 index 0000000..a5ba6c6 --- /dev/null +++ b/callback/vacall_r/vacall-alpha-macro.S @@ -0,0 +1,197 @@ + .set noreorder + .set volatile + .set noat + .set nomacro + .text + .align 2 + .align 4 + .ent callback_receiver +callback_receiver: + .frame $15,192,$26,48 + .mask 0x4008000,-192 + ldah $29,0($27) !gpdisp!1 + lda $29,0($29) !gpdisp!1 +$callback_receiver..ng: + lda $30,-192($30) + ldq $27,0($1) + stq $15,8($30) + mov $30,$15 + lda $3,144($15) + stq $26,0($30) + .prologue 1 + stq $31,48($15) + lda $2,88($15) + stq $16,144($15) + subq $2,$3,$2 + ldq $16,8($1) + stq $17,152($15) + lda $3,192($15) + stq $2,80($15) + lda $17,16($15) + lda $2,144($15) + stq $3,72($15) + stq $18,160($15) + stq $19,168($15) + stq $20,176($15) + stq $21,184($15) + stt $f16,88($15) + stt $f17,96($15) + stt $f18,104($15) + stt $f19,112($15) + stt $f20,120($15) + stt $f21,128($15) + stl $31,16($15) + stq $2,40($15) + stl $31,56($15) + jsr $26,($27),0 + ldah $29,0($26) !gpdisp!2 + lda $29,0($29) !gpdisp!2 + ldl $2,56($15) + beq $2,$L43 + zapnot $2,15,$3 + cmpeq $3,1,$2 + bne $2,$L44 + cmpeq $3,2,$2 + bne $2,$L44 + cmpeq $3,3,$2 + bne $2,$L50 + cmpeq $3,4,$2 + bne $2,$L51 + cmpeq $3,5,$2 + bne $2,$L52 + cmpeq $3,6,$2 + bne $2,$L53 + cmpeq $3,7,$2 + bne $2,$L54 + cmpeq $3,8,$2 + bne $2,$L48 + cmpeq $3,9,$2 + bne $2,$L48 + cmpeq $3,10,$2 + bne $2,$L48 + cmpeq $3,11,$2 + bne $2,$L48 + cmpeq $3,12,$2 + bne $2,$L55 + cmpeq $3,13,$2 + bne $2,$L56 + cmpeq $3,14,$2 + bne $2,$L48 + cmpeq $3,15,$2 + beq $2,$L43 + lda $2,1024($31) + ldl $3,16($15) + and $2,$3,$2 + beq $2,$L43 + ldq $3,64($15) + cmpeq $3,1,$2 + bne $2,$L57 + cmpeq $3,2,$2 + bne $2,$L58 + cmpeq $3,4,$2 + bne $2,$L59 + cmpeq $3,8,$2 + bne $2,$L60 + cmpeq $3,16,$2 + beq $2,$L43 + ldq $2,48($15) + ldq $1,8($2) + ldq $0,0($2) + .align 4 +$L43: + mov $15,$30 + ldq $26,0($30) + ldq $15,8($30) + lda $30,192($30) + ret $31,($26),1 + .align 4 +$L44: + mov $15,$30 + ldl $2,24($15) + ldq $26,0($30) + sll $2,56,$2 + sra $2,56,$0 + ldq $15,8($30) + lda $30,192($30) + ret $31,($26),1 +$L51: + ldl $2,24($15) + sll $2,48,$2 + sra $2,48,$0 + br $31,$L43 +$L50: + ldl $2,24($15) + bis $31,$31,$31 + and $2,0xff,$0 + br $31,$L43 +$L48: + ldq $0,24($15) + br $31,$L43 +$L52: + ldl $2,24($15) + bis $31,$31,$31 + zapnot $2,3,$0 + br $31,$L43 +$L53: + ldl $3,24($15) + bis $31,$31,$31 + mov $3,$0 + br $31,$L43 +$L54: + ldl $2,24($15) + bis $31,$31,$31 + zapnot $2,15,$0 + br $31,$L43 +$L55: + lds $f0,24($15) + br $31,$L43 +$L56: + ldt $f0,24($15) + br $31,$L43 +$L57: + ldq $3,48($15) + ldq_u $2,0($3) + extbl $2,$3,$0 + br $31,$L43 +$L58: + ldq $3,48($15) + ldq_u $2,0($3) + extwl $2,$3,$0 + br $31,$L43 +$L60: + ldq $2,48($15) + bis $31,$31,$31 + ldq $0,0($2) + br $31,$L43 +$L59: + ldq $2,48($15) + ldl $3,0($2) + zapnot $3,15,$0 + br $31,$L43 + .end callback_receiver + .align 2 + .align 4 + .globl callback_get_receiver + .ent callback_get_receiver +callback_get_receiver: + .frame $15,16,$26,0 + .mask 0x4008000,-16 + ldah $29,0($27) !gpdisp!3 + lda $29,0($29) !gpdisp!3 +$callback_get_receiver..ng: + lda $30,-16($30) + ldah $2,callback_receiver($29) !gprelhigh + stq $15,8($30) + mov $30,$15 + stq $26,0($30) + .prologue 1 + mov $15,$30 + lda $0,callback_receiver($2) !gprellow + ldq $26,0($30) + ldq $15,8($30) + lda $30,16($30) + ret $31,($26),1 + .end callback_get_receiver +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/callback/vacall_r/vacall-arm-macro.S b/callback/vacall_r/vacall-arm-macro.S new file mode 100644 index 0000000..ec08a56 --- /dev/null +++ b/callback/vacall_r/vacall-arm-macro.S @@ -0,0 +1,110 @@ +#include "asm-arm.h" + .text + .align 2 + DECLARE_FUNCTION(callback_receiver) +FUNBEGIN(callback_receiver) + // args = 28, pretend = 0, frame = 32 + // frame_needed = 1, uses_anonymous_args = 0 + mov ip, sp + stmfd sp!, {r4, fp, ip, lr, pc} + mov r2, $0 + sub fp, ip, $4 + sub sp, sp, $32 + ldr r4, [fp, $4] + str r2, [fp, $-28] + add r3, fp, $28 + str r2, [fp, $-24] + str r2, [fp, $-48] + str r3, [fp, $-32] + bic sp, sp, $7 + ldr r0, [r4, $4] + sub r1, fp, $48 + mov lr, pc + ldr pc, [r4, $0] + ldr r2, [fp, $-24] + cmp r2, $0 + ldmeqea fp, {r4, fp, sp, pc} + cmp r2, $1 + beq L(36) + cmp r2, $2 + ldreqsb r0, [fp, $-40] + ldmeqea fp, {r4, fp, sp, pc} + cmp r2, $3 + beq L(36) + cmp r2, $4 + ldreqsh r0, [fp, $-40] + ldmeqea fp, {r4, fp, sp, pc} + cmp r2, $5 + ldreqh r0, [fp, $-40] + ldmeqea fp, {r4, fp, sp, pc} + cmp r2, $6 + beq L(40) + cmp r2, $7 + beq L(40) + cmp r2, $8 + beq L(40) + cmp r2, $9 + beq L(40) + sub r3, r2, $10 + cmp r3, $1 + bls L(41) + cmp r2, $12 + ldreq r0, [fp, $-40] // float + ldmeqea fp, {r4, fp, sp, pc} + cmp r2, $13 + beq L(41) + cmp r2, $14 + beq L(40) + cmp r2, $15 + ldmneea fp, {r4, fp, sp, pc} + ldr r3, [fp, $-48] + tst r3, $1024 + ldmeqea fp, {r4, fp, sp, pc} + ldr r3, [fp, $-20] + cmp r3, $1 + ldreq r3, [fp, $-28] + ldreqb r0, [r3, $0] // zero_extendqisi2 + ldmeqea fp, {r4, fp, sp, pc} + cmp r3, $2 + ldreq r3, [fp, $-28] + ldrne r3, [fp, $-28] + ldreqh r0, [r3, $0] + ldrne r0, [r3, $0] + ldmea fp, {r4, fp, sp, pc} +L(40): + ldr r0, [fp, $-40] + ldmea fp, {r4, fp, sp, pc} +L(41): + sub r0, fp, $40 + ldmia r0, {r0, r1} // phole ldm + ldmea fp, {r4, fp, sp, pc} +L(36): + ldrb r0, [fp, $-40] // zero_extendqisi2 + ldmea fp, {r4, fp, sp, pc} +L(fe1): + FUNEND(callback_receiver) + .align 2 + .global C(callback_get_receiver) + DECLARE_FUNCTION(callback_get_receiver) +FUNBEGIN(callback_get_receiver) + // args = 0, pretend = 0, frame = 0 + // frame_needed = 1, uses_anonymous_args = 0 + mov ip, sp + stmfd sp!, {sl, fp, ip, lr, pc} + ldr sl, L(44) + ldr r3, L(44)+4 +L(43): + add sl, pc, sl + sub fp, ip, $4 + add r0, sl, r3 + ldmea fp, {sl, fp, sp, pc} +L(45): + .align 2 +L(44): + .word _GLOBAL_OFFSET_TABLE_-(L(43)+8) + .word callback_receiver(GOTOFF) +L(fe2): + FUNEND(callback_get_receiver) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",%progbits +#endif diff --git a/callback/vacall_r/vacall-arm64-macro.S b/callback/vacall_r/vacall-arm64-macro.S new file mode 100644 index 0000000..9f275fd --- /dev/null +++ b/callback/vacall_r/vacall-arm64-macro.S @@ -0,0 +1,190 @@ +#include "asm-arm.h" + .cpu generic+fp+simd + .text + .align 2 + .p2align 3,,7 + .type callback_receiver, %function +FUNBEGIN(callback_receiver) + stp x29, x30, [sp, -256]! + add x29, sp, 0 + ldr x10, [x18] + add x11, x29, 256 + stp s0, s1, [x29, 156] + stp s2, s3, [x29, 164] + stp x0, x1, [x29, 88] + stp s4, s5, [x29, 172] + stp x11, xzr, [x29, 40] + stp s6, s7, [x29, 180] + str x8, [x29, 72] + stp d0, d1, [x29, 192] + stp x2, x3, [x29, 104] + stp d2, d3, [x29, 208] + stp x4, x5, [x29, 120] + stp d4, d5, [x29, 224] + stp x6, x7, [x29, 136] + stp d6, d7, [x29, 240] + str wzr, [x29, 16] + add x1, x29, 16 + str wzr, [x29, 56] + ldr x0, [x18, 8] + str wzr, [x29, 80] + str wzr, [x29, 152] + blr x10 + ldr w9, [x29, 56] + cbz w9, L(1) + cmp w9, 1 + beq L(25) + cmp w9, 2 + beq L(29) + cmp w9, 3 + beq L(25) + cmp w9, 4 + beq L(30) + cmp w9, 5 + beq L(31) + cmp w9, 6 + beq L(32) + cmp w9, 7 + beq L(33) + and w10, w9, -3 + cmp w10, 8 + beq L(27) + cmp w10, 9 + beq L(27) + cmp w9, 12 + beq L(34) + cmp w9, 13 + beq L(35) + cmp w9, 14 + beq L(27) + cmp w9, 15 + bne L(1) + ldr w9, [x29, 16] + tbz x9, 10, L(1) + ldr x9, [x29, 64] + sub x10, x9, $1 + cmp x10, 15 + bhi L(1) + ldr x11, [x29, 48] + cmp x9, 8 + and x10, x11, 7 + and x11, x11, -8 + add x9, x9, x10 + bhi L(15) + cmp x9, 8 + lsl w9, w9, 3 + bhi L(16) + mov x12, 2 + sub w9, w9, $1 + lsl x9, x12, x9 + ldr x11, [x11] + sub x9, x9, $1 + lsl w10, w10, 3 + and x9, x9, x11 + asr x0, x9, x10 +L(1): + ldp x29, x30, [sp], 256 + ret + .p2align 3 +L(25): + ldrb w0, [x29, 24] + ldp x29, x30, [sp], 256 + ret + .p2align 3 +L(27): + ldr x0, [x29, 24] + b L(1) + .p2align 3 +L(29): + ldrsb x0, [x29, 24] + b L(1) + .p2align 3 +L(30): + ldrsh x0, [x29, 24] + b L(1) + .p2align 3 +L(31): + ldrh w0, [x29, 24] + b L(1) + .p2align 3 +L(32): + ldrsw x0, [x29, 24] + b L(1) + .p2align 3 +L(33): + ldr w0, [x29, 24] + b L(1) +L(34): + ldr s0, [x29, 24] + b L(1) +L(35): + ldr d0, [x29, 24] + b L(1) +L(15): + cmp x9, 16 + lsl w9, w9, 3 + bls L(36) + mov x13, 2 + sub w9, w9, $129 + ldp x14, x12, [x11, 8] + lsl x9, x13, x9 + lsl w15, w10, 3 + sub x9, x9, $1 + neg w10, w10, lsl 3 + ldr x11, [x11] + add w10, w10, 64 + and x9, x9, x12 + lsl x16, x14, x10 + asr x11, x11, x15 + asr x14, x14, x15 + lsl x10, x9, x10 + orr x0, x11, x16 + orr x1, x10, x14 + b L(1) +L(16): + mov w13, -8 + mov x14, 2 + sub w9, w9, $65 + lsl w15, w10, 3 + ldr x12, [x11, 8] + lsl x9, x14, x9 + mul w10, w13, w10 + sub x9, x9, $1 + ldr x11, [x11] + add w10, w10, 64 + and x9, x9, x12 + asr x11, x11, x15 + lsl x9, x9, x10 + orr x0, x9, x11 + b L(1) +L(36): + mov w13, -4 + mov x14, 2 + sub w9, w9, $65 + lsl w15, w10, 3 + ldr x12, [x11, 8] + lsl x9, x14, x9 + mul w10, w13, w10 + sub x9, x9, $1 + ldr x11, [x11] + add w10, w10, 32 + and x9, x9, x12 + asr x1, x9, x15 + lsl x9, x9, x10 + asr x11, x11, x15 + lsl x9, x9, x10 + orr x0, x11, x9 + b L(1) + FUNEND(callback_receiver) + .align 2 + .p2align 3,,7 + .global C(callback_get_receiver) + .type callback_get_receiver, %function +FUNBEGIN(callback_get_receiver) + adrp x9, callback_receiver + add x0, x9, :lo12:callback_receiver + ret + FUNEND(callback_get_receiver) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",%progbits +#endif diff --git a/callback/vacall_r/vacall-armhf-macro.S b/callback/vacall_r/vacall-armhf-macro.S new file mode 100644 index 0000000..f9e743a --- /dev/null +++ b/callback/vacall_r/vacall-armhf-macro.S @@ -0,0 +1,167 @@ +#include "asm-arm.h" + .arch armv6 + .eabi_attribute 28, 1 + .eabi_attribute 20, 1 + .eabi_attribute 21, 1 + .eabi_attribute 23, 3 + .eabi_attribute 24, 1 + .eabi_attribute 25, 1 + .eabi_attribute 26, 1 + .eabi_attribute 30, 2 + .eabi_attribute 34, 1 + .eabi_attribute 18, 4 + .text + .align 2 + .global C(callback_receiver) + .syntax unified + .arm + .fpu vfpv3-d16 + .type callback_receiver, %function +FUNBEGIN(callback_receiver) + // args = 28, pretend = 0, frame = 176 + // frame_needed = 1, uses_anonymous_args = 0 + push {fp, lr} + add fp, sp, $4 + sub sp, sp, $176 + ldr r2, [fp, $4] + mov r3, $0 + add lr, fp, $28 + add ip, fp, $44 + vstr.32 s0, [fp, $-136] + vstr.32 s1, [fp, $-132] + vstr.32 s2, [fp, $-128] + vstr.32 s3, [fp, $-124] + vstr.32 s4, [fp, $-120] + vstr.32 s5, [fp, $-116] + vstr.32 s6, [fp, $-112] + vstr.32 s7, [fp, $-108] + vstr.32 s8, [fp, $-104] + vstr.32 s9, [fp, $-100] + vstr.32 s10, [fp, $-96] + vstr.32 s11, [fp, $-92] + vstr.32 s12, [fp, $-88] + vstr.32 s13, [fp, $-84] + vstr.32 s14, [fp, $-80] + vstr.32 s15, [fp, $-76] + vstr.64 d0, [fp, $-68] + vstr.64 d1, [fp, $-60] + vstr.64 d2, [fp, $-52] + vstr.64 d3, [fp, $-44] + vstr.64 d4, [fp, $-36] + vstr.64 d5, [fp, $-28] + vstr.64 d6, [fp, $-20] + vstr.64 d7, [fp, $-12] + str r3, [fp, $-180] + str r3, [fp, $-144] + str r3, [fp, $-140] + str r3, [fp, $-160] + strb r3, [fp, $-156] + sub r1, fp, $180 + str lr, [fp, $-148] + ldr r3, [r2] + str ip, [fp, $-164] + ldr r0, [r2, $4] + blx r3 + ldrb r3, [fp, $-156] // zero_extendqisi2 + cmp r3, $0 + beq L(1) + cmp r3, $1 + beq L(25) + cmp r3, $2 + ldrsbeq r0, [fp, $-172] + beq L(1) + cmp r3, $3 + beq L(25) + cmp r3, $4 + ldrsheq r0, [fp, $-172] + beq L(1) + cmp r3, $5 + ldrheq r0, [fp, $-172] + beq L(1) + cmp r3, $6 + beq L(27) + cmp r3, $7 + beq L(27) + cmp r3, $8 + beq L(27) + cmp r3, $9 + beq L(27) + sub r2, r3, $10 + cmp r2, $1 + bls L(29) + cmp r3, $12 + vldreq.32 s0, [fp, $-172] + beq L(1) + cmp r3, $13 + beq L(30) + cmp r3, $14 + beq L(27) + cmp r3, $15 + bne L(1) + ldr r3, [fp, $-180] + tst r3, $1024 + beq L(1) + ldr r3, [fp, $-152] + cmp r3, $1 + beq L(31) + cmp r3, $2 + ldr r3, [fp, $-160] + ldrheq r0, [r3] + ldrne r0, [r3] +L(1): + sub sp, fp, $4 + // sp needed + pop {fp, pc} +L(25): + ldrb r0, [fp, $-172] // zero_extendqisi2 + sub sp, fp, $4 + // sp needed + pop {fp, pc} +L(27): + ldr r0, [fp, $-172] + sub sp, fp, $4 + // sp needed + pop {fp, pc} +L(30): + vldr.64 d0, [fp, $-172] + b L(1) +L(29): + ldr r0, [fp, $-172] + ldr r1, [fp, $-168] + b L(1) +L(31): + ldr r3, [fp, $-160] + ldrb r0, [r3] // zero_extendqisi2 + b L(1) + FUNEND(callback_receiver) + .align 2 + .global C(callback_get_receiver) + .syntax unified + .arm + .fpu vfpv3-d16 + .type callback_get_receiver, %function +FUNBEGIN(callback_get_receiver) + // args = 0, pretend = 0, frame = 0 + // frame_needed = 1, uses_anonymous_args = 0 + // link register save eliminated. + ldr r3, L(34) + ldr r2, L(34)+4 +L(PIC0): + add r3, pc, r3 + str fp, [sp, $-4]! + add fp, sp, $0 + ldr r3, [r3, r2] + mov r0, r3 + add sp, fp, $0 + // sp needed + ldr fp, [sp], $4 + bx lr +L(35): + .align 2 +L(34): + .word _GLOBAL_OFFSET_TABLE_-(L(PIC0)+8) + .word callback_receiver(GOT) + FUNEND(callback_get_receiver) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",%progbits +#endif diff --git a/callback/vacall_r/vacall-hppa-linux.s b/callback/vacall_r/vacall-hppa-linux.s new file mode 100644 index 0000000..bc5c935 --- /dev/null +++ b/callback/vacall_r/vacall-hppa-linux.s @@ -0,0 +1,218 @@ + .LEVEL 1.1 + .text + .align 4 + .type callback_receiver,@function +callback_receiver: + .PROC + .CALLINFO FRAME=192,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=5 + .ENTRY + copy %r3,%r1 + stw %r2,-20(%r30) + copy %r30,%r3 + stwm %r1,192(%r30) + ldo -32(%r3),%r2 + ldo 16(%r3),%r21 + ldo 88(%r3),%r20 + stw %r5,96(%r3) + sub %r21,%r2,%r31 + copy %r19,%r5 + stw %r4,100(%r3) + ldo 80(%r31),%r4 + ldo 64(%r31),%r31 + stw %r19,-32(%r30) + stw %r25,-40(%r3) + copy %r21,%r25 + ldo 80(%r3),%r21 + fstds %fr5,0(%r20) + ldo 76(%r3),%r20 + fstws %fr4L,0(%r20) + ldo 68(%r3),%r20 + stw %r0,36(%r3) + stw %r28,48(%r3) + fstds %fr7,0(%r21) + ldo 72(%r3),%r21 + fstws %fr5L,0(%r21) + ldo 64(%r3),%r21 + fstws %fr6L,0(%r20) + ldo -48(%r3),%r20 + stw %r26,-36(%r3) + fstws %fr7L,0(%r21) + ldw 0(%r29),%r22 + stw %r20,52(%r3) + stw %r31,56(%r3) + stw %r4,60(%r3) + stw %r24,-44(%r3) + stw %r23,-48(%r3) + stw %r0,16(%r3) + stw %r2,32(%r3) + stw %r0,40(%r3) + ldw 4(%r29),%r26 + .CALL ARGW0=GR + bl $$dyncall,%r31 + copy %r31,%r2 + ldw 40(%r3),%r21 + comib,= 0,%r21,.L1 + copy %r5,%r19 + comib,= 1,%r21,.L48 + ldb 24(%r3),%r20 + comib,=,n 2,%r21,.L48 + comib,=,n 3,%r21,.L43 + comib,=,n 4,%r21,.L44 + comib,=,n 5,%r21,.L45 + comib,=,n 6,%r21,.L41 + comib,=,n 7,%r21,.L41 + comib,=,n 8,%r21,.L41 + comib,= 9,%r21,.L41 + ldo -10(%r21),%r20 + comib,<<,n 1,%r20,.L22 + ldw 24(%r3),%r28 +.L40: + ldw 28(%r3),%r29 +.L1: + ldw -20(%r3),%r2 +.L49: +.L50: + ldw 96(%r3),%r5 + ldw 100(%r3),%r4 + ldo 64(%r3),%r30 + bv %r0(%r2) + ldwm -64(%r30),%r3 +.L22: + comib,= 12,%r21,.L46 + ldo 24(%r3),%r20 + comib,=,n 13,%r21,.L47 + comib,=,n 14,%r21,.L1 + ldw 24(%r3),%r28 + comib,<> 15,%r21,.L49 + ldw -20(%r3),%r2 + ldw 16(%r3),%r20 + bb,>= %r20,30,.L49 + ldw 44(%r3),%r4 + ldo -1(%r4),%r20 + comib,<< 7,%r20,.L50 + ldw 36(%r3),%r20 + extru %r20,31,2,%r31 + copy %r20,%r2 + depi 0,31,2,%r2 + comib,<< 4,%r4,.L33 + addl %r31,%r4,%r5 + zdep %r31,28,29,%r31 + mtsar %r31 + zvdepi 2,32,%r20 + comib,<< 4,%r5,.L34 + ldo -1(%r20),%r31 + ldw 0(%r2),%r20 + zdep %r5,28,29,%r21 + ldo -1(%r21),%r21 + and %r20,%r31,%r20 + mtsar %r21 + vextrs %r20,32,%r20 + movb,tr %r20,%r28,.L49 + ldw -20(%r3),%r2 +.L34: + ldw 0(%r2),%r20 + zdep %r5,28,29,%r22 + ldw 4(%r2),%r21 + and %r20,%r31,%r20 + ldo -33(%r22),%r2 + subi 63,%r22,%r22 + mtsar %r22 + zvdep %r20,32,%r20 + mtsar %r2 + vextrs %r21,32,%r21 +.L39: + b .L1 + or %r21,%r20,%r28 +.L33: + zdep %r31,28,29,%r31 + mtsar %r31 + zvdepi 2,32,%r20 + comib,<< 8,%r5,.L37 + ldo -1(%r20),%r4 + ldw 0(%r2),%r22 + zdep %r5,29,30,%r20 + and %r22,%r4,%r22 + ldw 4(%r2),%r31 + subi 47,%r20,%r4 + zdep %r5,28,29,%r20 + mtsar %r4 + ldo -33(%r20),%r20 + zvdep %r22,32,%r21 + zvdep %r21,32,%r21 + mtsar %r20 + vextrs %r31,32,%r31 + vextrs %r22,32,%r22 + movb,tr %r22,%r28,.L1 + or %r21,%r31,%r29 +.L37: + ldw 0(%r2),%r21 + zdep %r5,28,29,%r31 + ldw 8(%r2),%r22 + and %r21,%r4,%r21 + ldo -65(%r31),%r4 + ldw 4(%r2),%r20 + mtsar %r4 + subi 95,%r31,%r2 + vextrs %r22,32,%r22 + mtsar %r2 + zvdep %r20,32,%r31 + zvdep %r21,32,%r21 + or %r31,%r22,%r29 + mtsar %r4 + b .L39 + vextrs %r20,32,%r20 +.L41: + b .L1 + ldw 24(%r3),%r28 +.L47: + ldw 24(%r3),%r28 + b .L40 + fldds 0(%r20),%fr4 +.L46: + ldw 24(%r3),%r28 + b .L1 + fldws 0(%r20),%fr4L +.L45: + b .L1 + ldh 24(%r3),%r28 +.L44: + ldh 24(%r3),%r20 + b .L1 + extrs %r20,31,16,%r28 +.L43: + b .L1 + ldb 24(%r3),%r28 +.L48: + b .L1 + extrs %r20,31,8,%r28 + .EXIT + .PROCEND +.Lfe1: + .size callback_receiver,.Lfe1-callback_receiver + .data + .align 4 +.LC0: + .word P%callback_receiver + .text + .align 4 +.globl callback_get_receiver + .type callback_get_receiver,@function +callback_get_receiver: + .PROC + .CALLINFO FRAME=64,NO_CALLS,SAVE_SP,ENTRY_GR=3 + .ENTRY + copy %r3,%r1 + copy %r30,%r3 + stwm %r1,64(%r30) + addil LT'.LC0,%r19 + stw %r19,-32(%r30) + ldw RT'.LC0(%r1),%r1 + ldw 0(%r1),%r28 + ldo 64(%r3),%r30 + bv %r0(%r2) + ldwm -64(%r30),%r3 + .EXIT + .PROCEND +.Lfe2: + .size callback_get_receiver,.Lfe2-callback_get_receiver + .ident "GCC: (GNU) 3.1" diff --git a/callback/vacall_r/vacall-hppa-macro.S b/callback/vacall_r/vacall-hppa-macro.S new file mode 100644 index 0000000..d5613be --- /dev/null +++ b/callback/vacall_r/vacall-hppa-macro.S @@ -0,0 +1,224 @@ +#include "asm-hppa.h" + .LEVEL 1.1 + IMPORT_MILLICODE($$dyncall) + TEXT1() + TEXT2() + .align 4 + DECLARE_FUNCTION(callback_receiver) +DEF(callback_receiver) + .PROC + .CALLINFO FRAME=192,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=5 + .ENTRY + copy %r3,%r1 + stw %r2,-20(%r30) + copy %r30,%r3 + stwm %r1,192(%r30) + ldo -32(%r3),%r2 + ldo 16(%r3),%r21 + ldo 88(%r3),%r20 + stw %r5,96(%r3) + sub %r21,%r2,%r31 + copy %r19,%r5 + stw %r4,100(%r3) + ldo 80(%r31),%r4 + ldo 64(%r31),%r31 + stw %r19,-32(%r30) + stw %r25,-40(%r3) + copy %r21,%r25 + ldo 80(%r3),%r21 + fstds %fr5,0(%r20) + ldo 76(%r3),%r20 + fstws %fr4L,0(%r20) + ldo 68(%r3),%r20 + stw %r0,36(%r3) + stw %r28,48(%r3) + fstds %fr7,0(%r21) + ldo 72(%r3),%r21 + fstws %fr5L,0(%r21) + ldo 64(%r3),%r21 + fstws %fr6L,0(%r20) + ldo -48(%r3),%r20 + stw %r26,-36(%r3) + fstws %fr7L,0(%r21) + ldw 0(%r29),%r22 + stw %r20,52(%r3) + stw %r31,56(%r3) + stw %r4,60(%r3) + stw %r24,-44(%r3) + stw %r23,-48(%r3) + stw %r0,16(%r3) + stw %r2,32(%r3) + stw %r0,40(%r3) + ldw 4(%r29),%r26 + .CALL ARGW0=GR + bl $$dyncall,%r31 + copy %r31,%r2 + ldw 40(%r3),%r21 + comib,= 0,%r21,L(1) + copy %r5,%r19 + comib,= 1,%r21,L(48) + ldb 24(%r3),%r20 + comib,=,n 2,%r21,L(48) + comib,=,n 3,%r21,L(43) + comib,=,n 4,%r21,L(44) + comib,=,n 5,%r21,L(45) + comib,=,n 6,%r21,L(41) + comib,=,n 7,%r21,L(41) + comib,=,n 8,%r21,L(41) + comib,= 9,%r21,L(41) + ldo -10(%r21),%r20 + comib,<<,n 1,%r20,L(22) + ldw 24(%r3),%r28 +DEF(L(40)) + ldw 28(%r3),%r29 +DEF(L(1)) + ldw -20(%r3),%r2 +DEF(L(49)) +DEF(L(50)) + ldw 96(%r3),%r5 + ldw 100(%r3),%r4 + ldo 64(%r3),%r30 + bv %r0(%r2) + ldwm -64(%r30),%r3 +DEF(L(22)) + comib,= 12,%r21,L(46) + ldo 24(%r3),%r20 + comib,=,n 13,%r21,L(47) + comib,=,n 14,%r21,L(1) + ldw 24(%r3),%r28 + comib,<> 15,%r21,L(49) + ldw -20(%r3),%r2 + ldw 16(%r3),%r20 + bb,>= %r20,30,L(49) + ldw 44(%r3),%r4 + ldo -1(%r4),%r20 + comib,<< 7,%r20,L(50) + ldw 36(%r3),%r20 + extru %r20,31,2,%r31 + copy %r20,%r2 + depi 0,31,2,%r2 + comib,<< 4,%r4,L(33) + addl %r31,%r4,%r5 + zdep %r31,28,29,%r31 + mtsar %r31 + zvdepi 2,32,%r20 + comib,<< 4,%r5,L(34) + ldo -1(%r20),%r31 + ldw 0(%r2),%r20 + zdep %r5,28,29,%r21 + ldo -1(%r21),%r21 + and %r20,%r31,%r20 + mtsar %r21 + vextrs %r20,32,%r20 + movb,tr %r20,%r28,L(49) + ldw -20(%r3),%r2 +DEF(L(34)) + ldw 0(%r2),%r20 + zdep %r5,28,29,%r22 + ldw 4(%r2),%r21 + and %r20,%r31,%r20 + ldo -33(%r22),%r2 + subi 63,%r22,%r22 + mtsar %r22 + zvdep %r20,32,%r20 + mtsar %r2 + vextrs %r21,32,%r21 +DEF(L(39)) + b L(1) + or %r21,%r20,%r28 +DEF(L(33)) + zdep %r31,28,29,%r31 + mtsar %r31 + zvdepi 2,32,%r20 + comib,<< 8,%r5,L(37) + ldo -1(%r20),%r4 + ldw 0(%r2),%r22 + zdep %r5,29,30,%r20 + and %r22,%r4,%r22 + ldw 4(%r2),%r31 + subi 47,%r20,%r4 + zdep %r5,28,29,%r20 + mtsar %r4 + ldo -33(%r20),%r20 + zvdep %r22,32,%r21 + zvdep %r21,32,%r21 + mtsar %r20 + vextrs %r31,32,%r31 + vextrs %r22,32,%r22 + movb,tr %r22,%r28,L(1) + or %r21,%r31,%r29 +DEF(L(37)) + ldw 0(%r2),%r21 + zdep %r5,28,29,%r31 + ldw 8(%r2),%r22 + and %r21,%r4,%r21 + ldo -65(%r31),%r4 + ldw 4(%r2),%r20 + mtsar %r4 + subi 95,%r31,%r2 + vextrs %r22,32,%r22 + mtsar %r2 + zvdep %r20,32,%r31 + zvdep %r21,32,%r21 + or %r31,%r22,%r29 + mtsar %r4 + b L(39) + vextrs %r20,32,%r20 +DEF(L(41)) + b L(1) + ldw 24(%r3),%r28 +DEF(L(47)) + ldw 24(%r3),%r28 + b L(40) + fldds 0(%r20),%fr4 +DEF(L(46)) + ldw 24(%r3),%r28 + b L(1) + fldws 0(%r20),%fr4L +DEF(L(45)) + b L(1) + ldh 24(%r3),%r28 +DEF(L(44)) + ldh 24(%r3),%r20 + b L(1) + extrs %r20,31,16,%r28 +DEF(L(43)) + b L(1) + ldb 24(%r3),%r28 +DEF(L(48)) + b L(1) + extrs %r20,31,8,%r28 + .EXIT + .PROCEND +DEF(L(fe1)) + FUNEND(callback_receiver) + .data + .align 4 +DEF(L(C0)) + .word P%callback_receiver + TEXT1() + TEXT2() + .align 4 +GLOBL(callback_get_receiver) + DECLARE_FUNCTION(callback_get_receiver) +DEF(callback_get_receiver) + .PROC + .CALLINFO FRAME=64,NO_CALLS,SAVE_SP,ENTRY_GR=3 + .ENTRY + copy %r3,%r1 + copy %r30,%r3 + stwm %r1,64(%r30) + addil LT!L(C0),%r19 + stw %r19,-32(%r30) + ldw RT!L(C0)(%r1),%r1 + ldw 0(%r1),%r28 + ldo 64(%r3),%r30 + bv %r0(%r2) + ldwm -64(%r30),%r3 + .EXIT + .PROCEND +DEF(L(fe2)) + FUNEND(callback_get_receiver) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/callback/vacall_r/vacall-hppa64-linux.s b/callback/vacall_r/vacall-hppa64-linux.s new file mode 100644 index 0000000..6426765 --- /dev/null +++ b/callback/vacall_r/vacall-hppa64-linux.s @@ -0,0 +1,251 @@ + .LEVEL 2.0w + .text + .align 8 +.globl callback_receiver + .type callback_receiver,@function +callback_receiver: + .PROC + .CALLINFO FRAME=384,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=9 + .ENTRY + copy %r3,%r1 + std %r2,-16(%r30) + copy %r30,%r3 + std,ma %r1,384(%r30) + std %r5,224(%r3) + copy %r27,%r5 + std %r9,192(%r3) + std %r8,200(%r3) + std %r7,208(%r3) + std %r6,216(%r3) + std %r4,232(%r3) + std %r26,-64(%r29) + std %r25,-56(%r29) + std %r19,-8(%r29) + std %r24,-48(%r29) + std %r23,-40(%r29) + std %r22,-32(%r29) + std %r21,-24(%r29) + std %r20,-16(%r29) +#APP + fstw %fr4R,88(%r3) + fstw %fr5R,92(%r3) + fstw %fr6R,96(%r3) + fstw %fr7R,100(%r3) + fstw %fr8R,104(%r3) + fstw %fr9R,108(%r3) + fstw %fr10R,112(%r3) + fstw %fr11R,116(%r3) +#NO_APP + fstd %fr10,168(%r3) + ldo -64(%r29),%r2 + ldo 16(%r3),%r25 + std %r0,48(%r3) + std %r2,40(%r3) + std %r29,80(%r3) + ldo -16(%r30),%r29 + fstd %fr11,176(%r3) + fstd %fr4,120(%r3) + fstd %fr5,128(%r3) + fstd %fr6,136(%r3) + fstd %fr7,144(%r3) + fstd %fr8,152(%r3) + fstd %fr9,160(%r3) + stw %r0,16(%r3) + stw %r0,56(%r3) + ldd 0(%r31),%r4 + ldd 8(%r31),%r26 + ldd 16(%r4),%r2 + ldd 24(%r4),%r27 + bve,l (%r2),%r2 + nop + ldw 56(%r3),%r2 + cmpib,= 0,%r2,.L1 + copy %r5,%r27 + cmpib,=,n 1,%r2,.L43 + cmpib,=,n 2,%r2,.L43 + cmpib,=,n 3,%r2,.L44 + cmpib,=,n 4,%r2,.L45 + cmpib,=,n 5,%r2,.L46 + cmpib,=,n 6,%r2,.L47 + cmpib,=,n 7,%r2,.L41 + cmpib,=,n 8,%r2,.L40 + cmpib,=,n 10,%r2,.L40 + cmpib,=,n 9,%r2,.L40 + cmpib,=,n 11,%r2,.L40 + cmpib,=,n 12,%r2,.L48 + cmpib,=,n 13,%r2,.L49 + cmpib,=,n 14,%r2,.L40 + cmpib,= 15,%r2,.L50 + ldw 16(%r3),%r2 +.L1: + ldd -16(%r3),%r2 + ldd 192(%r3),%r9 + ldd 200(%r3),%r8 + ldd 208(%r3),%r7 + ldd 216(%r3),%r6 + ldd 224(%r3),%r5 + ldd 232(%r3),%r4 + ldo 64(%r3),%r30 + bve (%r2) + ldd,mb -64(%r30),%r3 +.L50: + extrd,u %r2,53+1-1,1,%r2 + cmpib,= 0,%r2,.L1 + ldd 48(%r3),%r28 + ldd 48(%r3),%r2 + ldd 64(%r3),%r4 + extrd,u %r2,63,3,%r7 + copy %r2,%r1 + depdi 0,63,3,%r1 + cmpib,*<< 8,%r4,.L32 + add,l %r7,%r4,%r5 + cmpib,*<< 8,%r5,.L33 + depd,z %r5,60,61,%r2 + subi 64,%r2,%r2 + ldd 0(%r1),%r4 + extrd,s %r2,63,32,%r2 + mtsarcm %r2 + depd,z %r7,60,61,%r5 + depdi,z 1,%sar,64,%r2 + mtsarcm %r5 + sub %r0,%r2,%r2 + and %r4,%r2,%r4 + depd,z %r4,%sar,64,%r4 + b .L1 + copy %r4,%r28 +.L33: + subi 128,%r2,%r2 + depd,z %r7,60,61,%r4 + extrd,s %r2,63,32,%r2 + subi 64,%r4,%r6 + mtsarcm %r2 + subi 63,%r4,%r8 + depdi,z 1,%sar,64,%r2 + mtsar %r8 + ldd 8(%r1),%r5 + sub %r0,%r2,%r2 + extrd,s %r6,63,32,%r6 + ldd 0(%r1),%r4 + subi 63,%r6,%r6 + and %r5,%r2,%r5 + depd,z %r4,%sar,64,%r4 + mtsar %r6 + extrd,s %r5,%sar,64,%r5 +.L39: + b .L1 + or %r5,%r4,%r28 +.L32: + ldi 16,%r2 + cmpb,*<< %r2,%r5,.L36 + depd,z %r5,60,61,%r2 + subi 128,%r2,%r2 + depd,z %r7,61,62,%r4 + extrd,s %r2,63,32,%r2 + subi 32,%r4,%r4 + mtsarcm %r2 + extrd,s %r4,63,32,%r4 + depdi,z 1,%sar,64,%r2 + subi 63,%r4,%r8 + ldd 8(%r1),%r5 + sub %r0,%r2,%r2 + mtsar %r8 + ldd 0(%r1),%r6 + and %r5,%r2,%r5 + depd,z %r7,60,61,%r2 + extrd,s %r5,%sar,64,%r4 + subi 63,%r2,%r2 + extrd,s %r4,%sar,64,%r4 + mtsar %r2 + depd,z %r5,%sar,64,%r5 + depd,z %r6,%sar,64,%r6 + copy %r5,%r29 + b .L1 + or %r6,%r4,%r28 +.L36: + subi 192,%r2,%r2 + depd,z %r7,60,61,%r4 + extrd,s %r2,63,32,%r2 + subi 64,%r4,%r7 + mtsarcm %r2 + subi 63,%r4,%r9 + depdi,z 1,%sar,64,%r2 + mtsar %r9 + ldd 8(%r1),%r4 + sub %r0,%r2,%r2 + ldd 16(%r1),%r6 + extrd,s %r7,63,32,%r7 + subi 63,%r7,%r7 + and %r6,%r2,%r6 + ldd 0(%r1),%r5 + depd,z %r4,%sar,64,%r2 + mtsar %r7 + extrd,s %r6,%sar,64,%r6 + mtsar %r9 + depd,z %r5,%sar,64,%r5 + or %r2,%r6,%r29 + mtsar %r7 + b .L39 + extrd,s %r4,%sar,64,%r4 +.L40: + b .L1 + ldd 24(%r3),%r28 +.L49: + b .L40 + fldd 24(%r3),%fr4 +.L48: +#APP + fldw 24(%r3),%fr4R +#NO_APP +.L41: + ldw 24(%r3),%r2 +.L42: + b .L1 + copy %r2,%r28 +.L47: + ldw 24(%r3),%r2 + b .L1 + extrd,s %r2,63,32,%r28 +.L46: + b .L42 + ldh 24(%r3),%r2 +.L45: + ldh 24(%r3),%r2 + b .L1 + extrd,s %r2,63,16,%r28 +.L44: + b .L42 + ldb 24(%r3),%r2 +.L43: + ldb 24(%r3),%r2 + b .L1 + extrd,s %r2,63,8,%r28 + .EXIT + .PROCEND +.Lfe1: + .size callback_receiver,.Lfe1-callback_receiver + .data + .align 8 +.LC0: + .dword P%callback_receiver + .text + .align 8 +.globl callback_get_receiver + .type callback_get_receiver,@function +callback_get_receiver: + .PROC + .CALLINFO FRAME=128,NO_CALLS,SAVE_SP,ENTRY_GR=3 + .ENTRY + copy %r3,%r1 + copy %r30,%r3 + std,ma %r1,128(%r30) + addil LT'.LC0,%r27 + ldd RT'.LC0(%r1),%r1 + ldd 0(%r1),%r28 + ldo 64(%r3),%r30 + bve (%r2) + ldd,mb -64(%r30),%r3 + .EXIT + .PROCEND +.Lfe2: + .size callback_get_receiver,.Lfe2-callback_get_receiver + .ident "GCC: (GNU) 3.1" diff --git a/callback/vacall_r/vacall-hppa64-macro.S b/callback/vacall_r/vacall-hppa64-macro.S new file mode 100644 index 0000000..628dccf --- /dev/null +++ b/callback/vacall_r/vacall-hppa64-macro.S @@ -0,0 +1,252 @@ +#include "asm-hppa64.h" + .LEVEL 2.0w + TEXT1() + TEXT2() + .align 8 +GLOBL(callback_receiver) + DECLARE_FUNCTION(callback_receiver) +DEF(callback_receiver) + .PROC + .CALLINFO FRAME=384,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=9 + .ENTRY + copy %r3,%r1 + std %r2,-16(%r30) + copy %r30,%r3 + std,ma %r1,384(%r30) + std %r5,224(%r3) + copy %r27,%r5 + std %r9,192(%r3) + std %r8,200(%r3) + std %r7,208(%r3) + std %r6,216(%r3) + std %r4,232(%r3) + std %r26,-64(%r29) + std %r25,-56(%r29) + std %r19,-8(%r29) + std %r24,-48(%r29) + std %r23,-40(%r29) + std %r22,-32(%r29) + std %r21,-24(%r29) + std %r20,-16(%r29) + fstw %fr4R,88(%r3) + fstw %fr5R,92(%r3) + fstw %fr6R,96(%r3) + fstw %fr7R,100(%r3) + fstw %fr8R,104(%r3) + fstw %fr9R,108(%r3) + fstw %fr10R,112(%r3) + fstw %fr11R,116(%r3) + fstd %fr10,168(%r3) + ldo -64(%r29),%r2 + ldo 16(%r3),%r25 + std %r0,48(%r3) + std %r2,40(%r3) + std %r29,80(%r3) + ldo -16(%r30),%r29 + fstd %fr11,176(%r3) + fstd %fr4,120(%r3) + fstd %fr5,128(%r3) + fstd %fr6,136(%r3) + fstd %fr7,144(%r3) + fstd %fr8,152(%r3) + fstd %fr9,160(%r3) + stw %r0,16(%r3) + stw %r0,56(%r3) + ldd 0(%r31),%r4 + ldd 8(%r31),%r26 + ldd 16(%r4),%r2 + ldd 24(%r4),%r27 + bve,l (%r2),%r2 + nop + ldw 56(%r3),%r2 + cmpib,= 0,%r2,L(1) + copy %r5,%r27 + cmpib,=,n 1,%r2,L(43) + cmpib,=,n 2,%r2,L(43) + cmpib,=,n 3,%r2,L(44) + cmpib,=,n 4,%r2,L(45) + cmpib,=,n 5,%r2,L(46) + cmpib,=,n 6,%r2,L(47) + cmpib,=,n 7,%r2,L(41) + cmpib,=,n 8,%r2,L(40) + cmpib,=,n 10,%r2,L(40) + cmpib,=,n 9,%r2,L(40) + cmpib,=,n 11,%r2,L(40) + cmpib,=,n 12,%r2,L(48) + cmpib,=,n 13,%r2,L(49) + cmpib,=,n 14,%r2,L(40) + cmpib,= 15,%r2,L(50) + ldw 16(%r3),%r2 +DEF(L(1)) + ldd -16(%r3),%r2 + ldd 192(%r3),%r9 + ldd 200(%r3),%r8 + ldd 208(%r3),%r7 + ldd 216(%r3),%r6 + ldd 224(%r3),%r5 + ldd 232(%r3),%r4 + ldo 64(%r3),%r30 + bve (%r2) + ldd,mb -64(%r30),%r3 +DEF(L(50)) + extrd,u %r2,53+1-1,1,%r2 + cmpib,= 0,%r2,L(1) + ldd 48(%r3),%r28 + ldd 48(%r3),%r2 + ldd 64(%r3),%r4 + extrd,u %r2,63,3,%r7 + copy %r2,%r1 + depdi 0,63,3,%r1 + cmpib,*<< 8,%r4,L(32) + add,l %r7,%r4,%r5 + cmpib,*<< 8,%r5,L(33) + depd,z %r5,60,61,%r2 + subi 64,%r2,%r2 + ldd 0(%r1),%r4 + extrd,s %r2,63,32,%r2 + mtsarcm %r2 + depd,z %r7,60,61,%r5 + depdi,z 1,%sar,64,%r2 + mtsarcm %r5 + sub %r0,%r2,%r2 + and %r4,%r2,%r4 + depd,z %r4,%sar,64,%r4 + b L(1) + copy %r4,%r28 +DEF(L(33)) + subi 128,%r2,%r2 + depd,z %r7,60,61,%r4 + extrd,s %r2,63,32,%r2 + subi 64,%r4,%r6 + mtsarcm %r2 + subi 63,%r4,%r8 + depdi,z 1,%sar,64,%r2 + mtsar %r8 + ldd 8(%r1),%r5 + sub %r0,%r2,%r2 + extrd,s %r6,63,32,%r6 + ldd 0(%r1),%r4 + subi 63,%r6,%r6 + and %r5,%r2,%r5 + depd,z %r4,%sar,64,%r4 + mtsar %r6 + extrd,s %r5,%sar,64,%r5 +DEF(L(39)) + b L(1) + or %r5,%r4,%r28 +DEF(L(32)) + ldi 16,%r2 + cmpb,*<< %r2,%r5,L(36) + depd,z %r5,60,61,%r2 + subi 128,%r2,%r2 + depd,z %r7,61,62,%r4 + extrd,s %r2,63,32,%r2 + subi 32,%r4,%r4 + mtsarcm %r2 + extrd,s %r4,63,32,%r4 + depdi,z 1,%sar,64,%r2 + subi 63,%r4,%r8 + ldd 8(%r1),%r5 + sub %r0,%r2,%r2 + mtsar %r8 + ldd 0(%r1),%r6 + and %r5,%r2,%r5 + depd,z %r7,60,61,%r2 + extrd,s %r5,%sar,64,%r4 + subi 63,%r2,%r2 + extrd,s %r4,%sar,64,%r4 + mtsar %r2 + depd,z %r5,%sar,64,%r5 + depd,z %r6,%sar,64,%r6 + copy %r5,%r29 + b L(1) + or %r6,%r4,%r28 +DEF(L(36)) + subi 192,%r2,%r2 + depd,z %r7,60,61,%r4 + extrd,s %r2,63,32,%r2 + subi 64,%r4,%r7 + mtsarcm %r2 + subi 63,%r4,%r9 + depdi,z 1,%sar,64,%r2 + mtsar %r9 + ldd 8(%r1),%r4 + sub %r0,%r2,%r2 + ldd 16(%r1),%r6 + extrd,s %r7,63,32,%r7 + subi 63,%r7,%r7 + and %r6,%r2,%r6 + ldd 0(%r1),%r5 + depd,z %r4,%sar,64,%r2 + mtsar %r7 + extrd,s %r6,%sar,64,%r6 + mtsar %r9 + depd,z %r5,%sar,64,%r5 + or %r2,%r6,%r29 + mtsar %r7 + b L(39) + extrd,s %r4,%sar,64,%r4 +DEF(L(40)) + b L(1) + ldd 24(%r3),%r28 +DEF(L(49)) + b L(40) + fldd 24(%r3),%fr4 +DEF(L(48)) + fldw 24(%r3),%fr4R +DEF(L(41)) + ldw 24(%r3),%r2 +DEF(L(42)) + b L(1) + copy %r2,%r28 +DEF(L(47)) + ldw 24(%r3),%r2 + b L(1) + extrd,s %r2,63,32,%r28 +DEF(L(46)) + b L(42) + ldh 24(%r3),%r2 +DEF(L(45)) + ldh 24(%r3),%r2 + b L(1) + extrd,s %r2,63,16,%r28 +DEF(L(44)) + b L(42) + ldb 24(%r3),%r2 +DEF(L(43)) + ldb 24(%r3),%r2 + b L(1) + extrd,s %r2,63,8,%r28 + .EXIT + .PROCEND +DEF(L(fe1)) + FUNEND(callback_receiver) + .data + .align 8 +DEF(L(C0)) + .dword P%callback_receiver + TEXT1() + TEXT2() + .align 8 +GLOBL(callback_get_receiver) + DECLARE_FUNCTION(callback_get_receiver) +DEF(callback_get_receiver) + .PROC + .CALLINFO FRAME=128,NO_CALLS,SAVE_SP,ENTRY_GR=3 + .ENTRY + copy %r3,%r1 + copy %r30,%r3 + std,ma %r1,128(%r30) + addil LT!L(C0),%r27 + ldd RT!L(C0)(%r1),%r1 + ldd 0(%r1),%r28 + ldo 64(%r3),%r30 + bve (%r2) + ldd,mb -64(%r30),%r3 + .EXIT + .PROCEND +DEF(L(fe2)) + FUNEND(callback_get_receiver) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/callback/vacall_r/vacall-i386-linux.s b/callback/vacall_r/vacall-i386-linux.s new file mode 100644 index 0000000..42dac11 --- /dev/null +++ b/callback/vacall_r/vacall-i386-linux.s @@ -0,0 +1,172 @@ + .file "vacall-i386.c" + .text + .align 2 + .p2align 2,,3 + .type callback_receiver,@function +callback_receiver: + pushl %ebp + movl %esp, %ebp + pushl %edi + pushl %esi + leal 8(%ebp), %edx + subl $56, %esp + movl %edx, -40(%ebp) + leal -56(%ebp), %edx + movl $0, -56(%ebp) + movl $0, -36(%ebp) + movl $0, -32(%ebp) + movl %ebx, -24(%ebp) + pushl %edx + pushl 4(%ecx) + call *(%ecx) + movl -32(%ebp), %esi + addl $16, %esp + testl %esi, %esi + je .L43 + cmpl $1, %esi + je .L44 + cmpl $2, %esi + je .L44 + cmpl $3, %esi + je .L49 + cmpl $4, %esi + je .L50 + cmpl $5, %esi + je .L51 + cmpl $6, %esi + je .L48 + cmpl $7, %esi + je .L48 + cmpl $8, %esi + je .L48 + cmpl $9, %esi + je .L48 + leal -10(%esi), %edx + cmpl $1, %edx + ja .L22 + movl -48(%ebp), %eax +#APP + movl -44(%ebp),%edx +.L33: + .p2align 2,,3 +#NO_APP +.L43: + movl -56(%ebp), %esi +.L3: + andl $512, %esi + je .L1 +#APP + movl 0(%ebp),%ecx +#NO_APP + movl -40(%ebp), %esp +#APP + jmp *%ecx +#NO_APP +.L1: + leal -8(%ebp), %esp + popl %esi + popl %edi + leave + ret +.L22: + cmpl $12, %esi + je .L52 + cmpl $13, %esi + je .L53 + cmpl $14, %esi + je .L48 + cmpl $15, %esi + jne .L43 + movl -56(%ebp), %esi + testl $1024, %esi + movl %esi, %edi + je .L31 + movl -28(%ebp), %edx + cmpl $1, %edx + je .L54 + cmpl $2, %edx + je .L55 + cmpl $4, %edx + je .L56 + cmpl $8, %edx + je .L57 +.L31: + andl $16, %edi + movl -36(%ebp), %eax + jne .L3 +#APP + leal -8(%ebp), %esp + popl %esi + popl %edi + leave + ret $4 +#NO_APP + jmp .L3 +.L57: + movl -36(%ebp), %edx + movl (%edx), %eax +#APP + movl 4(%edx),%edx +#NO_APP + jmp .L3 +.L56: + movl -36(%ebp), %edx + movl (%edx), %eax + jmp .L3 +.L55: + movl -36(%ebp), %edx + movzwl (%edx), %eax + jmp .L3 +.L54: + movl -36(%ebp), %edx + movzbl (%edx), %eax + jmp .L3 + .p2align 2,,3 +.L48: + movl -48(%ebp), %eax + jmp .L43 +.L53: +#APP + fldl -48(%ebp) +#NO_APP + jmp .L43 +.L52: +#APP + flds -48(%ebp) +#NO_APP + jmp .L43 + .p2align 2,,3 +.L51: + movzwl -48(%ebp), %eax + jmp .L43 +.L50: + movswl -48(%ebp),%eax + jmp .L43 +.L49: + movzbl -48(%ebp), %eax + jmp .L43 + .p2align 2,,3 +.L44: + movsbl -48(%ebp),%eax + jmp .L43 +.Lfe1: + .size callback_receiver,.Lfe1-callback_receiver + .align 2 + .p2align 2,,3 +.globl callback_get_receiver + .type callback_get_receiver,@function +callback_get_receiver: + pushl %ebp + movl %esp, %ebp + pushl %ebx + call .L59 +.L59: + popl %ebx + addl $_GLOBAL_OFFSET_TABLE_+[.-.L59], %ebx + leal callback_receiver@GOTOFF(%ebx), %eax + movl (%esp), %ebx + leave + ret +.Lfe2: + .size callback_get_receiver,.Lfe2-callback_get_receiver + .ident "GCC: (GNU) 3.1" diff --git a/callback/vacall_r/vacall-i386-macro.S b/callback/vacall_r/vacall-i386-macro.S new file mode 100644 index 0000000..ecc611b --- /dev/null +++ b/callback/vacall_r/vacall-i386-macro.S @@ -0,0 +1,167 @@ +#include "asm-i386.h" + TEXT() + ALIGN(2) + P2ALIGN(2,3) + DECLARE_FUNCTION(callback_receiver) +FUNBEGIN(callback_receiver) + INSN1(push,l ,R(ebp)) + INSN2(mov,l ,R(esp), R(ebp)) + INSN1(push,l ,R(edi)) + INSN1(push,l ,R(esi)) + INSN2(lea,l ,X4 MEM_DISP(ebp,8), R(edx)) + INSN2(sub,l ,NUM(56), R(esp)) + INSN2(mov,l ,R(edx),X4 MEM_DISP(ebp,-40)) + INSN2(lea,l ,X4 MEM_DISP(ebp,-56), R(edx)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(ebp,-56)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(ebp,-36)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(ebp,-32)) + INSN2(mov,l ,R(ebx),X4 MEM_DISP(ebp,-24)) + INSN1(push,l ,R(edx)) + INSN1(push,l ,X4 MEM_DISP(ecx,4)) + INSN1(call,_ ,INDIR(X4 MEM(ecx))) + INSN2(mov,l ,X4 MEM_DISP(ebp,-32), R(esi)) + INSN2(add,l ,NUM(16), R(esp)) + INSN2(test,l ,R(esi), R(esi)) + INSN1(je,_ ,L(43)) + INSN2(cmp,l ,NUM(1), R(esi)) + INSN1(je,_ ,L(44)) + INSN2(cmp,l ,NUM(2), R(esi)) + INSN1(je,_ ,L(44)) + INSN2(cmp,l ,NUM(3), R(esi)) + INSN1(je,_ ,L(49)) + INSN2(cmp,l ,NUM(4), R(esi)) + INSN1(je,_ ,L(50)) + INSN2(cmp,l ,NUM(5), R(esi)) + INSN1(je,_ ,L(51)) + INSN2(cmp,l ,NUM(6), R(esi)) + INSN1(je,_ ,L(48)) + INSN2(cmp,l ,NUM(7), R(esi)) + INSN1(je,_ ,L(48)) + INSN2(cmp,l ,NUM(8), R(esi)) + INSN1(je,_ ,L(48)) + INSN2(cmp,l ,NUM(9), R(esi)) + INSN1(je,_ ,L(48)) + INSN2(lea,l ,X4 MEM_DISP(esi,-10), R(edx)) + INSN2(cmp,l ,NUM(1), R(edx)) + INSN1(ja,_ ,L(22)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-48), R(eax)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-44),R(edx)) +L(33): + P2ALIGN(2,3) +L(43): + INSN2(mov,l ,X4 MEM_DISP(ebp,-56), R(esi)) +L(3): + INSN2(and,l ,NUM(512), R(esi)) + INSN1(je,_ ,L(1)) + INSN2(mov,l ,X4 MEM_DISP(ebp,0),R(ecx)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-40), R(esp)) + INSN1(jmp,_ ,INDIR(R(ecx))) +L(1): + INSN2(lea,l ,X4 MEM_DISP(ebp,-8), R(esp)) + INSN1(pop,l ,R(esi)) + INSN1(pop,l ,R(edi)) + leave + ret +L(22): + INSN2(cmp,l ,NUM(12), R(esi)) + INSN1(je,_ ,L(52)) + INSN2(cmp,l ,NUM(13), R(esi)) + INSN1(je,_ ,L(53)) + INSN2(cmp,l ,NUM(14), R(esi)) + INSN1(je,_ ,L(48)) + INSN2(cmp,l ,NUM(15), R(esi)) + INSN1(jne,_ ,L(43)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-56), R(esi)) + INSN2(test,l ,NUM(1024), R(esi)) + INSN2(mov,l ,R(esi), R(edi)) + INSN1(je,_ ,L(31)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-28), R(edx)) + INSN2(cmp,l ,NUM(1), R(edx)) + INSN1(je,_ ,L(54)) + INSN2(cmp,l ,NUM(2), R(edx)) + INSN1(je,_ ,L(55)) + INSN2(cmp,l ,NUM(4), R(edx)) + INSN1(je,_ ,L(56)) + INSN2(cmp,l ,NUM(8), R(edx)) + INSN1(je,_ ,L(57)) +L(31): + INSN2(and,l ,NUM(16), R(edi)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(eax)) + INSN1(jne,_ ,L(3)) + INSN2(lea,l ,X4 MEM_DISP(ebp,-8), R(esp)) + INSN1(pop,l ,R(esi)) + INSN1(pop,l ,R(edi)) + leave + ret NUM(4) + INSN1(jmp,_ ,L(3)) +L(57): + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(edx)) + INSN2(mov,l ,X4 MEM(edx), R(eax)) + INSN2(mov,l ,X4 MEM_DISP(edx,4),R(edx)) + INSN1(jmp,_ ,L(3)) +L(56): + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(edx)) + INSN2(mov,l ,X4 MEM(edx), R(eax)) + INSN1(jmp,_ ,L(3)) +L(55): + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(edx)) + INSN2MOVXL(movz,w,X2 MEM(edx), R(eax)) + INSN1(jmp,_ ,L(3)) +L(54): + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(edx)) + INSN2MOVXL(movz,b,X1 MEM(edx), R(eax)) + INSN1(jmp,_ ,L(3)) + P2ALIGN(2,3) +L(48): + INSN2(mov,l ,X4 MEM_DISP(ebp,-48), R(eax)) + INSN1(jmp,_ ,L(43)) +L(53): + INSN1(fld,l ,X8 MEM_DISP(ebp,-48)) + INSN1(jmp,_ ,L(43)) +L(52): + INSN1(fld,s ,X4 MEM_DISP(ebp,-48)) + INSN1(jmp,_ ,L(43)) + P2ALIGN(2,3) +L(51): + INSN2MOVXL(movz,w,X2 MEM_DISP(ebp,-48), R(eax)) + INSN1(jmp,_ ,L(43)) +L(50): + INSN2MOVXL(movs,w,X2 MEM_DISP(ebp,-48),R(eax)) + INSN1(jmp,_ ,L(43)) +L(49): + INSN2MOVXL(movz,b,X1 MEM_DISP(ebp,-48), R(eax)) + INSN1(jmp,_ ,L(43)) + P2ALIGN(2,3) +L(44): + INSN2MOVXL(movs,b,X1 MEM_DISP(ebp,-48),R(eax)) + INSN1(jmp,_ ,L(43)) +L(fe1): + FUNEND(callback_receiver,L(fe1)-callback_receiver) + ALIGN(2) + P2ALIGN(2,3) +GLOBL(C(callback_get_receiver)) + DECLARE_FUNCTION(callback_get_receiver) +FUNBEGIN(callback_get_receiver) + INSN1(push,l ,R(ebp)) + INSN2(mov,l ,R(esp), R(ebp)) + INSN1(push,l ,R(ebx)) + INSN1(call,_ ,L(59)) +L(59): + INSN1(pop,l ,R(ebx)) +#ifdef __ELF__ + INSN2(add,l ,NUM()_GLOBAL_OFFSET_TABLE_+[.-L(59)],R(ebx)) +#endif +#ifdef __ELF__ + INSN2(lea,l ,callback_receiver@MEM_DISP(ebx,GOTOFF), R(eax)) +#else + INSN2(lea,l ,C(callback_receiver)-L(59)MEM(ebx), R(eax)) +#endif + INSN2(mov,l ,X4 MEM(esp), R(ebx)) + leave + ret +L(fe2): + FUNEND(callback_get_receiver,L(fe2)-callback_get_receiver) + +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/callback/vacall_r/vacall-i386-msvc.c b/callback/vacall_r/vacall-i386-msvc.c new file mode 100644 index 0000000..339a063 --- /dev/null +++ b/callback/vacall_r/vacall-i386-msvc.c @@ -0,0 +1,166 @@ +#ifdef _MSC_VER +#include "vacall_r.h" +#endif +#include "asm-i386.h" + TEXT() + ALIGN(2) + P2ALIGN(2,3) + DECLARE_FUNCTION(callback_receiver) +FUNBEGIN(callback_receiver) + INSN1(push,l ,R(ebp)) + INSN2(mov,l ,R(esp), R(ebp)) + INSN1(push,l ,R(edi)) + INSN1(push,l ,R(esi)) + INSN2(lea,l ,X4 MEM_DISP(ebp,8), R(edx)) + INSN2(sub,l ,NUM(56), R(esp)) + INSN2(mov,l ,R(edx),X4 MEM_DISP(ebp,-40)) + INSN2(lea,l ,X4 MEM_DISP(ebp,-56), R(edx)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(ebp,-56)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(ebp,-36)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(ebp,-32)) + INSN2(mov,l ,R(ebx),X4 MEM_DISP(ebp,-24)) + INSN1(push,l ,R(edx)) + INSN1(push,l ,X4 MEM_DISP(ecx,4)) + INSN1(call,_ ,INDIR(X4 MEM(ecx))) + INSN2(mov,l ,X4 MEM_DISP(ebp,-32), R(esi)) + INSN2(add,l ,NUM(16), R(esp)) + INSN2(test,l ,R(esi), R(esi)) + INSN1(je,_ ,L(43)) + INSN2(cmp,l ,NUM(1), R(esi)) + INSN1(je,_ ,L(44)) + INSN2(cmp,l ,NUM(2), R(esi)) + INSN1(je,_ ,L(44)) + INSN2(cmp,l ,NUM(3), R(esi)) + INSN1(je,_ ,L(49)) + INSN2(cmp,l ,NUM(4), R(esi)) + INSN1(je,_ ,L(50)) + INSN2(cmp,l ,NUM(5), R(esi)) + INSN1(je,_ ,L(51)) + INSN2(cmp,l ,NUM(6), R(esi)) + INSN1(je,_ ,L(48)) + INSN2(cmp,l ,NUM(7), R(esi)) + INSN1(je,_ ,L(48)) + INSN2(cmp,l ,NUM(8), R(esi)) + INSN1(je,_ ,L(48)) + INSN2(cmp,l ,NUM(9), R(esi)) + INSN1(je,_ ,L(48)) + INSN2(lea,l ,X4 MEM_DISP(esi,-10), R(edx)) + INSN2(cmp,l ,NUM(1), R(edx)) + INSN1(ja,_ ,L(22)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-48), R(eax)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-44),R(edx)) +L(33): + P2ALIGN(2,3) +L(43): + INSN2(mov,l ,X4 MEM_DISP(ebp,-56), R(esi)) +L(3): + INSN2(and,l ,NUM(512), R(esi)) + INSN1(je,_ ,L(1)) + INSN2(mov,l ,X4 MEM_DISP(ebp,0),R(ecx)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-40), R(esp)) + INSN1(jmp,_ ,INDIR(R(ecx))) +L(1): + INSN2(lea,l ,X4 MEM_DISP(ebp,-8), R(esp)) + INSN1(pop,l ,R(esi)) + INSN1(pop,l ,R(edi)) + leave + ret +L(22): + INSN2(cmp,l ,NUM(12), R(esi)) + INSN1(je,_ ,L(52)) + INSN2(cmp,l ,NUM(13), R(esi)) + INSN1(je,_ ,L(53)) + INSN2(cmp,l ,NUM(14), R(esi)) + INSN1(je,_ ,L(48)) + INSN2(cmp,l ,NUM(15), R(esi)) + INSN1(jne,_ ,L(43)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-56), R(esi)) + INSN2(test,l ,NUM(1024), R(esi)) + INSN2(mov,l ,R(esi), R(edi)) + INSN1(je,_ ,L(31)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-28), R(edx)) + INSN2(cmp,l ,NUM(1), R(edx)) + INSN1(je,_ ,L(54)) + INSN2(cmp,l ,NUM(2), R(edx)) + INSN1(je,_ ,L(55)) + INSN2(cmp,l ,NUM(4), R(edx)) + INSN1(je,_ ,L(56)) + INSN2(cmp,l ,NUM(8), R(edx)) + INSN1(je,_ ,L(57)) +L(31): + INSN2(and,l ,NUM(16), R(edi)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(eax)) + INSN1(jne,_ ,L(3)) + INSN2(lea,l ,X4 MEM_DISP(ebp,-8), R(esp)) + INSN1(pop,l ,R(esi)) + INSN1(pop,l ,R(edi)) + leave + ret NUM(4) + INSN1(jmp,_ ,L(3)) +L(57): + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(edx)) + INSN2(mov,l ,X4 MEM(edx), R(eax)) + INSN2(mov,l ,X4 MEM_DISP(edx,4),R(edx)) + INSN1(jmp,_ ,L(3)) +L(56): + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(edx)) + INSN2(mov,l ,X4 MEM(edx), R(eax)) + INSN1(jmp,_ ,L(3)) +L(55): + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(edx)) + INSN2MOVXL(movz,w,X2 MEM(edx), R(eax)) + INSN1(jmp,_ ,L(3)) +L(54): + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(edx)) + INSN2MOVXL(movz,b,X1 MEM(edx), R(eax)) + INSN1(jmp,_ ,L(3)) + P2ALIGN(2,3) +L(48): + INSN2(mov,l ,X4 MEM_DISP(ebp,-48), R(eax)) + INSN1(jmp,_ ,L(43)) +L(53): + INSN1(fld,l ,X8 MEM_DISP(ebp,-48)) + INSN1(jmp,_ ,L(43)) +L(52): + INSN1(fld,s ,X4 MEM_DISP(ebp,-48)) + INSN1(jmp,_ ,L(43)) + P2ALIGN(2,3) +L(51): + INSN2MOVXL(movz,w,X2 MEM_DISP(ebp,-48), R(eax)) + INSN1(jmp,_ ,L(43)) +L(50): + INSN2MOVXL(movs,w,X2 MEM_DISP(ebp,-48),R(eax)) + INSN1(jmp,_ ,L(43)) +L(49): + INSN2MOVXL(movz,b,X1 MEM_DISP(ebp,-48), R(eax)) + INSN1(jmp,_ ,L(43)) + P2ALIGN(2,3) +L(44): + INSN2MOVXL(movs,b,X1 MEM_DISP(ebp,-48),R(eax)) + INSN1(jmp,_ ,L(43)) +L(fe1): + FUNEND(callback_receiver,L(fe1)-callback_receiver) +/* Implementation of callback_get_receiver */ + +/* + * Copyright 2017 Bruno Haible + * + * 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, see . + */ + +__vacall_r_t +callback_get_receiver (void) +{ + return (__vacall_r_t)(void*)&callback_receiver; +} diff --git a/callback/vacall_r/vacall-ia64-linux.s b/callback/vacall_r/vacall-ia64-linux.s new file mode 100644 index 0000000..30457bf --- /dev/null +++ b/callback/vacall_r/vacall-ia64-linux.s @@ -0,0 +1,851 @@ + .file "vacall-ia64.c" + .pred.safe_across_calls p1-p5,p16-p63 + .text + .align 16 + .proc callback_receiver# +callback_receiver: + .prologue 14, 42 + .spill 48 + .mmb + .save ar.pfs, r43 + alloc r43 = ar.pfs, 8, 6, 2, 0 + .vframe r44 + mov r44 = r12 + nop 0 + .mmi + adds r12 = -208, r12 + adds r18 = 8, r15 + mov r45 = r1 + ;; + .mmi + adds r16 = -48, r44 + adds r14 = -136, r44 + adds r17 = -48, r44 + .mmi + adds r40 = -152, r44 + adds r47 = -192, r44 + adds r41 = -160, r44 + ;; + .mmb + st8 [r14] = r8 + adds r14 = -32, r44 + nop 0 + .mfi + st8 [r16] = r32, 8 + nop 0 + .save rp, r42 + mov r42 = b0 + .body + ;; + .mfi + st8 [r14] = r34 + nop 0 + adds r14 = -24, r44 + .mmb + st8 [r16] = r33 + ld8 r16 = [r15] + nop 0 + ;; + .mmi + nop 0 + st8 [r14] = r35 + adds r14 = -16, r44 + .mmi + st8 [r41] = r0 + ;; + st8 [r14] = r36 + adds r14 = -8, r44 + .mmb + st4 [r40] = r0 + ld8 r46 = [r18] + nop 0 + ;; + .mmi + nop 0 + st8 [r14] = r37 + adds r14 = 8, r44 + .mmi + st8 [r44] = r38 + ;; + st8 [r14] = r39 + adds r14 = -112, r44 + .mmi + st4 [r47] = r0 + ;; + stfd [r14] = f8 + nop 0 + .mmi + adds r14 = -104, r44 + ;; + stfd [r14] = f9 + adds r14 = -96, r44 + ;; + .mfi + stfd [r14] = f10 + nop 0 + adds r14 = -88, r44 + .mmi + nop 0 + ;; + stfd [r14] = f11 + nop 0 + .mmi + adds r14 = -80, r44 + ;; + stfd [r14] = f12 + adds r14 = -72, r44 + ;; + .mfi + stfd [r14] = f13 + nop 0 + adds r14 = -64, r44 + .mmi + nop 0 + ;; + stfd [r14] = f14 + nop 0 + .mmi + adds r14 = -56, r44 + ;; + stfd [r14] = f15 + adds r14 = -168, r44 + ;; + .mii + st8 [r14] = r17 + adds r14 = -128, r44 + ;; + nop 0 + .mii + st8 [r14] = r17 + adds r14 = -120, r44 + ;; + nop 0 + .mmb + st4 [r14] = r0 + ld8 r14 = [r16], 8 + nop 0 + ;; + .mib + nop 0 + mov b6 = r14 + nop 0 + .mbb + ld8 r1 = [r16] + nop 0 + br.call.sptk.many b0 = b6 + ;; + .mmb + mov r1 = r45 + ld4 r40 = [r40] + nop 0 + ;; + .mfb + cmp4.eq p6, p7 = 0, r40 + nop 0 + (p6) br.cond.dpnt .L49 + ;; + .mfb + cmp4.ne p6, p7 = 1, r40 + nop 0 + (p7) br.cond.dpnt .L50 + ;; + .mfb + cmp4.ne p6, p7 = 2, r40 + nop 0 + (p7) br.cond.dpnt .L50 + ;; + .mii + nop 0 + cmp4.ne p6, p7 = 3, r40 + ;; + (p7) adds r14 = -184, r44 + ;; + .mfb + (p7) ld1 r8 = [r14] + nop 0 + (p7) br.cond.dpnt .L49 + .mii + nop 0 + cmp4.ne p6, p7 = 4, r40 + ;; + nop 0 + .mmi + (p7) adds r14 = -184, r44 + ;; + (p7) ld2 r14 = [r14] + nop 0 + ;; + .mib + nop 0 + (p7) sxt2 r8 = r14 + (p7) br.cond.dpnt .L49 + .mii + nop 0 + cmp4.ne p6, p7 = 5, r40 + ;; + (p7) adds r14 = -184, r44 + ;; + .mfb + (p7) ld2 r8 = [r14] + nop 0 + (p7) br.cond.dpnt .L49 + .mii + nop 0 + cmp4.ne p6, p7 = 6, r40 + ;; + nop 0 + .mmi + (p7) adds r14 = -184, r44 + ;; + (p7) ld4 r14 = [r14] + nop 0 + ;; + .mib + nop 0 + (p7) sxt4 r8 = r14 + (p7) br.cond.dpnt .L49 + .mii + nop 0 + cmp4.ne p6, p7 = 7, r40 + ;; + (p7) adds r14 = -184, r44 + ;; + .mfb + (p7) ld4 r8 = [r14] + nop 0 + (p7) br.cond.dpnt .L49 + .mfb + cmp4.ne p6, p7 = 8, r40 + nop 0 + (p7) br.cond.dpnt .L54 + ;; + .mfb + cmp4.ne p6, p7 = 9, r40 + nop 0 + (p7) br.cond.dpnt .L54 + ;; + .mfb + cmp4.ne p6, p7 = 10, r40 + nop 0 + (p7) br.cond.dpnt .L54 + ;; + .mfb + cmp4.ne p6, p7 = 11, r40 + nop 0 + (p7) br.cond.dpnt .L54 + ;; + .mii + nop 0 + cmp4.ne p6, p7 = 12, r40 + ;; + (p7) adds r14 = -184, r44 + ;; + .mfb + (p7) ldfs f8 = [r14] + nop 0 + (p7) br.cond.dpnt .L49 + .mii + nop 0 + cmp4.ne p6, p7 = 13, r40 + ;; + (p7) adds r14 = -184, r44 + ;; + .mfb + (p7) ldfd f8 = [r14] + nop 0 + (p7) br.cond.dpnt .L49 + .mfb + cmp4.ne p6, p7 = 14, r40 + nop 0 + (p7) br.cond.dpnt .L54 + ;; + .mib + nop 0 + cmp4.ne p6, p7 = 15, r40 + (p6) br.cond.dptk .L49 + .mii + nop 0 + adds r16 = -192, r44 + ;; + nop 0 + .mmi + ld4 r14 = [r16] + ;; + nop 0 + tbit.z p6, p7 = r14, 10 + .mfb + adds r14 = -144, r44 + nop 0 + (p6) br.cond.dpnt .L49 + ;; + .mmi + ld8 r22 = [r14] + ;; + adds r14 = -1, r22 + nop 0 + ;; + .mib + nop 0 + cmp.ltu p6, p7 = 31, r14 + (p6) br.cond.dpnt .L49 + .mmi + ld8 r14 = [r41] + ;; + and r21 = 7, r14 + and r24 = -8, r14 + .mii + nop 0 + cmp.ltu p6, p7 = 8, r22 + ;; + nop 0 + .mfb + add r14 = r22, r21 + nop 0 + (p6) br.cond.dptk .L35 + ;; + .mib + nop 0 + cmp.ltu p6, p7 = 8, r14 + (p6) br.cond.dptk .L37 + .mfi + shladd r16 = r14, 3, r0 + nop 0 + addl r14 = 2, r0 + .mii + ld8 r17 = [r24] + shladd r18 = r21, 3, r0 + ;; + adds r16 = -1, r16 + ;; + .mii + nop 0 + sxt4 r16 = r16 + ;; + shl r14 = r14, r16 + ;; + .mmi + adds r14 = -1, r14 + ;; + and r14 = r17, r14 + nop 0 + .mmi + nop 0 + ;; + nop 0 + shr r8 = r14, r18 +.L49: + .mii + nop 0 + mov ar.pfs = r43 + mov b0 = r42 + .mib + nop 0 + .label_state 1 + .restore sp + mov r12 = r44 + br.ret.sptk.many b0 +.L50: + .body + .copy_state 1 + .mii + nop 0 + adds r14 = -184, r44 + ;; + nop 0 + .mii + ld1 r14 = [r14] + nop 0 + ;; + sxt1 r8 = r14 + .mii + nop 0 + mov ar.pfs = r43 + mov b0 = r42 + .mib + nop 0 + .label_state 2 + .restore sp + mov r12 = r44 + br.ret.sptk.many b0 +.L54: + .body + .copy_state 2 + .mmb + nop 0 + adds r14 = -184, r44 + nop 0 + ;; + .mii + ld8 r8 = [r14] + mov ar.pfs = r43 + mov b0 = r42 + .mib + nop 0 + .label_state 3 + .restore sp + mov r12 = r44 + br.ret.sptk.many b0 +.L35: + .body + .copy_state 3 + .mib + nop 0 + cmp.ltu p6, p7 = 16, r22 + (p6) br.cond.dptk .L39 + ;; + .mib + nop 0 + cmp.ltu p6, p7 = 16, r14 + (p6) br.cond.dptk .L41 + .mmi + shladd r16 = r14, 3, r0 + adds r14 = 8, r24 + shladd r17 = r21, 2, r0 + .mmb + shladd r19 = r21, 3, r0 + ld8 r18 = [r24] + nop 0 + ;; + .mfi + ld8 r20 = [r14] + nop 0 + addl r14 = 2, r0 + .mii + adds r16 = -65, r16 + sub r17 = 32, r17 + ;; + sxt4 r16 = r16 + .mii + nop 0 + sxt4 r17 = r17 + shr r18 = r18, r19 + ;; + .mii + nop 0 + shl r14 = r14, r16 + ;; + adds r14 = -1, r14 + ;; + .mii + nop 0 + and r14 = r20, r14 + ;; + shl r16 = r14, r17 + .mii + nop 0 + shr r9 = r14, r19 + ;; + shl r16 = r16, r17 + ;; + .mii + or r8 = r16, r18 + mov ar.pfs = r43 + mov b0 = r42 + .mib + nop 0 + .label_state 4 + .restore sp + mov r12 = r44 + br.ret.sptk.many b0 +.L37: + .body + .copy_state 4 + .mfi + shladd r16 = r14, 3, r0 + nop 0 + addl r14 = 2, r0 + .mii + ld8 r18 = [r24], 8 + shladd r19 = r21, 3, r0 + ;; + adds r16 = -65, r16 + .mii + ld8 r20 = [r24] + sub r17 = 64, r19 + ;; + sxt4 r16 = r16 + .mii + nop 0 + sxt4 r17 = r17 + ;; + shl r14 = r14, r16 + .mii + nop 0 + shr r18 = r18, r19 + ;; + adds r14 = -1, r14 + ;; + .mii + nop 0 + and r14 = r20, r14 + ;; + shl r14 = r14, r17 + ;; + .mii + or r8 = r14, r18 + mov ar.pfs = r43 + mov b0 = r42 + .mib + nop 0 + .label_state 5 + .restore sp + mov r12 = r44 + br.ret.sptk.many b0 +.L39: + .body + .copy_state 5 + .mib + nop 0 + cmp.ltu p6, p7 = 24, r22 + (p6) br.cond.dptk .L43 + ;; + .mib + nop 0 + cmp.ltu p6, p7 = 24, r14 + (p6) br.cond.dptk .L45 + .mmi + shladd r16 = r14, 3, r0 + adds r14 = 8, r24 + shladd r17 = r21, 2, r0 + .mmb + shladd r20 = r21, 3, r0 + ld8 r19 = [r24], 16 + nop 0 + ;; + .mmi + ld8 r18 = [r14] + addl r14 = 2, r0 + adds r16 = -65, r16 + .mmb + sub r17 = 32, r17 + ld8 r21 = [r24] + nop 0 + ;; + .mii + nop 0 + sxt4 r16 = r16 + sxt4 r17 = r17 + .mii + nop 0 + shr r19 = r19, r20 + ;; + shl r14 = r14, r16 + .mii + nop 0 + shl r16 = r18, r17 + shr r18 = r18, r20 + ;; + .mii + nop 0 + shl r16 = r16, r17 + adds r14 = -1, r14 + ;; + .mii + and r14 = r21, r14 + or r8 = r16, r19 + ;; + shl r16 = r14, r17 + .mii + nop 0 + shr r10 = r14, r20 + ;; + shl r16 = r16, r17 + ;; + .mii + or r9 = r16, r18 + mov ar.pfs = r43 + mov b0 = r42 + .mib + nop 0 + .label_state 6 + .restore sp + mov r12 = r44 + br.ret.sptk.many b0 +.L41: + .body + .copy_state 6 + .mfi + shladd r17 = r14, 3, r0 + nop 0 + adds r14 = 8, r24 + .mfi + ld8 r19 = [r24], 16 + nop 0 + shladd r16 = r21, 3, r0 + ;; + .mmi + ld8 r18 = [r14] + addl r14 = 2, r0 + adds r17 = -129, r17 + .mmi + ld8 r21 = [r24] + mov r20 = r16 + sub r16 = 64, r16 + ;; + .mii + nop 0 + sxt4 r17 = r17 + sxt4 r16 = r16 + ;; + .mii + nop 0 + shl r14 = r14, r17 + shr r19 = r19, r20 + .mii + nop 0 + shl r17 = r18, r16 + shr r18 = r18, r20 + ;; + .mmi + adds r14 = -1, r14 + ;; + and r14 = r21, r14 + or r8 = r17, r19 + ;; + .mib + nop 0 + shl r14 = r14, r16 + nop 0 + ;; + .mii + or r9 = r14, r18 + mov ar.pfs = r43 + mov b0 = r42 + .mib + nop 0 + .label_state 7 + .restore sp + mov r12 = r44 + br.ret.sptk.many b0 +.L45: + .body + .copy_state 7 + .mmi + shladd r17 = r14, 3, r0 + adds r14 = 24, r24 + shladd r16 = r21, 3, r0 + .mmi + adds r19 = 8, r24 + ld8 r21 = [r24] + adds r20 = 16, r24 + ;; + .mmi + ld8 r23 = [r14] + addl r14 = 2, r0 + adds r17 = -129, r17 + .mmi + mov r18 = r16 + ld8 r19 = [r19] + sub r16 = 64, r16 + ;; + .mib + nop 0 + sxt4 r17 = r17 + nop 0 + .mii + ld8 r20 = [r20] + sxt4 r16 = r16 + ;; + shl r14 = r14, r17 + .mii + nop 0 + shr r22 = r20, r18 + shl r17 = r19, r16 + .mii + nop 0 + shr r21 = r21, r18 + shr r19 = r19, r18 + .mii + nop 0 + shl r20 = r20, r16 + ;; + nop 0 + .mmi + adds r14 = -1, r14 + ;; + and r14 = r23, r14 + or r8 = r17, r21 + .mii + nop 0 + or r9 = r20, r19 + ;; + shl r14 = r14, r16 + ;; + .mii + or r10 = r14, r22 + mov ar.pfs = r43 + mov b0 = r42 + .mib + nop 0 + .label_state 8 + .restore sp + mov r12 = r44 + br.ret.sptk.many b0 +.L43: + .body + .copy_state 8 + .mib + nop 0 + cmp.ltu p6, p7 = 32, r14 + (p6) br.cond.dptk .L47 + .mmi + adds r16 = 24, r24 + shladd r14 = r14, 3, r0 + adds r18 = 8, r24 + .mmi + shladd r17 = r21, 2, r0 + adds r19 = 16, r24 + shladd r21 = r21, 3, r0 + ;; + .mmi + nop 0 + ld8 r23 = [r16] + addl r16 = 2, r0 + .mmi + adds r14 = -65, r14 + ld8 r20 = [r18] + sub r17 = 32, r17 + ;; + .mii + nop 0 + sxt4 r14 = r14 + sxt4 r17 = r17 + .mmb + ld8 r22 = [r19] + ld8 r19 = [r24] + nop 0 + ;; + .mii + nop 0 + shl r16 = r16, r14 + shl r14 = r20, r17 + .mii + nop 0 + shr r19 = r19, r21 + shl r18 = r22, r17 + ;; + .mii + nop 0 + shl r14 = r14, r17 + shr r20 = r20, r21 + .mii + adds r16 = -1, r16 + shl r18 = r18, r17 + shr r22 = r22, r21 + ;; + .mmi + nop 0 + and r16 = r23, r16 + or r8 = r14, r19 + .mmi + or r9 = r18, r20 + ;; + nop 0 + shl r14 = r16, r17 + .mii + nop 0 + shr r11 = r16, r21 + ;; + shl r14 = r14, r17 + ;; + .mii + or r10 = r14, r22 + mov ar.pfs = r43 + mov b0 = r42 + .mib + nop 0 + .label_state 9 + .restore sp + mov r12 = r44 + br.ret.sptk.many b0 +.L47: + .body + .copy_state 9 + .mmb + shladd r17 = r14, 3, r0 + adds r14 = 32, r24 + nop 0 + .mmi + adds r19 = 8, r24 + adds r20 = 16, r24 + shladd r16 = r21, 3, r0 + ;; + .mfi + ld8 r23 = [r14] + nop 0 + adds r14 = 24, r24 + .mmi + ld8 r21 = [r19] + adds r17 = -129, r17 + mov r18 = r16 + .mfi + ld8 r19 = [r20] + nop 0 + sub r16 = 64, r16 + ;; + .mmi + ld8 r20 = [r14] + addl r14 = 2, r0 + sxt4 r17 = r17 + .mii + nop 0 + sxt4 r16 = r16 + ;; + shl r22 = r21, r16 + .mii + nop 0 + shr r21 = r21, r18 + shl r14 = r14, r17 + .mii + ld8 r17 = [r24] + shr r24 = r20, r18 + shl r20 = r20, r16 + ;; + .mii + nop 0 + shr r17 = r17, r18 + shr r18 = r19, r18 + .mii + adds r14 = -1, r14 + shl r19 = r19, r16 + ;; + and r14 = r23, r14 + .mmi + nop 0 + or r8 = r22, r17 + or r10 = r20, r18 + .mii + nop 0 + or r9 = r19, r21 + ;; + shl r14 = r14, r16 + ;; + .mii + or r11 = r14, r24 + mov ar.pfs = r43 + mov b0 = r42 + .mib + nop 0 + .restore sp + mov r12 = r44 + br.ret.sptk.many b0 + .endp callback_receiver# + .align 16 + .global callback_get_receiver# + .proc callback_get_receiver# +callback_get_receiver: + .prologue 2, 2 + .mfi + .vframe r2 + mov r2 = r12 + .body + nop 0 + addl r8 = @ltoff(@fptr(callback_receiver#)), gp + ;; + .mib + ld8 r8 = [r8] + .restore sp + mov r12 = r2 + br.ret.sptk.many b0 + .endp callback_get_receiver# + .ident "GCC: (GNU) 4.0.1" diff --git a/callback/vacall_r/vacall-ia64-macro.S b/callback/vacall_r/vacall-ia64-macro.S new file mode 100644 index 0000000..1d24177 --- /dev/null +++ b/callback/vacall_r/vacall-ia64-macro.S @@ -0,0 +1,854 @@ + .file "vacall-ia64.c" + .pred.safe_across_calls p1-p5,p16-p63 + .text + .align 16 + .proc callback_receiver# +callback_receiver: + .prologue 14, 42 + .spill 48 + .mmb + .save ar.pfs, r43 + alloc r43 = ar.pfs, 8, 6, 2, 0 + .vframe r44 + mov r44 = r12 + nop 0 + .mmi + adds r12 = -208, r12 + adds r18 = 8, r15 + mov r45 = r1 + ;; + .mmi + adds r16 = -48, r44 + adds r14 = -136, r44 + adds r17 = -48, r44 + .mmi + adds r40 = -152, r44 + adds r47 = -192, r44 + adds r41 = -160, r44 + ;; + .mmb + st8 [r14] = r8 + adds r14 = -32, r44 + nop 0 + .mfi + st8 [r16] = r32, 8 + nop 0 + .save rp, r42 + mov r42 = b0 + .body + ;; + .mfi + st8 [r14] = r34 + nop 0 + adds r14 = -24, r44 + .mmb + st8 [r16] = r33 + ld8 r16 = [r15] + nop 0 + ;; + .mmi + nop 0 + st8 [r14] = r35 + adds r14 = -16, r44 + .mmi + st8 [r41] = r0 + ;; + st8 [r14] = r36 + adds r14 = -8, r44 + .mmb + st4 [r40] = r0 + ld8 r46 = [r18] + nop 0 + ;; + .mmi + nop 0 + st8 [r14] = r37 + adds r14 = 8, r44 + .mmi + st8 [r44] = r38 + ;; + st8 [r14] = r39 + adds r14 = -112, r44 + .mmi + st4 [r47] = r0 + ;; + stfd [r14] = f8 + nop 0 + .mmi + adds r14 = -104, r44 + ;; + stfd [r14] = f9 + adds r14 = -96, r44 + ;; + .mfi + stfd [r14] = f10 + nop 0 + adds r14 = -88, r44 + .mmi + nop 0 + ;; + stfd [r14] = f11 + nop 0 + .mmi + adds r14 = -80, r44 + ;; + stfd [r14] = f12 + adds r14 = -72, r44 + ;; + .mfi + stfd [r14] = f13 + nop 0 + adds r14 = -64, r44 + .mmi + nop 0 + ;; + stfd [r14] = f14 + nop 0 + .mmi + adds r14 = -56, r44 + ;; + stfd [r14] = f15 + adds r14 = -168, r44 + ;; + .mii + st8 [r14] = r17 + adds r14 = -128, r44 + ;; + nop 0 + .mii + st8 [r14] = r17 + adds r14 = -120, r44 + ;; + nop 0 + .mmb + st4 [r14] = r0 + ld8 r14 = [r16], 8 + nop 0 + ;; + .mib + nop 0 + mov b6 = r14 + nop 0 + .mbb + ld8 r1 = [r16] + nop 0 + br.call.sptk.many b0 = b6 + ;; + .mmb + mov r1 = r45 + ld4 r40 = [r40] + nop 0 + ;; + .mfb + cmp4.eq p6, p7 = 0, r40 + nop 0 + (p6) br.cond.dpnt .L49 + ;; + .mfb + cmp4.ne p6, p7 = 1, r40 + nop 0 + (p7) br.cond.dpnt .L50 + ;; + .mfb + cmp4.ne p6, p7 = 2, r40 + nop 0 + (p7) br.cond.dpnt .L50 + ;; + .mii + nop 0 + cmp4.ne p6, p7 = 3, r40 + ;; + (p7) adds r14 = -184, r44 + ;; + .mfb + (p7) ld1 r8 = [r14] + nop 0 + (p7) br.cond.dpnt .L49 + .mii + nop 0 + cmp4.ne p6, p7 = 4, r40 + ;; + nop 0 + .mmi + (p7) adds r14 = -184, r44 + ;; + (p7) ld2 r14 = [r14] + nop 0 + ;; + .mib + nop 0 + (p7) sxt2 r8 = r14 + (p7) br.cond.dpnt .L49 + .mii + nop 0 + cmp4.ne p6, p7 = 5, r40 + ;; + (p7) adds r14 = -184, r44 + ;; + .mfb + (p7) ld2 r8 = [r14] + nop 0 + (p7) br.cond.dpnt .L49 + .mii + nop 0 + cmp4.ne p6, p7 = 6, r40 + ;; + nop 0 + .mmi + (p7) adds r14 = -184, r44 + ;; + (p7) ld4 r14 = [r14] + nop 0 + ;; + .mib + nop 0 + (p7) sxt4 r8 = r14 + (p7) br.cond.dpnt .L49 + .mii + nop 0 + cmp4.ne p6, p7 = 7, r40 + ;; + (p7) adds r14 = -184, r44 + ;; + .mfb + (p7) ld4 r8 = [r14] + nop 0 + (p7) br.cond.dpnt .L49 + .mfb + cmp4.ne p6, p7 = 8, r40 + nop 0 + (p7) br.cond.dpnt .L54 + ;; + .mfb + cmp4.ne p6, p7 = 9, r40 + nop 0 + (p7) br.cond.dpnt .L54 + ;; + .mfb + cmp4.ne p6, p7 = 10, r40 + nop 0 + (p7) br.cond.dpnt .L54 + ;; + .mfb + cmp4.ne p6, p7 = 11, r40 + nop 0 + (p7) br.cond.dpnt .L54 + ;; + .mii + nop 0 + cmp4.ne p6, p7 = 12, r40 + ;; + (p7) adds r14 = -184, r44 + ;; + .mfb + (p7) ldfs f8 = [r14] + nop 0 + (p7) br.cond.dpnt .L49 + .mii + nop 0 + cmp4.ne p6, p7 = 13, r40 + ;; + (p7) adds r14 = -184, r44 + ;; + .mfb + (p7) ldfd f8 = [r14] + nop 0 + (p7) br.cond.dpnt .L49 + .mfb + cmp4.ne p6, p7 = 14, r40 + nop 0 + (p7) br.cond.dpnt .L54 + ;; + .mib + nop 0 + cmp4.ne p6, p7 = 15, r40 + (p6) br.cond.dptk .L49 + .mii + nop 0 + adds r16 = -192, r44 + ;; + nop 0 + .mmi + ld4 r14 = [r16] + ;; + nop 0 + tbit.z p6, p7 = r14, 10 + .mfb + adds r14 = -144, r44 + nop 0 + (p6) br.cond.dpnt .L49 + ;; + .mmi + ld8 r22 = [r14] + ;; + adds r14 = -1, r22 + nop 0 + ;; + .mib + nop 0 + cmp.ltu p6, p7 = 31, r14 + (p6) br.cond.dpnt .L49 + .mmi + ld8 r14 = [r41] + ;; + and r21 = 7, r14 + and r24 = -8, r14 + .mii + nop 0 + cmp.ltu p6, p7 = 8, r22 + ;; + nop 0 + .mfb + add r14 = r22, r21 + nop 0 + (p6) br.cond.dptk .L35 + ;; + .mib + nop 0 + cmp.ltu p6, p7 = 8, r14 + (p6) br.cond.dptk .L37 + .mfi + shladd r16 = r14, 3, r0 + nop 0 + addl r14 = 2, r0 + .mii + ld8 r17 = [r24] + shladd r18 = r21, 3, r0 + ;; + adds r16 = -1, r16 + ;; + .mii + nop 0 + sxt4 r16 = r16 + ;; + shl r14 = r14, r16 + ;; + .mmi + adds r14 = -1, r14 + ;; + and r14 = r17, r14 + nop 0 + .mmi + nop 0 + ;; + nop 0 + shr r8 = r14, r18 +.L49: + .mii + nop 0 + mov ar.pfs = r43 + mov b0 = r42 + .mib + nop 0 + .label_state 1 + .restore sp + mov r12 = r44 + br.ret.sptk.many b0 +.L50: + .body + .copy_state 1 + .mii + nop 0 + adds r14 = -184, r44 + ;; + nop 0 + .mii + ld1 r14 = [r14] + nop 0 + ;; + sxt1 r8 = r14 + .mii + nop 0 + mov ar.pfs = r43 + mov b0 = r42 + .mib + nop 0 + .label_state 2 + .restore sp + mov r12 = r44 + br.ret.sptk.many b0 +.L54: + .body + .copy_state 2 + .mmb + nop 0 + adds r14 = -184, r44 + nop 0 + ;; + .mii + ld8 r8 = [r14] + mov ar.pfs = r43 + mov b0 = r42 + .mib + nop 0 + .label_state 3 + .restore sp + mov r12 = r44 + br.ret.sptk.many b0 +.L35: + .body + .copy_state 3 + .mib + nop 0 + cmp.ltu p6, p7 = 16, r22 + (p6) br.cond.dptk .L39 + ;; + .mib + nop 0 + cmp.ltu p6, p7 = 16, r14 + (p6) br.cond.dptk .L41 + .mmi + shladd r16 = r14, 3, r0 + adds r14 = 8, r24 + shladd r17 = r21, 2, r0 + .mmb + shladd r19 = r21, 3, r0 + ld8 r18 = [r24] + nop 0 + ;; + .mfi + ld8 r20 = [r14] + nop 0 + addl r14 = 2, r0 + .mii + adds r16 = -65, r16 + sub r17 = 32, r17 + ;; + sxt4 r16 = r16 + .mii + nop 0 + sxt4 r17 = r17 + shr r18 = r18, r19 + ;; + .mii + nop 0 + shl r14 = r14, r16 + ;; + adds r14 = -1, r14 + ;; + .mii + nop 0 + and r14 = r20, r14 + ;; + shl r16 = r14, r17 + .mii + nop 0 + shr r9 = r14, r19 + ;; + shl r16 = r16, r17 + ;; + .mii + or r8 = r16, r18 + mov ar.pfs = r43 + mov b0 = r42 + .mib + nop 0 + .label_state 4 + .restore sp + mov r12 = r44 + br.ret.sptk.many b0 +.L37: + .body + .copy_state 4 + .mfi + shladd r16 = r14, 3, r0 + nop 0 + addl r14 = 2, r0 + .mii + ld8 r18 = [r24], 8 + shladd r19 = r21, 3, r0 + ;; + adds r16 = -65, r16 + .mii + ld8 r20 = [r24] + sub r17 = 64, r19 + ;; + sxt4 r16 = r16 + .mii + nop 0 + sxt4 r17 = r17 + ;; + shl r14 = r14, r16 + .mii + nop 0 + shr r18 = r18, r19 + ;; + adds r14 = -1, r14 + ;; + .mii + nop 0 + and r14 = r20, r14 + ;; + shl r14 = r14, r17 + ;; + .mii + or r8 = r14, r18 + mov ar.pfs = r43 + mov b0 = r42 + .mib + nop 0 + .label_state 5 + .restore sp + mov r12 = r44 + br.ret.sptk.many b0 +.L39: + .body + .copy_state 5 + .mib + nop 0 + cmp.ltu p6, p7 = 24, r22 + (p6) br.cond.dptk .L43 + ;; + .mib + nop 0 + cmp.ltu p6, p7 = 24, r14 + (p6) br.cond.dptk .L45 + .mmi + shladd r16 = r14, 3, r0 + adds r14 = 8, r24 + shladd r17 = r21, 2, r0 + .mmb + shladd r20 = r21, 3, r0 + ld8 r19 = [r24], 16 + nop 0 + ;; + .mmi + ld8 r18 = [r14] + addl r14 = 2, r0 + adds r16 = -65, r16 + .mmb + sub r17 = 32, r17 + ld8 r21 = [r24] + nop 0 + ;; + .mii + nop 0 + sxt4 r16 = r16 + sxt4 r17 = r17 + .mii + nop 0 + shr r19 = r19, r20 + ;; + shl r14 = r14, r16 + .mii + nop 0 + shl r16 = r18, r17 + shr r18 = r18, r20 + ;; + .mii + nop 0 + shl r16 = r16, r17 + adds r14 = -1, r14 + ;; + .mii + and r14 = r21, r14 + or r8 = r16, r19 + ;; + shl r16 = r14, r17 + .mii + nop 0 + shr r10 = r14, r20 + ;; + shl r16 = r16, r17 + ;; + .mii + or r9 = r16, r18 + mov ar.pfs = r43 + mov b0 = r42 + .mib + nop 0 + .label_state 6 + .restore sp + mov r12 = r44 + br.ret.sptk.many b0 +.L41: + .body + .copy_state 6 + .mfi + shladd r17 = r14, 3, r0 + nop 0 + adds r14 = 8, r24 + .mfi + ld8 r19 = [r24], 16 + nop 0 + shladd r16 = r21, 3, r0 + ;; + .mmi + ld8 r18 = [r14] + addl r14 = 2, r0 + adds r17 = -129, r17 + .mmi + ld8 r21 = [r24] + mov r20 = r16 + sub r16 = 64, r16 + ;; + .mii + nop 0 + sxt4 r17 = r17 + sxt4 r16 = r16 + ;; + .mii + nop 0 + shl r14 = r14, r17 + shr r19 = r19, r20 + .mii + nop 0 + shl r17 = r18, r16 + shr r18 = r18, r20 + ;; + .mmi + adds r14 = -1, r14 + ;; + and r14 = r21, r14 + or r8 = r17, r19 + ;; + .mib + nop 0 + shl r14 = r14, r16 + nop 0 + ;; + .mii + or r9 = r14, r18 + mov ar.pfs = r43 + mov b0 = r42 + .mib + nop 0 + .label_state 7 + .restore sp + mov r12 = r44 + br.ret.sptk.many b0 +.L45: + .body + .copy_state 7 + .mmi + shladd r17 = r14, 3, r0 + adds r14 = 24, r24 + shladd r16 = r21, 3, r0 + .mmi + adds r19 = 8, r24 + ld8 r21 = [r24] + adds r20 = 16, r24 + ;; + .mmi + ld8 r23 = [r14] + addl r14 = 2, r0 + adds r17 = -129, r17 + .mmi + mov r18 = r16 + ld8 r19 = [r19] + sub r16 = 64, r16 + ;; + .mib + nop 0 + sxt4 r17 = r17 + nop 0 + .mii + ld8 r20 = [r20] + sxt4 r16 = r16 + ;; + shl r14 = r14, r17 + .mii + nop 0 + shr r22 = r20, r18 + shl r17 = r19, r16 + .mii + nop 0 + shr r21 = r21, r18 + shr r19 = r19, r18 + .mii + nop 0 + shl r20 = r20, r16 + ;; + nop 0 + .mmi + adds r14 = -1, r14 + ;; + and r14 = r23, r14 + or r8 = r17, r21 + .mii + nop 0 + or r9 = r20, r19 + ;; + shl r14 = r14, r16 + ;; + .mii + or r10 = r14, r22 + mov ar.pfs = r43 + mov b0 = r42 + .mib + nop 0 + .label_state 8 + .restore sp + mov r12 = r44 + br.ret.sptk.many b0 +.L43: + .body + .copy_state 8 + .mib + nop 0 + cmp.ltu p6, p7 = 32, r14 + (p6) br.cond.dptk .L47 + .mmi + adds r16 = 24, r24 + shladd r14 = r14, 3, r0 + adds r18 = 8, r24 + .mmi + shladd r17 = r21, 2, r0 + adds r19 = 16, r24 + shladd r21 = r21, 3, r0 + ;; + .mmi + nop 0 + ld8 r23 = [r16] + addl r16 = 2, r0 + .mmi + adds r14 = -65, r14 + ld8 r20 = [r18] + sub r17 = 32, r17 + ;; + .mii + nop 0 + sxt4 r14 = r14 + sxt4 r17 = r17 + .mmb + ld8 r22 = [r19] + ld8 r19 = [r24] + nop 0 + ;; + .mii + nop 0 + shl r16 = r16, r14 + shl r14 = r20, r17 + .mii + nop 0 + shr r19 = r19, r21 + shl r18 = r22, r17 + ;; + .mii + nop 0 + shl r14 = r14, r17 + shr r20 = r20, r21 + .mii + adds r16 = -1, r16 + shl r18 = r18, r17 + shr r22 = r22, r21 + ;; + .mmi + nop 0 + and r16 = r23, r16 + or r8 = r14, r19 + .mmi + or r9 = r18, r20 + ;; + nop 0 + shl r14 = r16, r17 + .mii + nop 0 + shr r11 = r16, r21 + ;; + shl r14 = r14, r17 + ;; + .mii + or r10 = r14, r22 + mov ar.pfs = r43 + mov b0 = r42 + .mib + nop 0 + .label_state 9 + .restore sp + mov r12 = r44 + br.ret.sptk.many b0 +.L47: + .body + .copy_state 9 + .mmb + shladd r17 = r14, 3, r0 + adds r14 = 32, r24 + nop 0 + .mmi + adds r19 = 8, r24 + adds r20 = 16, r24 + shladd r16 = r21, 3, r0 + ;; + .mfi + ld8 r23 = [r14] + nop 0 + adds r14 = 24, r24 + .mmi + ld8 r21 = [r19] + adds r17 = -129, r17 + mov r18 = r16 + .mfi + ld8 r19 = [r20] + nop 0 + sub r16 = 64, r16 + ;; + .mmi + ld8 r20 = [r14] + addl r14 = 2, r0 + sxt4 r17 = r17 + .mii + nop 0 + sxt4 r16 = r16 + ;; + shl r22 = r21, r16 + .mii + nop 0 + shr r21 = r21, r18 + shl r14 = r14, r17 + .mii + ld8 r17 = [r24] + shr r24 = r20, r18 + shl r20 = r20, r16 + ;; + .mii + nop 0 + shr r17 = r17, r18 + shr r18 = r19, r18 + .mii + adds r14 = -1, r14 + shl r19 = r19, r16 + ;; + and r14 = r23, r14 + .mmi + nop 0 + or r8 = r22, r17 + or r10 = r20, r18 + .mii + nop 0 + or r9 = r19, r21 + ;; + shl r14 = r14, r16 + ;; + .mii + or r11 = r14, r24 + mov ar.pfs = r43 + mov b0 = r42 + .mib + nop 0 + .restore sp + mov r12 = r44 + br.ret.sptk.many b0 + .endp callback_receiver# + .align 16 + .global callback_get_receiver# + .proc callback_get_receiver# +callback_get_receiver: + .prologue 2, 2 + .mfi + .vframe r2 + mov r2 = r12 + .body + nop 0 + addl r8 = @ltoff(@fptr(callback_receiver#)), gp + ;; + .mib + ld8 r8 = [r8] + .restore sp + mov r12 = r2 + br.ret.sptk.many b0 + .endp callback_get_receiver# + .ident "GCC: (GNU) 4.0.1" +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/callback/vacall_r/vacall-libapi.c b/callback/vacall_r/vacall-libapi.c new file mode 100644 index 0000000..60ccee5 --- /dev/null +++ b/callback/vacall_r/vacall-libapi.c @@ -0,0 +1,210 @@ +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +#include "config.h" +#include +#include +#include + +#include "vacall-internal.h" + +/* Room for returning structs according to the Sun C non-reentrant struct return convention. */ +typedef union { __vaword room[__VA_ALIST_WORDS]; double align; } __va_struct_buffer_t; +static __va_struct_buffer_t vacall_struct_buffer; + +static _Noreturn void +vacall_error_type_mismatch (enum __VAtype start_type, enum __VAtype return_type) +{ + /* If you see this, fix your code. */ + fprintf (stderr, "vacall: va_start type %d and va_return type %d disagree.\n", + (int)start_type, (int)return_type); + abort(); +} + +static _Noreturn void +vacall_error_struct_too_large (unsigned int size) +{ + /* If you see this, increase __VA_ALIST_WORDS: */ + fprintf (stderr, "vacall: struct of size %u too large for Sun C struct return.\n", + size); + abort(); +} + +void vacall_start (va_alist list, int rettype, int flags) +{ + __va_start(list,rettype,flags); +} + +void vacall_start_struct (va_alist list, size_t type_size, size_t type_align, int type_splittable, int flags) +{ + __va_start_struct(list,type_size,type_align,type_splittable,flags); +} + +char vacall_arg_char (va_alist list) +{ + return _va_arg_char(list); +} + +signed char vacall_arg_schar (va_alist list) +{ + return _va_arg_schar(list); +} + +unsigned char vacall_arg_uchar (va_alist list) +{ + return _va_arg_uchar(list); +} + +short vacall_arg_short (va_alist list) +{ + return _va_arg_short(list); +} + +unsigned short vacall_arg_ushort (va_alist list) +{ + return _va_arg_ushort(list); +} + +int vacall_arg_int (va_alist list) +{ + return _va_arg_int(list); +} + +unsigned int vacall_arg_uint (va_alist list) +{ + return _va_arg_uint(list); +} + +long vacall_arg_long (va_alist list) +{ + return _va_arg_long(list); +} + +unsigned long vacall_arg_ulong (va_alist list) +{ + return _va_arg_ulong(list); +} + +long long vacall_arg_longlong (va_alist list) +{ + return _va_arg_longlong(list); +} + +unsigned long long vacall_arg_ulonglong (va_alist list) +{ + return _va_arg_ulonglong(list); +} + +float vacall_arg_float (va_alist list) +{ + return _va_arg_float(list); +} + +double vacall_arg_double (va_alist list) +{ + return _va_arg_double(list); +} + +void* vacall_arg_ptr (va_alist list) +{ + return _va_arg_ptr(list); +} + +void* vacall_arg_struct (va_alist list, size_t type_size, size_t type_align) +{ + return __va_arg_struct(list,type_size,type_align); +} + +void vacall_return_void (va_alist list) +{ + _va_return_void(list); +} + +void vacall_return_char (va_alist list, char val) +{ + _va_return_char(list,val); +} + +void vacall_return_schar (va_alist list, signed char val) +{ + _va_return_schar(list,val); +} + +void vacall_return_uchar (va_alist list, unsigned char val) +{ + _va_return_uchar(list,val); +} + +void vacall_return_short (va_alist list, short val) +{ + _va_return_short(list,val); +} + +void vacall_return_ushort (va_alist list, unsigned short val) +{ + _va_return_ushort(list,val); +} + +void vacall_return_int (va_alist list, int val) +{ + _va_return_int(list,val); +} + +void vacall_return_uint (va_alist list, unsigned int val) +{ + _va_return_uint(list,val); +} + +void vacall_return_long (va_alist list, long val) +{ + _va_return_long(list,val); +} + +void vacall_return_ulong (va_alist list, unsigned long val) +{ + _va_return_ulong(list,val); +} + +void vacall_return_longlong (va_alist list, long long val) +{ + _va_return_longlong(list,val); +} + +void vacall_return_ulonglong (va_alist list, unsigned long long val) +{ + _va_return_ulonglong(list,val); +} + +void vacall_return_float (va_alist list, float val) +{ + _va_return_float(list,val); +} + +void vacall_return_double (va_alist list, double val) +{ + _va_return_double(list,val); +} + +void vacall_return_ptr (va_alist list, void* val) +{ + _va_return_ptr(list,val); +} + +void vacall_return_struct (va_alist list, size_t type_size, size_t type_align, const void* val_addr) +{ + __va_return_struct(list,type_size,type_align,val_addr); +} diff --git a/callback/vacall_r/vacall-m68k-linux.s b/callback/vacall_r/vacall-m68k-linux.s new file mode 100644 index 0000000..a687a7e --- /dev/null +++ b/callback/vacall_r/vacall-m68k-linux.s @@ -0,0 +1,185 @@ + .file "vacall-m68k.c" + .text + .align 2 + .type callback_receiver,@function +callback_receiver: + link.w %a6,#-32 + movm.l #0x3030,-(%sp) + clr.l -32(%a6) + lea (8,%a6),%a2 + move.l %a2,-20(%a6) + clr.l -16(%a6) + clr.l -12(%a6) + move.l %a1,-4(%a6) + pea -32(%a6) + move.l 4(%a0),-(%sp) + move.l (%a0),%a2 + jsr (%a2) + addq.l #8,%sp + move.l -12(%a6),%a3 + tst.l %a3 + jbeq .L1 + moveq.l #1,%d2 + cmp.l %a3,%d2 + jbeq .L46 + moveq.l #2,%d3 + cmp.l %a3,%d3 + jbeq .L46 + moveq.l #3,%d2 + cmp.l %a3,%d2 + jbeq .L47 + moveq.l #4,%d3 + cmp.l %a3,%d3 + jbeq .L48 + moveq.l #5,%d2 + cmp.l %a3,%d2 + jbeq .L49 + moveq.l #6,%d3 + cmp.l %a3,%d3 + jbeq .L45 + moveq.l #7,%d2 + cmp.l %a3,%d2 + jbeq .L45 + moveq.l #8,%d3 + cmp.l %a3,%d3 + jbeq .L45 + moveq.l #9,%d2 + cmp.l %a3,%d2 + jbeq .L45 + lea (-10,%a3),%a2 + moveq.l #1,%d3 + cmp.l %a2,%d3 + jbcs .L22 + move.l -28(%a6),%d0 + move.l -24(%a6),%d1 + jbra .L1 + .align 2 +.L22: + moveq.l #12,%d2 + cmp.l %a3,%d2 + jbeq .L50 + moveq.l #13,%d2 + cmp.l %a3,%d2 + jbeq .L51 + moveq.l #14,%d3 + cmp.l %a3,%d3 + jbeq .L52 + moveq.l #15,%d2 + cmp.l %a3,%d2 + jbne .L1 + btst #2,-30(%a6) + jbeq .L1 + move.l -8(%a6),%d2 + moveq.l #1,%d3 + cmp.l %d2,%d3 + jbeq .L53 + moveq.l #2,%d3 + cmp.l %d2,%d3 + jbeq .L54 + moveq.l #4,%d3 + cmp.l %d2,%d3 + jbeq .L55 + moveq.l #8,%d3 + cmp.l %d2,%d3 + jbne .L1 + move.l -16(%a6),%a2 + move.l (%a2),%d0 + move.l 4(%a2),%d1 + jbra .L1 + .align 2 +.L55: + move.l -16(%a6),%a2 + move.l (%a2),%d0 + jbra .L1 + .align 2 +.L54: + move.l -16(%a6),%a2 + clr.l %d0 + move.w (%a2),%d0 + jbra .L1 + .align 2 +.L53: + move.l -16(%a6),%a2 + clr.l %d0 + move.b (%a2),%d0 + jbra .L1 + .align 2 +.L52: + move.l -28(%a6),%d0 + move.l %d0,%a0 + jbra .L1 + .align 2 +.L51: + btst #6,-29(%a6) + jbeq .L31 + fmove.d -28(%a6),%fp0 + jbra .L1 + .align 2 +.L31: + move.l -28(%a6),%d0 + move.l -24(%a6),%d1 + jbra .L1 + .align 2 +.L50: + move.l -32(%a6),%d2 + btst #6,%d2 + jbeq .L25 + fmove.s -28(%a6),%fp0 + jbra .L1 + .align 2 +.L25: + btst #5,%d2 + jbeq .L27 + fmove.s -28(%a6),%fp1 + fmove.d %fp1,-(%sp) + move.l (%sp)+,%d0 + move.l (%sp)+,%d1 + jbra .L1 + .align 2 +.L27: + move.l -28(%a6),%d0 + jbra .L1 + .align 2 +.L45: + move.l -28(%a6),%d0 + jbra .L1 + .align 2 +.L49: + clr.l %d0 + move.w -28(%a6),%d0 + jbra .L1 + .align 2 +.L48: + move.w -28(%a6),%d0 + ext.l %d0 + jbra .L1 + .align 2 +.L47: + clr.l %d0 + move.b -28(%a6),%d0 + jbra .L1 + .align 2 +.L46: + move.b -28(%a6),%d0 + extb.l %d0 +.L1: + movm.l -48(%a6),#0xc0c + unlk %a6 + rts +.Lfe1: + .size callback_receiver,.Lfe1-callback_receiver + .align 2 + .globl callback_get_receiver + .type callback_get_receiver,@function +callback_get_receiver: + link.w %a6,#0 + move.l %a5,-(%sp) + lea (%pc, _GLOBAL_OFFSET_TABLE_@GOTPC), %a5 + move.l callback_receiver@GOT(%a5),%a0 + move.l %a0,%d0 + move.l (%sp)+,%a5 + unlk %a6 + rts +.Lfe2: + .size callback_get_receiver,.Lfe2-callback_get_receiver + .ident "GCC: (GNU) 3.1" diff --git a/callback/vacall_r/vacall-m68k-sun.s b/callback/vacall_r/vacall-m68k-sun.s new file mode 100644 index 0000000..86f3f16 --- /dev/null +++ b/callback/vacall_r/vacall-m68k-sun.s @@ -0,0 +1,178 @@ +#NO_APP + .text + .even +_callback_receiver: + link a6,#-32 + moveml #0x3030,sp@- + clrl a6@(-32) + lea a6@(8),a2 + movel a2,a6@(-20) + clrl a6@(-16) + clrl a6@(-12) + movel a1,a6@(-4) + pea a6@(-32) + movel a0@(4),sp@- + movel a0@,a2 + jsr a2@ + addql #8,sp + movel a6@(-12),a3 + tstl a3 + jeq L1 + moveq #1,d2 + cmpl a3,d2 + jeq L46 + moveq #2,d3 + cmpl a3,d3 + jeq L46 + moveq #3,d2 + cmpl a3,d2 + jeq L47 + moveq #4,d3 + cmpl a3,d3 + jeq L48 + moveq #5,d2 + cmpl a3,d2 + jeq L49 + moveq #6,d3 + cmpl a3,d3 + jeq L45 + moveq #7,d2 + cmpl a3,d2 + jeq L45 + moveq #8,d3 + cmpl a3,d3 + jeq L45 + moveq #9,d2 + cmpl a3,d2 + jeq L45 + lea a3@(-10),a2 + moveq #1,d3 + cmpl a2,d3 + jcs L22 + movel a6@(-28),d0 + movel a6@(-24),d1 + jra L1 + .even +L22: + moveq #12,d2 + cmpl a3,d2 + jeq L50 + moveq #13,d2 + cmpl a3,d2 + jeq L51 + moveq #14,d3 + cmpl a3,d3 + jeq L52 + moveq #15,d2 + cmpl a3,d2 + jne L1 + btst #2,a6@(-30) + jeq L1 + movel a6@(-8),d2 + moveq #1,d3 + cmpl d2,d3 + jeq L53 + moveq #2,d3 + cmpl d2,d3 + jeq L54 + moveq #4,d3 + cmpl d2,d3 + jeq L55 + moveq #8,d3 + cmpl d2,d3 + jne L1 + movel a6@(-16),a2 + movel a2@,d0 + movel a2@(4),d1 + jra L1 + .even +L55: + movel a6@(-16),a2 + movel a2@,d0 + jra L1 + .even +L54: + movel a6@(-16),a2 + clrl d0 + movew a2@,d0 + jra L1 + .even +L53: + movel a6@(-16),a2 + clrl d0 + moveb a2@,d0 + jra L1 + .even +L52: + movel a6@(-28),d0 + movel d0,a0 + jra L1 + .even +L51: + btst #6,a6@(-29) + jeq L31 + fmoved a6@(-28),fp0 + jra L1 + .even +L31: + movel a6@(-28),d0 + movel a6@(-24),d1 + jra L1 + .even +L50: + movel a6@(-32),d2 + btst #6,d2 + jeq L25 + fmoves a6@(-28),fp0 + jra L1 + .even +L25: + btst #5,d2 + jeq L27 + fmoves a6@(-28),fp1 + fmoved fp1,sp@- + movel sp@+,d0 + movel sp@+,d1 + jra L1 + .even +L27: + movel a6@(-28),d0 + jra L1 + .even +L45: + movel a6@(-28),d0 + jra L1 + .even +L49: + clrl d0 + movew a6@(-28),d0 + jra L1 + .even +L48: + movew a6@(-28),d0 + extl d0 + jra L1 + .even +L47: + clrl d0 + moveb a6@(-28),d0 + jra L1 + .even +L46: + moveb a6@(-28),d0 + extbl d0 +L1: + moveml a6@(-48),#0xc0c + unlk a6 + rts + .even + .globl _callback_get_receiver +_callback_get_receiver: + link a6,#0 + movel a5,sp@- + movel #__GLOBAL_OFFSET_TABLE_, a5 + lea pc@(0,a5:l),a5 + movel a5@(_callback_receiver:l),d0 + movel sp@+,a5 + unlk a6 + rts diff --git a/callback/vacall_r/vacall-m68k.mit.S b/callback/vacall_r/vacall-m68k.mit.S new file mode 100644 index 0000000..5acb6a8 --- /dev/null +++ b/callback/vacall_r/vacall-m68k.mit.S @@ -0,0 +1,183 @@ +#include "asm-m68k.h" + .text + .even +FUNBEGIN(callback_receiver) + link $a6,#-32 + moveml #0x3030,$sp@- + clrl $a6@(-32) + lea $a6@(8),$a2 + movel $a2,$a6@(-20) + clrl $a6@(-16) + clrl $a6@(-12) + movel $a1,$a6@(-4) + pea $a6@(-32) + movel $a0@(4),$sp@- + movel $a0@,$a2 + jsr $a2@ + addql #8,$sp + movel $a6@(-12),$a3 + tstl $a3 + jeq L(1) + moveq #1,$d2 + cmpl $a3,$d2 + jeq L(46) + moveq #2,$d3 + cmpl $a3,$d3 + jeq L(46) + moveq #3,$d2 + cmpl $a3,$d2 + jeq L(47) + moveq #4,$d3 + cmpl $a3,$d3 + jeq L(48) + moveq #5,$d2 + cmpl $a3,$d2 + jeq L(49) + moveq #6,$d3 + cmpl $a3,$d3 + jeq L(45) + moveq #7,$d2 + cmpl $a3,$d2 + jeq L(45) + moveq #8,$d3 + cmpl $a3,$d3 + jeq L(45) + moveq #9,$d2 + cmpl $a3,$d2 + jeq L(45) + lea $a3@(-10),$a2 + moveq #1,$d3 + cmpl $a2,$d3 + jcs L(22) + movel $a6@(-28),$d0 + movel $a6@(-24),$d1 + jra L(1) + .even +L(22): + moveq #12,$d2 + cmpl $a3,$d2 + jeq L(50) + moveq #13,$d2 + cmpl $a3,$d2 + jeq L(51) + moveq #14,$d3 + cmpl $a3,$d3 + jeq L(52) + moveq #15,$d2 + cmpl $a3,$d2 + jne L(1) + btst #2,$a6@(-30) + jeq L(1) + movel $a6@(-8),$d2 + moveq #1,$d3 + cmpl $d2,$d3 + jeq L(53) + moveq #2,$d3 + cmpl $d2,$d3 + jeq L(54) + moveq #4,$d3 + cmpl $d2,$d3 + jeq L(55) + moveq #8,$d3 + cmpl $d2,$d3 + jne L(1) + movel $a6@(-16),$a2 + movel $a2@,$d0 + movel $a2@(4),$d1 + jra L(1) + .even +L(55): + movel $a6@(-16),$a2 + movel $a2@,$d0 + jra L(1) + .even +L(54): + movel $a6@(-16),$a2 + clrl $d0 + movew $a2@,$d0 + jra L(1) + .even +L(53): + movel $a6@(-16),$a2 + clrl $d0 + moveb $a2@,$d0 + jra L(1) + .even +L(52): + movel $a6@(-28),$d0 + movel $d0,$a0 + jra L(1) + .even +L(51): + btst #6,$a6@(-29) + jeq L(31) + fmoved $a6@(-28),$fp0 + jra L(1) + .even +L(31): + movel $a6@(-28),$d0 + movel $a6@(-24),$d1 + jra L(1) + .even +L(50): + movel $a6@(-32),$d2 + btst #6,$d2 + jeq L(25) + fmoves $a6@(-28),$fp0 + jra L(1) + .even +L(25): + btst #5,$d2 + jeq L(27) + fmoves $a6@(-28),$fp1 + fmoved $fp1,$sp@- + movel $sp@+,$d0 + movel $sp@+,$d1 + jra L(1) + .even +L(27): + movel $a6@(-28),$d0 + jra L(1) + .even +L(45): + movel $a6@(-28),$d0 + jra L(1) + .even +L(49): + clrl $d0 + movew $a6@(-28),$d0 + jra L(1) + .even +L(48): + movew $a6@(-28),$d0 + extl $d0 + jra L(1) + .even +L(47): + clrl $d0 + moveb $a6@(-28),$d0 + jra L(1) + .even +L(46): + moveb $a6@(-28),$d0 + extbl $d0 +L(1): + moveml $a6@(-48),#0xc0c + unlk $a6 + rts + .even + .globl C(callback_get_receiver) + DECLARE_FUNCTION(callback_get_receiver) +FUNBEGIN(callback_get_receiver) + link $a6,#0 + movel $a5,$sp@- + movel #C(_GLOBAL_OFFSET_TABLE_), $a5 + lea $pc@(0,$a5:l),$a5 + movel $a5@(C(callback_receiver):l),$d0 + movel $sp@+,$a5 + unlk $a6 + rts +FUNEND(callback_get_receiver) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/callback/vacall_r/vacall-m68k.motorola.S b/callback/vacall_r/vacall-m68k.motorola.S new file mode 100644 index 0000000..7910d88 --- /dev/null +++ b/callback/vacall_r/vacall-m68k.motorola.S @@ -0,0 +1,187 @@ +#include "asm-m68k.h" + .text + .align 2 + DECLARE_FUNCTION(callback_receiver) +FUNBEGIN(callback_receiver) + link.w %a6,#-32 + movm.l #0x3030,-(%sp) + clr.l -32(%a6) + lea (8,%a6),%a2 + move.l %a2,-20(%a6) + clr.l -16(%a6) + clr.l -12(%a6) + move.l %a1,-4(%a6) + pea -32(%a6) + move.l 4(%a0),-(%sp) + move.l (%a0),%a2 + jsr (%a2) + addq.l #8,%sp + move.l -12(%a6),%a3 + tst.l %a3 + jbeq L(1) + moveq.l #1,%d2 + cmp.l %a3,%d2 + jbeq L(46) + moveq.l #2,%d3 + cmp.l %a3,%d3 + jbeq L(46) + moveq.l #3,%d2 + cmp.l %a3,%d2 + jbeq L(47) + moveq.l #4,%d3 + cmp.l %a3,%d3 + jbeq L(48) + moveq.l #5,%d2 + cmp.l %a3,%d2 + jbeq L(49) + moveq.l #6,%d3 + cmp.l %a3,%d3 + jbeq L(45) + moveq.l #7,%d2 + cmp.l %a3,%d2 + jbeq L(45) + moveq.l #8,%d3 + cmp.l %a3,%d3 + jbeq L(45) + moveq.l #9,%d2 + cmp.l %a3,%d2 + jbeq L(45) + lea (-10,%a3),%a2 + moveq.l #1,%d3 + cmp.l %a2,%d3 + jbcs L(22) + move.l -28(%a6),%d0 + move.l -24(%a6),%d1 + jbra L(1) + .align 2 +L(22): + moveq.l #12,%d2 + cmp.l %a3,%d2 + jbeq L(50) + moveq.l #13,%d2 + cmp.l %a3,%d2 + jbeq L(51) + moveq.l #14,%d3 + cmp.l %a3,%d3 + jbeq L(52) + moveq.l #15,%d2 + cmp.l %a3,%d2 + jbne L(1) + btst #2,-30(%a6) + jbeq L(1) + move.l -8(%a6),%d2 + moveq.l #1,%d3 + cmp.l %d2,%d3 + jbeq L(53) + moveq.l #2,%d3 + cmp.l %d2,%d3 + jbeq L(54) + moveq.l #4,%d3 + cmp.l %d2,%d3 + jbeq L(55) + moveq.l #8,%d3 + cmp.l %d2,%d3 + jbne L(1) + move.l -16(%a6),%a2 + move.l (%a2),%d0 + move.l 4(%a2),%d1 + jbra L(1) + .align 2 +L(55): + move.l -16(%a6),%a2 + move.l (%a2),%d0 + jbra L(1) + .align 2 +L(54): + move.l -16(%a6),%a2 + clr.l %d0 + move.w (%a2),%d0 + jbra L(1) + .align 2 +L(53): + move.l -16(%a6),%a2 + clr.l %d0 + move.b (%a2),%d0 + jbra L(1) + .align 2 +L(52): + move.l -28(%a6),%d0 + move.l %d0,%a0 + jbra L(1) + .align 2 +L(51): + btst #6,-29(%a6) + jbeq L(31) + fmove.d -28(%a6),%fp0 + jbra L(1) + .align 2 +L(31): + move.l -28(%a6),%d0 + move.l -24(%a6),%d1 + jbra L(1) + .align 2 +L(50): + move.l -32(%a6),%d2 + btst #6,%d2 + jbeq L(25) + fmove.s -28(%a6),%fp0 + jbra L(1) + .align 2 +L(25): + btst #5,%d2 + jbeq L(27) + fmove.s -28(%a6),%fp1 + fmove.d %fp1,-(%sp) + move.l (%sp)+,%d0 + move.l (%sp)+,%d1 + jbra L(1) + .align 2 +L(27): + move.l -28(%a6),%d0 + jbra L(1) + .align 2 +L(45): + move.l -28(%a6),%d0 + jbra L(1) + .align 2 +L(49): + clr.l %d0 + move.w -28(%a6),%d0 + jbra L(1) + .align 2 +L(48): + move.w -28(%a6),%d0 + ext.l %d0 + jbra L(1) + .align 2 +L(47): + clr.l %d0 + move.b -28(%a6),%d0 + jbra L(1) + .align 2 +L(46): + move.b -28(%a6),%d0 + extb.l %d0 +L(1): + movm.l -48(%a6),#0xc0c + unlk %a6 + rts +L(fe1): + FUNEND(callback_receiver) + .align 2 + .globl C(callback_get_receiver) + DECLARE_FUNCTION(callback_get_receiver) +FUNBEGIN(callback_get_receiver) + link.w %a6,#0 + move.l %a5,-(%sp) + lea (%pc, _GLOBAL_OFFSET_TABLE_@GOTPC), %a5 + move.l callback_receiver@GOT(%a5),%a0 + move.l %a0,%d0 + move.l (%sp)+,%a5 + unlk %a6 + rts +L(fe2): + FUNEND(callback_get_receiver) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/callback/vacall_r/vacall-mips64eb-linux.s b/callback/vacall_r/vacall-mips64eb-linux.s new file mode 100644 index 0000000..26582be --- /dev/null +++ b/callback/vacall_r/vacall-mips64eb-linux.s @@ -0,0 +1,385 @@ + .file 1 "vacall-mips64.c" + .section .mdebug.abi64 + .previous + .nan legacy + .module fp=64 + .module oddspreg + .abicalls + .text + .align 2 + .align 3 + .set nomips16 + .set nomicromips + .ent callback_receiver + .type callback_receiver, @function +callback_receiver: + .frame $fp,272,$31 # vars= 160, regs= 6/0, args= 0, gp= 0 + .mask 0xd0070000,-72 + .fmask 0x00000000,0 + .set noreorder + .set nomacro + daddiu $sp,$sp,-272 + sd $fp,192($sp) + move $fp,$sp + sd $4,208($fp) + ld $4,8($2) + ld $25,0($2) + daddiu $12,$fp,208 + sd $31,200($sp) + sd $18,176($sp) + sd $17,168($sp) + sd $16,160($sp) + sd $5,216($fp) + sd $6,224($fp) + sd $7,232($fp) + sd $8,240($fp) + sd $9,248($fp) + sd $10,256($fp) + sd $11,264($fp) + sdc1 $f12,96($fp) + sdc1 $f13,104($fp) + sdc1 $f14,112($fp) + sdc1 $f15,120($fp) + sdc1 $f16,128($fp) + sdc1 $f17,136($fp) + sdc1 $f18,144($fp) + sdc1 $f19,152($fp) + swc1 $f12,60($fp) + swc1 $f13,64($fp) + swc1 $f14,68($fp) + swc1 $f15,72($fp) + swc1 $f16,76($fp) + swc1 $f17,80($fp) + swc1 $f18,84($fp) + move $5,$fp + swc1 $f19,88($fp) + sd $12,24($fp) + sw $0,0($fp) + sd $0,32($fp) + sw $0,40($fp) + jalr $25 + sw $0,56($fp) + + lw $12,40($fp) + beq $12,$0,.L1 + li $13,1 # 0x1 + + beq $12,$13,.L43 + li $13,2 # 0x2 + + beq $12,$13,.L43 + li $13,3 # 0x3 + + beq $12,$13,.L46 + li $13,4 # 0x4 + + beq $12,$13,.L47 + li $13,5 # 0x5 + + beq $12,$13,.L48 + li $13,6 # 0x6 + + beq $12,$13,.L49 + li $13,7 # 0x7 + + beq $12,$13,.L50 + li $13,8 # 0x8 + + beq $12,$13,.L44 + li $13,9 # 0x9 + + beq $12,$13,.L44 + li $13,10 # 0xa + + beq $12,$13,.L44 + li $13,11 # 0xb + + beq $12,$13,.L44 + li $13,12 # 0xc + + beq $12,$13,.L51 + li $13,13 # 0xd + + beq $12,$13,.L52 + li $13,14 # 0xe + + beq $12,$13,.L44 + li $13,15 # 0xf + + bnel $12,$13,.L58 + move $sp,$fp + + lw $12,0($fp) + andi $13,$12,0x400 + beq $13,$0,.L1 + andi $13,$12,0x4 + + beq $13,$0,.L19 + ld $14,48($fp) + + ld $12,48($fp) + li $13,1 # 0x1 + beq $12,$13,.L53 + li $13,2 # 0x2 + + beq $12,$13,.L54 + li $13,4 # 0x4 + + beq $12,$13,.L55 + li $13,8 # 0x8 + + bnel $12,$13,.L58 + move $sp,$fp + + ld $12,32($fp) + ld $2,0($12) +.L1: + move $sp,$fp +.L58: + ld $31,200($sp) + ld $fp,192($sp) + ld $18,176($sp) + ld $17,168($sp) + ld $16,160($sp) + j $31 + daddiu $sp,$sp,272 + + .align 3 +.L43: + move $sp,$fp + ld $31,200($sp) + ld $18,176($sp) + ld $17,168($sp) + ld $16,160($sp) + lb $2,8($fp) + ld $fp,192($sp) + j $31 + daddiu $sp,$sp,272 + + .align 3 +.L44: + b .L1 + ld $2,8($fp) + + .align 3 +.L46: + b .L1 + lbu $2,8($fp) + + .align 3 +.L47: + b .L1 + lh $2,8($fp) + + .align 3 +.L48: + b .L1 + lhu $2,8($fp) + + .align 3 +.L49: + b .L1 + lw $2,8($fp) + + .align 3 +.L51: + b .L1 + lwc1 $f0,8($fp) + + .align 3 +.L50: + b .L1 + lwu $2,8($fp) + +.L52: + b .L1 + ldc1 $f0,8($fp) + +.L19: + daddiu $13,$14,-1 + sltu $13,$13,16 + beql $13,$0,.L59 + andi $13,$12,0x800 + + ld $13,32($fp) + li $24,-8 # 0xfffffffffffffff8 + sltu $25,$14,9 + andi $15,$13,0x7 + and $24,$13,$24 + beq $25,$0,.L24 + daddu $13,$14,$15 + + sltu $25,$13,9 + sll $13,$13,0 + beq $25,$0,.L25 + subu $13,$0,$13 + + ld $25,0($24) + sll $13,$13,3 + li $24,-1 # 0xffffffffffffffff + dsll $13,$24,$13 + and $13,$13,$25 + sll $15,$15,3 + dsll $2,$13,$15 +.L23: + andi $13,$12,0x800 +.L59: + beql $13,$0,.L27 + andi $12,$12,0x1000 + + li $13,4 # 0x4 + beq $14,$13,.L56 + li $13,8 # 0x8 + + beql $14,$13,.L57 + ld $13,32($fp) + + andi $12,$12,0x1000 + beql $12,$0,.L58 + move $sp,$fp + + li $12,16 # 0x10 +.L60: + bnel $14,$12,.L58 + move $sp,$fp + + ld $12,32($fp) + ldc1 $f0,0($12) + b .L1 + ldc1 $f2,8($12) + +.L27: + beq $12,$0,.L1 + li $12,8 # 0x8 + + bne $14,$12,.L60 + li $12,16 # 0x10 + + ld $13,32($fp) + b .L1 + ldc1 $f0,0($13) + +.L24: + sltu $25,$13,17 + beq $25,$0,.L26 + sll $13,$13,0 + + ld $18,8($24) + subu $13,$0,$13 + move $16,$15 + li $25,-1 # 0xffffffffffffffff + subu $15,$0,$15 + sll $13,$13,3 + dsll $13,$25,$13 + ld $17,0($24) + sll $25,$15,2 + addiu $24,$25,32 + and $13,$13,$18 + sll $15,$16,3 + dsra $25,$13,$24 + dsll $16,$17,$15 + dsra $24,$25,$24 + or $2,$16,$24 + b .L23 + dsll $3,$13,$15 + +.L53: + ld $12,32($fp) + b .L1 + lbu $2,0($12) + +.L54: + ld $12,32($fp) + b .L1 + lhu $2,0($12) + +.L26: + ld $18,16($24) + subu $13,$0,$13 + ld $16,8($24) + ld $17,0($24) + subu $25,$0,$15 + sll $13,$13,3 + li $24,-1 # 0xffffffffffffffff + dsll $24,$24,$13 + sll $25,$25,3 + sll $15,$15,3 + addiu $25,$25,64 + and $13,$24,$18 + dsra $13,$13,$25 + dsll $24,$17,$15 + dsra $17,$16,$25 + dsll $15,$16,$15 + or $2,$24,$17 + b .L23 + or $3,$13,$15 + +.L56: + ld $12,32($fp) + b .L1 + lwc1 $f0,0($12) + +.L55: + ld $12,32($fp) + b .L1 + lwu $2,0($12) + +.L25: + ld $16,8($24) + ld $25,0($24) + sll $13,$13,3 + li $24,-1 # 0xffffffffffffffff + dsll $13,$24,$13 + subu $24,$0,$15 + and $13,$13,$16 + sll $24,$24,3 + sll $15,$15,3 + dsra $13,$13,$24 + dsll $15,$25,$15 + b .L23 + or $2,$13,$15 + +.L57: + andi $12,$12,0x1000 + lwc1 $f0,0($13) + beq $12,$0,.L1 + lwc1 $f2,4($13) + + b .L1 + ldc1 $f0,0($13) + + .set macro + .set reorder + .end callback_receiver + .size callback_receiver, .-callback_receiver + .align 2 + .align 3 + .globl callback_get_receiver + .set nomips16 + .set nomicromips + .ent callback_get_receiver + .type callback_get_receiver, @function +callback_get_receiver: + .frame $fp,16,$31 # vars= 0, regs= 1/0, args= 0, gp= 0 + .mask 0x40000000,-8 + .fmask 0x00000000,0 + .set noreorder + .set nomacro + lui $13,%hi(%neg(%gp_rel(callback_get_receiver))) + daddu $13,$13,$25 + daddiu $13,$13,%lo(%neg(%gp_rel(callback_get_receiver))) + daddiu $sp,$sp,-16 + ld $12,%got_page(callback_receiver)($13) + sd $fp,8($sp) + move $fp,$sp + move $sp,$fp + ld $fp,8($sp) + daddiu $2,$12,%got_ofst(callback_receiver) + j $31 + daddiu $sp,$sp,16 + + .set macro + .set reorder + .end callback_get_receiver + .size callback_get_receiver, .-callback_get_receiver + .ident "GCC: (GNU) 5.4.0" diff --git a/callback/vacall_r/vacall-mips64eb-macro.S b/callback/vacall_r/vacall-mips64eb-macro.S new file mode 100644 index 0000000..a0cd04c --- /dev/null +++ b/callback/vacall_r/vacall-mips64eb-macro.S @@ -0,0 +1,379 @@ +#include "asm-mips.h" + .file 1 "vacall-mips64.c" + .text + .align 2 + .align 3 + .set nomips16 + .set nomicromips + .ent callback_receiver + DECLARE_FUNCTION(callback_receiver) +callback_receiver: + .frame $fp,272,$31 + .mask 0xd0070000,-72 + .fmask 0x00000000,0 + .set noreorder + .set nomacro + daddiu $sp,$sp,-272 + sd $fp,192($sp) + move $fp,$sp + sd $4,208($fp) + ld $4,8($2) + ld $25,0($2) + daddiu $12,$fp,208 + sd $31,200($sp) + sd $18,176($sp) + sd $17,168($sp) + sd $16,160($sp) + sd $5,216($fp) + sd $6,224($fp) + sd $7,232($fp) + sd $8,240($fp) + sd $9,248($fp) + sd $10,256($fp) + sd $11,264($fp) + sdc1 $f12,96($fp) + sdc1 $f13,104($fp) + sdc1 $f14,112($fp) + sdc1 $f15,120($fp) + sdc1 $f16,128($fp) + sdc1 $f17,136($fp) + sdc1 $f18,144($fp) + sdc1 $f19,152($fp) + swc1 $f12,60($fp) + swc1 $f13,64($fp) + swc1 $f14,68($fp) + swc1 $f15,72($fp) + swc1 $f16,76($fp) + swc1 $f17,80($fp) + swc1 $f18,84($fp) + move $5,$fp + swc1 $f19,88($fp) + sd $12,24($fp) + sw $0,0($fp) + sd $0,32($fp) + sw $0,40($fp) + jalr $25 + sw $0,56($fp) + + lw $12,40($fp) + beq $12,$0,.L1 + li $13,1 + + beq $12,$13,.L43 + li $13,2 + + beq $12,$13,.L43 + li $13,3 + + beq $12,$13,.L46 + li $13,4 + + beq $12,$13,.L47 + li $13,5 + + beq $12,$13,.L48 + li $13,6 + + beq $12,$13,.L49 + li $13,7 + + beq $12,$13,.L50 + li $13,8 + + beq $12,$13,.L44 + li $13,9 + + beq $12,$13,.L44 + li $13,10 + + beq $12,$13,.L44 + li $13,11 + + beq $12,$13,.L44 + li $13,12 + + beq $12,$13,.L51 + li $13,13 + + beq $12,$13,.L52 + li $13,14 + + beq $12,$13,.L44 + li $13,15 + + bnel $12,$13,.L58 + move $sp,$fp + + lw $12,0($fp) + andi $13,$12,0x400 + beq $13,$0,.L1 + andi $13,$12,0x4 + + beq $13,$0,.L19 + ld $14,48($fp) + + ld $12,48($fp) + li $13,1 + beq $12,$13,.L53 + li $13,2 + + beq $12,$13,.L54 + li $13,4 + + beq $12,$13,.L55 + li $13,8 + + bnel $12,$13,.L58 + move $sp,$fp + + ld $12,32($fp) + ld $2,0($12) +.L1: + move $sp,$fp +.L58: + ld $31,200($sp) + ld $fp,192($sp) + ld $18,176($sp) + ld $17,168($sp) + ld $16,160($sp) + j $31 + daddiu $sp,$sp,272 + + .align 3 +.L43: + move $sp,$fp + ld $31,200($sp) + ld $18,176($sp) + ld $17,168($sp) + ld $16,160($sp) + lb $2,8($fp) + ld $fp,192($sp) + j $31 + daddiu $sp,$sp,272 + + .align 3 +.L44: + b .L1 + ld $2,8($fp) + + .align 3 +.L46: + b .L1 + lbu $2,8($fp) + + .align 3 +.L47: + b .L1 + lh $2,8($fp) + + .align 3 +.L48: + b .L1 + lhu $2,8($fp) + + .align 3 +.L49: + b .L1 + lw $2,8($fp) + + .align 3 +.L51: + b .L1 + lwc1 $f0,8($fp) + + .align 3 +.L50: + b .L1 + lwu $2,8($fp) + +.L52: + b .L1 + ldc1 $f0,8($fp) + +.L19: + daddiu $13,$14,-1 + sltu $13,$13,16 + beql $13,$0,.L59 + andi $13,$12,0x800 + + ld $13,32($fp) + li $24,-8 + sltu $25,$14,9 + andi $15,$13,0x7 + and $24,$13,$24 + beq $25,$0,.L24 + daddu $13,$14,$15 + + sltu $25,$13,9 + sll $13,$13,0 + beq $25,$0,.L25 + subu $13,$0,$13 + + ld $25,0($24) + sll $13,$13,3 + li $24,-1 + dsll $13,$24,$13 + and $13,$13,$25 + sll $15,$15,3 + dsll $2,$13,$15 +.L23: + andi $13,$12,0x800 +.L59: + beql $13,$0,.L27 + andi $12,$12,0x1000 + + li $13,4 + beq $14,$13,.L56 + li $13,8 + + beql $14,$13,.L57 + ld $13,32($fp) + + andi $12,$12,0x1000 + beql $12,$0,.L58 + move $sp,$fp + + li $12,16 +.L60: + bnel $14,$12,.L58 + move $sp,$fp + + ld $12,32($fp) + ldc1 $f0,0($12) + b .L1 + ldc1 $f2,8($12) + +.L27: + beq $12,$0,.L1 + li $12,8 + + bne $14,$12,.L60 + li $12,16 + + ld $13,32($fp) + b .L1 + ldc1 $f0,0($13) + +.L24: + sltu $25,$13,17 + beq $25,$0,.L26 + sll $13,$13,0 + + ld $18,8($24) + subu $13,$0,$13 + move $16,$15 + li $25,-1 + subu $15,$0,$15 + sll $13,$13,3 + dsll $13,$25,$13 + ld $17,0($24) + sll $25,$15,2 + addiu $24,$25,32 + and $13,$13,$18 + sll $15,$16,3 + dsra $25,$13,$24 + dsll $16,$17,$15 + dsra $24,$25,$24 + or $2,$16,$24 + b .L23 + dsll $3,$13,$15 + +.L53: + ld $12,32($fp) + b .L1 + lbu $2,0($12) + +.L54: + ld $12,32($fp) + b .L1 + lhu $2,0($12) + +.L26: + ld $18,16($24) + subu $13,$0,$13 + ld $16,8($24) + ld $17,0($24) + subu $25,$0,$15 + sll $13,$13,3 + li $24,-1 + dsll $24,$24,$13 + sll $25,$25,3 + sll $15,$15,3 + addiu $25,$25,64 + and $13,$24,$18 + dsra $13,$13,$25 + dsll $24,$17,$15 + dsra $17,$16,$25 + dsll $15,$16,$15 + or $2,$24,$17 + b .L23 + or $3,$13,$15 + +.L56: + ld $12,32($fp) + b .L1 + lwc1 $f0,0($12) + +.L55: + ld $12,32($fp) + b .L1 + lwu $2,0($12) + +.L25: + ld $16,8($24) + ld $25,0($24) + sll $13,$13,3 + li $24,-1 + dsll $13,$24,$13 + subu $24,$0,$15 + and $13,$13,$16 + sll $24,$24,3 + sll $15,$15,3 + dsra $13,$13,$24 + dsll $15,$25,$15 + b .L23 + or $2,$13,$15 + +.L57: + andi $12,$12,0x1000 + lwc1 $f0,0($13) + beq $12,$0,.L1 + lwc1 $f2,4($13) + + b .L1 + ldc1 $f0,0($13) + + .set macro + .set reorder + .end callback_receiver + .size callback_receiver, .-callback_receiver + .align 2 + .align 3 + .globl callback_get_receiver + .set nomips16 + .set nomicromips + .ent callback_get_receiver + DECLARE_FUNCTION(callback_get_receiver) +callback_get_receiver: + .frame $fp,16,$31 + .mask 0x40000000,-8 + .fmask 0x00000000,0 + .set noreorder + .set nomacro + lui $13,%hi(%neg(%gp_rel(callback_get_receiver))) + daddu $13,$13,$25 + daddiu $13,$13,%lo(%neg(%gp_rel(callback_get_receiver))) + daddiu $sp,$sp,-16 + ld $12,%got_page(callback_receiver)($13) + sd $fp,8($sp) + move $fp,$sp + move $sp,$fp + ld $fp,8($sp) + daddiu $2,$12,%got_ofst(callback_receiver) + j $31 + daddiu $sp,$sp,16 + + .set macro + .set reorder + .end callback_get_receiver + .size callback_get_receiver, .-callback_get_receiver diff --git a/callback/vacall_r/vacall-mips64el-linux.s b/callback/vacall_r/vacall-mips64el-linux.s new file mode 100644 index 0000000..152978d --- /dev/null +++ b/callback/vacall_r/vacall-mips64el-linux.s @@ -0,0 +1,389 @@ + .file 1 "vacall-mips64.c" + .section .mdebug.abi64 + .previous + .nan legacy + .module fp=64 + .module oddspreg + .abicalls + .text + .align 2 + .align 3 + .set nomips16 + .set nomicromips + .ent callback_receiver + .type callback_receiver, @function +callback_receiver: + .frame $fp,272,$31 # vars= 160, regs= 6/0, args= 0, gp= 0 + .mask 0xd0070000,-72 + .fmask 0x00000000,0 + .set noreorder + .set nomacro + daddiu $sp,$sp,-272 + sd $fp,192($sp) + move $fp,$sp + sd $4,208($fp) + ld $4,8($2) + ld $25,0($2) + daddiu $12,$fp,208 + sd $31,200($sp) + sd $18,176($sp) + sd $17,168($sp) + sd $16,160($sp) + sd $5,216($fp) + sd $6,224($fp) + sd $7,232($fp) + sd $8,240($fp) + sd $9,248($fp) + sd $10,256($fp) + sd $11,264($fp) + sdc1 $f12,96($fp) + sdc1 $f13,104($fp) + sdc1 $f14,112($fp) + sdc1 $f15,120($fp) + sdc1 $f16,128($fp) + sdc1 $f17,136($fp) + sdc1 $f18,144($fp) + sdc1 $f19,152($fp) + swc1 $f12,60($fp) + swc1 $f13,64($fp) + swc1 $f14,68($fp) + swc1 $f15,72($fp) + swc1 $f16,76($fp) + swc1 $f17,80($fp) + swc1 $f18,84($fp) + move $5,$fp + swc1 $f19,88($fp) + sd $12,24($fp) + sw $0,0($fp) + sd $0,32($fp) + sw $0,40($fp) + jalr $25 + sw $0,56($fp) + + lw $12,40($fp) + beq $12,$0,.L1 + li $13,1 # 0x1 + + beq $12,$13,.L43 + li $13,2 # 0x2 + + beq $12,$13,.L43 + li $13,3 # 0x3 + + beq $12,$13,.L46 + li $13,4 # 0x4 + + beq $12,$13,.L47 + li $13,5 # 0x5 + + beq $12,$13,.L48 + li $13,6 # 0x6 + + beq $12,$13,.L49 + li $13,7 # 0x7 + + beq $12,$13,.L50 + li $13,8 # 0x8 + + beq $12,$13,.L44 + li $13,9 # 0x9 + + beq $12,$13,.L44 + li $13,10 # 0xa + + beq $12,$13,.L44 + li $13,11 # 0xb + + beq $12,$13,.L44 + li $13,12 # 0xc + + beq $12,$13,.L51 + li $13,13 # 0xd + + beq $12,$13,.L52 + li $13,14 # 0xe + + beq $12,$13,.L44 + li $13,15 # 0xf + + bnel $12,$13,.L58 + move $sp,$fp + + lw $12,0($fp) + andi $13,$12,0x400 + beq $13,$0,.L1 + andi $13,$12,0x4 + + beq $13,$0,.L19 + ld $14,48($fp) + + ld $12,48($fp) + li $13,1 # 0x1 + beq $12,$13,.L53 + li $13,2 # 0x2 + + beq $12,$13,.L54 + li $13,4 # 0x4 + + beq $12,$13,.L55 + li $13,8 # 0x8 + + bnel $12,$13,.L58 + move $sp,$fp + + ld $12,32($fp) + ld $2,0($12) +.L1: + move $sp,$fp +.L58: + ld $31,200($sp) + ld $fp,192($sp) + ld $18,176($sp) + ld $17,168($sp) + ld $16,160($sp) + j $31 + daddiu $sp,$sp,272 + + .align 3 +.L43: + move $sp,$fp + ld $31,200($sp) + ld $18,176($sp) + ld $17,168($sp) + ld $16,160($sp) + lb $2,8($fp) + ld $fp,192($sp) + j $31 + daddiu $sp,$sp,272 + + .align 3 +.L44: + b .L1 + ld $2,8($fp) + + .align 3 +.L46: + b .L1 + lbu $2,8($fp) + + .align 3 +.L47: + b .L1 + lh $2,8($fp) + + .align 3 +.L48: + b .L1 + lhu $2,8($fp) + + .align 3 +.L49: + b .L1 + lw $2,8($fp) + + .align 3 +.L51: + b .L1 + lwc1 $f0,8($fp) + + .align 3 +.L50: + b .L1 + lwu $2,8($fp) + +.L52: + b .L1 + ldc1 $f0,8($fp) + +.L19: + daddiu $13,$14,-1 + sltu $13,$13,16 + beql $13,$0,.L59 + andi $13,$12,0x800 + + ld $13,32($fp) + li $15,-8 # 0xfffffffffffffff8 + sltu $25,$14,9 + andi $24,$13,0x7 + and $15,$13,$15 + beq $25,$0,.L24 + daddu $13,$14,$24 + + sltu $25,$13,9 + beq $25,$0,.L25 + dsll $13,$13,3 + + daddiu $13,$13,-1 + ld $25,0($15) + sll $13,$13,0 + li $15,2 # 0x2 + dsll $13,$15,$13 + daddiu $13,$13,-1 + and $13,$13,$25 + sll $24,$24,3 + dsra $2,$13,$24 +.L23: + andi $13,$12,0x800 +.L59: + beql $13,$0,.L27 + andi $12,$12,0x1000 + + li $13,4 # 0x4 + beq $14,$13,.L56 + li $13,8 # 0x8 + + beql $14,$13,.L57 + ld $13,32($fp) + + andi $12,$12,0x1000 + beql $12,$0,.L58 + move $sp,$fp + + li $12,16 # 0x10 +.L60: + bnel $14,$12,.L58 + move $sp,$fp + + ld $12,32($fp) + ldc1 $f0,0($12) + b .L1 + ldc1 $f2,8($12) + +.L27: + beq $12,$0,.L1 + li $12,8 # 0x8 + + bne $14,$12,.L60 + li $12,16 # 0x10 + + ld $13,32($fp) + b .L1 + ldc1 $f0,0($13) + +.L24: + sltu $25,$13,17 + beq $25,$0,.L26 + dsll $13,$13,3 + + daddiu $13,$13,-65 + ld $17,8($15) + li $25,2 # 0x2 + sll $13,$13,0 + dsll $13,$25,$13 + subu $25,$0,$24 + sll $25,$25,2 + ld $16,0($15) + daddiu $13,$13,-1 + addiu $15,$25,32 + and $13,$13,$17 + sll $24,$24,3 + dsll $25,$13,$15 + dsra $16,$16,$24 + dsll $15,$25,$15 + or $2,$16,$15 + b .L23 + dsra $3,$13,$24 + +.L53: + ld $12,32($fp) + b .L1 + lbu $2,0($12) + +.L54: + ld $12,32($fp) + b .L1 + lhu $2,0($12) + +.L26: + daddiu $13,$13,-129 + ld $16,8($15) + ld $17,0($15) + sll $13,$13,0 + ld $18,16($15) + li $15,2 # 0x2 + subu $25,$0,$24 + dsll $15,$15,$13 + daddiu $15,$15,-1 + sll $25,$25,3 + sll $24,$24,3 + addiu $25,$25,64 + and $13,$15,$18 + dsll $13,$13,$25 + dsra $15,$17,$24 + dsll $17,$16,$25 + dsra $24,$16,$24 + or $2,$15,$17 + b .L23 + or $3,$13,$24 + +.L56: + ld $12,32($fp) + b .L1 + lwc1 $f0,0($12) + +.L55: + ld $12,32($fp) + b .L1 + lwu $2,0($12) + +.L25: + daddiu $13,$13,-65 + li $25,2 # 0x2 + sll $13,$13,0 + ld $17,8($15) + dsll $13,$25,$13 + ld $25,0($15) + daddiu $13,$13,-1 + subu $16,$0,$24 + and $15,$13,$17 + sll $24,$24,3 + sll $13,$16,3 + dsll $13,$15,$13 + dsra $24,$25,$24 + b .L23 + or $2,$13,$24 + +.L57: + andi $12,$12,0x1000 + lwc1 $f0,0($13) + beq $12,$0,.L1 + lwc1 $f2,4($13) + + b .L1 + ldc1 $f0,0($13) + + .set macro + .set reorder + .end callback_receiver + .size callback_receiver, .-callback_receiver + .align 2 + .align 3 + .globl callback_get_receiver + .set nomips16 + .set nomicromips + .ent callback_get_receiver + .type callback_get_receiver, @function +callback_get_receiver: + .frame $fp,16,$31 # vars= 0, regs= 1/0, args= 0, gp= 0 + .mask 0x40000000,-8 + .fmask 0x00000000,0 + .set noreorder + .set nomacro + lui $13,%hi(%neg(%gp_rel(callback_get_receiver))) + daddu $13,$13,$25 + daddiu $13,$13,%lo(%neg(%gp_rel(callback_get_receiver))) + daddiu $sp,$sp,-16 + ld $12,%got_page(callback_receiver)($13) + sd $fp,8($sp) + move $fp,$sp + move $sp,$fp + ld $fp,8($sp) + daddiu $2,$12,%got_ofst(callback_receiver) + j $31 + daddiu $sp,$sp,16 + + .set macro + .set reorder + .end callback_get_receiver + .size callback_get_receiver, .-callback_get_receiver + .ident "GCC: (GNU) 5.4.0" diff --git a/callback/vacall_r/vacall-mips64el-macro.S b/callback/vacall_r/vacall-mips64el-macro.S new file mode 100644 index 0000000..d2d7d89 --- /dev/null +++ b/callback/vacall_r/vacall-mips64el-macro.S @@ -0,0 +1,383 @@ +#include "asm-mips.h" + .file 1 "vacall-mips64.c" + .text + .align 2 + .align 3 + .set nomips16 + .set nomicromips + .ent callback_receiver + DECLARE_FUNCTION(callback_receiver) +callback_receiver: + .frame $fp,272,$31 + .mask 0xd0070000,-72 + .fmask 0x00000000,0 + .set noreorder + .set nomacro + daddiu $sp,$sp,-272 + sd $fp,192($sp) + move $fp,$sp + sd $4,208($fp) + ld $4,8($2) + ld $25,0($2) + daddiu $12,$fp,208 + sd $31,200($sp) + sd $18,176($sp) + sd $17,168($sp) + sd $16,160($sp) + sd $5,216($fp) + sd $6,224($fp) + sd $7,232($fp) + sd $8,240($fp) + sd $9,248($fp) + sd $10,256($fp) + sd $11,264($fp) + sdc1 $f12,96($fp) + sdc1 $f13,104($fp) + sdc1 $f14,112($fp) + sdc1 $f15,120($fp) + sdc1 $f16,128($fp) + sdc1 $f17,136($fp) + sdc1 $f18,144($fp) + sdc1 $f19,152($fp) + swc1 $f12,60($fp) + swc1 $f13,64($fp) + swc1 $f14,68($fp) + swc1 $f15,72($fp) + swc1 $f16,76($fp) + swc1 $f17,80($fp) + swc1 $f18,84($fp) + move $5,$fp + swc1 $f19,88($fp) + sd $12,24($fp) + sw $0,0($fp) + sd $0,32($fp) + sw $0,40($fp) + jalr $25 + sw $0,56($fp) + + lw $12,40($fp) + beq $12,$0,.L1 + li $13,1 + + beq $12,$13,.L43 + li $13,2 + + beq $12,$13,.L43 + li $13,3 + + beq $12,$13,.L46 + li $13,4 + + beq $12,$13,.L47 + li $13,5 + + beq $12,$13,.L48 + li $13,6 + + beq $12,$13,.L49 + li $13,7 + + beq $12,$13,.L50 + li $13,8 + + beq $12,$13,.L44 + li $13,9 + + beq $12,$13,.L44 + li $13,10 + + beq $12,$13,.L44 + li $13,11 + + beq $12,$13,.L44 + li $13,12 + + beq $12,$13,.L51 + li $13,13 + + beq $12,$13,.L52 + li $13,14 + + beq $12,$13,.L44 + li $13,15 + + bnel $12,$13,.L58 + move $sp,$fp + + lw $12,0($fp) + andi $13,$12,0x400 + beq $13,$0,.L1 + andi $13,$12,0x4 + + beq $13,$0,.L19 + ld $14,48($fp) + + ld $12,48($fp) + li $13,1 + beq $12,$13,.L53 + li $13,2 + + beq $12,$13,.L54 + li $13,4 + + beq $12,$13,.L55 + li $13,8 + + bnel $12,$13,.L58 + move $sp,$fp + + ld $12,32($fp) + ld $2,0($12) +.L1: + move $sp,$fp +.L58: + ld $31,200($sp) + ld $fp,192($sp) + ld $18,176($sp) + ld $17,168($sp) + ld $16,160($sp) + j $31 + daddiu $sp,$sp,272 + + .align 3 +.L43: + move $sp,$fp + ld $31,200($sp) + ld $18,176($sp) + ld $17,168($sp) + ld $16,160($sp) + lb $2,8($fp) + ld $fp,192($sp) + j $31 + daddiu $sp,$sp,272 + + .align 3 +.L44: + b .L1 + ld $2,8($fp) + + .align 3 +.L46: + b .L1 + lbu $2,8($fp) + + .align 3 +.L47: + b .L1 + lh $2,8($fp) + + .align 3 +.L48: + b .L1 + lhu $2,8($fp) + + .align 3 +.L49: + b .L1 + lw $2,8($fp) + + .align 3 +.L51: + b .L1 + lwc1 $f0,8($fp) + + .align 3 +.L50: + b .L1 + lwu $2,8($fp) + +.L52: + b .L1 + ldc1 $f0,8($fp) + +.L19: + daddiu $13,$14,-1 + sltu $13,$13,16 + beql $13,$0,.L59 + andi $13,$12,0x800 + + ld $13,32($fp) + li $15,-8 + sltu $25,$14,9 + andi $24,$13,0x7 + and $15,$13,$15 + beq $25,$0,.L24 + daddu $13,$14,$24 + + sltu $25,$13,9 + beq $25,$0,.L25 + dsll $13,$13,3 + + daddiu $13,$13,-1 + ld $25,0($15) + sll $13,$13,0 + li $15,2 + dsll $13,$15,$13 + daddiu $13,$13,-1 + and $13,$13,$25 + sll $24,$24,3 + dsra $2,$13,$24 +.L23: + andi $13,$12,0x800 +.L59: + beql $13,$0,.L27 + andi $12,$12,0x1000 + + li $13,4 + beq $14,$13,.L56 + li $13,8 + + beql $14,$13,.L57 + ld $13,32($fp) + + andi $12,$12,0x1000 + beql $12,$0,.L58 + move $sp,$fp + + li $12,16 +.L60: + bnel $14,$12,.L58 + move $sp,$fp + + ld $12,32($fp) + ldc1 $f0,0($12) + b .L1 + ldc1 $f2,8($12) + +.L27: + beq $12,$0,.L1 + li $12,8 + + bne $14,$12,.L60 + li $12,16 + + ld $13,32($fp) + b .L1 + ldc1 $f0,0($13) + +.L24: + sltu $25,$13,17 + beq $25,$0,.L26 + dsll $13,$13,3 + + daddiu $13,$13,-65 + ld $17,8($15) + li $25,2 + sll $13,$13,0 + dsll $13,$25,$13 + subu $25,$0,$24 + sll $25,$25,2 + ld $16,0($15) + daddiu $13,$13,-1 + addiu $15,$25,32 + and $13,$13,$17 + sll $24,$24,3 + dsll $25,$13,$15 + dsra $16,$16,$24 + dsll $15,$25,$15 + or $2,$16,$15 + b .L23 + dsra $3,$13,$24 + +.L53: + ld $12,32($fp) + b .L1 + lbu $2,0($12) + +.L54: + ld $12,32($fp) + b .L1 + lhu $2,0($12) + +.L26: + daddiu $13,$13,-129 + ld $16,8($15) + ld $17,0($15) + sll $13,$13,0 + ld $18,16($15) + li $15,2 + subu $25,$0,$24 + dsll $15,$15,$13 + daddiu $15,$15,-1 + sll $25,$25,3 + sll $24,$24,3 + addiu $25,$25,64 + and $13,$15,$18 + dsll $13,$13,$25 + dsra $15,$17,$24 + dsll $17,$16,$25 + dsra $24,$16,$24 + or $2,$15,$17 + b .L23 + or $3,$13,$24 + +.L56: + ld $12,32($fp) + b .L1 + lwc1 $f0,0($12) + +.L55: + ld $12,32($fp) + b .L1 + lwu $2,0($12) + +.L25: + daddiu $13,$13,-65 + li $25,2 + sll $13,$13,0 + ld $17,8($15) + dsll $13,$25,$13 + ld $25,0($15) + daddiu $13,$13,-1 + subu $16,$0,$24 + and $15,$13,$17 + sll $24,$24,3 + sll $13,$16,3 + dsll $13,$15,$13 + dsra $24,$25,$24 + b .L23 + or $2,$13,$24 + +.L57: + andi $12,$12,0x1000 + lwc1 $f0,0($13) + beq $12,$0,.L1 + lwc1 $f2,4($13) + + b .L1 + ldc1 $f0,0($13) + + .set macro + .set reorder + .end callback_receiver + .size callback_receiver, .-callback_receiver + .align 2 + .align 3 + .globl callback_get_receiver + .set nomips16 + .set nomicromips + .ent callback_get_receiver + DECLARE_FUNCTION(callback_get_receiver) +callback_get_receiver: + .frame $fp,16,$31 + .mask 0x40000000,-8 + .fmask 0x00000000,0 + .set noreorder + .set nomacro + lui $13,%hi(%neg(%gp_rel(callback_get_receiver))) + daddu $13,$13,$25 + daddiu $13,$13,%lo(%neg(%gp_rel(callback_get_receiver))) + daddiu $sp,$sp,-16 + ld $12,%got_page(callback_receiver)($13) + sd $fp,8($sp) + move $fp,$sp + move $sp,$fp + ld $fp,8($sp) + daddiu $2,$12,%got_ofst(callback_receiver) + j $31 + daddiu $sp,$sp,16 + + .set macro + .set reorder + .end callback_get_receiver + .size callback_get_receiver, .-callback_get_receiver diff --git a/callback/vacall_r/vacall-mipseb-linux.s b/callback/vacall_r/vacall-mipseb-linux.s new file mode 100644 index 0000000..7d3634c --- /dev/null +++ b/callback/vacall_r/vacall-mipseb-linux.s @@ -0,0 +1,322 @@ + .file 1 "vacall-mips.c" + .section .mdebug.abi32 + .previous + .nan legacy + .module fp=xx + .module nooddspreg + .abicalls + .text + .align 2 + .set nomips16 + .set nomicromips + .ent callback_receiver + .type callback_receiver, @function +callback_receiver: + .frame $fp,104,$31 # vars= 72, regs= 2/0, args= 16, gp= 8 + .mask 0xc0000000,-4 + .fmask 0x00000000,0 + .set noreorder + .cpload $25 + .set reorder + addiu $sp,$sp,-104 + sw $fp,96($sp) + move $fp,$sp + sw $31,100($sp) + lw $25,0($2) + sw $4,104($fp) + lw $4,4($2) + sw $5,108($fp) + addiu $5,$fp,104 + sw $5,40($fp) + addiu $5,$fp,120 + sw $5,56($fp) + .cprestore 16 + sw $6,112($fp) + sw $7,116($fp) + sdc1 $f12,80($fp) + sdc1 $f14,88($fp) + swc1 $f12,68($fp) + swc1 $f14,72($fp) + sw $0,24($fp) + sw $0,44($fp) + sw $0,48($fp) + sw $0,60($fp) + sw $0,64($fp) + addiu $5,$fp,24 + jal $25 + lw $4,48($fp) + .set noreorder + .set nomacro + beq $4,$0,$L1 + li $5,1 # 0x1 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L23 + li $5,2 # 0x2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L23 + li $5,3 # 0x3 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L29 + li $5,4 # 0x4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L30 + li $5,5 # 0x5 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L31 + li $5,6 # 0x6 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,7 # 0x7 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,8 # 0x8 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,9 # 0x9 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + addiu $5,$4,-10 + .set macro + .set reorder + + sltu $5,$5,2 + .set noreorder + .set nomacro + bne $5,$0,$L32 + li $5,12 # 0xc + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L33 + li $5,13 # 0xd + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L34 + li $5,14 # 0xe + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,15 # 0xf + .set macro + .set reorder + + .set noreorder + .set nomacro + bnel $4,$5,$L37 + move $sp,$fp + .set macro + .set reorder + + lw $4,24($fp) + andi $4,$4,0x2 + .set noreorder + .set nomacro + beql $4,$0,$L38 + lw $2,44($fp) + .set macro + .set reorder + + lw $4,52($fp) + li $5,1 # 0x1 + .set noreorder + .set nomacro + beql $4,$5,$L35 + lw $4,44($fp) + .set macro + .set reorder + + li $5,2 # 0x2 + .set noreorder + .set nomacro + beq $4,$5,$L36 + li $5,4 # 0x4 + .set macro + .set reorder + + .set noreorder + .set nomacro + bnel $4,$5,$L37 + move $sp,$fp + .set macro + .set reorder + + lw $4,44($fp) + lw $2,0($4) +$L1: +$L38: + move $sp,$fp +$L37: + lw $31,100($sp) + lw $fp,96($sp) + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,104 + .set macro + .set reorder + +$L23: + move $sp,$fp + lw $31,100($sp) + lb $2,32($fp) + lw $fp,96($sp) + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,104 + .set macro + .set reorder + +$L27: + move $sp,$fp + lw $31,100($sp) + lw $2,32($fp) + lw $fp,96($sp) + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,104 + .set macro + .set reorder + +$L29: + .set noreorder + .set nomacro + b $L1 + lbu $2,32($fp) + .set macro + .set reorder + +$L30: + .set noreorder + .set nomacro + b $L1 + lh $2,32($fp) + .set macro + .set reorder + +$L31: + .set noreorder + .set nomacro + b $L1 + lhu $2,32($fp) + .set macro + .set reorder + +$L34: + .set noreorder + .set nomacro + b $L1 + ldc1 $f0,32($fp) + .set macro + .set reorder + +$L32: + lw $2,32($fp) + .set noreorder + .set nomacro + b $L1 + lw $3,36($fp) + .set macro + .set reorder + +$L33: + .set noreorder + .set nomacro + b $L1 + lwc1 $f0,32($fp) + .set macro + .set reorder + +$L35: + .set noreorder + .set nomacro + b $L1 + lbu $2,0($4) + .set macro + .set reorder + +$L36: + lw $4,44($fp) + .set noreorder + .set nomacro + b $L1 + lhu $2,0($4) + .set macro + .set reorder + + .end callback_receiver + .size callback_receiver, .-callback_receiver + .align 2 + .globl callback_get_receiver + .set nomips16 + .set nomicromips + .ent callback_get_receiver + .type callback_get_receiver, @function +callback_get_receiver: + .frame $fp,8,$31 # vars= 0, regs= 1/0, args= 0, gp= 0 + .mask 0x40000000,-4 + .fmask 0x00000000,0 + .set noreorder + .cpload $25 + .set reorder + addiu $sp,$sp,-8 + sw $fp,4($sp) + move $fp,$sp + move $sp,$fp + lw $fp,4($sp) + la $2,callback_receiver + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,8 + .set macro + .set reorder + + .end callback_get_receiver + .size callback_get_receiver, .-callback_get_receiver + .ident "GCC: (GNU) 5.4.0" diff --git a/callback/vacall_r/vacall-mipseb-macro.S b/callback/vacall_r/vacall-mipseb-macro.S new file mode 100644 index 0000000..f97bbb4 --- /dev/null +++ b/callback/vacall_r/vacall-mipseb-macro.S @@ -0,0 +1,316 @@ +#include "asm-mips.h" + .file 1 "vacall-mips.c" + .text + .align 2 + .set nomips16 + .set nomicromips + .ent callback_receiver + DECLARE_FUNCTION(callback_receiver) +callback_receiver: + .frame $fp,104,$31 + .mask 0xc0000000,-4 + .fmask 0x00000000,0 + .set noreorder + .cpload $25 + .set reorder + addiu $sp,$sp,-104 + sw $fp,96($sp) + move $fp,$sp + sw $31,100($sp) + lw $25,0($2) + sw $4,104($fp) + lw $4,4($2) + sw $5,108($fp) + addiu $5,$fp,104 + sw $5,40($fp) + addiu $5,$fp,120 + sw $5,56($fp) + .cprestore 16 + sw $6,112($fp) + sw $7,116($fp) + sdc1 $f12,80($fp) + sdc1 $f14,88($fp) + swc1 $f12,68($fp) + swc1 $f14,72($fp) + sw $0,24($fp) + sw $0,44($fp) + sw $0,48($fp) + sw $0,60($fp) + sw $0,64($fp) + addiu $5,$fp,24 + jal $25 + lw $4,48($fp) + .set noreorder + .set nomacro + beq $4,$0,$L1 + li $5,1 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L23 + li $5,2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L23 + li $5,3 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L29 + li $5,4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L30 + li $5,5 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L31 + li $5,6 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,7 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,8 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,9 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + addiu $5,$4,-10 + .set macro + .set reorder + + sltu $5,$5,2 + .set noreorder + .set nomacro + bne $5,$0,$L32 + li $5,12 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L33 + li $5,13 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L34 + li $5,14 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,15 + .set macro + .set reorder + + .set noreorder + .set nomacro + bnel $4,$5,$L37 + move $sp,$fp + .set macro + .set reorder + + lw $4,24($fp) + andi $4,$4,0x2 + .set noreorder + .set nomacro + beql $4,$0,$L38 + lw $2,44($fp) + .set macro + .set reorder + + lw $4,52($fp) + li $5,1 + .set noreorder + .set nomacro + beql $4,$5,$L35 + lw $4,44($fp) + .set macro + .set reorder + + li $5,2 + .set noreorder + .set nomacro + beq $4,$5,$L36 + li $5,4 + .set macro + .set reorder + + .set noreorder + .set nomacro + bnel $4,$5,$L37 + move $sp,$fp + .set macro + .set reorder + + lw $4,44($fp) + lw $2,0($4) +$L1: +$L38: + move $sp,$fp +$L37: + lw $31,100($sp) + lw $fp,96($sp) + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,104 + .set macro + .set reorder + +$L23: + move $sp,$fp + lw $31,100($sp) + lb $2,32($fp) + lw $fp,96($sp) + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,104 + .set macro + .set reorder + +$L27: + move $sp,$fp + lw $31,100($sp) + lw $2,32($fp) + lw $fp,96($sp) + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,104 + .set macro + .set reorder + +$L29: + .set noreorder + .set nomacro + b $L1 + lbu $2,32($fp) + .set macro + .set reorder + +$L30: + .set noreorder + .set nomacro + b $L1 + lh $2,32($fp) + .set macro + .set reorder + +$L31: + .set noreorder + .set nomacro + b $L1 + lhu $2,32($fp) + .set macro + .set reorder + +$L34: + .set noreorder + .set nomacro + b $L1 + ldc1 $f0,32($fp) + .set macro + .set reorder + +$L32: + lw $2,32($fp) + .set noreorder + .set nomacro + b $L1 + lw $3,36($fp) + .set macro + .set reorder + +$L33: + .set noreorder + .set nomacro + b $L1 + lwc1 $f0,32($fp) + .set macro + .set reorder + +$L35: + .set noreorder + .set nomacro + b $L1 + lbu $2,0($4) + .set macro + .set reorder + +$L36: + lw $4,44($fp) + .set noreorder + .set nomacro + b $L1 + lhu $2,0($4) + .set macro + .set reorder + + .end callback_receiver + .size callback_receiver, .-callback_receiver + .align 2 + .globl callback_get_receiver + .set nomips16 + .set nomicromips + .ent callback_get_receiver + DECLARE_FUNCTION(callback_get_receiver) +callback_get_receiver: + .frame $fp,8,$31 + .mask 0x40000000,-4 + .fmask 0x00000000,0 + .set noreorder + .cpload $25 + .set reorder + addiu $sp,$sp,-8 + sw $fp,4($sp) + move $fp,$sp + move $sp,$fp + lw $fp,4($sp) + la $2,callback_receiver + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,8 + .set macro + .set reorder + + .end callback_get_receiver + .size callback_get_receiver, .-callback_get_receiver diff --git a/callback/vacall_r/vacall-mipsel-linux.s b/callback/vacall_r/vacall-mipsel-linux.s new file mode 100644 index 0000000..7d3634c --- /dev/null +++ b/callback/vacall_r/vacall-mipsel-linux.s @@ -0,0 +1,322 @@ + .file 1 "vacall-mips.c" + .section .mdebug.abi32 + .previous + .nan legacy + .module fp=xx + .module nooddspreg + .abicalls + .text + .align 2 + .set nomips16 + .set nomicromips + .ent callback_receiver + .type callback_receiver, @function +callback_receiver: + .frame $fp,104,$31 # vars= 72, regs= 2/0, args= 16, gp= 8 + .mask 0xc0000000,-4 + .fmask 0x00000000,0 + .set noreorder + .cpload $25 + .set reorder + addiu $sp,$sp,-104 + sw $fp,96($sp) + move $fp,$sp + sw $31,100($sp) + lw $25,0($2) + sw $4,104($fp) + lw $4,4($2) + sw $5,108($fp) + addiu $5,$fp,104 + sw $5,40($fp) + addiu $5,$fp,120 + sw $5,56($fp) + .cprestore 16 + sw $6,112($fp) + sw $7,116($fp) + sdc1 $f12,80($fp) + sdc1 $f14,88($fp) + swc1 $f12,68($fp) + swc1 $f14,72($fp) + sw $0,24($fp) + sw $0,44($fp) + sw $0,48($fp) + sw $0,60($fp) + sw $0,64($fp) + addiu $5,$fp,24 + jal $25 + lw $4,48($fp) + .set noreorder + .set nomacro + beq $4,$0,$L1 + li $5,1 # 0x1 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L23 + li $5,2 # 0x2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L23 + li $5,3 # 0x3 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L29 + li $5,4 # 0x4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L30 + li $5,5 # 0x5 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L31 + li $5,6 # 0x6 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,7 # 0x7 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,8 # 0x8 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,9 # 0x9 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + addiu $5,$4,-10 + .set macro + .set reorder + + sltu $5,$5,2 + .set noreorder + .set nomacro + bne $5,$0,$L32 + li $5,12 # 0xc + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L33 + li $5,13 # 0xd + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L34 + li $5,14 # 0xe + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,15 # 0xf + .set macro + .set reorder + + .set noreorder + .set nomacro + bnel $4,$5,$L37 + move $sp,$fp + .set macro + .set reorder + + lw $4,24($fp) + andi $4,$4,0x2 + .set noreorder + .set nomacro + beql $4,$0,$L38 + lw $2,44($fp) + .set macro + .set reorder + + lw $4,52($fp) + li $5,1 # 0x1 + .set noreorder + .set nomacro + beql $4,$5,$L35 + lw $4,44($fp) + .set macro + .set reorder + + li $5,2 # 0x2 + .set noreorder + .set nomacro + beq $4,$5,$L36 + li $5,4 # 0x4 + .set macro + .set reorder + + .set noreorder + .set nomacro + bnel $4,$5,$L37 + move $sp,$fp + .set macro + .set reorder + + lw $4,44($fp) + lw $2,0($4) +$L1: +$L38: + move $sp,$fp +$L37: + lw $31,100($sp) + lw $fp,96($sp) + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,104 + .set macro + .set reorder + +$L23: + move $sp,$fp + lw $31,100($sp) + lb $2,32($fp) + lw $fp,96($sp) + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,104 + .set macro + .set reorder + +$L27: + move $sp,$fp + lw $31,100($sp) + lw $2,32($fp) + lw $fp,96($sp) + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,104 + .set macro + .set reorder + +$L29: + .set noreorder + .set nomacro + b $L1 + lbu $2,32($fp) + .set macro + .set reorder + +$L30: + .set noreorder + .set nomacro + b $L1 + lh $2,32($fp) + .set macro + .set reorder + +$L31: + .set noreorder + .set nomacro + b $L1 + lhu $2,32($fp) + .set macro + .set reorder + +$L34: + .set noreorder + .set nomacro + b $L1 + ldc1 $f0,32($fp) + .set macro + .set reorder + +$L32: + lw $2,32($fp) + .set noreorder + .set nomacro + b $L1 + lw $3,36($fp) + .set macro + .set reorder + +$L33: + .set noreorder + .set nomacro + b $L1 + lwc1 $f0,32($fp) + .set macro + .set reorder + +$L35: + .set noreorder + .set nomacro + b $L1 + lbu $2,0($4) + .set macro + .set reorder + +$L36: + lw $4,44($fp) + .set noreorder + .set nomacro + b $L1 + lhu $2,0($4) + .set macro + .set reorder + + .end callback_receiver + .size callback_receiver, .-callback_receiver + .align 2 + .globl callback_get_receiver + .set nomips16 + .set nomicromips + .ent callback_get_receiver + .type callback_get_receiver, @function +callback_get_receiver: + .frame $fp,8,$31 # vars= 0, regs= 1/0, args= 0, gp= 0 + .mask 0x40000000,-4 + .fmask 0x00000000,0 + .set noreorder + .cpload $25 + .set reorder + addiu $sp,$sp,-8 + sw $fp,4($sp) + move $fp,$sp + move $sp,$fp + lw $fp,4($sp) + la $2,callback_receiver + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,8 + .set macro + .set reorder + + .end callback_get_receiver + .size callback_get_receiver, .-callback_get_receiver + .ident "GCC: (GNU) 5.4.0" diff --git a/callback/vacall_r/vacall-mipsel-macro.S b/callback/vacall_r/vacall-mipsel-macro.S new file mode 100644 index 0000000..f97bbb4 --- /dev/null +++ b/callback/vacall_r/vacall-mipsel-macro.S @@ -0,0 +1,316 @@ +#include "asm-mips.h" + .file 1 "vacall-mips.c" + .text + .align 2 + .set nomips16 + .set nomicromips + .ent callback_receiver + DECLARE_FUNCTION(callback_receiver) +callback_receiver: + .frame $fp,104,$31 + .mask 0xc0000000,-4 + .fmask 0x00000000,0 + .set noreorder + .cpload $25 + .set reorder + addiu $sp,$sp,-104 + sw $fp,96($sp) + move $fp,$sp + sw $31,100($sp) + lw $25,0($2) + sw $4,104($fp) + lw $4,4($2) + sw $5,108($fp) + addiu $5,$fp,104 + sw $5,40($fp) + addiu $5,$fp,120 + sw $5,56($fp) + .cprestore 16 + sw $6,112($fp) + sw $7,116($fp) + sdc1 $f12,80($fp) + sdc1 $f14,88($fp) + swc1 $f12,68($fp) + swc1 $f14,72($fp) + sw $0,24($fp) + sw $0,44($fp) + sw $0,48($fp) + sw $0,60($fp) + sw $0,64($fp) + addiu $5,$fp,24 + jal $25 + lw $4,48($fp) + .set noreorder + .set nomacro + beq $4,$0,$L1 + li $5,1 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L23 + li $5,2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L23 + li $5,3 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L29 + li $5,4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L30 + li $5,5 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L31 + li $5,6 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,7 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,8 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,9 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + addiu $5,$4,-10 + .set macro + .set reorder + + sltu $5,$5,2 + .set noreorder + .set nomacro + bne $5,$0,$L32 + li $5,12 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L33 + li $5,13 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L34 + li $5,14 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,15 + .set macro + .set reorder + + .set noreorder + .set nomacro + bnel $4,$5,$L37 + move $sp,$fp + .set macro + .set reorder + + lw $4,24($fp) + andi $4,$4,0x2 + .set noreorder + .set nomacro + beql $4,$0,$L38 + lw $2,44($fp) + .set macro + .set reorder + + lw $4,52($fp) + li $5,1 + .set noreorder + .set nomacro + beql $4,$5,$L35 + lw $4,44($fp) + .set macro + .set reorder + + li $5,2 + .set noreorder + .set nomacro + beq $4,$5,$L36 + li $5,4 + .set macro + .set reorder + + .set noreorder + .set nomacro + bnel $4,$5,$L37 + move $sp,$fp + .set macro + .set reorder + + lw $4,44($fp) + lw $2,0($4) +$L1: +$L38: + move $sp,$fp +$L37: + lw $31,100($sp) + lw $fp,96($sp) + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,104 + .set macro + .set reorder + +$L23: + move $sp,$fp + lw $31,100($sp) + lb $2,32($fp) + lw $fp,96($sp) + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,104 + .set macro + .set reorder + +$L27: + move $sp,$fp + lw $31,100($sp) + lw $2,32($fp) + lw $fp,96($sp) + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,104 + .set macro + .set reorder + +$L29: + .set noreorder + .set nomacro + b $L1 + lbu $2,32($fp) + .set macro + .set reorder + +$L30: + .set noreorder + .set nomacro + b $L1 + lh $2,32($fp) + .set macro + .set reorder + +$L31: + .set noreorder + .set nomacro + b $L1 + lhu $2,32($fp) + .set macro + .set reorder + +$L34: + .set noreorder + .set nomacro + b $L1 + ldc1 $f0,32($fp) + .set macro + .set reorder + +$L32: + lw $2,32($fp) + .set noreorder + .set nomacro + b $L1 + lw $3,36($fp) + .set macro + .set reorder + +$L33: + .set noreorder + .set nomacro + b $L1 + lwc1 $f0,32($fp) + .set macro + .set reorder + +$L35: + .set noreorder + .set nomacro + b $L1 + lbu $2,0($4) + .set macro + .set reorder + +$L36: + lw $4,44($fp) + .set noreorder + .set nomacro + b $L1 + lhu $2,0($4) + .set macro + .set reorder + + .end callback_receiver + .size callback_receiver, .-callback_receiver + .align 2 + .globl callback_get_receiver + .set nomips16 + .set nomicromips + .ent callback_get_receiver + DECLARE_FUNCTION(callback_get_receiver) +callback_get_receiver: + .frame $fp,8,$31 + .mask 0x40000000,-4 + .fmask 0x00000000,0 + .set noreorder + .cpload $25 + .set reorder + addiu $sp,$sp,-8 + sw $fp,4($sp) + move $fp,$sp + move $sp,$fp + lw $fp,4($sp) + la $2,callback_receiver + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,8 + .set macro + .set reorder + + .end callback_get_receiver + .size callback_get_receiver, .-callback_get_receiver diff --git a/callback/vacall_r/vacall-mipsn32eb-linux.s b/callback/vacall_r/vacall-mipsn32eb-linux.s new file mode 100644 index 0000000..96318a1 --- /dev/null +++ b/callback/vacall_r/vacall-mipsn32eb-linux.s @@ -0,0 +1,381 @@ + .file 1 "vacall-mipsn32.c" + .section .mdebug.abiN32 + .previous + .nan legacy + .module fp=64 + .module oddspreg + .abicalls + .text + .align 2 + .align 3 + .set nomips16 + .set nomicromips + .ent callback_receiver + .type callback_receiver, @function +callback_receiver: + .frame $fp,256,$31 # vars= 144, regs= 6/0, args= 0, gp= 0 + .mask 0xd0070000,-72 + .fmask 0x00000000,0 + .set noreorder + .set nomacro + addiu $sp,$sp,-256 + sd $fp,176($sp) + move $fp,$sp + sd $4,192($fp) + lw $4,4($2) + lw $25,0($2) + addiu $12,$fp,192 + sd $31,184($sp) + sd $18,160($sp) + sd $17,152($sp) + sd $16,144($sp) + sd $5,200($fp) + sd $6,208($fp) + sd $7,216($fp) + sd $8,224($fp) + sd $9,232($fp) + sd $10,240($fp) + sd $11,248($fp) + sdc1 $f12,80($fp) + sdc1 $f13,88($fp) + sdc1 $f14,96($fp) + sdc1 $f15,104($fp) + sdc1 $f16,112($fp) + sdc1 $f17,120($fp) + sdc1 $f18,128($fp) + sdc1 $f19,136($fp) + swc1 $f12,44($fp) + swc1 $f13,48($fp) + swc1 $f14,52($fp) + swc1 $f15,56($fp) + swc1 $f16,60($fp) + swc1 $f17,64($fp) + swc1 $f18,68($fp) + move $5,$fp + swc1 $f19,72($fp) + sw $12,24($fp) + sw $0,0($fp) + sw $0,28($fp) + sw $0,32($fp) + jalr $25 + sw $0,40($fp) + + lw $12,32($fp) + beq $12,$0,.L1 + li $13,1 # 0x1 + + beq $12,$13,.L43 + li $13,2 # 0x2 + + beq $12,$13,.L43 + li $13,3 # 0x3 + + beq $12,$13,.L49 + li $13,4 # 0x4 + + beq $12,$13,.L50 + li $13,5 # 0x5 + + beq $12,$13,.L51 + li $13,6 # 0x6 + + beq $12,$13,.L46 + li $13,7 # 0x7 + + beq $12,$13,.L45 + li $13,8 # 0x8 + + beq $12,$13,.L46 + li $13,9 # 0x9 + + beq $12,$13,.L45 + li $13,10 # 0xa + + beq $12,$13,.L47 + li $13,11 # 0xb + + beq $12,$13,.L47 + li $13,12 # 0xc + + beq $12,$13,.L52 + li $13,13 # 0xd + + beq $12,$13,.L53 + li $13,14 # 0xe + + beq $12,$13,.L46 + li $13,15 # 0xf + + bnel $12,$13,.L59 + move $sp,$fp + + lw $12,0($fp) + andi $13,$12,0x400 + beq $13,$0,.L1 + andi $13,$12,0x4 + + beq $13,$0,.L19 + lw $24,36($fp) + + lw $12,36($fp) + li $13,1 # 0x1 + beq $12,$13,.L54 + li $13,2 # 0x2 + + beq $12,$13,.L55 + li $13,4 # 0x4 + + beq $12,$13,.L56 + li $13,8 # 0x8 + + bnel $12,$13,.L59 + move $sp,$fp + + lw $12,28($fp) + ld $2,0($12) +.L1: + move $sp,$fp +.L59: + ld $31,184($sp) + ld $fp,176($sp) + ld $18,160($sp) + ld $17,152($sp) + ld $16,144($sp) + j $31 + addiu $sp,$sp,256 + + .align 3 +.L43: + move $sp,$fp + ld $31,184($sp) + ld $18,160($sp) + ld $17,152($sp) + ld $16,144($sp) + lb $2,8($fp) + ld $fp,176($sp) + j $31 + addiu $sp,$sp,256 + + .align 3 +.L46: + b .L1 + lw $2,8($fp) + + .align 3 +.L49: + b .L1 + lbu $2,8($fp) + + .align 3 +.L50: + b .L1 + lh $2,8($fp) + + .align 3 +.L45: + b .L1 + lwu $2,8($fp) + + .align 3 +.L51: + b .L1 + lhu $2,8($fp) + + .align 3 +.L52: + b .L1 + lwc1 $f0,8($fp) + + .align 3 +.L47: + b .L1 + ld $2,8($fp) + +.L53: + b .L1 + ldc1 $f0,8($fp) + +.L19: + addiu $13,$24,-1 + sltu $13,$13,16 + beql $13,$0,.L60 + andi $13,$12,0x800 + + lw $13,28($fp) + li $15,-8 # 0xfffffffffffffff8 + sltu $25,$24,9 + andi $14,$13,0x7 + and $15,$13,$15 + beq $25,$0,.L24 + addu $13,$24,$14 + + sltu $25,$13,9 + beq $25,$0,.L25 + subu $13,$0,$13 + + ld $25,0($15) + sll $13,$13,3 + li $15,-1 # 0xffffffffffffffff + dsll $13,$15,$13 + and $13,$13,$25 + sll $14,$14,3 + dsll $2,$13,$14 +.L23: + andi $13,$12,0x800 +.L60: + beql $13,$0,.L27 + andi $12,$12,0x1000 + + li $13,4 # 0x4 + beq $24,$13,.L57 + li $13,8 # 0x8 + + beql $24,$13,.L58 + lw $13,28($fp) + + andi $12,$12,0x1000 + beql $12,$0,.L59 + move $sp,$fp + + li $12,16 # 0x10 +.L61: + bnel $24,$12,.L59 + move $sp,$fp + + lw $12,28($fp) + ldc1 $f0,0($12) + b .L1 + ldc1 $f2,8($12) + +.L27: + beq $12,$0,.L1 + li $12,8 # 0x8 + + bne $24,$12,.L61 + li $12,16 # 0x10 + + lw $13,28($fp) + b .L1 + ldc1 $f0,0($13) + +.L24: + sltu $25,$13,17 + beq $25,$0,.L26 + subu $13,$0,$13 + + ld $17,8($15) + subu $16,$0,$14 + li $25,-1 # 0xffffffffffffffff + sll $13,$13,3 + dsll $13,$25,$13 + sll $25,$16,2 + ld $16,0($15) + and $13,$13,$17 + addiu $15,$25,32 + sll $14,$14,3 + dsra $25,$13,$15 + dsll $16,$16,$14 + dsra $15,$25,$15 + or $2,$16,$15 + b .L23 + dsll $3,$13,$14 + +.L54: + lw $12,28($fp) + b .L1 + lbu $2,0($12) + +.L55: + lw $12,28($fp) + b .L1 + lhu $2,0($12) + +.L26: + ld $18,16($15) + ld $16,8($15) + ld $17,0($15) + subu $25,$0,$14 + li $15,-1 # 0xffffffffffffffff + sll $13,$13,3 + sll $25,$25,3 + dsll $13,$15,$13 + sll $14,$14,3 + addiu $15,$25,64 + and $13,$13,$18 + dsll $25,$17,$14 + dsra $13,$13,$15 + dsra $17,$16,$15 + dsll $14,$16,$14 + or $2,$25,$17 + b .L23 + or $3,$13,$14 + +.L57: + lw $12,28($fp) + b .L1 + lwc1 $f0,0($12) + +.L56: + lw $12,28($fp) + b .L1 + lwu $2,0($12) + +.L25: + ld $16,8($15) + ld $25,0($15) + sll $13,$13,3 + li $15,-1 # 0xffffffffffffffff + dsll $13,$15,$13 + subu $15,$0,$14 + and $13,$13,$16 + sll $15,$15,3 + sll $14,$14,3 + dsra $13,$13,$15 + dsll $14,$25,$14 + b .L23 + or $2,$13,$14 + +.L58: + andi $12,$12,0x1000 + lwc1 $f0,0($13) + beq $12,$0,.L1 + lwc1 $f2,4($13) + + b .L1 + ldc1 $f0,0($13) + + .set macro + .set reorder + .end callback_receiver + .size callback_receiver, .-callback_receiver + .align 2 + .align 3 + .globl callback_get_receiver + .set nomips16 + .set nomicromips + .ent callback_get_receiver + .type callback_get_receiver, @function +callback_get_receiver: + .frame $fp,16,$31 # vars= 0, regs= 1/0, args= 0, gp= 0 + .mask 0x40000000,-8 + .fmask 0x00000000,0 + .set noreorder + .set nomacro + lui $13,%hi(%neg(%gp_rel(callback_get_receiver))) + addu $13,$13,$25 + addiu $13,$13,%lo(%neg(%gp_rel(callback_get_receiver))) + addiu $sp,$sp,-16 + lw $12,%got_page(callback_receiver)($13) + sd $fp,8($sp) + move $fp,$sp + move $sp,$fp + ld $fp,8($sp) + addiu $2,$12,%got_ofst(callback_receiver) + j $31 + addiu $sp,$sp,16 + + .set macro + .set reorder + .end callback_get_receiver + .size callback_get_receiver, .-callback_get_receiver + .ident "GCC: (GNU) 5.4.0" diff --git a/callback/vacall_r/vacall-mipsn32eb-macro.S b/callback/vacall_r/vacall-mipsn32eb-macro.S new file mode 100644 index 0000000..6f1e482 --- /dev/null +++ b/callback/vacall_r/vacall-mipsn32eb-macro.S @@ -0,0 +1,375 @@ +#include "asm-mips.h" + .file 1 "vacall-mipsn32.c" + .text + .align 2 + .align 3 + .set nomips16 + .set nomicromips + .ent callback_receiver + DECLARE_FUNCTION(callback_receiver) +callback_receiver: + .frame $fp,256,$31 + .mask 0xd0070000,-72 + .fmask 0x00000000,0 + .set noreorder + .set nomacro + addiu $sp,$sp,-256 + sd $fp,176($sp) + move $fp,$sp + sd $4,192($fp) + lw $4,4($2) + lw $25,0($2) + addiu $12,$fp,192 + sd $31,184($sp) + sd $18,160($sp) + sd $17,152($sp) + sd $16,144($sp) + sd $5,200($fp) + sd $6,208($fp) + sd $7,216($fp) + sd $8,224($fp) + sd $9,232($fp) + sd $10,240($fp) + sd $11,248($fp) + sdc1 $f12,80($fp) + sdc1 $f13,88($fp) + sdc1 $f14,96($fp) + sdc1 $f15,104($fp) + sdc1 $f16,112($fp) + sdc1 $f17,120($fp) + sdc1 $f18,128($fp) + sdc1 $f19,136($fp) + swc1 $f12,44($fp) + swc1 $f13,48($fp) + swc1 $f14,52($fp) + swc1 $f15,56($fp) + swc1 $f16,60($fp) + swc1 $f17,64($fp) + swc1 $f18,68($fp) + move $5,$fp + swc1 $f19,72($fp) + sw $12,24($fp) + sw $0,0($fp) + sw $0,28($fp) + sw $0,32($fp) + jalr $25 + sw $0,40($fp) + + lw $12,32($fp) + beq $12,$0,.L1 + li $13,1 + + beq $12,$13,.L43 + li $13,2 + + beq $12,$13,.L43 + li $13,3 + + beq $12,$13,.L49 + li $13,4 + + beq $12,$13,.L50 + li $13,5 + + beq $12,$13,.L51 + li $13,6 + + beq $12,$13,.L46 + li $13,7 + + beq $12,$13,.L45 + li $13,8 + + beq $12,$13,.L46 + li $13,9 + + beq $12,$13,.L45 + li $13,10 + + beq $12,$13,.L47 + li $13,11 + + beq $12,$13,.L47 + li $13,12 + + beq $12,$13,.L52 + li $13,13 + + beq $12,$13,.L53 + li $13,14 + + beq $12,$13,.L46 + li $13,15 + + bnel $12,$13,.L59 + move $sp,$fp + + lw $12,0($fp) + andi $13,$12,0x400 + beq $13,$0,.L1 + andi $13,$12,0x4 + + beq $13,$0,.L19 + lw $24,36($fp) + + lw $12,36($fp) + li $13,1 + beq $12,$13,.L54 + li $13,2 + + beq $12,$13,.L55 + li $13,4 + + beq $12,$13,.L56 + li $13,8 + + bnel $12,$13,.L59 + move $sp,$fp + + lw $12,28($fp) + ld $2,0($12) +.L1: + move $sp,$fp +.L59: + ld $31,184($sp) + ld $fp,176($sp) + ld $18,160($sp) + ld $17,152($sp) + ld $16,144($sp) + j $31 + addiu $sp,$sp,256 + + .align 3 +.L43: + move $sp,$fp + ld $31,184($sp) + ld $18,160($sp) + ld $17,152($sp) + ld $16,144($sp) + lb $2,8($fp) + ld $fp,176($sp) + j $31 + addiu $sp,$sp,256 + + .align 3 +.L46: + b .L1 + lw $2,8($fp) + + .align 3 +.L49: + b .L1 + lbu $2,8($fp) + + .align 3 +.L50: + b .L1 + lh $2,8($fp) + + .align 3 +.L45: + b .L1 + lwu $2,8($fp) + + .align 3 +.L51: + b .L1 + lhu $2,8($fp) + + .align 3 +.L52: + b .L1 + lwc1 $f0,8($fp) + + .align 3 +.L47: + b .L1 + ld $2,8($fp) + +.L53: + b .L1 + ldc1 $f0,8($fp) + +.L19: + addiu $13,$24,-1 + sltu $13,$13,16 + beql $13,$0,.L60 + andi $13,$12,0x800 + + lw $13,28($fp) + li $15,-8 + sltu $25,$24,9 + andi $14,$13,0x7 + and $15,$13,$15 + beq $25,$0,.L24 + addu $13,$24,$14 + + sltu $25,$13,9 + beq $25,$0,.L25 + subu $13,$0,$13 + + ld $25,0($15) + sll $13,$13,3 + li $15,-1 + dsll $13,$15,$13 + and $13,$13,$25 + sll $14,$14,3 + dsll $2,$13,$14 +.L23: + andi $13,$12,0x800 +.L60: + beql $13,$0,.L27 + andi $12,$12,0x1000 + + li $13,4 + beq $24,$13,.L57 + li $13,8 + + beql $24,$13,.L58 + lw $13,28($fp) + + andi $12,$12,0x1000 + beql $12,$0,.L59 + move $sp,$fp + + li $12,16 +.L61: + bnel $24,$12,.L59 + move $sp,$fp + + lw $12,28($fp) + ldc1 $f0,0($12) + b .L1 + ldc1 $f2,8($12) + +.L27: + beq $12,$0,.L1 + li $12,8 + + bne $24,$12,.L61 + li $12,16 + + lw $13,28($fp) + b .L1 + ldc1 $f0,0($13) + +.L24: + sltu $25,$13,17 + beq $25,$0,.L26 + subu $13,$0,$13 + + ld $17,8($15) + subu $16,$0,$14 + li $25,-1 + sll $13,$13,3 + dsll $13,$25,$13 + sll $25,$16,2 + ld $16,0($15) + and $13,$13,$17 + addiu $15,$25,32 + sll $14,$14,3 + dsra $25,$13,$15 + dsll $16,$16,$14 + dsra $15,$25,$15 + or $2,$16,$15 + b .L23 + dsll $3,$13,$14 + +.L54: + lw $12,28($fp) + b .L1 + lbu $2,0($12) + +.L55: + lw $12,28($fp) + b .L1 + lhu $2,0($12) + +.L26: + ld $18,16($15) + ld $16,8($15) + ld $17,0($15) + subu $25,$0,$14 + li $15,-1 + sll $13,$13,3 + sll $25,$25,3 + dsll $13,$15,$13 + sll $14,$14,3 + addiu $15,$25,64 + and $13,$13,$18 + dsll $25,$17,$14 + dsra $13,$13,$15 + dsra $17,$16,$15 + dsll $14,$16,$14 + or $2,$25,$17 + b .L23 + or $3,$13,$14 + +.L57: + lw $12,28($fp) + b .L1 + lwc1 $f0,0($12) + +.L56: + lw $12,28($fp) + b .L1 + lwu $2,0($12) + +.L25: + ld $16,8($15) + ld $25,0($15) + sll $13,$13,3 + li $15,-1 + dsll $13,$15,$13 + subu $15,$0,$14 + and $13,$13,$16 + sll $15,$15,3 + sll $14,$14,3 + dsra $13,$13,$15 + dsll $14,$25,$14 + b .L23 + or $2,$13,$14 + +.L58: + andi $12,$12,0x1000 + lwc1 $f0,0($13) + beq $12,$0,.L1 + lwc1 $f2,4($13) + + b .L1 + ldc1 $f0,0($13) + + .set macro + .set reorder + .end callback_receiver + .size callback_receiver, .-callback_receiver + .align 2 + .align 3 + .globl callback_get_receiver + .set nomips16 + .set nomicromips + .ent callback_get_receiver + DECLARE_FUNCTION(callback_get_receiver) +callback_get_receiver: + .frame $fp,16,$31 + .mask 0x40000000,-8 + .fmask 0x00000000,0 + .set noreorder + .set nomacro + lui $13,%hi(%neg(%gp_rel(callback_get_receiver))) + addu $13,$13,$25 + addiu $13,$13,%lo(%neg(%gp_rel(callback_get_receiver))) + addiu $sp,$sp,-16 + lw $12,%got_page(callback_receiver)($13) + sd $fp,8($sp) + move $fp,$sp + move $sp,$fp + ld $fp,8($sp) + addiu $2,$12,%got_ofst(callback_receiver) + j $31 + addiu $sp,$sp,16 + + .set macro + .set reorder + .end callback_get_receiver + .size callback_get_receiver, .-callback_get_receiver diff --git a/callback/vacall_r/vacall-mipsn32el-linux.s b/callback/vacall_r/vacall-mipsn32el-linux.s new file mode 100644 index 0000000..9f568ea --- /dev/null +++ b/callback/vacall_r/vacall-mipsn32el-linux.s @@ -0,0 +1,385 @@ + .file 1 "vacall-mipsn32.c" + .section .mdebug.abiN32 + .previous + .nan legacy + .module fp=64 + .module oddspreg + .abicalls + .text + .align 2 + .align 3 + .set nomips16 + .set nomicromips + .ent callback_receiver + .type callback_receiver, @function +callback_receiver: + .frame $fp,256,$31 # vars= 144, regs= 6/0, args= 0, gp= 0 + .mask 0xd0070000,-72 + .fmask 0x00000000,0 + .set noreorder + .set nomacro + addiu $sp,$sp,-256 + sd $fp,176($sp) + move $fp,$sp + sd $4,192($fp) + lw $4,4($2) + lw $25,0($2) + addiu $12,$fp,192 + sd $31,184($sp) + sd $18,160($sp) + sd $17,152($sp) + sd $16,144($sp) + sd $5,200($fp) + sd $6,208($fp) + sd $7,216($fp) + sd $8,224($fp) + sd $9,232($fp) + sd $10,240($fp) + sd $11,248($fp) + sdc1 $f12,80($fp) + sdc1 $f13,88($fp) + sdc1 $f14,96($fp) + sdc1 $f15,104($fp) + sdc1 $f16,112($fp) + sdc1 $f17,120($fp) + sdc1 $f18,128($fp) + sdc1 $f19,136($fp) + swc1 $f12,44($fp) + swc1 $f13,48($fp) + swc1 $f14,52($fp) + swc1 $f15,56($fp) + swc1 $f16,60($fp) + swc1 $f17,64($fp) + swc1 $f18,68($fp) + move $5,$fp + swc1 $f19,72($fp) + sw $12,24($fp) + sw $0,0($fp) + sw $0,28($fp) + sw $0,32($fp) + jalr $25 + sw $0,40($fp) + + lw $12,32($fp) + beq $12,$0,.L1 + li $13,1 # 0x1 + + beq $12,$13,.L43 + li $13,2 # 0x2 + + beq $12,$13,.L43 + li $13,3 # 0x3 + + beq $12,$13,.L49 + li $13,4 # 0x4 + + beq $12,$13,.L50 + li $13,5 # 0x5 + + beq $12,$13,.L51 + li $13,6 # 0x6 + + beq $12,$13,.L46 + li $13,7 # 0x7 + + beq $12,$13,.L45 + li $13,8 # 0x8 + + beq $12,$13,.L46 + li $13,9 # 0x9 + + beq $12,$13,.L45 + li $13,10 # 0xa + + beq $12,$13,.L47 + li $13,11 # 0xb + + beq $12,$13,.L47 + li $13,12 # 0xc + + beq $12,$13,.L52 + li $13,13 # 0xd + + beq $12,$13,.L53 + li $13,14 # 0xe + + beq $12,$13,.L46 + li $13,15 # 0xf + + bnel $12,$13,.L59 + move $sp,$fp + + lw $12,0($fp) + andi $13,$12,0x400 + beq $13,$0,.L1 + andi $13,$12,0x4 + + beq $13,$0,.L19 + lw $24,36($fp) + + lw $12,36($fp) + li $13,1 # 0x1 + beq $12,$13,.L54 + li $13,2 # 0x2 + + beq $12,$13,.L55 + li $13,4 # 0x4 + + beq $12,$13,.L56 + li $13,8 # 0x8 + + bnel $12,$13,.L59 + move $sp,$fp + + lw $12,28($fp) + ld $2,0($12) +.L1: + move $sp,$fp +.L59: + ld $31,184($sp) + ld $fp,176($sp) + ld $18,160($sp) + ld $17,152($sp) + ld $16,144($sp) + j $31 + addiu $sp,$sp,256 + + .align 3 +.L43: + move $sp,$fp + ld $31,184($sp) + ld $18,160($sp) + ld $17,152($sp) + ld $16,144($sp) + lb $2,8($fp) + ld $fp,176($sp) + j $31 + addiu $sp,$sp,256 + + .align 3 +.L46: + b .L1 + lw $2,8($fp) + + .align 3 +.L49: + b .L1 + lbu $2,8($fp) + + .align 3 +.L50: + b .L1 + lh $2,8($fp) + + .align 3 +.L45: + b .L1 + lwu $2,8($fp) + + .align 3 +.L51: + b .L1 + lhu $2,8($fp) + + .align 3 +.L52: + b .L1 + lwc1 $f0,8($fp) + + .align 3 +.L47: + b .L1 + ld $2,8($fp) + +.L53: + b .L1 + ldc1 $f0,8($fp) + +.L19: + addiu $13,$24,-1 + sltu $13,$13,16 + beql $13,$0,.L60 + andi $13,$12,0x800 + + lw $13,28($fp) + li $15,-8 # 0xfffffffffffffff8 + sltu $25,$24,9 + andi $14,$13,0x7 + and $15,$13,$15 + beq $25,$0,.L24 + addu $13,$24,$14 + + sltu $25,$13,9 + beq $25,$0,.L25 + sll $13,$13,3 + + ld $25,0($15) + addiu $13,$13,-1 + li $15,2 # 0x2 + dsll $13,$15,$13 + daddiu $13,$13,-1 + and $13,$13,$25 + sll $14,$14,3 + dsra $2,$13,$14 +.L23: + andi $13,$12,0x800 +.L60: + beql $13,$0,.L27 + andi $12,$12,0x1000 + + li $13,4 # 0x4 + beq $24,$13,.L57 + li $13,8 # 0x8 + + beql $24,$13,.L58 + lw $13,28($fp) + + andi $12,$12,0x1000 + beql $12,$0,.L59 + move $sp,$fp + + li $12,16 # 0x10 +.L61: + bnel $24,$12,.L59 + move $sp,$fp + + lw $12,28($fp) + ldc1 $f0,0($12) + b .L1 + ldc1 $f2,8($12) + +.L27: + beq $12,$0,.L1 + li $12,8 # 0x8 + + bne $24,$12,.L61 + li $12,16 # 0x10 + + lw $13,28($fp) + b .L1 + ldc1 $f0,0($13) + +.L24: + sltu $25,$13,17 + beq $25,$0,.L26 + sll $13,$13,3 + + ld $17,8($15) + li $25,2 # 0x2 + addiu $13,$13,-65 + dsll $13,$25,$13 + subu $25,$0,$14 + sll $25,$25,2 + ld $16,0($15) + daddiu $13,$13,-1 + addiu $15,$25,32 + and $13,$13,$17 + sll $14,$14,3 + dsll $25,$13,$15 + dsra $16,$16,$14 + dsll $15,$25,$15 + or $2,$16,$15 + b .L23 + dsra $3,$13,$14 + +.L54: + lw $12,28($fp) + b .L1 + lbu $2,0($12) + +.L55: + lw $12,28($fp) + b .L1 + lhu $2,0($12) + +.L26: + ld $16,8($15) + ld $17,0($15) + addiu $13,$13,-129 + ld $18,16($15) + li $15,2 # 0x2 + subu $25,$0,$14 + dsll $15,$15,$13 + daddiu $15,$15,-1 + sll $25,$25,3 + sll $14,$14,3 + addiu $25,$25,64 + and $13,$15,$18 + dsll $13,$13,$25 + dsra $15,$17,$14 + dsll $17,$16,$25 + dsra $14,$16,$14 + or $2,$15,$17 + b .L23 + or $3,$13,$14 + +.L57: + lw $12,28($fp) + b .L1 + lwc1 $f0,0($12) + +.L56: + lw $12,28($fp) + b .L1 + lwu $2,0($12) + +.L25: + li $25,2 # 0x2 + addiu $13,$13,-65 + ld $17,8($15) + dsll $13,$25,$13 + ld $25,0($15) + daddiu $13,$13,-1 + subu $16,$0,$14 + and $15,$13,$17 + sll $14,$14,3 + sll $13,$16,3 + dsll $13,$15,$13 + dsra $14,$25,$14 + b .L23 + or $2,$13,$14 + +.L58: + andi $12,$12,0x1000 + lwc1 $f0,0($13) + beq $12,$0,.L1 + lwc1 $f2,4($13) + + b .L1 + ldc1 $f0,0($13) + + .set macro + .set reorder + .end callback_receiver + .size callback_receiver, .-callback_receiver + .align 2 + .align 3 + .globl callback_get_receiver + .set nomips16 + .set nomicromips + .ent callback_get_receiver + .type callback_get_receiver, @function +callback_get_receiver: + .frame $fp,16,$31 # vars= 0, regs= 1/0, args= 0, gp= 0 + .mask 0x40000000,-8 + .fmask 0x00000000,0 + .set noreorder + .set nomacro + lui $13,%hi(%neg(%gp_rel(callback_get_receiver))) + addu $13,$13,$25 + addiu $13,$13,%lo(%neg(%gp_rel(callback_get_receiver))) + addiu $sp,$sp,-16 + lw $12,%got_page(callback_receiver)($13) + sd $fp,8($sp) + move $fp,$sp + move $sp,$fp + ld $fp,8($sp) + addiu $2,$12,%got_ofst(callback_receiver) + j $31 + addiu $sp,$sp,16 + + .set macro + .set reorder + .end callback_get_receiver + .size callback_get_receiver, .-callback_get_receiver + .ident "GCC: (GNU) 5.4.0" diff --git a/callback/vacall_r/vacall-mipsn32el-macro.S b/callback/vacall_r/vacall-mipsn32el-macro.S new file mode 100644 index 0000000..d1391d7 --- /dev/null +++ b/callback/vacall_r/vacall-mipsn32el-macro.S @@ -0,0 +1,379 @@ +#include "asm-mips.h" + .file 1 "vacall-mipsn32.c" + .text + .align 2 + .align 3 + .set nomips16 + .set nomicromips + .ent callback_receiver + DECLARE_FUNCTION(callback_receiver) +callback_receiver: + .frame $fp,256,$31 + .mask 0xd0070000,-72 + .fmask 0x00000000,0 + .set noreorder + .set nomacro + addiu $sp,$sp,-256 + sd $fp,176($sp) + move $fp,$sp + sd $4,192($fp) + lw $4,4($2) + lw $25,0($2) + addiu $12,$fp,192 + sd $31,184($sp) + sd $18,160($sp) + sd $17,152($sp) + sd $16,144($sp) + sd $5,200($fp) + sd $6,208($fp) + sd $7,216($fp) + sd $8,224($fp) + sd $9,232($fp) + sd $10,240($fp) + sd $11,248($fp) + sdc1 $f12,80($fp) + sdc1 $f13,88($fp) + sdc1 $f14,96($fp) + sdc1 $f15,104($fp) + sdc1 $f16,112($fp) + sdc1 $f17,120($fp) + sdc1 $f18,128($fp) + sdc1 $f19,136($fp) + swc1 $f12,44($fp) + swc1 $f13,48($fp) + swc1 $f14,52($fp) + swc1 $f15,56($fp) + swc1 $f16,60($fp) + swc1 $f17,64($fp) + swc1 $f18,68($fp) + move $5,$fp + swc1 $f19,72($fp) + sw $12,24($fp) + sw $0,0($fp) + sw $0,28($fp) + sw $0,32($fp) + jalr $25 + sw $0,40($fp) + + lw $12,32($fp) + beq $12,$0,.L1 + li $13,1 + + beq $12,$13,.L43 + li $13,2 + + beq $12,$13,.L43 + li $13,3 + + beq $12,$13,.L49 + li $13,4 + + beq $12,$13,.L50 + li $13,5 + + beq $12,$13,.L51 + li $13,6 + + beq $12,$13,.L46 + li $13,7 + + beq $12,$13,.L45 + li $13,8 + + beq $12,$13,.L46 + li $13,9 + + beq $12,$13,.L45 + li $13,10 + + beq $12,$13,.L47 + li $13,11 + + beq $12,$13,.L47 + li $13,12 + + beq $12,$13,.L52 + li $13,13 + + beq $12,$13,.L53 + li $13,14 + + beq $12,$13,.L46 + li $13,15 + + bnel $12,$13,.L59 + move $sp,$fp + + lw $12,0($fp) + andi $13,$12,0x400 + beq $13,$0,.L1 + andi $13,$12,0x4 + + beq $13,$0,.L19 + lw $24,36($fp) + + lw $12,36($fp) + li $13,1 + beq $12,$13,.L54 + li $13,2 + + beq $12,$13,.L55 + li $13,4 + + beq $12,$13,.L56 + li $13,8 + + bnel $12,$13,.L59 + move $sp,$fp + + lw $12,28($fp) + ld $2,0($12) +.L1: + move $sp,$fp +.L59: + ld $31,184($sp) + ld $fp,176($sp) + ld $18,160($sp) + ld $17,152($sp) + ld $16,144($sp) + j $31 + addiu $sp,$sp,256 + + .align 3 +.L43: + move $sp,$fp + ld $31,184($sp) + ld $18,160($sp) + ld $17,152($sp) + ld $16,144($sp) + lb $2,8($fp) + ld $fp,176($sp) + j $31 + addiu $sp,$sp,256 + + .align 3 +.L46: + b .L1 + lw $2,8($fp) + + .align 3 +.L49: + b .L1 + lbu $2,8($fp) + + .align 3 +.L50: + b .L1 + lh $2,8($fp) + + .align 3 +.L45: + b .L1 + lwu $2,8($fp) + + .align 3 +.L51: + b .L1 + lhu $2,8($fp) + + .align 3 +.L52: + b .L1 + lwc1 $f0,8($fp) + + .align 3 +.L47: + b .L1 + ld $2,8($fp) + +.L53: + b .L1 + ldc1 $f0,8($fp) + +.L19: + addiu $13,$24,-1 + sltu $13,$13,16 + beql $13,$0,.L60 + andi $13,$12,0x800 + + lw $13,28($fp) + li $15,-8 + sltu $25,$24,9 + andi $14,$13,0x7 + and $15,$13,$15 + beq $25,$0,.L24 + addu $13,$24,$14 + + sltu $25,$13,9 + beq $25,$0,.L25 + sll $13,$13,3 + + ld $25,0($15) + addiu $13,$13,-1 + li $15,2 + dsll $13,$15,$13 + daddiu $13,$13,-1 + and $13,$13,$25 + sll $14,$14,3 + dsra $2,$13,$14 +.L23: + andi $13,$12,0x800 +.L60: + beql $13,$0,.L27 + andi $12,$12,0x1000 + + li $13,4 + beq $24,$13,.L57 + li $13,8 + + beql $24,$13,.L58 + lw $13,28($fp) + + andi $12,$12,0x1000 + beql $12,$0,.L59 + move $sp,$fp + + li $12,16 +.L61: + bnel $24,$12,.L59 + move $sp,$fp + + lw $12,28($fp) + ldc1 $f0,0($12) + b .L1 + ldc1 $f2,8($12) + +.L27: + beq $12,$0,.L1 + li $12,8 + + bne $24,$12,.L61 + li $12,16 + + lw $13,28($fp) + b .L1 + ldc1 $f0,0($13) + +.L24: + sltu $25,$13,17 + beq $25,$0,.L26 + sll $13,$13,3 + + ld $17,8($15) + li $25,2 + addiu $13,$13,-65 + dsll $13,$25,$13 + subu $25,$0,$14 + sll $25,$25,2 + ld $16,0($15) + daddiu $13,$13,-1 + addiu $15,$25,32 + and $13,$13,$17 + sll $14,$14,3 + dsll $25,$13,$15 + dsra $16,$16,$14 + dsll $15,$25,$15 + or $2,$16,$15 + b .L23 + dsra $3,$13,$14 + +.L54: + lw $12,28($fp) + b .L1 + lbu $2,0($12) + +.L55: + lw $12,28($fp) + b .L1 + lhu $2,0($12) + +.L26: + ld $16,8($15) + ld $17,0($15) + addiu $13,$13,-129 + ld $18,16($15) + li $15,2 + subu $25,$0,$14 + dsll $15,$15,$13 + daddiu $15,$15,-1 + sll $25,$25,3 + sll $14,$14,3 + addiu $25,$25,64 + and $13,$15,$18 + dsll $13,$13,$25 + dsra $15,$17,$14 + dsll $17,$16,$25 + dsra $14,$16,$14 + or $2,$15,$17 + b .L23 + or $3,$13,$14 + +.L57: + lw $12,28($fp) + b .L1 + lwc1 $f0,0($12) + +.L56: + lw $12,28($fp) + b .L1 + lwu $2,0($12) + +.L25: + li $25,2 + addiu $13,$13,-65 + ld $17,8($15) + dsll $13,$25,$13 + ld $25,0($15) + daddiu $13,$13,-1 + subu $16,$0,$14 + and $15,$13,$17 + sll $14,$14,3 + sll $13,$16,3 + dsll $13,$15,$13 + dsra $14,$25,$14 + b .L23 + or $2,$13,$14 + +.L58: + andi $12,$12,0x1000 + lwc1 $f0,0($13) + beq $12,$0,.L1 + lwc1 $f2,4($13) + + b .L1 + ldc1 $f0,0($13) + + .set macro + .set reorder + .end callback_receiver + .size callback_receiver, .-callback_receiver + .align 2 + .align 3 + .globl callback_get_receiver + .set nomips16 + .set nomicromips + .ent callback_get_receiver + DECLARE_FUNCTION(callback_get_receiver) +callback_get_receiver: + .frame $fp,16,$31 + .mask 0x40000000,-8 + .fmask 0x00000000,0 + .set noreorder + .set nomacro + lui $13,%hi(%neg(%gp_rel(callback_get_receiver))) + addu $13,$13,$25 + addiu $13,$13,%lo(%neg(%gp_rel(callback_get_receiver))) + addiu $sp,$sp,-16 + lw $12,%got_page(callback_receiver)($13) + sd $fp,8($sp) + move $fp,$sp + move $sp,$fp + ld $fp,8($sp) + addiu $2,$12,%got_ofst(callback_receiver) + j $31 + addiu $sp,$sp,16 + + .set macro + .set reorder + .end callback_get_receiver + .size callback_get_receiver, .-callback_get_receiver diff --git a/callback/vacall_r/vacall-powerpc-aix.s b/callback/vacall_r/vacall-powerpc-aix.s new file mode 100644 index 0000000..6f4f595 --- /dev/null +++ b/callback/vacall_r/vacall-powerpc-aix.s @@ -0,0 +1,194 @@ + .file "../../vacall/vacall-powerpc.c" + .toc + .csect .text[PR] + .align 2 + .lglobl .callback_receiver + .csect callback_receiver[DS] +callback_receiver: + .long .callback_receiver, TOC[tc0], 0 + .csect .text[PR] +.callback_receiver: + .extern __mulh + .extern __mull + .extern __divss + .extern __divus + .extern __quoss + .extern __quous + mflr 0 + stw 0,8(1) + stw 28,-16(1) + stw 29,-12(1) + stw 31,-4(1) + stwu 1,-216(1) + mr 31,1 + lwz 28,0(11) + li 29,0 + addi 0,31,240 + stw 9,264(31) + stw 3,240(31) + stw 4,244(31) + stw 5,248(31) + stw 6,252(31) + stw 7,256(31) + stw 8,260(31) + stw 10,268(31) + stw 29,76(31) + stfd 1,92(31) + stfd 2,100(31) + stfd 3,108(31) + stfd 4,116(31) + stfd 5,124(31) + stfd 6,132(31) + stfd 7,140(31) + stfd 8,148(31) + stfd 9,156(31) + stfd 10,164(31) + stfd 11,172(31) + stfd 12,180(31) + stfd 13,188(31) + stw 0,72(31) + stw 29,88(31) + stw 29,56(31) + stw 29,80(31) + lwz 0,0(28) + lwz 3,4(11) + mtctr 0 + addi 4,31,56 + stw 2,20(1) + lwz 11,8(28) + lwz 2,4(28) + bctrl + lwz 2,20(1) + lwz 9,80(31) + cmpwi 0,9,0 + beq- 0,L..1 + cmpwi 0,9,1 + beq- 0,L..41 + cmpwi 0,9,2 + beq- 0,L..42 + cmpwi 0,9,3 + beq- 0,L..41 + cmpwi 0,9,4 + beq- 0,L..43 + cmpwi 0,9,5 + beq- 0,L..44 + cmpwi 0,9,6 + beq- 0,L..40 + cmpwi 0,9,7 + beq- 0,L..40 + cmpwi 0,9,8 + beq- 0,L..40 + cmpwi 0,9,9 + beq- 0,L..40 + addi 0,9,-10 + cmplwi 0,0,1 + bgt- 0,L..22 + lwz 3,64(31) + lwz 4,68(31) +L..1: + lwz 1,0(1) + lwz 0,8(1) + lwz 28,-16(1) + mtlr 0 + lwz 29,-12(1) + lwz 31,-4(1) + blr +L..22: + cmpwi 0,9,12 + beq- 0,L..45 + cmpwi 0,9,13 + beq- 0,L..46 + cmpwi 0,9,14 + beq- 0,L..40 + cmpwi 0,9,15 + bne+ 0,L..1 + lwz 0,56(31) + andi. 9,0,1024 + beq- 0,L..1 + lwz 0,84(31) + cmpwi 0,0,1 + beq- 0,L..47 + cmpwi 0,0,2 + beq- 0,L..48 + cmpwi 0,0,4 + beq- 0,L..49 + cmpwi 0,0,8 + bne+ 0,L..1 + lwz 9,76(31) + lwz 4,4(9) +L..39: + lwz 3,0(9) + b L..1 +L..49: + lwz 9,76(31) + b L..39 +L..48: + lwz 9,76(31) + lhz 3,0(9) + b L..1 +L..47: + lwz 9,76(31) + lbz 3,0(9) + b L..1 +L..40: + lwz 3,64(31) + b L..1 +L..46: + lfd 1,64(31) + b L..1 +L..45: + lfs 1,64(31) + b L..1 +L..44: + lhz 3,64(31) + b L..1 +L..43: + lha 3,64(31) + b L..1 +L..41: + lbz 3,64(31) + b L..1 +L..42: + lbz 0,64(31) + slwi 0,0,24 + srawi 3,0,24 + b L..1 +LT..callback_receiver: + .long 0 + .byte 0,0,32,97,128,4,8,0 + .long 0 + .long LT..callback_receiver-.callback_receiver + .short 17 + .byte "callback_receiver" + .byte 31 + .align 2 + .toc +LC..0: + .tc callback_receiver[TC],callback_receiver + .csect .text[PR] + .align 2 + .globl callback_get_receiver + .globl .callback_get_receiver + .csect callback_get_receiver[DS] +callback_get_receiver: + .long .callback_get_receiver, TOC[tc0], 0 + .csect .text[PR] +.callback_get_receiver: + stw 31,-4(1) + stwu 1,-40(1) + mr 31,1 + lwz 1,0(1) + lwz 3,LC..0(2) + lwz 31,-4(1) + blr +LT..callback_get_receiver: + .long 0 + .byte 0,0,32,96,128,1,0,0 + .long LT..callback_get_receiver-.callback_get_receiver + .short 21 + .byte "callback_get_receiver" + .byte 31 + .align 2 +_section_.text: + .csect .data[RW],3 + .long _section_.text diff --git a/callback/vacall_r/vacall-powerpc-linux-macro.S b/callback/vacall_r/vacall-powerpc-linux-macro.S new file mode 100644 index 0000000..d0d502f --- /dev/null +++ b/callback/vacall_r/vacall-powerpc-linux-macro.S @@ -0,0 +1,179 @@ + .file "vacall-powerpc.c" + .section ".text" + .align 2 + .type callback_receiver, @function +callback_receiver: + .extern __mulh + .extern __mull + .extern __divss + .extern __divus + .extern __quoss + .extern __quous + stwu 1,-176(1) + mflr 0 + stw 0,180(1) + stw 31,172(1) + mr 31,1 + stw 29,164(1) + addi 0,31,184 + li 29,0 + stw 0,32(31) + stw 29,36(31) + lwz 0,0(11) + stw 3,52(31) + stw 4,56(31) + mtctr 0 + stw 9,76(31) + addi 4,31,16 + stw 30,168(1) + stw 5,60(31) + stw 6,64(31) + stw 7,68(31) + stw 8,72(31) + stw 10,80(31) + stw 29,84(31) + stfd 1,88(31) + stfd 2,96(31) + stfd 3,104(31) + stfd 4,112(31) + stfd 5,120(31) + stfd 6,128(31) + stfd 7,136(31) + stfd 8,144(31) + stw 29,16(31) + stw 29,48(31) + stw 29,40(31) + lwz 3,4(11) + bctrl + lwz 9,40(31) + cmpwi 0,9,0 + beq- 0,.L1 + cmpwi 0,9,1 + beq- 0,.L41 + cmpwi 0,9,2 + beq- 0,.L42 + cmpwi 0,9,3 + beq- 0,.L41 + cmpwi 0,9,4 + beq- 0,.L43 + cmpwi 0,9,5 + beq- 0,.L44 + cmpwi 0,9,6 + beq- 0,.L40 + cmpwi 0,9,7 + beq- 0,.L40 + cmpwi 0,9,8 + beq- 0,.L40 + cmpwi 0,9,9 + beq- 0,.L40 + addi 0,9,-10 + cmplwi 0,0,1 + bgt- 0,.L22 + lwz 3,24(31) + lwz 4,28(31) +.L1: + lwz 11,0(1) + lwz 0,4(11) + lwz 29,-12(11) + lwz 30,-8(11) + mtlr 0 + lwz 31,-4(11) + mr 1,11 + blr +.L22: + cmpwi 0,9,12 + beq- 0,.L45 + cmpwi 0,9,13 + beq- 0,.L46 + cmpwi 0,9,14 + beq- 0,.L40 + cmpwi 0,9,15 + bne+ 0,.L1 + lwz 0,16(31) + andi. 9,0,1024 + beq- 0,.L1 + lwz 0,44(31) + cmpwi 0,0,1 + beq- 0,.L47 + cmpwi 0,0,2 + beq- 0,.L48 + cmpwi 0,0,4 + beq- 0,.L49 + cmpwi 0,0,8 + bne+ 0,.L1 + lwz 9,36(31) + lwz 4,4(9) +.L39: + lwz 3,0(9) + b .L1 +.L49: + lwz 9,36(31) + b .L39 +.L48: + lwz 9,36(31) + lhz 3,0(9) + b .L1 +.L47: + lwz 9,36(31) + lbz 3,0(9) + b .L1 +.L40: + lwz 3,24(31) + b .L1 +.L46: + lfd 1,24(31) + b .L1 +.L45: + lfs 1,24(31) + b .L1 +.L44: + lhz 3,24(31) + b .L1 +.L43: + lha 3,24(31) + b .L1 +.L41: + lbz 3,24(31) + b .L1 +.L42: + lbz 0,24(31) + slwi 0,0,24 + srawi 3,0,24 + b .L1 + .size callback_receiver, .-callback_receiver + .section ".got2","aw" +.LCTOC1 = .+32768 + .section ".text" + .section ".got2","aw" +.LC0: + .long callback_receiver + .section ".text" + .align 2 + .globl callback_get_receiver +.LCL1: + .long .LCTOC1-.LCF1 + .type callback_get_receiver, @function +callback_get_receiver: + stwu 1,-32(1) + mflr 0 + bcl 20,31,.LCF1 +.LCF1: + stw 30,24(1) + mflr 30 + stw 31,28(1) + mr 31,1 + stw 0,36(1) + lwz 11,0(1) + lwz 0,.LCL1-.LCF1(30) + lwz 31,-4(11) + add 30,0,30 + lwz 0,4(11) + lwz 3,.LC0-.LCTOC1(30) + lwz 30,-8(11) + mtlr 0 + mr 1,11 + blr + .size callback_get_receiver, .-callback_get_receiver +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/callback/vacall_r/vacall-powerpc-linux.s b/callback/vacall_r/vacall-powerpc-linux.s new file mode 100644 index 0000000..1456743 --- /dev/null +++ b/callback/vacall_r/vacall-powerpc-linux.s @@ -0,0 +1,178 @@ + .file "vacall-powerpc.c" + .section ".text" + .align 2 + .type callback_receiver, @function +callback_receiver: + .extern __mulh + .extern __mull + .extern __divss + .extern __divus + .extern __quoss + .extern __quous + stwu 1,-176(1) + mflr 0 + stw 0,180(1) + stw 31,172(1) + mr 31,1 + stw 29,164(1) + addi 0,31,184 + li 29,0 + stw 0,32(31) + stw 29,36(31) + lwz 0,0(11) + stw 3,52(31) + stw 4,56(31) + mtctr 0 + stw 9,76(31) + addi 4,31,16 + stw 30,168(1) + stw 5,60(31) + stw 6,64(31) + stw 7,68(31) + stw 8,72(31) + stw 10,80(31) + stw 29,84(31) + stfd 1,88(31) + stfd 2,96(31) + stfd 3,104(31) + stfd 4,112(31) + stfd 5,120(31) + stfd 6,128(31) + stfd 7,136(31) + stfd 8,144(31) + stw 29,16(31) + stw 29,48(31) + stw 29,40(31) + lwz 3,4(11) + bctrl + lwz 9,40(31) + cmpwi 0,9,0 + beq- 0,.L1 + cmpwi 0,9,1 + beq- 0,.L41 + cmpwi 0,9,2 + beq- 0,.L42 + cmpwi 0,9,3 + beq- 0,.L41 + cmpwi 0,9,4 + beq- 0,.L43 + cmpwi 0,9,5 + beq- 0,.L44 + cmpwi 0,9,6 + beq- 0,.L40 + cmpwi 0,9,7 + beq- 0,.L40 + cmpwi 0,9,8 + beq- 0,.L40 + cmpwi 0,9,9 + beq- 0,.L40 + addi 0,9,-10 + cmplwi 0,0,1 + bgt- 0,.L22 + lwz 3,24(31) + lwz 4,28(31) +.L1: + lwz 11,0(1) + lwz 0,4(11) + lwz 29,-12(11) + lwz 30,-8(11) + mtlr 0 + lwz 31,-4(11) + mr 1,11 + blr +.L22: + cmpwi 0,9,12 + beq- 0,.L45 + cmpwi 0,9,13 + beq- 0,.L46 + cmpwi 0,9,14 + beq- 0,.L40 + cmpwi 0,9,15 + bne+ 0,.L1 + lwz 0,16(31) + andi. 9,0,1024 + beq- 0,.L1 + lwz 0,44(31) + cmpwi 0,0,1 + beq- 0,.L47 + cmpwi 0,0,2 + beq- 0,.L48 + cmpwi 0,0,4 + beq- 0,.L49 + cmpwi 0,0,8 + bne+ 0,.L1 + lwz 9,36(31) + lwz 4,4(9) +.L39: + lwz 3,0(9) + b .L1 +.L49: + lwz 9,36(31) + b .L39 +.L48: + lwz 9,36(31) + lhz 3,0(9) + b .L1 +.L47: + lwz 9,36(31) + lbz 3,0(9) + b .L1 +.L40: + lwz 3,24(31) + b .L1 +.L46: + lfd 1,24(31) + b .L1 +.L45: + lfs 1,24(31) + b .L1 +.L44: + lhz 3,24(31) + b .L1 +.L43: + lha 3,24(31) + b .L1 +.L41: + lbz 3,24(31) + b .L1 +.L42: + lbz 0,24(31) + slwi 0,0,24 + srawi 3,0,24 + b .L1 + .size callback_receiver, .-callback_receiver + .section ".got2","aw" +.LCTOC1 = .+32768 + .section ".text" + .section ".got2","aw" +.LC0: + .long callback_receiver + .section ".text" + .align 2 + .globl callback_get_receiver +.LCL1: + .long .LCTOC1-.LCF1 + .type callback_get_receiver, @function +callback_get_receiver: + stwu 1,-32(1) + mflr 0 + bcl 20,31,.LCF1 +.LCF1: + stw 30,24(1) + mflr 30 + stw 31,28(1) + mr 31,1 + stw 0,36(1) + lwz 11,0(1) + lwz 0,.LCL1-.LCF1(30) + lwz 31,-4(11) + add 30,0,30 + lwz 0,4(11) + lwz 3,.LC0-.LCTOC1(30) + lwz 30,-8(11) + mtlr 0 + mr 1,11 + blr + .size callback_get_receiver, .-callback_get_receiver + .section .note.GNU-stack,"",@progbits + .ident "GCC: (GNU) 3.3.6" diff --git a/callback/vacall_r/vacall-powerpc-macos.s b/callback/vacall_r/vacall-powerpc-macos.s new file mode 100644 index 0000000..0c9ce3b --- /dev/null +++ b/callback/vacall_r/vacall-powerpc-macos.s @@ -0,0 +1,154 @@ +.text + .align 2 +_callback_receiver: + mflr r0 + stmw r29,-12(r1) + stw r0,8(r1) + li r29,0 + stwu r1,-224(r1) + mr r30,r1 + addi r0,r30,248 + stw r29,84(r30) + stw r0,80(r30) + lwz r0,0(r11) + stw r3,248(r30) + stw r4,252(r30) + mtctr r0 + stw r9,272(r30) + addi r4,r30,64 + stw r5,256(r30) + stw r6,260(r30) + stw r7,264(r30) + stw r8,268(r30) + stw r10,276(r30) + stw r29,96(r30) + stfd f1,100(r30) + stfd f2,108(r30) + stfd f3,116(r30) + stfd f4,124(r30) + stfd f5,132(r30) + stfd f6,140(r30) + stfd f7,148(r30) + stfd f8,156(r30) + stfd f9,164(r30) + stfd f10,172(r30) + stfd f11,180(r30) + stfd f12,188(r30) + stfd f13,196(r30) + stw r29,64(r30) + stw r29,88(r30) + lwz r3,4(r11) + bctrl + lwz r9,88(r30) + cmpwi cr0,r9,0 + beq- cr0,L1 + cmpwi cr0,r9,1 + beq- cr0,L41 + cmpwi cr0,r9,2 + beq- cr0,L41 + cmpwi cr0,r9,3 + beq- cr0,L42 + cmpwi cr0,r9,4 + beq- cr0,L43 + cmpwi cr0,r9,5 + beq- cr0,L44 + cmpwi cr0,r9,6 + beq- cr0,L40 + cmpwi cr0,r9,7 + beq- cr0,L40 + cmpwi cr0,r9,8 + beq- cr0,L40 + cmpwi cr0,r9,9 + beq- cr0,L40 + addi r0,r9,-10 + cmplwi cr0,r0,1 + bgt- cr0,L22 + lwz r3,72(r30) + lwz r4,76(r30) +L1: + lwz r1,0(r1) + lwz r0,8(r1) + lmw r29,-12(r1) + mtlr r0 + blr +L22: + cmpwi cr0,r9,12 + beq- cr0,L45 + cmpwi cr0,r9,13 + beq- cr0,L46 + cmpwi cr0,r9,14 + beq- cr0,L40 + cmpwi cr0,r9,15 + bne+ cr0,L1 + lwz r0,64(r30) + andi. r9,r0,1024 + beq- cr0,L1 + lwz r0,92(r30) + cmpwi cr0,r0,1 + beq- cr0,L47 + cmpwi cr0,r0,2 + beq- cr0,L48 + cmpwi cr0,r0,4 + beq- cr0,L49 + cmpwi cr0,r0,8 + bne+ cr0,L1 + lwz r9,84(r30) + lwz r4,4(r9) +L39: + lwz r3,0(r9) + b L1 +L49: + lwz r9,84(r30) + b L39 +L48: + lwz r9,84(r30) + lhz r3,0(r9) + b L1 +L47: + lwz r9,84(r30) + lbz r3,0(r9) + b L1 +L40: + lwz r3,72(r30) + b L1 +L46: + lfd f1,72(r30) + b L1 +L45: + lfs f1,72(r30) + b L1 +L44: + lhz r3,72(r30) + b L1 +L43: + lha r3,72(r30) + b L1 +L42: + lbz r3,72(r30) + b L1 +L41: + lbz r0,72(r30) + extsb r3,r0 + b L1 + .align 2 + .globl _callback_get_receiver +_callback_get_receiver: + mflr r0 + stmw r30,-8(r1) + stw r0,8(r1) + bcl 20,31,L1$pb +L1$pb: + stwu r1,-48(r1) + mflr r31 + addis r9,r31,ha16(L_callback_receiver$non_lazy_ptr-L1$pb) + mr r30,r1 + lwz r3,lo16(L_callback_receiver$non_lazy_ptr-L1$pb)(r9) + lwz r1,0(r1) + lwz r0,8(r1) + lmw r30,-8(r1) + mtlr r0 + blr +.data + .align 2 +L_callback_receiver$non_lazy_ptr: + .long _callback_receiver diff --git a/callback/vacall_r/vacall-powerpc-sysv4-macro.S b/callback/vacall_r/vacall-powerpc-sysv4-macro.S new file mode 100644 index 0000000..d0d502f --- /dev/null +++ b/callback/vacall_r/vacall-powerpc-sysv4-macro.S @@ -0,0 +1,179 @@ + .file "vacall-powerpc.c" + .section ".text" + .align 2 + .type callback_receiver, @function +callback_receiver: + .extern __mulh + .extern __mull + .extern __divss + .extern __divus + .extern __quoss + .extern __quous + stwu 1,-176(1) + mflr 0 + stw 0,180(1) + stw 31,172(1) + mr 31,1 + stw 29,164(1) + addi 0,31,184 + li 29,0 + stw 0,32(31) + stw 29,36(31) + lwz 0,0(11) + stw 3,52(31) + stw 4,56(31) + mtctr 0 + stw 9,76(31) + addi 4,31,16 + stw 30,168(1) + stw 5,60(31) + stw 6,64(31) + stw 7,68(31) + stw 8,72(31) + stw 10,80(31) + stw 29,84(31) + stfd 1,88(31) + stfd 2,96(31) + stfd 3,104(31) + stfd 4,112(31) + stfd 5,120(31) + stfd 6,128(31) + stfd 7,136(31) + stfd 8,144(31) + stw 29,16(31) + stw 29,48(31) + stw 29,40(31) + lwz 3,4(11) + bctrl + lwz 9,40(31) + cmpwi 0,9,0 + beq- 0,.L1 + cmpwi 0,9,1 + beq- 0,.L41 + cmpwi 0,9,2 + beq- 0,.L42 + cmpwi 0,9,3 + beq- 0,.L41 + cmpwi 0,9,4 + beq- 0,.L43 + cmpwi 0,9,5 + beq- 0,.L44 + cmpwi 0,9,6 + beq- 0,.L40 + cmpwi 0,9,7 + beq- 0,.L40 + cmpwi 0,9,8 + beq- 0,.L40 + cmpwi 0,9,9 + beq- 0,.L40 + addi 0,9,-10 + cmplwi 0,0,1 + bgt- 0,.L22 + lwz 3,24(31) + lwz 4,28(31) +.L1: + lwz 11,0(1) + lwz 0,4(11) + lwz 29,-12(11) + lwz 30,-8(11) + mtlr 0 + lwz 31,-4(11) + mr 1,11 + blr +.L22: + cmpwi 0,9,12 + beq- 0,.L45 + cmpwi 0,9,13 + beq- 0,.L46 + cmpwi 0,9,14 + beq- 0,.L40 + cmpwi 0,9,15 + bne+ 0,.L1 + lwz 0,16(31) + andi. 9,0,1024 + beq- 0,.L1 + lwz 0,44(31) + cmpwi 0,0,1 + beq- 0,.L47 + cmpwi 0,0,2 + beq- 0,.L48 + cmpwi 0,0,4 + beq- 0,.L49 + cmpwi 0,0,8 + bne+ 0,.L1 + lwz 9,36(31) + lwz 4,4(9) +.L39: + lwz 3,0(9) + b .L1 +.L49: + lwz 9,36(31) + b .L39 +.L48: + lwz 9,36(31) + lhz 3,0(9) + b .L1 +.L47: + lwz 9,36(31) + lbz 3,0(9) + b .L1 +.L40: + lwz 3,24(31) + b .L1 +.L46: + lfd 1,24(31) + b .L1 +.L45: + lfs 1,24(31) + b .L1 +.L44: + lhz 3,24(31) + b .L1 +.L43: + lha 3,24(31) + b .L1 +.L41: + lbz 3,24(31) + b .L1 +.L42: + lbz 0,24(31) + slwi 0,0,24 + srawi 3,0,24 + b .L1 + .size callback_receiver, .-callback_receiver + .section ".got2","aw" +.LCTOC1 = .+32768 + .section ".text" + .section ".got2","aw" +.LC0: + .long callback_receiver + .section ".text" + .align 2 + .globl callback_get_receiver +.LCL1: + .long .LCTOC1-.LCF1 + .type callback_get_receiver, @function +callback_get_receiver: + stwu 1,-32(1) + mflr 0 + bcl 20,31,.LCF1 +.LCF1: + stw 30,24(1) + mflr 30 + stw 31,28(1) + mr 31,1 + stw 0,36(1) + lwz 11,0(1) + lwz 0,.LCL1-.LCF1(30) + lwz 31,-4(11) + add 30,0,30 + lwz 0,4(11) + lwz 3,.LC0-.LCTOC1(30) + lwz 30,-8(11) + mtlr 0 + mr 1,11 + blr + .size callback_get_receiver, .-callback_get_receiver +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/callback/vacall_r/vacall-powerpc64-aix.s b/callback/vacall_r/vacall-powerpc64-aix.s new file mode 100644 index 0000000..39d740a --- /dev/null +++ b/callback/vacall_r/vacall-powerpc64-aix.s @@ -0,0 +1,176 @@ + .file "../../vacall/vacall-powerpc64.c" + .csect .text[PR] + .toc + .csect .text[PR] + .align 2 + .align 4 + .lglobl .callback_receiver + .csect callback_receiver[DS],3 +callback_receiver: + .llong .callback_receiver, TOC[tc0], 0 + .csect .text[PR] +.callback_receiver: + mflr 0 + std 30,-16(1) + std 31,-8(1) + li 30,0 + std 0,16(1) + li 0,0 + stdu 1,-304(1) + ld 12,0(11) + mr 31,1 + std 9,400(31) + addi 9,31,352 + stfd 1,172(31) + stw 0,152(31) + stw 0,168(31) + std 3,352(31) + std 4,360(31) + ld 3,8(11) + std 5,368(31) + addi 4,31,112 + std 6,376(31) + std 7,384(31) + std 8,392(31) + std 10,408(31) + stfd 2,180(31) + stfd 3,188(31) + stfd 4,196(31) + stfd 5,204(31) + stfd 6,212(31) + stfd 7,220(31) + stfd 8,228(31) + stfd 9,236(31) + stfd 10,244(31) + stfd 11,252(31) + stfd 12,260(31) + stfd 13,268(31) + std 9,136(31) + std 0,144(31) + stw 30,112(31) + std 2,40(1) + ld 9,0(12) + ld 11,16(12) + mtctr 9 + ld 2,8(12) + bctrl + ld 2,40(1) + lwz 9,152(31) + cmpdi 7,9,0 + beq 7,L..1 + cmplwi 7,9,1 + beq 7,L..20 + cmplwi 7,9,2 + beq 7,L..23 + cmplwi 7,9,3 + beq 7,L..20 + cmplwi 7,9,4 + beq 7,L..24 + cmplwi 7,9,5 + beq 7,L..25 + cmplwi 7,9,6 + beq 7,L..26 + cmplwi 7,9,7 + beq 7,L..27 + cmplwi 7,9,8 + beq 7,L..21 + cmplwi 7,9,9 + beq 7,L..21 + cmplwi 7,9,10 + beq 7,L..21 + cmplwi 7,9,11 + beq 7,L..21 + cmplwi 7,9,12 + beq 7,L..28 + cmplwi 7,9,13 + beq 7,L..29 + cmplwi 7,9,14 + beq 7,L..21 +L..1: + addi 1,31,304 + ld 0,16(1) + ld 30,-16(1) + ld 31,-8(1) + mtlr 0 + blr + .align 4 +L..20: + lbz 3,120(31) + addi 1,31,304 + ld 0,16(1) + ld 30,-16(1) + ld 31,-8(1) + mtlr 0 + blr + .align 4 +L..23: + lbz 9,120(31) + extsb 3,9 + b L..1 + .align 4 +L..21: + ld 3,120(31) + b L..1 + .align 4 +L..24: + lha 3,120(31) + b L..1 + .align 4 +L..25: + lhz 3,120(31) + b L..1 + .align 4 +L..26: + lwa 3,120(31) + b L..1 + .align 4 +L..28: + lfs 1,120(31) + b L..1 + .align 4 +L..27: + lwz 3,120(31) + b L..1 +L..29: + lfd 1,120(31) + b L..1 +LT..callback_receiver: + .long 0 + .byte 0,0,32,97,128,2,8,0 + .long 0 + .long LT..callback_receiver-.callback_receiver + .short 17 + .byte "callback_receiver" + .byte 31 + .align 2 + .toc +LC..0: + .tc callback_receiver[TC],callback_receiver + .csect .text[PR] + .align 2 + .align 4 + .globl callback_get_receiver + .globl .callback_get_receiver + .csect callback_get_receiver[DS],3 +callback_get_receiver: + .llong .callback_get_receiver, TOC[tc0], 0 + .csect .text[PR] +.callback_get_receiver: + std 31,-8(1) + ld 3,LC..0(2) + stdu 1,-64(1) + mr 31,1 + addi 1,31,64 + ld 31,-8(1) + blr +LT..callback_get_receiver: + .long 0 + .byte 0,0,32,96,128,1,0,0 + .long LT..callback_get_receiver-.callback_get_receiver + .short 21 + .byte "callback_get_receiver" + .byte 31 + .align 2 +_section_.text: + .csect .data[RW],4 + .llong _section_.text diff --git a/callback/vacall_r/vacall-powerpc64-elfv2-linux.S b/callback/vacall_r/vacall-powerpc64-elfv2-linux.S new file mode 100644 index 0000000..25af0eb --- /dev/null +++ b/callback/vacall_r/vacall-powerpc64-elfv2-linux.S @@ -0,0 +1,241 @@ + .file "vacall-powerpc64.c" + .machine power4 + .abiversion 2 + .section ".toc","aw" + .section ".text" + .align 2 + .p2align 4,,15 + .type callback_receiver, @function +callback_receiver: +0: addis 2,12,.TOC.-0b@ha + addi 2,2,.TOC.-0b@l + .localentry callback_receiver,.-callback_receiver + mflr 0 + std 30,-16(1) + std 31,-8(1) + std 0,16(1) + stdu 1,-224(1) + li 0,0 + ld 30,0(11) + mr 31,1 + std 3,256(31) + std 4,264(31) + addi 4,31,32 + ld 3,8(11) + std 9,304(31) + mtctr 30 + li 9,0 + std 5,272(31) + std 6,280(31) + std 7,288(31) + std 8,296(31) + stw 9,32(31) + std 10,312(31) + stfd 1,96(31) + stfd 2,104(31) + mr 12,30 + addi 9,31,256 + stfd 3,112(31) + stfd 4,120(31) + stfd 5,128(31) + stfd 6,136(31) + std 9,56(31) + stfd 7,144(31) + stfd 8,152(31) + stfd 9,160(31) + stfd 10,168(31) + stfd 11,176(31) + stfd 12,184(31) + stfd 13,192(31) + std 0,64(31) + stw 0,72(31) + stw 0,88(31) + std 2,24(1) + bctrl + ld 2,24(1) + lwz 9,72(31) + cmpdi 7,9,0 + beq 7,.L1 + cmplwi 7,9,1 + beq 7,.L27 + cmplwi 7,9,2 + beq 7,.L30 + cmplwi 7,9,3 + beq 7,.L27 + cmplwi 7,9,4 + beq 7,.L31 + cmplwi 7,9,5 + beq 7,.L32 + cmplwi 7,9,6 + beq 7,.L33 + cmplwi 7,9,7 + beq 7,.L34 + cmplwi 7,9,8 + beq 7,.L28 + cmplwi 7,9,9 + beq 7,.L28 + cmplwi 7,9,10 + beq 7,.L28 + cmplwi 7,9,11 + beq 7,.L28 + cmplwi 7,9,12 + beq 7,.L35 + cmplwi 7,9,13 + beq 7,.L36 + cmplwi 7,9,14 + beq 7,.L28 + cmplwi 7,9,15 + bne 7,.L1 + lwz 9,32(31) + rldicl. 10,9,54,63 + beq 0,.L1 + ld 9,80(31) + addi 10,9,-1 + cmpldi 7,10,15 + bgt 7,.L1 + ld 8,64(31) + cmpldi 7,9,8 + rldicl 10,8,0,61 + rldicr 8,8,0,60 + add 9,9,10 + bgt 7,.L17 + cmpldi 7,9,8 + slwi 9,9,3 + bgt 7,.L18 + ld 7,0(8) + addi 9,9,-1 + li 8,2 + slwi 10,10,3 + sld 9,8,9 + addi 9,9,-1 + and 9,9,7 + srad 3,9,10 +.L1: + addi 1,31,224 + ld 0,16(1) + ld 30,-16(1) + ld 31,-8(1) + mtlr 0 + blr + .p2align 4,,15 +.L27: + addi 1,31,224 + lbz 3,40(31) + ld 0,16(1) + ld 30,-16(1) + ld 31,-8(1) + mtlr 0 + blr + .p2align 4,,15 +.L30: + lbz 9,40(31) + extsb 3,9 + b .L1 + .p2align 4,,15 +.L28: + ld 3,40(31) + b .L1 + .p2align 4,,15 +.L31: + lha 3,40(31) + b .L1 + .p2align 4,,15 +.L32: + lhz 3,40(31) + b .L1 + .p2align 4,,15 +.L33: + lwa 3,40(31) + b .L1 + .p2align 4,,15 +.L35: + lfs 1,40(31) + b .L1 + .p2align 4,,15 +.L34: + lwz 3,40(31) + b .L1 +.L36: + lfd 1,40(31) + b .L1 +.L17: + cmpldi 7,9,16 + rldicl 10,10,0,32 + slwi 9,9,3 + ble 7,.L37 + li 7,2 + addi 9,9,-129 + ld 0,16(8) + ld 5,0(8) + mulli 6,10,-8 + sld 9,7,9 + ld 7,8(8) + addi 8,9,-1 + slwi 9,10,3 + addi 6,6,64 + and 10,8,0 + srad 8,5,9 + sld 5,7,6 + srad 9,7,9 + sld 10,10,6 + or 3,8,5 + or 4,10,9 + b .L1 +.L18: + rldicl 10,10,0,32 + li 7,2 + ld 6,8(8) + ld 8,0(8) + addi 9,9,-65 + sld 9,7,9 + mulli 7,10,-8 + slwi 10,10,3 + addi 9,9,-1 + srad 10,8,10 + and 9,9,6 + addi 7,7,64 + sld 9,9,7 + or 3,9,10 + b .L1 +.L37: + li 7,2 + addi 9,9,-65 + ld 5,8(8) + ld 6,0(8) + sld 9,7,9 + mulli 7,10,-4 + addi 9,9,-1 + addi 7,7,32 + and 8,9,5 + slwi 9,10,3 + sld 10,8,7 + srad 6,6,9 + srad 4,8,9 + sld 7,10,7 + or 3,6,7 + b .L1 + .long 0 + .byte 0,0,0,1,128,2,0,0 + .size callback_receiver,.-callback_receiver + .align 2 + .p2align 4,,15 + .globl callback_get_receiver + .type callback_get_receiver, @function +callback_get_receiver: +0: addis 2,12,.TOC.-0b@ha + addi 2,2,.TOC.-0b@l + .localentry callback_get_receiver,.-callback_get_receiver + std 31,-8(1) + stdu 1,-48(1) + addis 3,2,callback_receiver@toc@ha + addi 3,3,callback_receiver@toc@l + mr 31,1 + addi 1,31,48 + ld 31,-8(1) + blr + .long 0 + .byte 0,0,0,0,128,1,0,0 + .size callback_get_receiver,.-callback_get_receiver +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/callback/vacall_r/vacall-powerpc64-linux.S b/callback/vacall_r/vacall-powerpc64-linux.S new file mode 100644 index 0000000..581289b --- /dev/null +++ b/callback/vacall_r/vacall-powerpc64-linux.S @@ -0,0 +1,164 @@ + .file "vacall-powerpc64.c" + .machine power4 + .section ".toc","aw" + .section ".text" + .align 2 + .p2align 4,,15 + .section ".opd","aw" + .align 3 +callback_receiver: + .quad .L.callback_receiver,.TOC.@tocbase,0 + .previous + .type callback_receiver, @function +.L.callback_receiver: + mflr 0 + std 30,-16(1) + std 31,-8(1) + li 30,0 + std 0,16(1) + stdu 1,-304(1) + li 0,0 + mr 31,1 + ld 12,0(11) + std 9,400(31) + addi 9,31,352 + stw 0,152(31) + stw 0,168(31) + std 3,352(31) + std 4,360(31) + ld 3,8(11) + std 5,368(31) + std 6,376(31) + addi 4,31,112 + std 7,384(31) + std 8,392(31) + std 10,408(31) + stfd 1,176(31) + stfd 2,184(31) + stfd 3,192(31) + stfd 4,200(31) + stfd 5,208(31) + stfd 6,216(31) + stfd 7,224(31) + stfd 8,232(31) + stfd 9,240(31) + stfd 10,248(31) + stfd 11,256(31) + stfd 12,264(31) + stfd 13,272(31) + std 9,136(31) + std 0,144(31) + stw 30,112(31) + std 2,40(1) + ld 9,0(12) + ld 11,16(12) + mtctr 9 + ld 2,8(12) + bctrl + ld 2,40(1) + lwz 9,152(31) + cmpdi 7,9,0 + beq 7,.L1 + cmplwi 7,9,1 + beq 7,.L20 + cmplwi 7,9,2 + beq 7,.L23 + cmplwi 7,9,3 + beq 7,.L20 + cmplwi 7,9,4 + beq 7,.L24 + cmplwi 7,9,5 + beq 7,.L25 + cmplwi 7,9,6 + beq 7,.L26 + cmplwi 7,9,7 + beq 7,.L27 + cmplwi 7,9,8 + beq 7,.L21 + cmplwi 7,9,9 + beq 7,.L21 + cmplwi 7,9,10 + beq 7,.L21 + cmplwi 7,9,11 + beq 7,.L21 + cmplwi 7,9,12 + beq 7,.L28 + cmplwi 7,9,13 + beq 7,.L29 + cmplwi 7,9,14 + beq 7,.L21 +.L1: + addi 1,31,304 + ld 0,16(1) + ld 30,-16(1) + ld 31,-8(1) + mtlr 0 + blr + .p2align 4,,15 +.L20: + lbz 3,120(31) + addi 1,31,304 + ld 0,16(1) + ld 30,-16(1) + ld 31,-8(1) + mtlr 0 + blr + .p2align 4,,15 +.L23: + lbz 9,120(31) + extsb 3,9 + b .L1 + .p2align 4,,15 +.L21: + ld 3,120(31) + b .L1 + .p2align 4,,15 +.L24: + lha 3,120(31) + b .L1 + .p2align 4,,15 +.L25: + lhz 3,120(31) + b .L1 + .p2align 4,,15 +.L26: + lwa 3,120(31) + b .L1 + .p2align 4,,15 +.L28: + lfs 1,120(31) + b .L1 + .p2align 4,,15 +.L27: + lwz 3,120(31) + b .L1 +.L29: + lfd 1,120(31) + b .L1 + .long 0 + .byte 0,0,0,1,128,2,0,0 + .size callback_receiver,.-.L.callback_receiver + .align 2 + .p2align 4,,15 + .globl callback_get_receiver + .section ".opd","aw" + .align 3 +callback_get_receiver: + .quad .L.callback_get_receiver,.TOC.@tocbase,0 + .previous + .type callback_get_receiver, @function +.L.callback_get_receiver: + std 31,-8(1) + stdu 1,-64(1) + addis 3,2,callback_receiver@toc@ha + addi 3,3,callback_receiver@toc@l + mr 31,1 + addi 1,31,64 + ld 31,-8(1) + blr + .long 0 + .byte 0,0,0,0,128,1,0,0 + .size callback_get_receiver,.-.L.callback_get_receiver +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/callback/vacall_r/vacall-riscv32-ilp32d-linux.s b/callback/vacall_r/vacall-riscv32-ilp32d-linux.s new file mode 100644 index 0000000..d01ebaa --- /dev/null +++ b/callback/vacall_r/vacall-riscv32-ilp32d-linux.s @@ -0,0 +1,174 @@ + .file "vacall-riscv32.c" + .option pic + .text + .align 1 + .type callback_receiver, @function +callback_receiver: + add sp,sp,-208 + sw ra,188(sp) + sw s0,184(sp) + add s0,sp,192 + sw a1,-144(s0) + add a1,s0,16 + lw t3,0(t2) + sw a7,12(s0) + sw a2,-140(s0) + sw a3,-136(s0) + sw a4,-132(s0) + sw a5,-128(s0) + sw a6,-124(s0) + sw a7,-120(s0) + fsw fa0,-112(s0) + fsw fa1,-108(s0) + fsw fa2,-104(s0) + fsw fa3,-100(s0) + fsw fa4,-96(s0) + fsw fa5,-92(s0) + fsw fa6,-88(s0) + fsw fa7,-84(s0) + fsd fa0,-80(s0) + fsd fa1,-72(s0) + fsd fa2,-64(s0) + fsd fa3,-56(s0) + fsd fa4,-48(s0) + fsd fa5,-40(s0) + fsd fa6,-32(s0) + fsd fa7,-24(s0) + sw a1,-168(s0) + sw a0,-148(s0) + sw zero,-184(s0) + sw zero,-164(s0) + sw zero,-160(s0) + lw a0,4(t2) + sw zero,-152(s0) + sw zero,-116(s0) + add a1,s0,-184 + jalr t3 + lw t1,-160(s0) + beqz t1,.L1 + li t3,1 + beq t1,t3,.L22 + li t3,2 + beq t1,t3,.L25 + li t3,3 + beq t1,t3,.L22 + li t3,4 + beq t1,t3,.L26 + li t3,5 + beq t1,t3,.L27 + li t3,6 + beq t1,t3,.L23 + li t3,7 + beq t1,t3,.L23 + li t3,8 + beq t1,t3,.L23 + li t3,9 + beq t1,t3,.L23 + add t3,t1,-10 + li t4,1 + bleu t3,t4,.L28 + li t3,12 + beq t1,t3,.L29 + li t3,13 + beq t1,t3,.L30 + li t3,14 + beq t1,t3,.L23 + li t3,15 + bne t1,t3,.L1 + lw t1,-184(s0) + and t1,t1,2 + beqz t1,.L1 + lw t3,-156(s0) + li t1,7 + add t5,t3,-1 + bgtu t5,t1,.L1 + lw t1,-164(s0) + lbu t5,0(t1) + mv a0,t5 + beq t3,t4,.L1 + lbu t4,1(t1) + li t6,2 + sll t4,t4,8 + or t5,t4,t5 + mv a0,t5 + beq t3,t6,.L1 + lbu t4,2(t1) + li t6,3 + sll t4,t4,16 + or t4,t4,t5 + mv a0,t4 + beq t3,t6,.L1 + lbu a0,3(t1) + li t5,4 + sll a0,a0,24 + or a0,a0,t4 + beq t3,t5,.L1 + lbu t5,4(t1) + li t4,5 + mv a1,t5 + beq t3,t4,.L1 + lbu t4,5(t1) + li t6,6 + sll t4,t4,8 + or t5,t4,t5 + mv a1,t5 + beq t3,t6,.L1 + lbu t4,6(t1) + li t6,8 + sll t4,t4,16 + or t4,t4,t5 + mv a1,t4 + bne t3,t6,.L1 + lbu a1,7(t1) + sll a1,a1,24 + or a1,a1,t4 +.L1: + lw ra,188(sp) + lw s0,184(sp) + add sp,sp,208 + jr ra +.L22: + lbu a0,-176(s0) + lw ra,188(sp) + lw s0,184(sp) + add sp,sp,208 + jr ra +.L23: + lw a0,-176(s0) + j .L1 +.L25: + lb a0,-176(s0) + lw ra,188(sp) + lw s0,184(sp) + add sp,sp,208 + jr ra +.L26: + lh a0,-176(s0) + j .L1 +.L27: + lhu a0,-176(s0) + j .L1 +.L28: + lw a0,-176(s0) + lw a1,-172(s0) + j .L1 +.L29: + flw fa0,-176(s0) + j .L1 +.L30: + fld fa0,-176(s0) + j .L1 + .size callback_receiver, .-callback_receiver + .align 1 + .globl callback_get_receiver + .type callback_get_receiver, @function +callback_get_receiver: + add sp,sp,-16 + sw s0,12(sp) + add s0,sp,16 + lw s0,12(sp) + lla a0,callback_receiver + add sp,sp,16 + jr ra + .size callback_get_receiver, .-callback_get_receiver + .ident "GCC: (GNU) 7.3.0" diff --git a/callback/vacall_r/vacall-riscv32-ilp32d-macro.S b/callback/vacall_r/vacall-riscv32-ilp32d-macro.S new file mode 100644 index 0000000..c29c138 --- /dev/null +++ b/callback/vacall_r/vacall-riscv32-ilp32d-macro.S @@ -0,0 +1,176 @@ + .file "vacall-riscv32.c" + .option pic + .text + .align 1 + .type callback_receiver, @function +callback_receiver: + add sp,sp,-208 + sw ra,188(sp) + sw s0,184(sp) + add s0,sp,192 + sw a1,-144(s0) + add a1,s0,16 + lw t3,0(t2) + sw a7,12(s0) + sw a2,-140(s0) + sw a3,-136(s0) + sw a4,-132(s0) + sw a5,-128(s0) + sw a6,-124(s0) + sw a7,-120(s0) + fsw fa0,-112(s0) + fsw fa1,-108(s0) + fsw fa2,-104(s0) + fsw fa3,-100(s0) + fsw fa4,-96(s0) + fsw fa5,-92(s0) + fsw fa6,-88(s0) + fsw fa7,-84(s0) + fsd fa0,-80(s0) + fsd fa1,-72(s0) + fsd fa2,-64(s0) + fsd fa3,-56(s0) + fsd fa4,-48(s0) + fsd fa5,-40(s0) + fsd fa6,-32(s0) + fsd fa7,-24(s0) + sw a1,-168(s0) + sw a0,-148(s0) + sw zero,-184(s0) + sw zero,-164(s0) + sw zero,-160(s0) + lw a0,4(t2) + sw zero,-152(s0) + sw zero,-116(s0) + add a1,s0,-184 + jalr t3 + lw t1,-160(s0) + beqz t1,.L1 + li t3,1 + beq t1,t3,.L22 + li t3,2 + beq t1,t3,.L25 + li t3,3 + beq t1,t3,.L22 + li t3,4 + beq t1,t3,.L26 + li t3,5 + beq t1,t3,.L27 + li t3,6 + beq t1,t3,.L23 + li t3,7 + beq t1,t3,.L23 + li t3,8 + beq t1,t3,.L23 + li t3,9 + beq t1,t3,.L23 + add t3,t1,-10 + li t4,1 + bleu t3,t4,.L28 + li t3,12 + beq t1,t3,.L29 + li t3,13 + beq t1,t3,.L30 + li t3,14 + beq t1,t3,.L23 + li t3,15 + bne t1,t3,.L1 + lw t1,-184(s0) + and t1,t1,2 + beqz t1,.L1 + lw t3,-156(s0) + li t1,7 + add t5,t3,-1 + bgtu t5,t1,.L1 + lw t1,-164(s0) + lbu t5,0(t1) + mv a0,t5 + beq t3,t4,.L1 + lbu t4,1(t1) + li t6,2 + sll t4,t4,8 + or t5,t4,t5 + mv a0,t5 + beq t3,t6,.L1 + lbu t4,2(t1) + li t6,3 + sll t4,t4,16 + or t4,t4,t5 + mv a0,t4 + beq t3,t6,.L1 + lbu a0,3(t1) + li t5,4 + sll a0,a0,24 + or a0,a0,t4 + beq t3,t5,.L1 + lbu t5,4(t1) + li t4,5 + mv a1,t5 + beq t3,t4,.L1 + lbu t4,5(t1) + li t6,6 + sll t4,t4,8 + or t5,t4,t5 + mv a1,t5 + beq t3,t6,.L1 + lbu t4,6(t1) + li t6,8 + sll t4,t4,16 + or t4,t4,t5 + mv a1,t4 + bne t3,t6,.L1 + lbu a1,7(t1) + sll a1,a1,24 + or a1,a1,t4 +.L1: + lw ra,188(sp) + lw s0,184(sp) + add sp,sp,208 + jr ra +.L22: + lbu a0,-176(s0) + lw ra,188(sp) + lw s0,184(sp) + add sp,sp,208 + jr ra +.L23: + lw a0,-176(s0) + j .L1 +.L25: + lb a0,-176(s0) + lw ra,188(sp) + lw s0,184(sp) + add sp,sp,208 + jr ra +.L26: + lh a0,-176(s0) + j .L1 +.L27: + lhu a0,-176(s0) + j .L1 +.L28: + lw a0,-176(s0) + lw a1,-172(s0) + j .L1 +.L29: + flw fa0,-176(s0) + j .L1 +.L30: + fld fa0,-176(s0) + j .L1 + .size callback_receiver, .-callback_receiver + .align 1 + .globl callback_get_receiver + .type callback_get_receiver, @function +callback_get_receiver: + add sp,sp,-16 + sw s0,12(sp) + add s0,sp,16 + lw s0,12(sp) + lla a0,callback_receiver + add sp,sp,16 + jr ra + .size callback_get_receiver, .-callback_get_receiver +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/callback/vacall_r/vacall-riscv64-lp64d-linux.s b/callback/vacall_r/vacall-riscv64-lp64d-linux.s new file mode 100644 index 0000000..0eae01a --- /dev/null +++ b/callback/vacall_r/vacall-riscv64-lp64d-linux.s @@ -0,0 +1,205 @@ + .file "vacall-riscv64.c" + .option pic + .text + .align 1 + .type callback_receiver, @function +callback_receiver: + add sp,sp,-288 + sd ra,264(sp) + sd s0,256(sp) + sd s1,248(sp) + add s0,sp,272 + sd s2,240(sp) + sd a1,-192(s0) + add a1,s0,16 + ld t3,0(t2) + sd a7,8(s0) + sd a2,-184(s0) + sd a3,-176(s0) + sd a4,-168(s0) + sd a5,-160(s0) + sd a6,-152(s0) + sd a7,-144(s0) + fsw fa0,-132(s0) + fsw fa1,-128(s0) + fsw fa2,-124(s0) + fsw fa3,-120(s0) + fsw fa4,-116(s0) + fsw fa5,-112(s0) + fsw fa6,-108(s0) + fsw fa7,-104(s0) + fsd fa0,-96(s0) + fsd fa1,-88(s0) + fsd fa2,-80(s0) + fsd fa3,-72(s0) + fsd fa4,-64(s0) + fsd fa5,-56(s0) + fsd fa6,-48(s0) + fsd fa7,-40(s0) + sd a1,-240(s0) + sd a0,-200(s0) + sw zero,-264(s0) + ld a0,8(t2) + sd zero,-232(s0) + sw zero,-224(s0) + sw zero,-208(s0) + sw zero,-136(s0) + add a1,s0,-264 + jalr t3 + lw t1,-224(s0) + beqz t1,.L1 + li t3,1 + beq t1,t3,.L25 + li t3,2 + beq t1,t3,.L29 + li t3,3 + beq t1,t3,.L25 + li t3,4 + beq t1,t3,.L30 + li t3,5 + beq t1,t3,.L31 + li t3,6 + beq t1,t3,.L32 + li t3,7 + beq t1,t3,.L33 + and t3,t1,-3 + li t4,8 + beq t3,t4,.L27 + li t4,9 + beq t3,t4,.L27 + li t3,12 + beq t1,t3,.L34 + li t3,13 + beq t1,t3,.L35 + li t3,14 + beq t1,t3,.L27 + li t3,15 + bne t1,t3,.L1 + lw t3,-264(s0) + and t3,t3,1024 + beqz t3,.L1 + ld t0,-216(s0) + add t3,t0,-1 + bgtu t3,t1,.L1 + ld t5,-232(s0) + li s2,8 + and t6,t5,7 + add s1,t0,t6 + and t5,t5,-8 + sext.w t6,t6 + sllw t1,s1,3 + ld t4,0(t5) + sll t3,t6,3 + bgtu t0,s2,.L15 + bgtu s1,s2,.L16 + addw t1,t1,-1 + li a0,2 + sll a0,a0,t1 + add a0,a0,-1 + and a0,a0,t4 + sra a0,a0,t3 +.L1: + ld ra,264(sp) + ld s0,256(sp) + ld s1,248(sp) + ld s2,240(sp) + add sp,sp,288 + jr ra +.L25: + lbu a0,-256(s0) + ld ra,264(sp) + ld s0,256(sp) + ld s1,248(sp) + ld s2,240(sp) + add sp,sp,288 + jr ra +.L29: + lb a0,-256(s0) + ld ra,264(sp) + ld s0,256(sp) + ld s1,248(sp) + ld s2,240(sp) + add sp,sp,288 + jr ra +.L30: + lh a0,-256(s0) + j .L1 +.L33: + lwu a0,-256(s0) + j .L1 +.L31: + lhu a0,-256(s0) + j .L1 +.L27: + ld a0,-256(s0) + j .L1 +.L32: + lw a0,-256(s0) + j .L1 +.L34: + flw fa0,-256(s0) + j .L1 +.L35: + fld fa0,-256(s0) + j .L1 +.L15: + li s2,16 + sra t4,t4,t3 + ld t0,8(t5) + bleu s1,s2,.L36 + li a1,-8 + mulw t6,a1,t6 + addw t1,t1,-129 + ld a0,16(t5) + li a1,2 + sll a1,a1,t1 + add a1,a1,-1 + and a1,a1,a0 + sra t3,t0,t3 + addw t1,t6,64 + sll a0,t0,t1 + sll a1,a1,t1 + or a0,a0,t4 + or a1,a1,t3 + j .L1 +.L16: + li a0,-8 + mulw t6,a0,t6 + addw t1,t1,-65 + ld t5,8(t5) + li a0,2 + sll a0,a0,t1 + add a0,a0,-1 + and a0,a0,t5 + sra t4,t4,t3 + sll a0,a0,t6 + or a0,a0,t4 + j .L1 +.L36: + li a1,-4 + mulw t6,a1,t6 + addw t1,t1,-65 + li a0,2 + sll a0,a0,t1 + add a0,a0,-1 + and a0,a0,t0 + sra a1,a0,t3 + addw t1,t6,32 + sll a0,a0,t1 + sll a0,a0,t1 + or a0,a0,t4 + j .L1 + .size callback_receiver, .-callback_receiver + .align 1 + .globl callback_get_receiver + .type callback_get_receiver, @function +callback_get_receiver: + add sp,sp,-16 + sd s0,8(sp) + add s0,sp,16 + ld s0,8(sp) + lla a0,callback_receiver + add sp,sp,16 + jr ra + .size callback_get_receiver, .-callback_get_receiver + .ident "GCC: (GNU) 7.3.0" diff --git a/callback/vacall_r/vacall-riscv64-lp64d-macro.S b/callback/vacall_r/vacall-riscv64-lp64d-macro.S new file mode 100644 index 0000000..c245a59 --- /dev/null +++ b/callback/vacall_r/vacall-riscv64-lp64d-macro.S @@ -0,0 +1,207 @@ + .file "vacall-riscv64.c" + .option pic + .text + .align 1 + .type callback_receiver, @function +callback_receiver: + add sp,sp,-288 + sd ra,264(sp) + sd s0,256(sp) + sd s1,248(sp) + add s0,sp,272 + sd s2,240(sp) + sd a1,-192(s0) + add a1,s0,16 + ld t3,0(t2) + sd a7,8(s0) + sd a2,-184(s0) + sd a3,-176(s0) + sd a4,-168(s0) + sd a5,-160(s0) + sd a6,-152(s0) + sd a7,-144(s0) + fsw fa0,-132(s0) + fsw fa1,-128(s0) + fsw fa2,-124(s0) + fsw fa3,-120(s0) + fsw fa4,-116(s0) + fsw fa5,-112(s0) + fsw fa6,-108(s0) + fsw fa7,-104(s0) + fsd fa0,-96(s0) + fsd fa1,-88(s0) + fsd fa2,-80(s0) + fsd fa3,-72(s0) + fsd fa4,-64(s0) + fsd fa5,-56(s0) + fsd fa6,-48(s0) + fsd fa7,-40(s0) + sd a1,-240(s0) + sd a0,-200(s0) + sw zero,-264(s0) + ld a0,8(t2) + sd zero,-232(s0) + sw zero,-224(s0) + sw zero,-208(s0) + sw zero,-136(s0) + add a1,s0,-264 + jalr t3 + lw t1,-224(s0) + beqz t1,.L1 + li t3,1 + beq t1,t3,.L25 + li t3,2 + beq t1,t3,.L29 + li t3,3 + beq t1,t3,.L25 + li t3,4 + beq t1,t3,.L30 + li t3,5 + beq t1,t3,.L31 + li t3,6 + beq t1,t3,.L32 + li t3,7 + beq t1,t3,.L33 + and t3,t1,-3 + li t4,8 + beq t3,t4,.L27 + li t4,9 + beq t3,t4,.L27 + li t3,12 + beq t1,t3,.L34 + li t3,13 + beq t1,t3,.L35 + li t3,14 + beq t1,t3,.L27 + li t3,15 + bne t1,t3,.L1 + lw t3,-264(s0) + and t3,t3,1024 + beqz t3,.L1 + ld t0,-216(s0) + add t3,t0,-1 + bgtu t3,t1,.L1 + ld t5,-232(s0) + li s2,8 + and t6,t5,7 + add s1,t0,t6 + and t5,t5,-8 + sext.w t6,t6 + sllw t1,s1,3 + ld t4,0(t5) + sll t3,t6,3 + bgtu t0,s2,.L15 + bgtu s1,s2,.L16 + addw t1,t1,-1 + li a0,2 + sll a0,a0,t1 + add a0,a0,-1 + and a0,a0,t4 + sra a0,a0,t3 +.L1: + ld ra,264(sp) + ld s0,256(sp) + ld s1,248(sp) + ld s2,240(sp) + add sp,sp,288 + jr ra +.L25: + lbu a0,-256(s0) + ld ra,264(sp) + ld s0,256(sp) + ld s1,248(sp) + ld s2,240(sp) + add sp,sp,288 + jr ra +.L29: + lb a0,-256(s0) + ld ra,264(sp) + ld s0,256(sp) + ld s1,248(sp) + ld s2,240(sp) + add sp,sp,288 + jr ra +.L30: + lh a0,-256(s0) + j .L1 +.L33: + lwu a0,-256(s0) + j .L1 +.L31: + lhu a0,-256(s0) + j .L1 +.L27: + ld a0,-256(s0) + j .L1 +.L32: + lw a0,-256(s0) + j .L1 +.L34: + flw fa0,-256(s0) + j .L1 +.L35: + fld fa0,-256(s0) + j .L1 +.L15: + li s2,16 + sra t4,t4,t3 + ld t0,8(t5) + bleu s1,s2,.L36 + li a1,-8 + mulw t6,a1,t6 + addw t1,t1,-129 + ld a0,16(t5) + li a1,2 + sll a1,a1,t1 + add a1,a1,-1 + and a1,a1,a0 + sra t3,t0,t3 + addw t1,t6,64 + sll a0,t0,t1 + sll a1,a1,t1 + or a0,a0,t4 + or a1,a1,t3 + j .L1 +.L16: + li a0,-8 + mulw t6,a0,t6 + addw t1,t1,-65 + ld t5,8(t5) + li a0,2 + sll a0,a0,t1 + add a0,a0,-1 + and a0,a0,t5 + sra t4,t4,t3 + sll a0,a0,t6 + or a0,a0,t4 + j .L1 +.L36: + li a1,-4 + mulw t6,a1,t6 + addw t1,t1,-65 + li a0,2 + sll a0,a0,t1 + add a0,a0,-1 + and a0,a0,t0 + sra a1,a0,t3 + addw t1,t6,32 + sll a0,a0,t1 + sll a0,a0,t1 + or a0,a0,t4 + j .L1 + .size callback_receiver, .-callback_receiver + .align 1 + .globl callback_get_receiver + .type callback_get_receiver, @function +callback_get_receiver: + add sp,sp,-16 + sd s0,8(sp) + add s0,sp,16 + ld s0,8(sp) + lla a0,callback_receiver + add sp,sp,16 + jr ra + .size callback_get_receiver, .-callback_get_receiver +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/callback/vacall_r/vacall-s390-linux.s b/callback/vacall_r/vacall-s390-linux.s new file mode 100644 index 0000000..999229f --- /dev/null +++ b/callback/vacall_r/vacall-s390-linux.s @@ -0,0 +1,160 @@ + .file "vacall-s390.c" +.text + .align 4 + .type callback_receiver,@function +callback_receiver: + stm %r6,%r15,24(%r15) + bras %r13,.LTN0_0 +.LT0_0: +.LC0: + .long 0 +.LC1: + .long 255 +.LC2: + .long 65535 +.LC3: + .long 1 +.LTN0_0: + lr %r1,%r0 + lr %r14,%r15 + ahi %r15,-184 + lr %r11,%r15 + lr %r9,%r0 + l %r10,0(%r1) + st %r14,0(%r15) + la %r1,280(%r11) + mvc 116(4,%r11),.LC0-.LT0_0(%r13) + st %r2,132(%r11) + st %r3,136(%r11) + la %r3,96(%r11) + st %r4,140(%r11) + st %r5,144(%r11) + st %r6,148(%r11) + std %f2,176(%r11) + std %f0,168(%r11) + ste %f2,160(%r11) + ste %f0,156(%r11) + mvc 96(4,%r11),.LC0-.LT0_0(%r13) + st %r1,112(%r11) + mvc 120(4,%r11),.LC0-.LT0_0(%r13) + mvc 128(4,%r11),.LC0-.LT0_0(%r13) + mvc 152(4,%r11),.LC0-.LT0_0(%r13) + l %r2,4(%r9) + basr %r14,%r10 + icm %r4,15,120(%r11) + je .L1 + chi %r4,1 + je .L43 + chi %r4,2 + je .L44 + chi %r4,3 + je .L43 + chi %r4,4 + je .L45 + chi %r4,5 + je .L46 + chi %r4,6 + je .L40 + chi %r4,7 + je .L40 + chi %r4,8 + je .L40 + chi %r4,9 + je .L40 + lr %r1,%r4 + ahi %r1,-10 + cl %r1,.LC3-.LT0_0(%r13) + jh .L22 + l %r2,104(%r11) + l %r3,108(%r11) +.L1: + l %r4,240(%r11) + lm %r6,%r15,208(%r11) + br %r4 +.L22: + chi %r4,12 + je .L47 + chi %r4,13 + je .L48 + chi %r4,14 + je .L40 + chi %r4,15 + jne .L1 + tm 98(%r11),4 + je .L1 + l %r1,124(%r11) + chi %r1,1 + je .L49 + chi %r1,2 + je .L50 + chi %r1,4 + je .L51 + chi %r1,8 + jne .L1 + l %r1,116(%r11) + l %r3,4(%r1) +.L39: + l %r2,0(%r1) + j .L1 +.L51: + l %r1,116(%r11) + j .L39 +.L50: + l %r1,116(%r11) + lh %r4,0(%r1) + lr %r2,%r4 +.L41: + n %r2,.LC2-.LT0_0(%r13) + j .L1 +.L49: + l %r1,116(%r11) + ic %r4,0(%r1) + lr %r2,%r4 +.L42: + n %r2,.LC1-.LT0_0(%r13) + j .L1 +.L40: + l %r2,104(%r11) + j .L1 +.L48: + ld %f0,104(%r11) + j .L1 +.L47: + le %f0,104(%r11) + j .L1 +.L46: + lh %r1,104(%r11) + lr %r2,%r1 + j .L41 +.L45: + lh %r2,104(%r11) + j .L1 +.L43: + ic %r1,104(%r11) + lr %r2,%r1 + j .L42 +.L44: + icm %r1,8,104(%r11) + lr %r2,%r1 + sra %r2,24 + j .L1 +.Lfe1: + .size callback_receiver,.Lfe1-callback_receiver + .align 4 +.globl callback_get_receiver + .type callback_get_receiver,@function +callback_get_receiver: + stm %r11,%r13,44(%r15) + bras %r13,.LTN1_0 +.LT1_0: +.LC4: + .long callback_receiver-.LT1_0 +.LTN1_0: + l %r1,.LC4-.LT1_0(%r13) + lr %r11,%r15 + la %r2,0(%r13,%r1) + lm %r11,%r13,44(%r11) + br %r14 +.Lfe2: + .size callback_get_receiver,.Lfe2-callback_get_receiver + .ident "GCC: (GNU) 3.1" diff --git a/callback/vacall_r/vacall-s390-macro.S b/callback/vacall_r/vacall-s390-macro.S new file mode 100644 index 0000000..1c5314a --- /dev/null +++ b/callback/vacall_r/vacall-s390-macro.S @@ -0,0 +1,162 @@ + .file "vacall-s390.c" +.text + .align 4 + .type callback_receiver,@function +callback_receiver: + stm %r6,%r15,24(%r15) + bras %r13,.LTN0_0 +.LT0_0: +.LC0: + .long 0 +.LC1: + .long 255 +.LC2: + .long 65535 +.LC3: + .long 1 +.LTN0_0: + lr %r1,%r0 + lr %r14,%r15 + ahi %r15,-184 + lr %r11,%r15 + lr %r9,%r0 + l %r10,0(%r1) + st %r14,0(%r15) + la %r1,280(%r11) + mvc 116(4,%r11),.LC0-.LT0_0(%r13) + st %r2,132(%r11) + st %r3,136(%r11) + la %r3,96(%r11) + st %r4,140(%r11) + st %r5,144(%r11) + st %r6,148(%r11) + std %f2,176(%r11) + std %f0,168(%r11) + ste %f2,160(%r11) + ste %f0,156(%r11) + mvc 96(4,%r11),.LC0-.LT0_0(%r13) + st %r1,112(%r11) + mvc 120(4,%r11),.LC0-.LT0_0(%r13) + mvc 128(4,%r11),.LC0-.LT0_0(%r13) + mvc 152(4,%r11),.LC0-.LT0_0(%r13) + l %r2,4(%r9) + basr %r14,%r10 + icm %r4,15,120(%r11) + je .L1 + chi %r4,1 + je .L43 + chi %r4,2 + je .L44 + chi %r4,3 + je .L43 + chi %r4,4 + je .L45 + chi %r4,5 + je .L46 + chi %r4,6 + je .L40 + chi %r4,7 + je .L40 + chi %r4,8 + je .L40 + chi %r4,9 + je .L40 + lr %r1,%r4 + ahi %r1,-10 + cl %r1,.LC3-.LT0_0(%r13) + jh .L22 + l %r2,104(%r11) + l %r3,108(%r11) +.L1: + l %r4,240(%r11) + lm %r6,%r15,208(%r11) + br %r4 +.L22: + chi %r4,12 + je .L47 + chi %r4,13 + je .L48 + chi %r4,14 + je .L40 + chi %r4,15 + jne .L1 + tm 98(%r11),4 + je .L1 + l %r1,124(%r11) + chi %r1,1 + je .L49 + chi %r1,2 + je .L50 + chi %r1,4 + je .L51 + chi %r1,8 + jne .L1 + l %r1,116(%r11) + l %r3,4(%r1) +.L39: + l %r2,0(%r1) + j .L1 +.L51: + l %r1,116(%r11) + j .L39 +.L50: + l %r1,116(%r11) + lh %r4,0(%r1) + lr %r2,%r4 +.L41: + n %r2,.LC2-.LT0_0(%r13) + j .L1 +.L49: + l %r1,116(%r11) + ic %r4,0(%r1) + lr %r2,%r4 +.L42: + n %r2,.LC1-.LT0_0(%r13) + j .L1 +.L40: + l %r2,104(%r11) + j .L1 +.L48: + ld %f0,104(%r11) + j .L1 +.L47: + le %f0,104(%r11) + j .L1 +.L46: + lh %r1,104(%r11) + lr %r2,%r1 + j .L41 +.L45: + lh %r2,104(%r11) + j .L1 +.L43: + ic %r1,104(%r11) + lr %r2,%r1 + j .L42 +.L44: + icm %r1,8,104(%r11) + lr %r2,%r1 + sra %r2,24 + j .L1 +.Lfe1: + .size callback_receiver,.Lfe1-callback_receiver + .align 4 +.globl callback_get_receiver + .type callback_get_receiver,@function +callback_get_receiver: + stm %r11,%r13,44(%r15) + bras %r13,.LTN1_0 +.LT1_0: +.LC4: + .long callback_receiver-.LT1_0 +.LTN1_0: + l %r1,.LC4-.LT1_0(%r13) + lr %r11,%r15 + la %r2,0(%r13,%r1) + lm %r11,%r13,44(%r11) + br %r14 +.Lfe2: + .size callback_get_receiver,.Lfe2-callback_get_receiver +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/callback/vacall_r/vacall-s390x-linux.s b/callback/vacall_r/vacall-s390x-linux.s new file mode 100644 index 0000000..84d0283 --- /dev/null +++ b/callback/vacall_r/vacall-s390x-linux.s @@ -0,0 +1,148 @@ + .file "vacall-s390x.c" +.text + .align 8 + .type callback_receiver, @function +callback_receiver: +.LFB0: + .cfi_startproc + stmg %r10,%r15,80(%r15) + .cfi_offset 10, -80 + .cfi_offset 11, -72 + .cfi_offset 12, -64 + .cfi_offset 13, -56 + .cfi_offset 14, -48 + .cfi_offset 15, -40 + aghi %r15,-320 + .cfi_def_cfa_offset 480 + lgr %r11,%r15 + .cfi_def_cfa_register 11 + lgr %r1,%r0 + lhi %r14,0 + stg %r2,224(%r11) + lg %r10,0(%r1) + st %r14,160(%r11) + la %r14,480(%r11) + stg %r14,184(%r11) + lghi %r14,0 + stg %r3,232(%r11) + lg %r2,8(%r1) + stg %r4,240(%r11) + stg %r5,248(%r11) + stg %r6,256(%r11) + ste %f0,268(%r11) + ste %f2,272(%r11) + ste %f4,276(%r11) + ste %f6,280(%r11) + std %f0,288(%r11) + std %f2,296(%r11) + std %f4,304(%r11) + std %f6,312(%r11) + stg %r14,192(%r11) + st %r14,200(%r11) + st %r14,216(%r11) + st %r14,264(%r11) + la %r3,160(%r11) + basr %r14,%r10 + icm %r1,15,200(%r11) + je .L1 + chi %r1,1 + je .L18 + chi %r1,2 + je .L21 + chi %r1,3 + je .L18 + chi %r1,4 + je .L22 + chi %r1,5 + je .L23 + chi %r1,6 + je .L24 + chi %r1,7 + je .L25 + lr %r10,%r1 + nill %r10,65533 + chi %r10,8 + je .L19 + chi %r10,9 + je .L19 + chi %r1,12 + je .L26 + chi %r1,13 + je .L27 + chi %r1,14 + je .L19 +.L1: + lg %r4,432(%r11) + lmg %r10,%r15,400(%r11) + .cfi_remember_state + .cfi_restore 15 + .cfi_restore 14 + .cfi_restore 13 + .cfi_restore 12 + .cfi_restore 11 + .cfi_restore 10 + .cfi_def_cfa 15, 160 + br %r4 +.L18: + .cfi_restore_state + lg %r4,432(%r11) + llgc %r2,168(%r11) + lmg %r10,%r15,400(%r11) + .cfi_remember_state + .cfi_restore 10 + .cfi_restore 11 + .cfi_restore 12 + .cfi_restore 13 + .cfi_restore 14 + .cfi_restore 15 + .cfi_def_cfa 15, 160 + br %r4 +.L21: + .cfi_restore_state + icmh %r2,8,168(%r11) + srag %r2,%r2,56 + j .L1 +.L19: + lg %r2,168(%r11) + j .L1 +.L22: + lgh %r2,168(%r11) + j .L1 +.L23: + llgh %r2,168(%r11) + j .L1 +.L24: + lgf %r2,168(%r11) + j .L1 +.L26: + le %f0,168(%r11) + j .L1 +.L25: + llgf %r2,168(%r11) + j .L1 +.L27: + ld %f0,168(%r11) + j .L1 + .cfi_endproc +.LFE0: + .size callback_receiver, .-callback_receiver + .align 8 +.globl callback_get_receiver + .type callback_get_receiver, @function +callback_get_receiver: +.LFB1: + .cfi_startproc + stg %r11,88(%r15) + .cfi_offset 11, -72 + lgr %r11,%r15 + .cfi_def_cfa_register 11 + larl %r2,callback_receiver + lg %r11,88(%r11) + .cfi_restore 11 + .cfi_def_cfa_register 15 + br %r14 + .cfi_endproc +.LFE1: + .size callback_get_receiver, .-callback_get_receiver + .ident "GCC: (GNU) 5.4.0" + .section .note.GNU-stack,"",@progbits diff --git a/callback/vacall_r/vacall-s390x-macro.S b/callback/vacall_r/vacall-s390x-macro.S new file mode 100644 index 0000000..1306be6 --- /dev/null +++ b/callback/vacall_r/vacall-s390x-macro.S @@ -0,0 +1,149 @@ + .file "vacall-s390x.c" +.text + .align 8 + .type callback_receiver, @function +callback_receiver: +.LFB0: + .cfi_startproc + stmg %r10,%r15,80(%r15) + .cfi_offset 10, -80 + .cfi_offset 11, -72 + .cfi_offset 12, -64 + .cfi_offset 13, -56 + .cfi_offset 14, -48 + .cfi_offset 15, -40 + aghi %r15,-320 + .cfi_def_cfa_offset 480 + lgr %r11,%r15 + .cfi_def_cfa_register 11 + lgr %r1,%r0 + lhi %r14,0 + stg %r2,224(%r11) + lg %r10,0(%r1) + st %r14,160(%r11) + la %r14,480(%r11) + stg %r14,184(%r11) + lghi %r14,0 + stg %r3,232(%r11) + lg %r2,8(%r1) + stg %r4,240(%r11) + stg %r5,248(%r11) + stg %r6,256(%r11) + ste %f0,268(%r11) + ste %f2,272(%r11) + ste %f4,276(%r11) + ste %f6,280(%r11) + std %f0,288(%r11) + std %f2,296(%r11) + std %f4,304(%r11) + std %f6,312(%r11) + stg %r14,192(%r11) + st %r14,200(%r11) + st %r14,216(%r11) + st %r14,264(%r11) + la %r3,160(%r11) + basr %r14,%r10 + icm %r1,15,200(%r11) + je .L1 + chi %r1,1 + je .L18 + chi %r1,2 + je .L21 + chi %r1,3 + je .L18 + chi %r1,4 + je .L22 + chi %r1,5 + je .L23 + chi %r1,6 + je .L24 + chi %r1,7 + je .L25 + lr %r10,%r1 + nill %r10,65533 + chi %r10,8 + je .L19 + chi %r10,9 + je .L19 + chi %r1,12 + je .L26 + chi %r1,13 + je .L27 + chi %r1,14 + je .L19 +.L1: + lg %r4,432(%r11) + lmg %r10,%r15,400(%r11) + .cfi_remember_state + .cfi_restore 15 + .cfi_restore 14 + .cfi_restore 13 + .cfi_restore 12 + .cfi_restore 11 + .cfi_restore 10 + .cfi_def_cfa 15, 160 + br %r4 +.L18: + .cfi_restore_state + lg %r4,432(%r11) + llgc %r2,168(%r11) + lmg %r10,%r15,400(%r11) + .cfi_remember_state + .cfi_restore 10 + .cfi_restore 11 + .cfi_restore 12 + .cfi_restore 13 + .cfi_restore 14 + .cfi_restore 15 + .cfi_def_cfa 15, 160 + br %r4 +.L21: + .cfi_restore_state + icmh %r2,8,168(%r11) + srag %r2,%r2,56 + j .L1 +.L19: + lg %r2,168(%r11) + j .L1 +.L22: + lgh %r2,168(%r11) + j .L1 +.L23: + llgh %r2,168(%r11) + j .L1 +.L24: + lgf %r2,168(%r11) + j .L1 +.L26: + le %f0,168(%r11) + j .L1 +.L25: + llgf %r2,168(%r11) + j .L1 +.L27: + ld %f0,168(%r11) + j .L1 + .cfi_endproc +.LFE0: + .size callback_receiver, .-callback_receiver + .align 8 +.globl callback_get_receiver + .type callback_get_receiver, @function +callback_get_receiver: +.LFB1: + .cfi_startproc + stg %r11,88(%r15) + .cfi_offset 11, -72 + lgr %r11,%r15 + .cfi_def_cfa_register 11 + larl %r2,callback_receiver + lg %r11,88(%r11) + .cfi_restore 11 + .cfi_def_cfa_register 15 + br %r14 + .cfi_endproc +.LFE1: + .size callback_get_receiver, .-callback_get_receiver +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/callback/vacall_r/vacall-sparc-linux.s b/callback/vacall_r/vacall-sparc-linux.s new file mode 100644 index 0000000..881f004 --- /dev/null +++ b/callback/vacall_r/vacall-sparc-linux.s @@ -0,0 +1,129 @@ + .file "vacall-sparc.c" + .section ".text" + .align 4 + .global callback_receiver + .type callback_receiver,#function + .proc 020 +callback_receiver: + !#PROLOGUE# 0 + save %sp, -144, %sp + ld [%fp+64], %o0 + add %fp, 68, %o1 + st %g0, [%fp-28] + st %o0, [%fp-16] + st %o1, [%fp-32] + ld [%g2+4], %o0 + add %fp, -48, %o1 + ld [%g2], %o2 + st %i2, [%fp+76] + st %i3, [%fp+80] + st %i4, [%fp+84] + st %i5, [%fp+88] + st %i0, [%fp+68] + st %i1, [%fp+72] + st %g0, [%fp-48] + call %o2, 0 + st %g0, [%fp-24] + ld [%fp-24], %o1 + cmp %o1, 0 + be .LL1 + cmp %o1, 1 + be .LL44 + cmp %o1, 2 + be .LL44 + cmp %o1, 3 + be .LL45 + cmp %o1, 4 + be .LL46 + cmp %o1, 5 + be .LL47 + cmp %o1, 6 + be .LL43 + cmp %o1, 7 + be .LL43 + cmp %o1, 8 + be .LL43 + cmp %o1, 9 + be .LL43 + add %o1, -10, %o0 + cmp %o0, 1 + bgu .LL22 + cmp %o1, 12 + ld [%fp-40], %i0 + b .LL1 + ld [%fp-36], %i1 +.LL22: + be .LL48 + cmp %o1, 13 + be .LL49 + cmp %o1, 14 + be .LL43 + cmp %o1, 15 + bne .LL1 + ld [%fp-48], %o0 + andcc %o0, 16, %g0 + be .LL33 + andcc %o0, 2, %g0 + ld [%fp-20], %o0 + ld [%i7+8], %o1 + and %o0, 4095, %o0 + cmp %o0, %o1 + bne .LL1 + ld [%fp-28], %i0 + b .LL1 + add %i7, 4, %i7 +.LL33: + be,a .LL1 + add %i7, 4, %i7 + ld [%fp-20], %o0 + cmp %o0, 1 + be .LL50 + cmp %o0, 2 + be .LL51 + cmp %o0, 4 + bne,a .LL1 + add %i7, 4, %i7 + ld [%fp-28], %o0 + b .LL1 + ld [%o0], %i0 +.LL51: + ld [%fp-28], %o0 + b .LL1 + lduh [%o0], %i0 +.LL50: + ld [%fp-28], %o0 + b .LL1 + ldub [%o0], %i0 +.LL43: + b .LL1 + ld [%fp-40], %i0 +.LL49: + b .LL1 + ldd [%fp-40], %f0 +.LL48: + ld [%fp-48], %o0 + andcc %o0, 32, %g0 + be,a .LL1 + ld [%fp-40], %f0 + ld [%fp-40], %f2 + b .LL1 + fstod %f2, %f0 +.LL47: + b .LL1 + lduh [%fp-40], %i0 +.LL46: + b .LL1 + ldsh [%fp-40], %i0 +.LL45: + b .LL1 + ldub [%fp-40], %i0 +.LL44: + ldsb [%fp-40], %i0 +.LL38: +.LL1: + nop + ret + restore +.LLfe1: + .size callback_receiver,.LLfe1-callback_receiver + .ident "GCC: (GNU) 3.1" diff --git a/callback/vacall_r/vacall-sparc-macro.S b/callback/vacall_r/vacall-sparc-macro.S new file mode 100644 index 0000000..d4acde7 --- /dev/null +++ b/callback/vacall_r/vacall-sparc-macro.S @@ -0,0 +1,131 @@ +#include "asm-sparc.h" + .section ".text" + .align 4 + .global C(callback_receiver) + DECLARE_FUNCTION(callback_receiver) + .proc 020 +FUNBEGIN(callback_receiver) + !$PROLOGUE$ 0 + save %sp, -144, %sp + ld [%fp+64], %o0 + add %fp, 68, %o1 + st %g0, [%fp-28] + st %o0, [%fp-16] + st %o1, [%fp-32] + ld [%g2+4], %o0 + add %fp, -48, %o1 + ld [%g2], %o2 + st %i2, [%fp+76] + st %i3, [%fp+80] + st %i4, [%fp+84] + st %i5, [%fp+88] + st %i0, [%fp+68] + st %i1, [%fp+72] + st %g0, [%fp-48] + call %o2, 0 + st %g0, [%fp-24] + ld [%fp-24], %o1 + cmp %o1, 0 + be L(L1) + cmp %o1, 1 + be L(L44) + cmp %o1, 2 + be L(L44) + cmp %o1, 3 + be L(L45) + cmp %o1, 4 + be L(L46) + cmp %o1, 5 + be L(L47) + cmp %o1, 6 + be L(L43) + cmp %o1, 7 + be L(L43) + cmp %o1, 8 + be L(L43) + cmp %o1, 9 + be L(L43) + add %o1, -10, %o0 + cmp %o0, 1 + bgu L(L22) + cmp %o1, 12 + ld [%fp-40], %i0 + b L(L1) + ld [%fp-36], %i1 +L(L22): + be L(L48) + cmp %o1, 13 + be L(L49) + cmp %o1, 14 + be L(L43) + cmp %o1, 15 + bne L(L1) + ld [%fp-48], %o0 + andcc %o0, 16, %g0 + be L(L33) + andcc %o0, 2, %g0 + ld [%fp-20], %o0 + ld [%i7+8], %o1 + and %o0, 4095, %o0 + cmp %o0, %o1 + bne L(L1) + ld [%fp-28], %i0 + b L(L1) + add %i7, 4, %i7 +L(L33): + be,a L(L1) + add %i7, 4, %i7 + ld [%fp-20], %o0 + cmp %o0, 1 + be L(L50) + cmp %o0, 2 + be L(L51) + cmp %o0, 4 + bne,a L(L1) + add %i7, 4, %i7 + ld [%fp-28], %o0 + b L(L1) + ld [%o0], %i0 +L(L51): + ld [%fp-28], %o0 + b L(L1) + lduh [%o0], %i0 +L(L50): + ld [%fp-28], %o0 + b L(L1) + ldub [%o0], %i0 +L(L43): + b L(L1) + ld [%fp-40], %i0 +L(L49): + b L(L1) + ldd [%fp-40], %f0 +L(L48): + ld [%fp-48], %o0 + andcc %o0, 32, %g0 + be,a L(L1) + ld [%fp-40], %f0 + ld [%fp-40], %f2 + b L(L1) + fstod %f2, %f0 +L(L47): + b L(L1) + lduh [%fp-40], %i0 +L(L46): + b L(L1) + ldsh [%fp-40], %i0 +L(L45): + b L(L1) + ldub [%fp-40], %i0 +L(L44): + ldsb [%fp-40], %i0 +L(L38): +L(L1): + nop + ret + restore +L(Lfe1): + FUNEND(callback_receiver) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/callback/vacall_r/vacall-sparc64-linux.s b/callback/vacall_r/vacall-sparc64-linux.s new file mode 100644 index 0000000..c8723aa --- /dev/null +++ b/callback/vacall_r/vacall-sparc64-linux.s @@ -0,0 +1,319 @@ + .file "vacall-sparc64.c" + .section ".text" + .align 4 + .global callback_receiver + .type callback_receiver, #function + .proc 020 +callback_receiver: + .register %g2, #scratch + .register %g3, #scratch + save %sp, -448, %sp + stx %i0, [%fp+2175] + stx %i1, [%fp+2183] + stx %i2, [%fp+2191] + stx %i3, [%fp+2199] + stx %i4, [%fp+2207] + stx %i5, [%fp+2215] + std %f0, [%fp+1903] + std %f2, [%fp+1911] + std %f4, [%fp+1919] + std %f6, [%fp+1927] + std %f8, [%fp+1935] + std %f10, [%fp+1943] + std %f12, [%fp+1951] + std %f14, [%fp+1959] + std %f16, [%fp+1967] + std %f18, [%fp+1975] + std %f20, [%fp+1983] + std %f22, [%fp+1991] + std %f24, [%fp+1999] + std %f26, [%fp+2007] + std %f28, [%fp+2015] + std %f30, [%fp+2023] + st %f1, [%fp+1835] + st %f3, [%fp+1839] + st %f5, [%fp+1843] + st %f7, [%fp+1847] + st %f9, [%fp+1851] + st %f11, [%fp+1855] + st %f13, [%fp+1859] + st %f15, [%fp+1863] + st %f17, [%fp+1867] + st %f19, [%fp+1871] + st %f21, [%fp+1875] + st %f23, [%fp+1879] + add %fp, 2175, %g2 + stx %g0, [%fp+1807] + st %f25, [%fp+1883] + st %f27, [%fp+1887] + st %f29, [%fp+1891] + st %f31, [%fp+1895] + st %g0, [%fp+1775] + st %g0, [%fp+1815] + st %g0, [%fp+1831] + ldx [%g5+8], %o0 + stx %g2, [%fp+1799] + ldx [%g5], %g3 + call %g3, 0 + add %fp, 1775, %o1 + lduw [%fp+1815], %g1 + cmp %g1, 0 + be,pn %icc, .LL61 + cmp %g1, 1 + be,pn %icc, .LL50 + cmp %g1, 2 + be,pn %icc, .LL50 + cmp %g1, 3 + be,pn %icc, .LL53 + cmp %g1, 4 + be,pn %icc, .LL54 + cmp %g1, 5 + be,pn %icc, .LL55 + cmp %g1, 6 + be,pn %icc, .LL56 + cmp %g1, 7 + be,pn %icc, .LL57 + cmp %g1, 8 + be,pn %icc, .LL51 + cmp %g1, 9 + be,pn %icc, .LL51 + cmp %g1, 10 + be,pn %icc, .LL51 + cmp %g1, 11 + be,pn %icc, .LL51 + cmp %g1, 12 + be,pn %icc, .LL58 + cmp %g1, 13 + be,pn %icc, .LL59 + cmp %g1, 14 + be,pn %icc, .LL51 + cmp %g1, 15 + bne,pt %icc, .LL61 + lduw [%fp+1775], %g1 + andcc %g1, 1024, %g0 + be,pn %xcc, .LL61 + ldx [%fp+1823], %o5 + add %o5, -1, %g1 + cmp %g1, 31 + bgu,pn %xcc, .LL61 + ldx [%fp+1807], %g1 + cmp %o5, 8 + and %g1, 7, %o1 + and %g1, -8, %l1 + bgu,pt %xcc, .LL35 + add %o5, %o1, %g2 + cmp %g2, 8 + bgu,pt %xcc, .LL37 + sllx %o1, 3, %g4 + sllx %g2, 3, %g2 + ldx [%l1], %g3 + sub %g0, %g2, %g2 + mov -1, %g1 + sllx %g1, %g2, %g1 + and %g1, %g3, %g1 + return %i7+8 + sllx %g1, %g4, %o0 +.LL47: + ldx [%l1], %g1 + sllx %g1, %o3, %g1 + ldx [%l1+8], %g4 + ldx [%l1+16], %o5 + sllx %g4, %o3, %o0 + sllx %o5, %o3, %o7 + ldx [%l1+24], %o4 + sllx %g2, 3, %o2 + sllx %o4, %o3, %l0 + ldx [%l1+32], %o1 + sub %g0, %o2, %o2 + mov 64, %g3 + sub %g3, %o3, %g3 + srax %g4, %g3, %g4 + srax %o5, %g3, %o5 + or %g1, %g4, %i0 + srax %o4, %g3, %o4 + mov -1, %g1 + or %o0, %o5, %i1 + sllx %g1, %o2, %g1 + or %o7, %o4, %i2 + and %g1, %o1, %g1 + srax %g1, %g3, %g1 + or %l0, %g1, %i3 +.LL61: + return %i7+8 + nop +.LL50: + ldsb [%fp+1783], %i0 + return %i7+8 + nop +.LL54: + ldsh [%fp+1783], %i0 + return %i7+8 + nop +.LL53: + ldub [%fp+1783], %i0 + return %i7+8 + nop +.LL51: + ldx [%fp+1783], %i0 + return %i7+8 + nop +.LL55: + lduh [%fp+1783], %i0 + return %i7+8 + nop +.LL56: + ldsw [%fp+1783], %i0 + return %i7+8 + nop +.LL57: + lduw [%fp+1783], %i0 + return %i7+8 + nop +.LL58: + ld [%fp+1783], %f0 + return %i7+8 + nop +.LL59: + ldd [%fp+1783], %f0 + return %i7+8 + nop +.LL35: + cmp %o5, 16 + bgu,pt %xcc, .LL39 + cmp %o5, 24 + cmp %g2, 16 + bgu,pt %xcc, .LL41 + sllx %o1, 3, %o4 + sllx %g2, 3, %g3 + ldx [%l1+8], %g2 + sll %o1, 3, %o5 + sllx %o1, 2, %o4 + sub %g0, %g3, %g3 + ldx [%l1], %g4 + mov -1, %g1 + sllx %g4, %o5, %g4 + sllx %g1, %g3, %g1 + and %g1, %g2, %g1 + mov 32, %g2 + sllx %g1, %o5, %i1 + sub %g2, %o4, %g2 + srax %g1, %g2, %g1 + srax %g1, %g2, %g1 + return %i7+8 + or %g4, %g1, %o0 +.LL37: + sllx %g2, 3, %g3 + ldx [%l1+8], %o5 + sub %g0, %g3, %g3 + sub %g0, %g4, %o4 + ldx [%l1], %g2 + mov -1, %g1 + sllx %g2, %g4, %g2 + sllx %g1, %g3, %g1 + and %g1, %o5, %g1 + srax %g1, %o4, %g1 + return %i7+8 + or %g2, %g1, %o0 +.LL39: + bgu,pt %xcc, .LL43 + cmp %g2, 32 + cmp %g2, 24 + bgu,pt %xcc, .LL45 + sllx %o1, 3, %o3 + sllx %o1, 2, %g1 + sll %o1, 3, %o5 + sllx %g2, 3, %o4 + ldx [%l1+8], %g3 + ldx [%l1+16], %o3 + sllx %g3, %o5, %o2 + sub %g0, %o4, %o4 + mov 32, %g4 + ldx [%l1], %g2 + sub %g4, %g1, %g4 + sllx %g2, %o5, %g2 + srax %g3, %g4, %g3 + mov -1, %g1 + srax %g3, %g4, %g3 + sllx %g1, %o4, %g1 + and %g1, %o3, %g1 + sllx %g1, %o5, %i2 + srax %g1, %g4, %g1 + srax %g1, %g4, %g1 + or %o2, %g1, %i1 + return %i7+8 + or %g2, %g3, %o0 +.LL41: + sllx %g2, 3, %o5 + ldx [%l1+8], %g3 + ldx [%l1+16], %o3 + sllx %g3, %o4, %o2 + sub %g0, %o5, %o5 + mov 64, %g4 + ldx [%l1], %g2 + sub %g4, %o4, %g4 + sllx %g2, %o4, %g2 + srax %g3, %g4, %g3 + mov -1, %g1 + sllx %g1, %o5, %g1 + and %g1, %o3, %g1 + srax %g1, %g4, %g1 + or %o2, %g1, %i1 + return %i7+8 + or %g2, %g3, %o0 +.LL45: + ldx [%l1], %g1 + sllx %g1, %o3, %g1 + ldx [%l1+8], %g3 + ldx [%l1+16], %g4 + sllx %g3, %o3, %o2 + sllx %g4, %o3, %o0 + sllx %g2, 3, %o4 + ldx [%l1+24], %o1 + sub %g0, %o4, %o4 + mov 64, %o5 + sub %o5, %o3, %o5 + srax %g3, %o5, %g3 + srax %g4, %o5, %g4 + or %g1, %g3, %i0 + or %o2, %g4, %i1 + mov -1, %g1 + sllx %g1, %o4, %g1 + and %g1, %o1, %g1 + srax %g1, %o5, %g1 + or %o0, %g1, %i2 + return %i7+8 + nop +.LL43: + bgu,pt %xcc, .LL47 + sllx %o1, 3, %o3 + sll %o1, 3, %o4 + ldx [%l1], %g1 + sllx %g1, %o4, %g1 + sllx %o1, 2, %o3 + sllx %g2, 3, %o5 + ldx [%l1+8], %g3 + ldx [%l1+16], %g4 + sllx %g3, %o4, %o1 + sllx %g4, %o4, %o0 + ldx [%l1+24], %o2 + sub %g0, %o5, %o5 + mov 32, %g2 + sub %g2, %o3, %g2 + srax %g3, %g2, %g3 + srax %g4, %g2, %g4 + srax %g3, %g2, %g3 + srax %g4, %g2, %g4 + or %g1, %g3, %i0 + or %o1, %g4, %i1 + mov -1, %g1 + sllx %g1, %o5, %g1 + and %g1, %o2, %g1 + sllx %g1, %o4, %i3 + srax %g1, %g2, %g1 + srax %g1, %g2, %g1 + or %o0, %g1, %i2 + return %i7+8 + nop + .size callback_receiver, .-callback_receiver + .ident "GCC: (GNU) 4.0.2" + .section ".note.GNU-stack" diff --git a/callback/vacall_r/vacall-sparc64-macro.S b/callback/vacall_r/vacall-sparc64-macro.S new file mode 100644 index 0000000..da34bb9 --- /dev/null +++ b/callback/vacall_r/vacall-sparc64-macro.S @@ -0,0 +1,320 @@ +#include "asm-sparc.h" + .section ".text" + .align 4 + .global C(callback_receiver) + DECLARE_FUNCTION(callback_receiver) + .proc 020 +FUNBEGIN(callback_receiver) + .register %g2, $scratch + .register %g3, $scratch + save %sp, -448, %sp + stx %i0, [%fp+2175] + stx %i1, [%fp+2183] + stx %i2, [%fp+2191] + stx %i3, [%fp+2199] + stx %i4, [%fp+2207] + stx %i5, [%fp+2215] + std %f0, [%fp+1903] + std %f2, [%fp+1911] + std %f4, [%fp+1919] + std %f6, [%fp+1927] + std %f8, [%fp+1935] + std %f10, [%fp+1943] + std %f12, [%fp+1951] + std %f14, [%fp+1959] + std %f16, [%fp+1967] + std %f18, [%fp+1975] + std %f20, [%fp+1983] + std %f22, [%fp+1991] + std %f24, [%fp+1999] + std %f26, [%fp+2007] + std %f28, [%fp+2015] + std %f30, [%fp+2023] + st %f1, [%fp+1835] + st %f3, [%fp+1839] + st %f5, [%fp+1843] + st %f7, [%fp+1847] + st %f9, [%fp+1851] + st %f11, [%fp+1855] + st %f13, [%fp+1859] + st %f15, [%fp+1863] + st %f17, [%fp+1867] + st %f19, [%fp+1871] + st %f21, [%fp+1875] + st %f23, [%fp+1879] + add %fp, 2175, %g2 + stx %g0, [%fp+1807] + st %f25, [%fp+1883] + st %f27, [%fp+1887] + st %f29, [%fp+1891] + st %f31, [%fp+1895] + st %g0, [%fp+1775] + st %g0, [%fp+1815] + st %g0, [%fp+1831] + ldx [%g5+8], %o0 + stx %g2, [%fp+1799] + ldx [%g5], %g3 + call %g3, 0 + add %fp, 1775, %o1 + lduw [%fp+1815], %g1 + cmp %g1, 0 + be,pn %icc, L(L61) + cmp %g1, 1 + be,pn %icc, L(L50) + cmp %g1, 2 + be,pn %icc, L(L50) + cmp %g1, 3 + be,pn %icc, L(L53) + cmp %g1, 4 + be,pn %icc, L(L54) + cmp %g1, 5 + be,pn %icc, L(L55) + cmp %g1, 6 + be,pn %icc, L(L56) + cmp %g1, 7 + be,pn %icc, L(L57) + cmp %g1, 8 + be,pn %icc, L(L51) + cmp %g1, 9 + be,pn %icc, L(L51) + cmp %g1, 10 + be,pn %icc, L(L51) + cmp %g1, 11 + be,pn %icc, L(L51) + cmp %g1, 12 + be,pn %icc, L(L58) + cmp %g1, 13 + be,pn %icc, L(L59) + cmp %g1, 14 + be,pn %icc, L(L51) + cmp %g1, 15 + bne,pt %icc, L(L61) + lduw [%fp+1775], %g1 + andcc %g1, 1024, %g0 + be,pn %xcc, L(L61) + ldx [%fp+1823], %o5 + add %o5, -1, %g1 + cmp %g1, 31 + bgu,pn %xcc, L(L61) + ldx [%fp+1807], %g1 + cmp %o5, 8 + and %g1, 7, %o1 + and %g1, -8, %l1 + bgu,pt %xcc, L(L35) + add %o5, %o1, %g2 + cmp %g2, 8 + bgu,pt %xcc, L(L37) + sllx %o1, 3, %g4 + sllx %g2, 3, %g2 + ldx [%l1], %g3 + sub %g0, %g2, %g2 + mov -1, %g1 + sllx %g1, %g2, %g1 + and %g1, %g3, %g1 + return %i7+8 + sllx %g1, %g4, %o0 +L(L47): + ldx [%l1], %g1 + sllx %g1, %o3, %g1 + ldx [%l1+8], %g4 + ldx [%l1+16], %o5 + sllx %g4, %o3, %o0 + sllx %o5, %o3, %o7 + ldx [%l1+24], %o4 + sllx %g2, 3, %o2 + sllx %o4, %o3, %l0 + ldx [%l1+32], %o1 + sub %g0, %o2, %o2 + mov 64, %g3 + sub %g3, %o3, %g3 + srax %g4, %g3, %g4 + srax %o5, %g3, %o5 + or %g1, %g4, %i0 + srax %o4, %g3, %o4 + mov -1, %g1 + or %o0, %o5, %i1 + sllx %g1, %o2, %g1 + or %o7, %o4, %i2 + and %g1, %o1, %g1 + srax %g1, %g3, %g1 + or %l0, %g1, %i3 +L(L61): + return %i7+8 + nop +L(L50): + ldsb [%fp+1783], %i0 + return %i7+8 + nop +L(L54): + ldsh [%fp+1783], %i0 + return %i7+8 + nop +L(L53): + ldub [%fp+1783], %i0 + return %i7+8 + nop +L(L51): + ldx [%fp+1783], %i0 + return %i7+8 + nop +L(L55): + lduh [%fp+1783], %i0 + return %i7+8 + nop +L(L56): + ldsw [%fp+1783], %i0 + return %i7+8 + nop +L(L57): + lduw [%fp+1783], %i0 + return %i7+8 + nop +L(L58): + ld [%fp+1783], %f0 + return %i7+8 + nop +L(L59): + ldd [%fp+1783], %f0 + return %i7+8 + nop +L(L35): + cmp %o5, 16 + bgu,pt %xcc, L(L39) + cmp %o5, 24 + cmp %g2, 16 + bgu,pt %xcc, L(L41) + sllx %o1, 3, %o4 + sllx %g2, 3, %g3 + ldx [%l1+8], %g2 + sll %o1, 3, %o5 + sllx %o1, 2, %o4 + sub %g0, %g3, %g3 + ldx [%l1], %g4 + mov -1, %g1 + sllx %g4, %o5, %g4 + sllx %g1, %g3, %g1 + and %g1, %g2, %g1 + mov 32, %g2 + sllx %g1, %o5, %i1 + sub %g2, %o4, %g2 + srax %g1, %g2, %g1 + srax %g1, %g2, %g1 + return %i7+8 + or %g4, %g1, %o0 +L(L37): + sllx %g2, 3, %g3 + ldx [%l1+8], %o5 + sub %g0, %g3, %g3 + sub %g0, %g4, %o4 + ldx [%l1], %g2 + mov -1, %g1 + sllx %g2, %g4, %g2 + sllx %g1, %g3, %g1 + and %g1, %o5, %g1 + srax %g1, %o4, %g1 + return %i7+8 + or %g2, %g1, %o0 +L(L39): + bgu,pt %xcc, L(L43) + cmp %g2, 32 + cmp %g2, 24 + bgu,pt %xcc, L(L45) + sllx %o1, 3, %o3 + sllx %o1, 2, %g1 + sll %o1, 3, %o5 + sllx %g2, 3, %o4 + ldx [%l1+8], %g3 + ldx [%l1+16], %o3 + sllx %g3, %o5, %o2 + sub %g0, %o4, %o4 + mov 32, %g4 + ldx [%l1], %g2 + sub %g4, %g1, %g4 + sllx %g2, %o5, %g2 + srax %g3, %g4, %g3 + mov -1, %g1 + srax %g3, %g4, %g3 + sllx %g1, %o4, %g1 + and %g1, %o3, %g1 + sllx %g1, %o5, %i2 + srax %g1, %g4, %g1 + srax %g1, %g4, %g1 + or %o2, %g1, %i1 + return %i7+8 + or %g2, %g3, %o0 +L(L41): + sllx %g2, 3, %o5 + ldx [%l1+8], %g3 + ldx [%l1+16], %o3 + sllx %g3, %o4, %o2 + sub %g0, %o5, %o5 + mov 64, %g4 + ldx [%l1], %g2 + sub %g4, %o4, %g4 + sllx %g2, %o4, %g2 + srax %g3, %g4, %g3 + mov -1, %g1 + sllx %g1, %o5, %g1 + and %g1, %o3, %g1 + srax %g1, %g4, %g1 + or %o2, %g1, %i1 + return %i7+8 + or %g2, %g3, %o0 +L(L45): + ldx [%l1], %g1 + sllx %g1, %o3, %g1 + ldx [%l1+8], %g3 + ldx [%l1+16], %g4 + sllx %g3, %o3, %o2 + sllx %g4, %o3, %o0 + sllx %g2, 3, %o4 + ldx [%l1+24], %o1 + sub %g0, %o4, %o4 + mov 64, %o5 + sub %o5, %o3, %o5 + srax %g3, %o5, %g3 + srax %g4, %o5, %g4 + or %g1, %g3, %i0 + or %o2, %g4, %i1 + mov -1, %g1 + sllx %g1, %o4, %g1 + and %g1, %o1, %g1 + srax %g1, %o5, %g1 + or %o0, %g1, %i2 + return %i7+8 + nop +L(L43): + bgu,pt %xcc, L(L47) + sllx %o1, 3, %o3 + sll %o1, 3, %o4 + ldx [%l1], %g1 + sllx %g1, %o4, %g1 + sllx %o1, 2, %o3 + sllx %g2, 3, %o5 + ldx [%l1+8], %g3 + ldx [%l1+16], %g4 + sllx %g3, %o4, %o1 + sllx %g4, %o4, %o0 + ldx [%l1+24], %o2 + sub %g0, %o5, %o5 + mov 32, %g2 + sub %g2, %o3, %g2 + srax %g3, %g2, %g3 + srax %g4, %g2, %g4 + srax %g3, %g2, %g3 + srax %g4, %g2, %g4 + or %g1, %g3, %i0 + or %o1, %g4, %i1 + mov -1, %g1 + sllx %g1, %o5, %g1 + and %g1, %o2, %g1 + sllx %g1, %o4, %i3 + srax %g1, %g2, %g1 + srax %g1, %g2, %g1 + or %o0, %g1, %i2 + return %i7+8 + nop + FUNEND(callback_receiver) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/callback/vacall_r/vacall-structcpy.c b/callback/vacall_r/vacall-structcpy.c new file mode 100644 index 0000000..23d3e77 --- /dev/null +++ b/callback/vacall_r/vacall-structcpy.c @@ -0,0 +1,22 @@ +/* copy structs */ + +/* + * Copyright 2016 Bruno Haible + * + * 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, see . + */ + +#define __structcpy callback_structcpy + +#include "structcpy.c" diff --git a/callback/vacall_r/vacall-x86_64-linux.s b/callback/vacall_r/vacall-x86_64-linux.s new file mode 100644 index 0000000..d2d1b42 --- /dev/null +++ b/callback/vacall_r/vacall-x86_64-linux.s @@ -0,0 +1,300 @@ + .file "vacall-x86_64.c" + .text + .p2align 4,,15 + .type callback_receiver, @function +callback_receiver: +.LFB2: + pushq %rbp +.LCFI0: + movq %rsp, %rbp +.LCFI1: + pushq %r13 +.LCFI2: + pushq %r12 +.LCFI3: + subq $192, %rsp +.LCFI4: + movq %rcx, -48(%rbp) + leaq 16(%rbp), %rcx + movq %rdi, -72(%rbp) + movq %rsi, -64(%rbp) + movsd %xmm0, -144(%rbp) + movq %rcx, -184(%rbp) + movq $0, -176(%rbp) + movsd %xmm1, -136(%rbp) + movq %rdx, -56(%rbp) + movsd %xmm2, -128(%rbp) + leaq -208(%rbp), %rsi + movq %r8, -40(%rbp) + movsd %xmm3, -120(%rbp) + movq %r9, -32(%rbp) + movsd %xmm4, -112(%rbp) + movsd %xmm5, -104(%rbp) + movl $0, -208(%rbp) + movsd %xmm6, -96(%rbp) + movl $0, -168(%rbp) + movsd %xmm7, -88(%rbp) + movl $0, -80(%rbp) + movl $0, -152(%rbp) + movq 8(%r10), %rdi + call *(%r10) + movl -168(%rbp), %ecx + testl %ecx, %ecx + je .L41 + cmpl $1, %ecx + je .L42 + cmpl $2, %ecx + je .L42 + cmpl $3, %ecx + .p2align 4,,5 + je .L48 + cmpl $4, %ecx + .p2align 4,,5 + je .L49 + cmpl $5, %ecx + .p2align 4,,5 + je .L50 + cmpl $6, %ecx + .p2align 4,,5 + je .L51 + cmpl $7, %ecx + .p2align 4,,5 + je .L52 + cmpl $8, %ecx + .p2align 4,,5 + je .L46 + cmpl $9, %ecx + .p2align 4,,5 + je .L46 + cmpl $10, %ecx + .p2align 4,,5 + je .L46 + cmpl $11, %ecx + .p2align 4,,5 + je .L46 + cmpl $12, %ecx + .p2align 4,,5 + je .L53 + cmpl $13, %ecx + .p2align 4,,5 + je .L54 + cmpl $14, %ecx + .p2align 4,,5 + je .L46 + cmpl $15, %ecx + .p2align 4,,5 + jne .L41 + testb $4, -207(%rbp) + .p2align 4,,2 + je .L41 + movq -160(%rbp), %rsi + leaq -1(%rsi), %rcx + cmpq $15, %rcx + ja .L41 + movq -176(%rbp), %rcx + movq %rcx, %r12 + movq %rcx, %r8 + andl $7, %r8d + andq $-8, %r12 + cmpq $8, %rsi + leaq (%rsi,%r8), %r11 + ja .L35 + cmpq $8, %r11 + ja .L37 + leal -1(,%r11,8), %ecx + movl $2, %esi + salq %cl, %rsi + leal 0(,%r8,8), %ecx + decq %rsi + andq (%r12), %rsi + movq %rsi, %rax + sarq %cl, %rax + .p2align 4,,7 +.L41: + addq $192, %rsp + popq %r12 + popq %r13 + leave + ret + .p2align 4,,7 +.L42: + movsbq -200(%rbp),%rax + addq $192, %rsp + popq %r12 + popq %r13 + leave + ret +.L49: + movswq -200(%rbp),%rax + jmp .L41 +.L48: + movzbq -200(%rbp), %rax + jmp .L41 +.L46: + movq -200(%rbp), %rax + jmp .L41 +.L50: + movzwq -200(%rbp), %rax + jmp .L41 +.L51: + movslq -200(%rbp),%rax + jmp .L41 +.L52: + mov -200(%rbp), %eax + jmp .L41 +.L53: + movss -200(%rbp), %xmm0 + jmp .L41 +.L54: + movlpd -200(%rbp), %xmm0 + jmp .L41 +.L35: + cmpq $16, %r11 + ja .L39 + leal -65(,%r11,8), %ecx + movl $2, %esi + leal 0(,%r8,8), %r9d + movl $32, %edi + salq %cl, %rsi + leaq 0(,%r8,4), %rcx + movq (%r12), %r8 + decq %rsi + andq 8(%r12), %rsi + subl %ecx, %edi + movl %r9d, %ecx + sarq %cl, %r8 + movl %edi, %ecx + movq %r8, %rax + movq %rsi, %r11 + movq %rsi, %rdx + salq %cl, %r11 + salq %cl, %r11 + movl %r9d, %ecx + orq %r11, %rax + sarq %cl, %rdx + jmp .L41 +.L37: + movq (%r12), %rdi + leal -65(,%r11,8), %esi + salq $3, %r8 + movl %r8d, %ecx + movl $2, %r11d + sarq %cl, %rdi + movl %esi, %ecx + movl $64, %esi + salq %cl, %r11 + subl %r8d, %esi + movq %rdi, %rax + decq %r11 + andq 8(%r12), %r11 + movl %esi, %ecx + salq %cl, %r11 + orq %r11, %rax + jmp .L41 +.L39: + leaq 0(,%r8,8), %rcx + movq (%r12), %r13 + movq 8(%r12), %r8 + movl $64, %edi + subl %ecx, %edi + movl %ecx, %r9d + sarq %cl, %r13 + movq %r8, %rsi + movl %edi, %ecx + salq %cl, %rsi + movq %r13, %rax + movl %r9d, %ecx + orq %rsi, %rax + leal -129(,%r11,8), %esi + sarq %cl, %r8 + movl $2, %r9d + movq %r8, %rdx + movl %esi, %ecx + salq %cl, %r9 + movl %edi, %ecx + leaq -1(%r9), %rsi + andq 16(%r12), %rsi + salq %cl, %rsi + orq %rsi, %rdx + jmp .L41 +.LFE2: + .size callback_receiver, .-callback_receiver + .p2align 4,,15 +.globl callback_get_receiver + .type callback_get_receiver, @function +callback_get_receiver: +.LFB3: + pushq %rbp +.LCFI5: + leaq callback_receiver(%rip), %rax + movq %rsp, %rbp +.LCFI6: + leave + ret +.LFE3: + .size callback_get_receiver, .-callback_get_receiver + .section .eh_frame,"a",@progbits +.Lframe1: + .long .LECIE1-.LSCIE1 +.LSCIE1: + .long 0x0 + .byte 0x1 + .string "zR" + .uleb128 0x1 + .sleb128 -8 + .byte 0x10 + .uleb128 0x1 + .byte 0x1b + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x90 + .uleb128 0x1 + .align 8 +.LECIE1: +.LSFDE1: + .long .LEFDE1-.LASFDE1 +.LASFDE1: + .long .LASFDE1-.Lframe1 + .long .LFB2-. + .long .LFE2-.LFB2 + .uleb128 0x0 + .byte 0x4 + .long .LCFI0-.LFB2 + .byte 0xe + .uleb128 0x10 + .byte 0x86 + .uleb128 0x2 + .byte 0x4 + .long .LCFI1-.LCFI0 + .byte 0xd + .uleb128 0x6 + .byte 0x4 + .long .LCFI4-.LCFI1 + .byte 0x8c + .uleb128 0x4 + .byte 0x8d + .uleb128 0x3 + .align 8 +.LEFDE1: +.LSFDE3: + .long .LEFDE3-.LASFDE3 +.LASFDE3: + .long .LASFDE3-.Lframe1 + .long .LFB3-. + .long .LFE3-.LFB3 + .uleb128 0x0 + .byte 0x4 + .long .LCFI5-.LFB3 + .byte 0xe + .uleb128 0x10 + .byte 0x86 + .uleb128 0x2 + .byte 0x4 + .long .LCFI6-.LCFI5 + .byte 0xd + .uleb128 0x6 + .align 8 +.LEFDE3: + .ident "GCC: (GNU) 4.0.2" + .section .note.GNU-stack,"",@progbits diff --git a/callback/vacall_r/vacall-x86_64-macro.S b/callback/vacall_r/vacall-x86_64-macro.S new file mode 100644 index 0000000..d114a77 --- /dev/null +++ b/callback/vacall_r/vacall-x86_64-macro.S @@ -0,0 +1,303 @@ +#include "asm-x86_64.h" + TEXT() + P2ALIGN(4,15) + DECLARE_FUNCTION(callback_receiver) +FUNBEGIN(callback_receiver) +L(FB2): + INSN1(push,q ,R(rbp)) +L(CFI0): + INSN2(mov,q ,R(rsp), R(rbp)) +L(CFI1): + INSN1(push,q ,R(r13)) +L(CFI2): + INSN1(push,q ,R(r12)) +L(CFI3): + INSN2(sub,q ,NUM(192), R(rsp)) +L(CFI4): + INSN2(mov,q ,R(rcx),X8 MEM_DISP(rbp,-48)) + INSN2(lea,q ,X8 MEM_DISP(rbp,16), R(rcx)) + INSN2(mov,q ,R(rdi),X8 MEM_DISP(rbp,-72)) + INSN2(mov,q ,R(rsi),X8 MEM_DISP(rbp,-64)) + INSN2S(movs,d ,R(xmm0),X8 MEM_DISP(rbp,-144)) + INSN2(mov,q ,R(rcx),X8 MEM_DISP(rbp,-184)) + INSN2(mov,q ,NUM(0),X8 MEM_DISP(rbp,-176)) + INSN2S(movs,d ,R(xmm1),X8 MEM_DISP(rbp,-136)) + INSN2(mov,q ,R(rdx),X8 MEM_DISP(rbp,-56)) + INSN2S(movs,d ,R(xmm2),X8 MEM_DISP(rbp,-128)) + INSN2(lea,q ,X8 MEM_DISP(rbp,-208), R(rsi)) + INSN2(mov,q ,R(r8),X8 MEM_DISP(rbp,-40)) + INSN2S(movs,d ,R(xmm3),X8 MEM_DISP(rbp,-120)) + INSN2(mov,q ,R(r9),X8 MEM_DISP(rbp,-32)) + INSN2S(movs,d ,R(xmm4),X8 MEM_DISP(rbp,-112)) + INSN2S(movs,d ,R(xmm5),X8 MEM_DISP(rbp,-104)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(rbp,-208)) + INSN2S(movs,d ,R(xmm6),X8 MEM_DISP(rbp,-96)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(rbp,-168)) + INSN2S(movs,d ,R(xmm7),X8 MEM_DISP(rbp,-88)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(rbp,-80)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(rbp,-152)) + INSN2(mov,q ,X8 MEM_DISP(r10,8), R(rdi)) + INSN1(call,_ ,INDIR(X8 MEM(r10))) + INSN2(mov,l ,X4 MEM_DISP(rbp,-168), R(ecx)) + INSN2(test,l ,R(ecx), R(ecx)) + INSN1(je,_ ,L(41)) + INSN2(cmp,l ,NUM(1), R(ecx)) + INSN1(je,_ ,L(42)) + INSN2(cmp,l ,NUM(2), R(ecx)) + INSN1(je,_ ,L(42)) + INSN2(cmp,l ,NUM(3), R(ecx)) + P2ALIGN(4,5) + INSN1(je,_ ,L(48)) + INSN2(cmp,l ,NUM(4), R(ecx)) + P2ALIGN(4,5) + INSN1(je,_ ,L(49)) + INSN2(cmp,l ,NUM(5), R(ecx)) + P2ALIGN(4,5) + INSN1(je,_ ,L(50)) + INSN2(cmp,l ,NUM(6), R(ecx)) + P2ALIGN(4,5) + INSN1(je,_ ,L(51)) + INSN2(cmp,l ,NUM(7), R(ecx)) + P2ALIGN(4,5) + INSN1(je,_ ,L(52)) + INSN2(cmp,l ,NUM(8), R(ecx)) + P2ALIGN(4,5) + INSN1(je,_ ,L(46)) + INSN2(cmp,l ,NUM(9), R(ecx)) + P2ALIGN(4,5) + INSN1(je,_ ,L(46)) + INSN2(cmp,l ,NUM(10), R(ecx)) + P2ALIGN(4,5) + INSN1(je,_ ,L(46)) + INSN2(cmp,l ,NUM(11), R(ecx)) + P2ALIGN(4,5) + INSN1(je,_ ,L(46)) + INSN2(cmp,l ,NUM(12), R(ecx)) + P2ALIGN(4,5) + INSN1(je,_ ,L(53)) + INSN2(cmp,l ,NUM(13), R(ecx)) + P2ALIGN(4,5) + INSN1(je,_ ,L(54)) + INSN2(cmp,l ,NUM(14), R(ecx)) + P2ALIGN(4,5) + INSN1(je,_ ,L(46)) + INSN2(cmp,l ,NUM(15), R(ecx)) + P2ALIGN(4,5) + INSN1(jne,_ ,L(41)) + INSN2(test,b ,NUM(4),X1 MEM_DISP(rbp,-207)) + P2ALIGN(4,2) + INSN1(je,_ ,L(41)) + INSN2(mov,q ,X8 MEM_DISP(rbp,-160), R(rsi)) + INSN2(lea,q ,X8 MEM_DISP(rsi,-1), R(rcx)) + INSN2(cmp,q ,NUM(15), R(rcx)) + INSN1(ja,_ ,L(41)) + INSN2(mov,q ,X8 MEM_DISP(rbp,-176), R(rcx)) + INSN2(mov,q ,R(rcx), R(r12)) + INSN2(mov,q ,R(rcx), R(r8)) + INSN2(and,l ,NUM(7), R(r8d)) + INSN2(and,q ,NUM(-8), R(r12)) + INSN2(cmp,q ,NUM(8), R(rsi)) + INSN2(lea,q ,X8 MEM_INDEX(rsi,r8), R(r11)) + INSN1(ja,_ ,L(35)) + INSN2(cmp,q ,NUM(8), R(r11)) + INSN1(ja,_ ,L(37)) + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(-1,r11,8), R(ecx)) + INSN2(mov,l ,NUM(2), R(esi)) + INSN2(sal,q ,R(cl), R(rsi)) + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(0,r8,8), R(ecx)) + INSN1(dec,q ,R(rsi)) + INSN2(and,q ,X8 MEM(r12), R(rsi)) + INSN2(mov,q ,R(rsi), R(rax)) + INSN2(sar,q ,R(cl), R(rax)) + P2ALIGN(4,7) +L(41): + INSN2(add,q ,NUM(192), R(rsp)) + INSN1(pop,q ,R(r12)) + INSN1(pop,q ,R(r13)) + leave + ret + P2ALIGN(4,7) +L(42): + INSN2MOVXQ(movs,b,X1 MEM_DISP(rbp,-200),R(rax)) + INSN2(add,q ,NUM(192), R(rsp)) + INSN1(pop,q ,R(r12)) + INSN1(pop,q ,R(r13)) + leave + ret +L(49): + INSN2MOVXQ(movs,w,X2 MEM_DISP(rbp,-200),R(rax)) + INSN1(jmp,_ ,L(41)) +L(48): + INSN2MOVXQ(movz,b,X1 MEM_DISP(rbp,-200), R(rax)) + INSN1(jmp,_ ,L(41)) +L(46): + INSN2(mov,q ,X8 MEM_DISP(rbp,-200), R(rax)) + INSN1(jmp,_ ,L(41)) +L(50): + INSN2MOVXQ(movz,w,X2 MEM_DISP(rbp,-200), R(rax)) + INSN1(jmp,_ ,L(41)) +L(51): + INSN2MOVXLQ(movs,l,X4 MEM_DISP(rbp,-200),R(rax)) + INSN1(jmp,_ ,L(41)) +L(52): + INSN2(mov,l ,X4 MEM_DISP(rbp,-200), R(eax)) + INSN1(jmp,_ ,L(41)) +L(53): + INSN2S(movs,s ,X4 MEM_DISP(rbp,-200), R(xmm0)) + INSN1(jmp,_ ,L(41)) +L(54): + INSN2(movlp,d ,X8 MEM_DISP(rbp,-200), R(xmm0)) + INSN1(jmp,_ ,L(41)) +L(35): + INSN2(cmp,q ,NUM(16), R(r11)) + INSN1(ja,_ ,L(39)) + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(-65,r11,8), R(ecx)) + INSN2(mov,l ,NUM(2), R(esi)) + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(0,r8,8), R(r9d)) + INSN2(mov,l ,NUM(32), R(edi)) + INSN2(sal,q ,R(cl), R(rsi)) + INSN2(lea,q ,X8 MEM_DISP_SHINDEX0(0,r8,4), R(rcx)) + INSN2(mov,q ,X8 MEM(r12), R(r8)) + INSN1(dec,q ,R(rsi)) + INSN2(and,q ,X8 MEM_DISP(r12,8), R(rsi)) + INSN2(sub,l ,R(ecx), R(edi)) + INSN2(mov,l ,R(r9d), R(ecx)) + INSN2(sar,q ,R(cl), R(r8)) + INSN2(mov,l ,R(edi), R(ecx)) + INSN2(mov,q ,R(r8), R(rax)) + INSN2(mov,q ,R(rsi), R(r11)) + INSN2(mov,q ,R(rsi), R(rdx)) + INSN2(sal,q ,R(cl), R(r11)) + INSN2(sal,q ,R(cl), R(r11)) + INSN2(mov,l ,R(r9d), R(ecx)) + INSN2(or,q ,R(r11), R(rax)) + INSN2(sar,q ,R(cl), R(rdx)) + INSN1(jmp,_ ,L(41)) +L(37): + INSN2(mov,q ,X8 MEM(r12), R(rdi)) + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(-65,r11,8), R(esi)) + INSN2(sal,q ,NUM(3), R(r8)) + INSN2(mov,l ,R(r8d), R(ecx)) + INSN2(mov,l ,NUM(2), R(r11d)) + INSN2(sar,q ,R(cl), R(rdi)) + INSN2(mov,l ,R(esi), R(ecx)) + INSN2(mov,l ,NUM(64), R(esi)) + INSN2(sal,q ,R(cl), R(r11)) + INSN2(sub,l ,R(r8d), R(esi)) + INSN2(mov,q ,R(rdi), R(rax)) + INSN1(dec,q ,R(r11)) + INSN2(and,q ,X8 MEM_DISP(r12,8), R(r11)) + INSN2(mov,l ,R(esi), R(ecx)) + INSN2(sal,q ,R(cl), R(r11)) + INSN2(or,q ,R(r11), R(rax)) + INSN1(jmp,_ ,L(41)) +L(39): + INSN2(lea,q ,X8 MEM_DISP_SHINDEX0(0,r8,8), R(rcx)) + INSN2(mov,q ,X8 MEM(r12), R(r13)) + INSN2(mov,q ,X8 MEM_DISP(r12,8), R(r8)) + INSN2(mov,l ,NUM(64), R(edi)) + INSN2(sub,l ,R(ecx), R(edi)) + INSN2(mov,l ,R(ecx), R(r9d)) + INSN2(sar,q ,R(cl), R(r13)) + INSN2(mov,q ,R(r8), R(rsi)) + INSN2(mov,l ,R(edi), R(ecx)) + INSN2(sal,q ,R(cl), R(rsi)) + INSN2(mov,q ,R(r13), R(rax)) + INSN2(mov,l ,R(r9d), R(ecx)) + INSN2(or,q ,R(rsi), R(rax)) + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(-129,r11,8), R(esi)) + INSN2(sar,q ,R(cl), R(r8)) + INSN2(mov,l ,NUM(2), R(r9d)) + INSN2(mov,q ,R(r8), R(rdx)) + INSN2(mov,l ,R(esi), R(ecx)) + INSN2(sal,q ,R(cl), R(r9)) + INSN2(mov,l ,R(edi), R(ecx)) + INSN2(lea,q ,X8 MEM_DISP(r9,-1), R(rsi)) + INSN2(and,q ,X8 MEM_DISP(r12,16), R(rsi)) + INSN2(sal,q ,R(cl), R(rsi)) + INSN2(or,q ,R(rsi), R(rdx)) + INSN1(jmp,_ ,L(41)) +L(FE2): + FUNEND(callback_receiver, .-callback_receiver) + P2ALIGN(4,15) +GLOBL(C(callback_get_receiver)) + DECLARE_FUNCTION(callback_get_receiver) +FUNBEGIN(callback_get_receiver) +L(FB3): + INSN1(push,q ,R(rbp)) +L(CFI5): + INSN2(lea,q ,ADDR_PCRELATIVE(C(callback_receiver)), R(rax)) + INSN2(mov,q ,R(rsp), R(rbp)) +L(CFI6): + leave + ret +L(FE3): + FUNEND(callback_get_receiver, .-callback_get_receiver) +#if !(defined __sun || (defined __APPLE__ && defined __MACH__) || (defined _WIN32 || defined __CYGWIN__)) + .section EH_FRAME_SECTION +L(frame1): + .long L(ECIE1)-.LSCIE1 +L(SCIE1): + .long 0x0 + .byte 0x1 + .string "zR" + .uleb128 0x1 + .sleb128 -8 + .byte 0x10 + .uleb128 0x1 + .byte 0x1b + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x90 + .uleb128 0x1 + .align 8 +L(ECIE1): +L(SFDE1): + .long L(EFDE1)-.LASFDE1 +L(ASFDE1): + .long L(ASFDE1)-.Lframe1 + .long L(FB2)-. + .long L(FE2)-.LFB2 + .uleb128 0x0 + .byte 0x4 + .long L(CFI0)-.LFB2 + .byte 0xe + .uleb128 0x10 + .byte 0x86 + .uleb128 0x2 + .byte 0x4 + .long L(CFI1)-.LCFI0 + .byte 0xd + .uleb128 0x6 + .byte 0x4 + .long L(CFI4)-.LCFI1 + .byte 0x8c + .uleb128 0x4 + .byte 0x8d + .uleb128 0x3 + .align 8 +L(EFDE1): +L(SFDE3): + .long L(EFDE3)-.LASFDE3 +L(ASFDE3): + .long L(ASFDE3)-.Lframe1 + .long L(FB3)-. + .long L(FE3)-.LFB3 + .uleb128 0x0 + .byte 0x4 + .long L(CFI5)-.LFB3 + .byte 0xe + .uleb128 0x10 + .byte 0x86 + .uleb128 0x2 + .byte 0x4 + .long L(CFI6)-.LCFI5 + .byte 0xd + .uleb128 0x6 + .align 8 +L(EFDE3): +#endif +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/callback/vacall_r/vacall-x86_64-windows-macro.S b/callback/vacall_r/vacall-x86_64-windows-macro.S new file mode 100644 index 0000000..5a4ad0b --- /dev/null +++ b/callback/vacall_r/vacall-x86_64-windows-macro.S @@ -0,0 +1,390 @@ +#include "asm-x86_64.h" + TEXT() + P2ALIGN(4,15) + DECLARE_FUNCTION(callback_receiver) +FUNBEGIN(callback_receiver) +L(FB0): + INSN1(push,q ,R(rbp)) +L(CFI0): + INSN2(mov,q ,R(rsp), R(rbp)) +L(CFI1): + INSN2(sub,q ,NUM(144), R(rsp)) + INSN2(mov,q ,R(rcx),X8 MEM_DISP(rbp,16)) + INSN2(lea,q ,X8 MEM_DISP(rbp,16), R(rcx)) + INSN2(mov,q ,R(rdx),X8 MEM_DISP(rbp,24)) + INSN2(mov,q ,R(r8),X8 MEM_DISP(rbp,32)) + INSN2(lea,q ,X8 MEM_DISP(rbp,-112), R(rdx)) + INSN2(mov,q ,R(r9),X8 MEM_DISP(rbp,40)) + INSN2(mov,q ,R(rcx),X8 MEM_DISP(rbp,-88)) + INSN2S(movs,s ,R(xmm0),X4 MEM_DISP(rbp,-52)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(rbp,-112)) + INSN2S(movs,s ,R(xmm1),X4 MEM_DISP(rbp,-48)) + INSN2(mov,q ,NUM(0),X8 MEM_DISP(rbp,-80)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(rbp,-72)) + INSN2S(movs,s ,R(xmm2),X4 MEM_DISP(rbp,-44)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(rbp,-56)) + INSN2S(movs,s ,R(xmm3),X4 MEM_DISP(rbp,-40)) + INSN2(mov,q ,X8 MEM_DISP(r10,8), R(rcx)) + INSN2S(movs,d ,R(xmm0),X8 MEM_DISP(rbp,-32)) + INSN2S(movs,d ,R(xmm1),X8 MEM_DISP(rbp,-24)) + INSN2S(movs,d ,R(xmm2),X8 MEM_DISP(rbp,-16)) + INSN2S(movs,d ,R(xmm3),X8 MEM_DISP(rbp,-8)) + INSN1(call,_ ,INDIR(X8 MEM(r10))) + INSN2(mov,l ,X4 MEM_DISP(rbp,-72), R(edx)) + INSN2(test,l ,R(edx), R(edx)) + INSN1(je,_ ,L(1)) + INSN2(cmp,l ,NUM(1), R(edx)) + INSN1(je,_ ,L(34)) + INSN2(cmp,l ,NUM(2), R(edx)) + INSN1(je,_ ,L(34)) + INSN2(cmp,l ,NUM(3), R(edx)) + INSN1(je,_ ,L(37)) + INSN2(cmp,l ,NUM(4), R(edx)) + INSN1(je,_ ,L(38)) + INSN2(cmp,l ,NUM(5), R(edx)) + INSN1(je,_ ,L(39)) + INSN2(cmp,l ,NUM(6), R(edx)) + INSN1(je,_ ,L(40)) + INSN2(cmp,l ,NUM(7), R(edx)) + INSN1(je,_ ,L(41)) + INSN2(cmp,l ,NUM(8), R(edx)) + INSN1(je,_ ,L(35)) + INSN2(cmp,l ,NUM(9), R(edx)) + INSN1(je,_ ,L(35)) + INSN2(cmp,l ,NUM(10), R(edx)) + INSN1(je,_ ,L(35)) + INSN2(cmp,l ,NUM(11), R(edx)) + INSN1(je,_ ,L(35)) + INSN2(cmp,l ,NUM(12), R(edx)) + INSN1(je,_ ,L(42)) + INSN2(cmp,l ,NUM(13), R(edx)) + INSN1(je,_ ,L(43)) + INSN2(cmp,l ,NUM(14), R(edx)) + INSN1(je,_ ,L(35)) + INSN2(cmp,l ,NUM(15), R(edx)) + INSN1(jne,_ ,L(1)) + INSN2(test,b ,NUM(4),X1 MEM_DISP(rbp,-111)) + INSN1(je,_ ,L(17)) + INSN2(mov,q ,X8 MEM_DISP(rbp,-64), R(rdx)) + INSN2(lea,q ,X8 MEM_DISP(rdx,-4), R(rcx)) + INSN2(test,q ,NUM(-5), R(rcx)) + INSN1(je,_ ,L(20)) + INSN2(lea,q ,X8 MEM_DISP(rdx,-1), R(rcx)) + INSN2(cmp,q ,NUM(1), R(rcx)) + INSN1(ja,_ ,L(1)) +L(20): + INSN2(mov,q ,X8 MEM_DISP(rbp,-80), R(r8)) + INSN2(mov,q ,R(r8), R(r9)) + INSN2(and,l ,NUM(7), R(r8d)) + INSN2(add,q ,R(r8), R(rdx)) + INSN2(and,q ,NUM(-8), R(r9)) + INSN2(cmp,q ,NUM(8), R(rdx)) + INSN1(ja,_ ,L(19)) + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(-1,rdx,8), R(ecx)) + INSN2(mov,l ,NUM(2), R(edx)) + INSN2(sal,q ,R(cl), R(rdx)) + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(0,r8,8), R(ecx)) + INSN2(sub,q ,NUM(1), R(rdx)) + INSN2(and,q ,X8 MEM(r9), R(rdx)) + INSN2(sar,q ,R(cl), R(rdx)) + INSN2(mov,q ,R(rdx), R(rax)) +L(1): + leave +L(CFI2): + ret + P2ALIGN(4,10) + P2ALIGN(3,7) +L(34): +L(CFI3): + INSN2MOVXQ(movs,b,X1 MEM_DISP(rbp,-104), R(rax)) + leave +L(CFI4): + ret + P2ALIGN(4,10) + P2ALIGN(3,7) +L(35): +L(CFI5): + INSN2(mov,q ,X8 MEM_DISP(rbp,-104), R(rax)) + leave +L(CFI6): + ret + P2ALIGN(4,10) + P2ALIGN(3,7) +L(37): +L(CFI7): + INSN2MOVXL(movz,b,X1 MEM_DISP(rbp,-104), R(eax)) + leave +L(CFI8): + ret + P2ALIGN(4,10) + P2ALIGN(3,7) +L(38): +L(CFI9): + INSN2MOVXQ(movs,w,X2 MEM_DISP(rbp,-104), R(rax)) + leave +L(CFI10): + ret + P2ALIGN(4,10) + P2ALIGN(3,7) +L(39): +L(CFI11): + INSN2MOVXL(movz,w,X2 MEM_DISP(rbp,-104), R(eax)) + leave +L(CFI12): + ret + P2ALIGN(4,10) + P2ALIGN(3,7) +L(40): +L(CFI13): + INSN2MOVXLQ(movs,l,X4 MEM_DISP(rbp,-104), R(rax)) + leave +L(CFI14): + ret + P2ALIGN(4,10) + P2ALIGN(3,7) +L(42): +L(CFI15): + INSN2S(movs,s ,X4 MEM_DISP(rbp,-104), R(xmm0)) + leave +L(CFI16): + ret + P2ALIGN(4,10) + P2ALIGN(3,7) +L(41): +L(CFI17): + INSN2(mov,l ,X4 MEM_DISP(rbp,-104), R(eax)) + leave +L(CFI18): + ret +L(43): +L(CFI19): + INSN2S(movs,d ,X8 MEM_DISP(rbp,-104), R(xmm0)) + leave +L(CFI20): + ret +L(17): +L(CFI21): + INSN2(mov,q ,X8 MEM_DISP(rbp,-80), R(rax)) + leave +L(CFI22): + ret +L(19): +L(CFI23): + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(-65,rdx,8), R(ecx)) + INSN2(mov,l ,NUM(2), R(edx)) + INSN2(sal,q ,R(cl), R(rdx)) + INSN2(mov,l ,R(r8d), R(ecx)) + INSN2(sub,q ,NUM(1), R(rdx)) + INSN2(and,q ,X8 MEM_DISP(r9,8), R(rdx)) + INSN1(neg,l ,R(ecx)) + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(64,rcx,8), R(ecx)) + INSN2(sal,q ,R(cl), R(rdx)) + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(0,r8,8), R(ecx)) + INSN2(mov,q ,X8 MEM(r9), R(r8)) + leave +L(CFI24): + INSN2(sar,q ,R(cl), R(r8)) + INSN2(or,q ,R(r8), R(rdx)) + INSN2(mov,q ,R(rdx), R(rax)) + ret +L(FE0): + FUNEND(callback_receiver, .-callback_receiver) + P2ALIGN(4,15) + GLOBL(C(callback_get_receiver)) + DECLARE_FUNCTION(callback_get_receiver) +FUNBEGIN(callback_get_receiver) +L(FB1): + INSN1(push,q ,R(rbp)) +L(CFI25): + INSN2(lea,q ,ADDR_PCRELATIVE(C(callback_receiver)), R(rax)) + INSN2(mov,q ,R(rsp), R(rbp)) +L(CFI26): + INSN1(pop,q ,R(rbp)) +L(CFI27): + ret +L(FE1): + FUNEND(callback_get_receiver, .-callback_get_receiver) +#if !(defined __sun || (defined __APPLE__ && defined __MACH__) || (defined _WIN32 || defined __CYGWIN__)) + .section EH_FRAME_SECTION +L(frame1): + .long L(ECIE1)-.LSCIE1 +L(SCIE1): + .long 0 + .byte 0x3 + .string "zR" + .uleb128 0x1 + .sleb128 -8 + .uleb128 0x10 + .uleb128 0x1 + .byte 0x1b + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x90 + .uleb128 0x1 + .align 8 +L(ECIE1): +L(SFDE1): + .long L(EFDE1)-.LASFDE1 +L(ASFDE1): + .long L(ASFDE1)-.Lframe1 + .long L(FB0)-. + .long L(FE0)-.LFB0 + .uleb128 0 + .byte 0x4 + .long L(CFI0)-.LFB0 + .byte 0xe + .uleb128 0x10 + .byte 0x86 + .uleb128 0x2 + .byte 0x4 + .long L(CFI1)-.LCFI0 + .byte 0xd + .uleb128 0x6 + .byte 0x4 + .long L(CFI2)-.LCFI1 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long L(CFI3)-.LCFI2 + .byte 0xb + .byte 0x4 + .long L(CFI4)-.LCFI3 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long L(CFI5)-.LCFI4 + .byte 0xb + .byte 0x4 + .long L(CFI6)-.LCFI5 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long L(CFI7)-.LCFI6 + .byte 0xb + .byte 0x4 + .long L(CFI8)-.LCFI7 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long L(CFI9)-.LCFI8 + .byte 0xb + .byte 0x4 + .long L(CFI10)-.LCFI9 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long L(CFI11)-.LCFI10 + .byte 0xb + .byte 0x4 + .long L(CFI12)-.LCFI11 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long L(CFI13)-.LCFI12 + .byte 0xb + .byte 0x4 + .long L(CFI14)-.LCFI13 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long L(CFI15)-.LCFI14 + .byte 0xb + .byte 0x4 + .long L(CFI16)-.LCFI15 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long L(CFI17)-.LCFI16 + .byte 0xb + .byte 0x4 + .long L(CFI18)-.LCFI17 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long L(CFI19)-.LCFI18 + .byte 0xb + .byte 0x4 + .long L(CFI20)-.LCFI19 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long L(CFI21)-.LCFI20 + .byte 0xb + .byte 0x4 + .long L(CFI22)-.LCFI21 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long L(CFI23)-.LCFI22 + .byte 0xb + .byte 0x4 + .long L(CFI24)-.LCFI23 + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .align 8 +L(EFDE1): +L(SFDE3): + .long L(EFDE3)-.LASFDE3 +L(ASFDE3): + .long L(ASFDE3)-.Lframe1 + .long L(FB1)-. + .long L(FE1)-.LFB1 + .uleb128 0 + .byte 0x4 + .long L(CFI25)-.LFB1 + .byte 0xe + .uleb128 0x10 + .byte 0x86 + .uleb128 0x2 + .byte 0x4 + .long L(CFI26)-.LCFI25 + .byte 0xd + .uleb128 0x6 + .byte 0x4 + .long L(CFI27)-.LCFI26 + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .align 8 +L(EFDE3): +#endif +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/callback/vacall_r/vacall-x86_64-windows.s b/callback/vacall_r/vacall-x86_64-windows.s new file mode 100644 index 0000000..4665ea9 --- /dev/null +++ b/callback/vacall_r/vacall-x86_64-windows.s @@ -0,0 +1,387 @@ + .file "vacall-x86_64-windows.c" + .text + .p2align 4,,15 + .type callback_receiver, @function +callback_receiver: +.LFB0: + pushq %rbp +.LCFI0: + movq %rsp, %rbp +.LCFI1: + subq $144, %rsp + movq %rcx, 16(%rbp) + leaq 16(%rbp), %rcx + movq %rdx, 24(%rbp) + movq %r8, 32(%rbp) + leaq -112(%rbp), %rdx + movq %r9, 40(%rbp) + movq %rcx, -88(%rbp) + movss %xmm0, -52(%rbp) + movl $0, -112(%rbp) + movss %xmm1, -48(%rbp) + movq $0, -80(%rbp) + movl $0, -72(%rbp) + movss %xmm2, -44(%rbp) + movl $0, -56(%rbp) + movss %xmm3, -40(%rbp) + movq 8(%r10), %rcx + movsd %xmm0, -32(%rbp) + movsd %xmm1, -24(%rbp) + movsd %xmm2, -16(%rbp) + movsd %xmm3, -8(%rbp) + call *(%r10) + movl -72(%rbp), %edx + testl %edx, %edx + je .L1 + cmpl $1, %edx + je .L34 + cmpl $2, %edx + je .L34 + cmpl $3, %edx + je .L37 + cmpl $4, %edx + je .L38 + cmpl $5, %edx + je .L39 + cmpl $6, %edx + je .L40 + cmpl $7, %edx + je .L41 + cmpl $8, %edx + je .L35 + cmpl $9, %edx + je .L35 + cmpl $10, %edx + je .L35 + cmpl $11, %edx + je .L35 + cmpl $12, %edx + je .L42 + cmpl $13, %edx + je .L43 + cmpl $14, %edx + je .L35 + cmpl $15, %edx + jne .L1 + testb $4, -111(%rbp) + je .L17 + movq -64(%rbp), %rdx + leaq -4(%rdx), %rcx + testq $-5, %rcx + je .L20 + leaq -1(%rdx), %rcx + cmpq $1, %rcx + ja .L1 +.L20: + movq -80(%rbp), %r8 + movq %r8, %r9 + andl $7, %r8d + addq %r8, %rdx + andq $-8, %r9 + cmpq $8, %rdx + ja .L19 + leal -1(,%rdx,8), %ecx + movl $2, %edx + salq %cl, %rdx + leal 0(,%r8,8), %ecx + subq $1, %rdx + andq (%r9), %rdx + sarq %cl, %rdx + movq %rdx, %rax +.L1: + leave +.LCFI2: + ret + .p2align 4,,10 + .p2align 3 +.L34: +.LCFI3: + movsbq -104(%rbp), %rax + leave +.LCFI4: + ret + .p2align 4,,10 + .p2align 3 +.L35: +.LCFI5: + movq -104(%rbp), %rax + leave +.LCFI6: + ret + .p2align 4,,10 + .p2align 3 +.L37: +.LCFI7: + movzbl -104(%rbp), %eax + leave +.LCFI8: + ret + .p2align 4,,10 + .p2align 3 +.L38: +.LCFI9: + movswq -104(%rbp), %rax + leave +.LCFI10: + ret + .p2align 4,,10 + .p2align 3 +.L39: +.LCFI11: + movzwl -104(%rbp), %eax + leave +.LCFI12: + ret + .p2align 4,,10 + .p2align 3 +.L40: +.LCFI13: + movslq -104(%rbp), %rax + leave +.LCFI14: + ret + .p2align 4,,10 + .p2align 3 +.L42: +.LCFI15: + movss -104(%rbp), %xmm0 + leave +.LCFI16: + ret + .p2align 4,,10 + .p2align 3 +.L41: +.LCFI17: + movl -104(%rbp), %eax + leave +.LCFI18: + ret +.L43: +.LCFI19: + movsd -104(%rbp), %xmm0 + leave +.LCFI20: + ret +.L17: +.LCFI21: + movq -80(%rbp), %rax + leave +.LCFI22: + ret +.L19: +.LCFI23: + leal -65(,%rdx,8), %ecx + movl $2, %edx + salq %cl, %rdx + movl %r8d, %ecx + subq $1, %rdx + andq 8(%r9), %rdx + negl %ecx + leal 64(,%rcx,8), %ecx + salq %cl, %rdx + leal 0(,%r8,8), %ecx + movq (%r9), %r8 + leave +.LCFI24: + sarq %cl, %r8 + orq %r8, %rdx + movq %rdx, %rax + ret +.LFE0: + .size callback_receiver, .-callback_receiver + .p2align 4,,15 + .globl callback_get_receiver + .type callback_get_receiver, @function +callback_get_receiver: +.LFB1: + pushq %rbp +.LCFI25: + leaq callback_receiver(%rip), %rax + movq %rsp, %rbp +.LCFI26: + popq %rbp +.LCFI27: + ret +.LFE1: + .size callback_get_receiver, .-callback_get_receiver + .section .eh_frame,"a",@progbits +.Lframe1: + .long .LECIE1-.LSCIE1 +.LSCIE1: + .long 0 + .byte 0x3 + .string "zR" + .uleb128 0x1 + .sleb128 -8 + .uleb128 0x10 + .uleb128 0x1 + .byte 0x1b + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x90 + .uleb128 0x1 + .align 8 +.LECIE1: +.LSFDE1: + .long .LEFDE1-.LASFDE1 +.LASFDE1: + .long .LASFDE1-.Lframe1 + .long .LFB0-. + .long .LFE0-.LFB0 + .uleb128 0 + .byte 0x4 + .long .LCFI0-.LFB0 + .byte 0xe + .uleb128 0x10 + .byte 0x86 + .uleb128 0x2 + .byte 0x4 + .long .LCFI1-.LCFI0 + .byte 0xd + .uleb128 0x6 + .byte 0x4 + .long .LCFI2-.LCFI1 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI3-.LCFI2 + .byte 0xb + .byte 0x4 + .long .LCFI4-.LCFI3 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI5-.LCFI4 + .byte 0xb + .byte 0x4 + .long .LCFI6-.LCFI5 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI7-.LCFI6 + .byte 0xb + .byte 0x4 + .long .LCFI8-.LCFI7 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI9-.LCFI8 + .byte 0xb + .byte 0x4 + .long .LCFI10-.LCFI9 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI11-.LCFI10 + .byte 0xb + .byte 0x4 + .long .LCFI12-.LCFI11 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI13-.LCFI12 + .byte 0xb + .byte 0x4 + .long .LCFI14-.LCFI13 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI15-.LCFI14 + .byte 0xb + .byte 0x4 + .long .LCFI16-.LCFI15 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI17-.LCFI16 + .byte 0xb + .byte 0x4 + .long .LCFI18-.LCFI17 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI19-.LCFI18 + .byte 0xb + .byte 0x4 + .long .LCFI20-.LCFI19 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI21-.LCFI20 + .byte 0xb + .byte 0x4 + .long .LCFI22-.LCFI21 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI23-.LCFI22 + .byte 0xb + .byte 0x4 + .long .LCFI24-.LCFI23 + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .align 8 +.LEFDE1: +.LSFDE3: + .long .LEFDE3-.LASFDE3 +.LASFDE3: + .long .LASFDE3-.Lframe1 + .long .LFB1-. + .long .LFE1-.LFB1 + .uleb128 0 + .byte 0x4 + .long .LCFI25-.LFB1 + .byte 0xe + .uleb128 0x10 + .byte 0x86 + .uleb128 0x2 + .byte 0x4 + .long .LCFI26-.LCFI25 + .byte 0xd + .uleb128 0x6 + .byte 0x4 + .long .LCFI27-.LCFI26 + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .align 8 +.LEFDE3: + .ident "GCC: (GNU) 5.4.0" + .section .note.GNU-stack,"",@progbits diff --git a/callback/vacall_r/vacall-x86_64-x32-linux.s b/callback/vacall_r/vacall-x86_64-x32-linux.s new file mode 100644 index 0000000..ae2bf5b --- /dev/null +++ b/callback/vacall_r/vacall-x86_64-x32-linux.s @@ -0,0 +1,338 @@ + .file "vacall-x86_64.c" + .section .text.unlikely,"ax",@progbits +.LCOLDB0: + .text +.LHOTB0: + .p2align 4,,15 + .type callback_receiver, @function +callback_receiver: +.LFB0: + pushq %rbp +.LCFI0: + movl %esp, %ebp +.LCFI1: + pushq %r14 + pushq %r12 + subl $176, %esp +.LCFI2: + movq %rdi, -72(%ebp) + leal 16(%rbp), %edi + movq %rcx, -48(%ebp) + movl (%r10d), %ecx + movsd %xmm0, -144(%ebp) + movl %edi, -168(%ebp) + movl 4(%r10d), %edi + movsd %xmm1, -136(%ebp) + movq %rsi, -64(%ebp) + movsd %xmm2, -128(%ebp) + leal -192(%rbp), %esi + movq %rdx, -56(%ebp) + movsd %xmm3, -120(%ebp) + movq %r8, -40(%ebp) + movsd %xmm4, -112(%ebp) + movq %r9, -32(%ebp) + movsd %xmm5, -104(%ebp) + movsd %xmm6, -96(%ebp) + movl $0, -192(%ebp) + movsd %xmm7, -88(%ebp) + movl $0, -164(%ebp) + movl $0, -160(%ebp) + movl $0, -80(%ebp) + movl $0, -152(%ebp) + call *%rcx + movl -160(%ebp), %ecx + testl %ecx, %ecx + je .L1 + cmpl $1, %ecx + je .L27 + cmpl $2, %ecx + je .L27 + cmpl $3, %ecx + je .L33 + cmpl $4, %ecx + je .L34 + cmpl $5, %ecx + je .L35 + cmpl $6, %ecx + je .L28 + cmpl $7, %ecx + je .L30 + cmpl $8, %ecx + je .L28 + cmpl $9, %ecx + je .L30 + cmpl $10, %ecx + je .L31 + cmpl $11, %ecx + je .L31 + cmpl $12, %ecx + je .L36 + cmpl $13, %ecx + je .L37 + cmpl $14, %ecx + je .L30 + cmpl $15, %ecx + jne .L1 + testb $4, -191(%ebp) + je .L1 + movl -156(%ebp), %ecx + leal -1(%rcx), %esi + cmpl $15, %esi + ja .L1 + movl -164(%ebp), %esi + movl %esi, %edi + andl $7, %esi + andl $-8, %edi + cmpl $8, %ecx + leal (%rcx,%rsi), %r11d + ja .L17 + cmpl $8, %r11d + ja .L18 + leal -1(,%r11,8), %ecx + movl $2, %r8d + salq %cl, %r8 + movq %r8, %rcx + subq $1, %rcx + andq (%edi), %rcx + movq %rcx, %rdi + leal 0(,%rsi,8), %ecx + sarq %cl, %rdi + movq %rdi, %rax +.L1: + addl $176, %esp + popq %r12 + popq %r14 + popq %rbp +.LCFI3: + ret + .p2align 4,,10 + .p2align 3 +.L27: +.LCFI4: + movsbq -184(%ebp), %rax + addl $176, %esp + popq %r12 + popq %r14 + popq %rbp +.LCFI5: + ret + .p2align 4,,10 + .p2align 3 +.L28: +.LCFI6: + movslq -184(%ebp), %rax + jmp .L1 + .p2align 4,,10 + .p2align 3 +.L33: + movzbl -184(%ebp), %eax + jmp .L1 + .p2align 4,,10 + .p2align 3 +.L34: + movswq -184(%ebp), %rax + jmp .L1 + .p2align 4,,10 + .p2align 3 +.L30: + movl -184(%ebp), %eax + jmp .L1 + .p2align 4,,10 + .p2align 3 +.L35: + movzwl -184(%ebp), %eax + jmp .L1 + .p2align 4,,10 + .p2align 3 +.L36: + movss -184(%ebp), %xmm0 + jmp .L1 + .p2align 4,,10 + .p2align 3 +.L31: + movq -184(%ebp), %rax + jmp .L1 +.L37: + movsd -184(%ebp), %xmm0 + jmp .L1 +.L17: + cmpl $16, %r11d + leal 0(,%rsi,8), %r9d + jbe .L38 + negl %esi + movq 8(%edi), %r8 + movl %r9d, %ecx + leal 64(,%rsi,8), %r12d + movq (%edi), %rsi + movq %r8, %r14 + sarq %cl, %rsi + movl %r12d, %ecx + salq %cl, %r14 + leal -129(,%r11,8), %ecx + orq %r14, %rsi + movq %rsi, %rax + movl $2, %esi + salq %cl, %rsi + movl %r12d, %ecx + subq $1, %rsi + andq 16(%edi), %rsi + salq %cl, %rsi + movl %r9d, %ecx + sarq %cl, %r8 + orq %r8, %rsi + movq %rsi, %rdx + jmp .L1 +.L18: + leal -65(,%r11,8), %ecx + movl $2, %r8d + salq %cl, %r8 + movl %esi, %ecx + subq $1, %r8 + andq 8(%edi), %r8 + negl %ecx + leal 64(,%rcx,8), %ecx + movq (%edi), %rdi + salq %cl, %r8 + leal 0(,%rsi,8), %ecx + sarq %cl, %rdi + orq %rdi, %r8 + movq %r8, %rax + jmp .L1 +.L38: + leal -65(,%r11,8), %ecx + movl $2, %r8d + movq (%edi), %r11 + imull $-4, %esi, %esi + salq %cl, %r8 + movl %r9d, %ecx + subq $1, %r8 + andq 8(%edi), %r8 + sarq %cl, %r11 + addl $32, %esi + movl %esi, %ecx + movq %r8, %rdi + salq %cl, %rdi + salq %cl, %rdi + movl %r9d, %ecx + orq %rdi, %r11 + sarq %cl, %r8 + movq %r11, %rax + movq %r8, %rdx + jmp .L1 +.LFE0: + .size callback_receiver, .-callback_receiver + .section .text.unlikely +.LCOLDE0: + .text +.LHOTE0: + .section .text.unlikely +.LCOLDB1: + .text +.LHOTB1: + .p2align 4,,15 + .globl callback_get_receiver + .type callback_get_receiver, @function +callback_get_receiver: +.LFB1: + pushq %rbp +.LCFI7: + leal callback_receiver(%rip), %eax + movl %esp, %ebp +.LCFI8: + popq %rbp +.LCFI9: + ret +.LFE1: + .size callback_get_receiver, .-callback_get_receiver + .section .text.unlikely +.LCOLDE1: + .text +.LHOTE1: + .section .eh_frame,"a",@progbits +.Lframe1: + .long .LECIE1-.LSCIE1 +.LSCIE1: + .long 0 + .byte 0x3 + .string "zR" + .uleb128 0x1 + .sleb128 -8 + .uleb128 0x10 + .uleb128 0x1 + .byte 0x1b + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x90 + .uleb128 0x1 + .align 4 +.LECIE1: +.LSFDE1: + .long .LEFDE1-.LASFDE1 +.LASFDE1: + .long .LASFDE1-.Lframe1 + .long .LFB0-. + .long .LFE0-.LFB0 + .uleb128 0 + .byte 0x4 + .long .LCFI0-.LFB0 + .byte 0xe + .uleb128 0x10 + .byte 0x86 + .uleb128 0x2 + .byte 0x4 + .long .LCFI1-.LCFI0 + .byte 0xd + .uleb128 0x6 + .byte 0x4 + .long .LCFI2-.LCFI1 + .byte 0x8e + .uleb128 0x3 + .byte 0x8c + .uleb128 0x4 + .byte 0x4 + .long .LCFI3-.LCFI2 + .byte 0xa + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI4-.LCFI3 + .byte 0xb + .byte 0x4 + .long .LCFI5-.LCFI4 + .byte 0xa + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI6-.LCFI5 + .byte 0xb + .align 4 +.LEFDE1: +.LSFDE3: + .long .LEFDE3-.LASFDE3 +.LASFDE3: + .long .LASFDE3-.Lframe1 + .long .LFB1-. + .long .LFE1-.LFB1 + .uleb128 0 + .byte 0x4 + .long .LCFI7-.LFB1 + .byte 0xe + .uleb128 0x10 + .byte 0x86 + .uleb128 0x2 + .byte 0x4 + .long .LCFI8-.LCFI7 + .byte 0xd + .uleb128 0x6 + .byte 0x4 + .long .LCFI9-.LCFI8 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .align 4 +.LEFDE3: + .ident "GCC: (GNU) 5.4.0" + .section .note.GNU-stack,"",@progbits diff --git a/callback/vacall_r/vacall_r.h b/callback/vacall_r/vacall_r.h new file mode 100644 index 0000000..0e66c2e --- /dev/null +++ b/callback/vacall_r/vacall_r.h @@ -0,0 +1,548 @@ +/* + * Copyright 1995-2019 Bruno Haible + * + * 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, see . + */ + +#ifndef _VACALL_R_H +#define _VACALL_R_H + +#include + +#include "ffcall-abi.h" + + +/* Use a consistent prefix for all symbols in libcallback. */ +#define vacall_start callback_start +#define vacall_start_struct callback_start_struct +#define vacall_arg_char callback_arg_char +#define vacall_arg_schar callback_arg_schar +#define vacall_arg_uchar callback_arg_uchar +#define vacall_arg_short callback_arg_short +#define vacall_arg_ushort callback_arg_ushort +#define vacall_arg_int callback_arg_int +#define vacall_arg_uint callback_arg_uint +#define vacall_arg_long callback_arg_long +#define vacall_arg_ulong callback_arg_ulong +#define vacall_arg_longlong callback_arg_longlong +#define vacall_arg_ulonglong callback_arg_ulonglong +#define vacall_arg_float callback_arg_float +#define vacall_arg_double callback_arg_double +#define vacall_arg_ptr callback_arg_ptr +#define vacall_arg_struct callback_arg_struct +#define vacall_return_void callback_return_void +#define vacall_return_char callback_return_char +#define vacall_return_schar callback_return_schar +#define vacall_return_uchar callback_return_uchar +#define vacall_return_short callback_return_short +#define vacall_return_ushort callback_return_ushort +#define vacall_return_int callback_return_int +#define vacall_return_uint callback_return_uint +#define vacall_return_long callback_return_long +#define vacall_return_ulong callback_return_ulong +#define vacall_return_longlong callback_return_longlong +#define vacall_return_ulonglong callback_return_ulonglong +#define vacall_return_float callback_return_float +#define vacall_return_double callback_return_double +#define vacall_return_ptr callback_return_ptr +#define vacall_return_struct callback_return_struct +#define vacall_error_type_mismatch callback_error_type_mismatch +#define vacall_error_struct_too_large callback_error_struct_too_large +#define vacall_structcpy callback_structcpy +#define vacall_struct_buffer callback_struct_buffer + + +/* Determine whether the current ABI is LLP64 + ('long' = 32-bit, 'long long' = 'void*' = 64-bit). */ +#if defined(__x86_64__) && defined(_WIN32) && !defined(__CYGWIN__) +#define __VA_LLP64 1 +#endif + +/* Determine the alignment of a type at compile time. + */ +#if defined(__GNUC__) || defined(__IBM__ALIGNOF__) +#define __VA_alignof __alignof__ +#elif defined(__cplusplus) +template struct __VA_alignof_helper { char __slot1; type __slot2; }; +#define __VA_alignof(type) offsetof (__VA_alignof_helper, __slot2) +#elif defined(__mips__) || defined(__mipsn32__) || defined(__mips64__) /* SGI compiler */ +#define __VA_alignof __builtin_alignof +#else +#define __VA_offsetof(type,ident) ((unsigned long)&(((type*)0)->ident)) +#define __VA_alignof(type) __VA_offsetof(struct { char __slot1; type __slot2; }, __slot2) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* C builtin types. + */ +#if defined(__mipsn32__) || defined(__x86_64_x32__) || defined(__VA_LLP64) +typedef long long __vaword; +#else +typedef long __vaword; +#endif + +enum __VAtype +{ + __VAvoid, + __VAchar, + __VAschar, + __VAuchar, + __VAshort, + __VAushort, + __VAint, + __VAuint, + __VAlong, + __VAulong, + __VAlonglong, + __VAulonglong, + __VAfloat, + __VAdouble, + __VAvoidp, + __VAstruct +}; + +enum __VA_alist_flags +{ + + /* how to return structs */ + /* There are basically 3 ways to return structs: + * a. The called function returns a pointer to static data. Not reentrant. + * Not supported any more. + * b. The caller passes the return structure address in a dedicated register + * or as a first (or last), invisible argument. The called function stores + * its result there. + * c. Like b, and the called function also returns the return structure + * address in the return value register. (This is not very distinguishable + * from b.) + * Independently of this, + * r. small structures (<= 4 or <= 8 bytes) may be returned in the return + * value register(s), or + * m. even small structures are passed in memory. + */ + /* gcc-2.6.3 employs the following strategy: + * - If PCC_STATIC_STRUCT_RETURN is defined in the machine description + * it uses method a, else method c. + * - If flag_pcc_struct_return is set (either by -fpcc-struct-return or if + * DEFAULT_PCC_STRUCT_RETURN is defined to 1 in the machine description) + * it uses method m, else (either by -freg-struct-return or if + * DEFAULT_PCC_STRUCT_RETURN is defined to 0 in the machine description) + * method r. + */ + __VA_SMALL_STRUCT_RETURN = 1<<1, /* r: special case for small structs */ + __VA_GCC_STRUCT_RETURN = 1<<2, /* consider 8 byte structs as small */ +#if defined(__sparc__) && !defined(__sparc64__) + __VA_SUNCC_STRUCT_RETURN = 1<<3, + __VA_SUNPROCC_STRUCT_RETURN = 1<<4, +#else + __VA_SUNCC_STRUCT_RETURN = 0, + __VA_SUNPROCC_STRUCT_RETURN = 0, +#endif +#if defined(__i386__) + __VA_MSVC_STRUCT_RETURN = 1<<4, +#endif + /* the default way to return structs */ + /* This choice here is based on the assumption that the function you are + * going to call has been compiled with the same compiler you are using to + * include this file. + * If you want to call functions with another struct returning convention, + * just #define __VA_STRUCT_RETURN ... + * before or after #including . + */ +#ifndef __VA_STRUCT_RETURN + __VA_STRUCT_RETURN = +#if defined(__sparc__) && !defined(__sparc64__) && defined(__sun) && (defined(__SUNPRO_C) || defined(__SUNPRO_CC)) /* SUNWspro cc or CC */ + __VA_SUNPROCC_STRUCT_RETURN, +#else +#if (defined(__i386__) && (defined(_WIN32) || defined(__CYGWIN__) || (defined(__MACH__) && defined(__APPLE__)) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__))) || defined(__m68k__) || defined(__mipsn32__) || defined(__mips64__) || defined(__sparc64__) || defined(__hppa__) || defined(__hppa64__) || defined(__arm__) || defined(__armhf__) || defined(__arm64__) || defined(__powerpc64_elfv2__) || defined(__ia64__) || defined(__x86_64__) || defined(__riscv32__) || defined(__riscv64__) + __VA_SMALL_STRUCT_RETURN | +#endif +#if defined(__GNUC__) && !((defined(__mipsn32__) || defined(__mips64__)) && ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ > 3))) + __VA_GCC_STRUCT_RETURN | +#endif +#if defined(__i386__) && defined(_WIN32) && !defined(__CYGWIN__) /* native Windows */ + __VA_MSVC_STRUCT_RETURN | +#endif + 0, +#endif +#endif + + /* how to return floats */ +#if defined(__m68k__) || (defined(__sparc__) && !defined(__sparc64__)) + __VA_SUNCC_FLOAT_RETURN = 1<<5, +#endif +#if defined(__m68k__) + __VA_FREG_FLOAT_RETURN = 1<<6, +#endif + /* the default way to return floats */ + /* This choice here is based on the assumption that the function you are + * going to call has been compiled with the same compiler you are using to + * include this file. + * If you want to call functions with another float returning convention, + * just #define __VA_FLOAT_RETURN ... + * before or after #including . + */ +#ifndef __VA_FLOAT_RETURN +#if (defined(__m68k__) || (defined(__sparc__) && !defined(__sparc64__))) && !defined(__GNUC__) && defined(__sun) && !(defined(__SUNPRO_C) || defined(__SUNPRO_CC)) /* Sun cc or CC */ + __VA_FLOAT_RETURN = __VA_SUNCC_FLOAT_RETURN, +#elif defined(__m68k__) + __VA_FLOAT_RETURN = __VA_FREG_FLOAT_RETURN, +#else + __VA_FLOAT_RETURN = 0, +#endif +#endif + + /* how to pass structs */ +#if defined(__mips__) || defined(__mipsn32__) || defined(__mips64__) + __VA_SGICC_STRUCT_ARGS = 1<<7, +#endif +#if defined(__powerpc__) || defined(__powerpc64__) + __VA_AIXCC_STRUCT_ARGS = 1<<7, +#endif +#if defined(__ia64__) + __VA_OLDGCC_STRUCT_ARGS = 1<<7, +#endif + /* the default way to pass structs */ + /* This choice here is based on the assumption that the function you are + * going to call has been compiled with the same compiler you are using to + * include this file. + * If you want to call functions with another structs passing convention, + * just #define __VA_STRUCT_ARGS ... + * before or after #including . + */ +#ifndef __VA_STRUCT_ARGS +#if (defined(__mips__) && !defined(__mipsn32__) && !defined(__mips64__)) && !defined(__GNUC__) /* SGI mips cc */ + __VA_STRUCT_ARGS = __VA_SGICC_STRUCT_ARGS, +#else +#if (defined(__mipsn32__) || defined(__mips64__)) && (!defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ > 3)) /* SGI mips cc or gcc >= 3.4 */ + __VA_STRUCT_ARGS = __VA_SGICC_STRUCT_ARGS, +#else +#if defined(__powerpc__) && !defined(__powerpc64__) && defined(_AIX) && !defined(__GNUC__) /* AIX 32-bit cc, xlc */ + __VA_STRUCT_ARGS = __VA_AIXCC_STRUCT_ARGS, +#else +#if defined(__powerpc64__) && defined(_AIX) /* AIX 64-bit cc, xlc, gcc */ + __VA_STRUCT_ARGS = __VA_AIXCC_STRUCT_ARGS, +#else +#if defined(__ia64__) && !(defined(__GNUC__) && (__GNUC__ >= 3)) + __VA_STRUCT_ARGS = __VA_OLDGCC_STRUCT_ARGS, +#else + __VA_STRUCT_ARGS = 0, +#endif +#endif +#endif +#endif +#endif +#endif + + /* how to pass floats */ + /* ANSI C compilers and GNU gcc pass floats as floats. + * K&R C compilers pass floats as doubles. We don't support them any more. + */ +#if defined(__powerpc64__) + __VA_AIXCC_FLOAT_ARGS = 1<<8, /* pass floats in the low 4 bytes of an 8-bytes word */ +#endif + /* the default way to pass floats */ + /* This choice here is based on the assumption that the function you are + * going to call has been compiled with the same compiler you are using to + * include this file. + * If you want to call functions with another float passing convention, + * just #define __VA_FLOAT_ARGS ... + * before or after #including . + */ +#ifndef __VA_FLOAT_ARGS +#if defined(__powerpc64__) && defined(_AIX) && !defined(__GNUC__) /* AIX 64-bit xlc */ + __VA_FLOAT_ARGS = __VA_AIXCC_FLOAT_ARGS, +#else + __VA_FLOAT_ARGS = 0, +#endif +#endif + + /* how to pass and return small integer arguments */ + __VA_ANSI_INTEGERS = 0, /* no promotions */ + __VA_TRADITIONAL_INTEGERS = 0, /* promote [u]char, [u]short to [u]int */ + /* Fortunately these two methods are compatible. Our macros work with both. */ + + /* stack cleanup policy */ + __VA_CDECL_CLEANUP = 0, /* caller pops args after return */ + __VA_STDCALL_CLEANUP = 1<<9, /* callee pops args before return */ + /* currently only supported on __i386__ */ +#ifndef __VA_CLEANUP + __VA_CLEANUP = __VA_CDECL_CLEANUP, +#endif + + /* These are for internal use only */ +#if defined(__i386__) || defined(__m68k__) || defined(__mipsn32__) || defined(__mips64__) || defined(__sparc64__) || defined(__alpha__) || defined(__hppa64__) || defined(__arm__) || defined(__armhf__) || defined(__arm64__) || defined(__powerpc__) || defined(__powerpc64__) || defined(__ia64__) || defined(__x86_64__) || (defined(__s390__) && !defined(__s390x__)) || defined(__riscv64__) + __VA_REGISTER_STRUCT_RETURN = 1<<10, +#endif +#if defined(__mipsn32__) || defined(__mips64__) + __VA_REGISTER_FLOATSTRUCT_RETURN = 1<<11, + __VA_REGISTER_DOUBLESTRUCT_RETURN = 1<<12, +#endif + + __VA_flag_for_broken_compilers_that_dont_like_trailing_commas +}; + +/* + * Definition of the ‘va_alist’ type. + */ +struct vacall_alist +/* GNU clisp pokes in internals of the alist! */ +#ifdef LISPFUN +{ + /* some va_... macros need these flags */ + int flags; +#if defined(__i386__) || defined(__arm__) || defined(__armhf__) || (defined(__powerpc__) && !defined(__powerpc64__) && defined(__MACH__) && defined(__APPLE__)) + __vaword filler1; +#endif + /* temporary storage for return value */ + union { + char _char; + signed char _schar; + unsigned char _uchar; + short _short; + unsigned short _ushort; + int _int; + unsigned int _uint; + long _long; + unsigned long _ulong; + long long _longlong; + unsigned long long _ulonglong; + float _float; + double _double; + void* _ptr; + } tmp; +} +#endif +; +typedef struct vacall_alist * va_alist; + + +/* + * Definition of the va_start_xxx macros. + */ +#define __VA_START_FLAGS \ + __VA_STRUCT_RETURN | __VA_FLOAT_RETURN | __VA_STRUCT_ARGS | __VA_FLOAT_ARGS | __VA_CLEANUP + +extern void vacall_start (va_alist /* LIST */, int /* RETTYPE */, int /* FLAGS */); + +#define va_start_void(LIST) vacall_start(LIST,__VAvoid, __VA_START_FLAGS) +#define va_start_char(LIST) vacall_start(LIST,__VAchar, __VA_START_FLAGS) +#define va_start_schar(LIST) vacall_start(LIST,__VAschar, __VA_START_FLAGS) +#define va_start_uchar(LIST) vacall_start(LIST,__VAuchar, __VA_START_FLAGS) +#define va_start_short(LIST) vacall_start(LIST,__VAshort, __VA_START_FLAGS) +#define va_start_ushort(LIST) vacall_start(LIST,__VAushort, __VA_START_FLAGS) +#define va_start_int(LIST) vacall_start(LIST,__VAint, __VA_START_FLAGS) +#define va_start_uint(LIST) vacall_start(LIST,__VAuint, __VA_START_FLAGS) +#define va_start_long(LIST) vacall_start(LIST,__VAlong, __VA_START_FLAGS) +#define va_start_ulong(LIST) vacall_start(LIST,__VAulong, __VA_START_FLAGS) +#define va_start_longlong(LIST) vacall_start(LIST,__VAlonglong, __VA_START_FLAGS) +#define va_start_ulonglong(LIST) vacall_start(LIST,__VAulonglong,__VA_START_FLAGS) +#define va_start_float(LIST) vacall_start(LIST,__VAfloat, __VA_START_FLAGS) +#define va_start_double(LIST) vacall_start(LIST,__VAdouble, __VA_START_FLAGS) +#define va_start_ptr(LIST,TYPE) vacall_start(LIST,__VAvoidp, __VA_START_FLAGS) + +/* + * va_start_struct: Preparing structure return. + */ +extern void vacall_start_struct (va_alist /* LIST */, size_t /* TYPE_SIZE */, size_t /* TYPE_ALIGN */, int /* TYPE_SPLITTABLE */, int /* FLAGS */); + +#define va_start_struct(LIST,TYPE,TYPE_SPLITTABLE) \ + _va_start_struct(LIST,sizeof(TYPE),__VA_alignof(TYPE),TYPE_SPLITTABLE) +/* _va_start_struct() is like va_start_struct(), except that you pass + * the type's size and alignment instead of the type itself. + * Undocumented, but used by GNU clisp. + */ +#define _va_start_struct(LIST,TYPE_SIZE,TYPE_ALIGN,TYPE_SPLITTABLE) \ + vacall_start_struct(LIST,TYPE_SIZE,TYPE_ALIGN,TYPE_SPLITTABLE,__VA_START_FLAGS) + + +/* + * Definition of the va_arg_xxx macros. + */ + +extern char vacall_arg_char (va_alist /* LIST */); +extern signed char vacall_arg_schar (va_alist /* LIST */); +extern unsigned char vacall_arg_uchar (va_alist /* LIST */); +extern short vacall_arg_short (va_alist /* LIST */); +extern unsigned short vacall_arg_ushort (va_alist /* LIST */); +extern int vacall_arg_int (va_alist /* LIST */); +extern unsigned int vacall_arg_uint (va_alist /* LIST */); +extern long vacall_arg_long (va_alist /* LIST */); +extern unsigned long vacall_arg_ulong (va_alist /* LIST */); + +#define va_arg_char(LIST) vacall_arg_char(LIST) +#define va_arg_schar(LIST) vacall_arg_schar(LIST) +#define va_arg_uchar(LIST) vacall_arg_uchar(LIST) +#define va_arg_short(LIST) vacall_arg_short(LIST) +#define va_arg_ushort(LIST) vacall_arg_ushort(LIST) +#define va_arg_int(LIST) vacall_arg_int(LIST) +#define va_arg_uint(LIST) vacall_arg_uint(LIST) +#define va_arg_long(LIST) vacall_arg_long(LIST) +#define va_arg_ulong(LIST) vacall_arg_ulong(LIST) + +extern long long vacall_arg_longlong (va_alist /* LIST */); +extern unsigned long long vacall_arg_ulonglong (va_alist /* LIST */); + +#define va_arg_longlong(LIST) vacall_arg_longlong(LIST) +#define va_arg_ulonglong(LIST) vacall_arg_ulonglong(LIST) + +/* Floating point arguments. */ + +extern float vacall_arg_float (va_alist /* LIST */); +extern double vacall_arg_double (va_alist /* LIST */); + +#define va_arg_float(LIST) vacall_arg_float(LIST) +#define va_arg_double(LIST) vacall_arg_double(LIST) + +/* Pointer arguments. */ + +extern void* vacall_arg_ptr (va_alist /* LIST */); +#define va_arg_ptr(LIST,TYPE) ((TYPE)vacall_arg_ptr(LIST)) + +/* Structure arguments. */ + +extern void* vacall_arg_struct (va_alist /* LIST */, size_t /* TYPE_SIZE */, size_t /* TYPE_ALIGN */); + +#define va_arg_struct(LIST,TYPE) \ + *(TYPE*)vacall_arg_struct(LIST,sizeof(TYPE),__VA_alignof(TYPE)) +/* _va_arg_struct() is like va_arg_struct(), except that you pass the type's + * size and alignment instead of the type and get the value's address instead + * of the value itself. + * Undocumented, but used by GNU clisp. + */ +#define _va_arg_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ + vacall_arg_struct(LIST,TYPE_SIZE,TYPE_ALIGN) + + +/* + * Definition of the va_return_xxx macros. + */ + +extern void vacall_return_void (va_alist /* LIST */); +#define va_return_void(LIST) vacall_return_void(LIST) + +extern void vacall_return_char (va_alist /* LIST */, char /* VAL */); +extern void vacall_return_schar (va_alist /* LIST */, signed char /* VAL */); +extern void vacall_return_uchar (va_alist /* LIST */, unsigned char /* VAL */); +extern void vacall_return_short (va_alist /* LIST */, short /* VAL */); +extern void vacall_return_ushort (va_alist /* LIST */, unsigned short /* VAL */); +extern void vacall_return_int (va_alist /* LIST */, int /* VAL */); +extern void vacall_return_uint (va_alist /* LIST */, unsigned int /* VAL */); +extern void vacall_return_long (va_alist /* LIST */, long /* VAL */); +extern void vacall_return_ulong (va_alist /* LIST */, unsigned long /* VAL */); +#define va_return_char(LIST,VAL) vacall_return_char(LIST,VAL) +#define va_return_schar(LIST,VAL) vacall_return_schar(LIST,VAL) +#define va_return_uchar(LIST,VAL) vacall_return_uchar(LIST,VAL) +#define va_return_short(LIST,VAL) vacall_return_short(LIST,VAL) +#define va_return_ushort(LIST,VAL) vacall_return_ushort(LIST,VAL) +#define va_return_int(LIST,VAL) vacall_return_int(LIST,VAL) +#define va_return_uint(LIST,VAL) vacall_return_uint(LIST,VAL) +#define va_return_long(LIST,VAL) vacall_return_long(LIST,VAL) +#define va_return_ulong(LIST,VAL) vacall_return_ulong(LIST,VAL) + +extern void vacall_return_longlong (va_alist /* LIST */, long long /* VAL */); +extern void vacall_return_ulonglong (va_alist /* LIST */, unsigned long long /* VAL */); +#define va_return_longlong(LIST,VAL) vacall_return_longlong(LIST,VAL) +#define va_return_ulonglong(LIST,VAL) vacall_return_ulonglong(LIST,VAL) + +extern void vacall_return_float (va_alist /* LIST */, float /* VAL */); +extern void vacall_return_double (va_alist /* LIST */, double /* VAL */); +#define va_return_float(LIST,VAL) vacall_return_float(LIST,VAL) +#define va_return_double(LIST,VAL) vacall_return_double(LIST,VAL) + +extern void vacall_return_ptr (va_alist /* LIST */, void* /* VAL */); +#define va_return_ptr(LIST,TYPE,VAL) vacall_return_ptr(LIST,(void*)(TYPE)(VAL)) + +extern void vacall_return_struct (va_alist /* LIST */, size_t /* TYPE_SIZE */, size_t /* TYPE_ALIGN */, const void* /* VAL_ADDR */); + +#define va_return_struct(LIST,TYPE,VAL) \ + _va_return_struct(LIST,sizeof(TYPE),__VA_alignof(TYPE),&(VAL)) +/* Undocumented, but used by GNU clisp. */ +#define _va_return_struct(LIST,TYPE_SIZE,TYPE_ALIGN,VAL_ADDR) \ + vacall_return_struct(LIST,TYPE_SIZE,TYPE_ALIGN,VAL_ADDR) + + +/* Determine whether a struct type is word-splittable, i.e. whether each of + * its components fit into a register. + * The entire computation is done at compile time. + */ +#define va_word_splittable_1(slot1) \ + (__va_offset1(slot1)/sizeof(__vaword) == (__va_offset1(slot1)+sizeof(slot1)-1)/sizeof(__vaword)) +#define va_word_splittable_2(slot1,slot2) \ + ((__va_offset1(slot1)/sizeof(__vaword) == (__va_offset1(slot1)+sizeof(slot1)-1)/sizeof(__vaword)) \ + && (__va_offset2(slot1,slot2)/sizeof(__vaword) == (__va_offset2(slot1,slot2)+sizeof(slot2)-1)/sizeof(__vaword)) \ + ) +#define va_word_splittable_3(slot1,slot2,slot3) \ + ((__va_offset1(slot1)/sizeof(__vaword) == (__va_offset1(slot1)+sizeof(slot1)-1)/sizeof(__vaword)) \ + && (__va_offset2(slot1,slot2)/sizeof(__vaword) == (__va_offset2(slot1,slot2)+sizeof(slot2)-1)/sizeof(__vaword)) \ + && (__va_offset3(slot1,slot2,slot3)/sizeof(__vaword) == (__va_offset3(slot1,slot2,slot3)+sizeof(slot3)-1)/sizeof(__vaword)) \ + ) +#define va_word_splittable_4(slot1,slot2,slot3,slot4) \ + ((__va_offset1(slot1)/sizeof(__vaword) == (__va_offset1(slot1)+sizeof(slot1)-1)/sizeof(__vaword)) \ + && (__va_offset2(slot1,slot2)/sizeof(__vaword) == (__va_offset2(slot1,slot2)+sizeof(slot2)-1)/sizeof(__vaword)) \ + && (__va_offset3(slot1,slot2,slot3)/sizeof(__vaword) == (__va_offset3(slot1,slot2,slot3)+sizeof(slot3)-1)/sizeof(__vaword)) \ + && (__va_offset4(slot1,slot2,slot3,slot4)/sizeof(__vaword) == (__va_offset4(slot1,slot2,slot3,slot4)+sizeof(slot4)-1)/sizeof(__vaword)) \ + ) +#define __va_offset1(slot1) \ + 0 +#define __va_offset2(slot1,slot2) \ + ((__va_offset1(slot1)+sizeof(slot1)+__VA_alignof(slot2)-1) & -(long)__VA_alignof(slot2)) +#define __va_offset3(slot1,slot2,slot3) \ + ((__va_offset2(slot1,slot2)+sizeof(slot2)+__VA_alignof(slot3)-1) & -(long)__VA_alignof(slot3)) +#define __va_offset4(slot1,slot2,slot3,slot4) \ + ((__va_offset3(slot1,slot2,slot3)+sizeof(slot3)+__VA_alignof(slot4)-1) & -(long)__VA_alignof(slot4)) + + +/* + * Miscellaneous declarations. + */ + +#if defined(__sparc__) || defined(__sparc64__) +/* On SPARC, PIC compiled code crashes when used outside of a shared library. + Therefore, don't use the callback_get_receiver indirection on this platform. */ + +extern +#ifdef __cplusplus +"C" +#endif +void callback_receiver (); /* Actually it takes arguments and returns values! */ + +#define callback_get_receiver() (&callback_receiver) + +#else + +/* A fake type for callback_receiver. + Actually it takes arguments and returns values. */ +typedef void (*__vacall_r_t) (void); + +/* This function returns the address of callback_receiver. + callback_receiver is not a global symbol, because on ELF platforms, functions + with global visibility cannot accept additional arguments in registers. See + elf-hack.txt for more details. */ +extern +#ifdef __cplusplus +"C" +#endif +__vacall_r_t callback_get_receiver (void); + +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* _VACALL_R_H */ diff --git a/common/asm-alpha.sh b/common/asm-alpha.sh new file mode 100755 index 0000000..f39b238 --- /dev/null +++ b/common/asm-alpha.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# Translate the assembler syntax of alpha assembler programs +# Usage: asm-alpha.sh < alphalinux-asm-file > portable-asm-file +# The portable-asm-file has to be +# 1. preprocessed, +# 2. grep -v '^ *#line' | grep -v '^#' +# 3. sed -e 's,% ,%,g' -e 's,//.*$,,' + +# Copyright (C) 2017 Bruno Haible +# +# 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, see . + +tmpscript1=sed$$tmp1 +tmpscript2=sed$$tmp2 +tmpremove='rm -f $tmpscript1 $tmpscript2' +trap "$tmpremove" 1 2 15 + +cat > $tmpscript1 << \EOF +# ----------- Remove gcc self-identification +/gcc2_compiled/d +/gnu_compiled_c/d +/\.ident/d +EOF + +cat > $tmpscript2 << \EOF +# ----------- Introduce macro syntax for assembler pseudo-ops +/\.section\([ ]\+\).*GNU-stack/d +EOF + +sed -f $tmpscript1 | \ +sed -f $tmpscript2 + +eval "$tmpremove" diff --git a/common/asm-arm.h b/common/asm-arm.h new file mode 100644 index 0000000..fee4030 --- /dev/null +++ b/common/asm-arm.h @@ -0,0 +1,59 @@ +// Assembly language support for arm CPU. +// Bruno Haible 1999-05-29 + +// Copyright (C) 1999-2017 Bruno Haible +// +// 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, see . + +// In order not to have to maintain several copies of the assembly language +// code, we use some macros which expand into the correct syntax. +// These macros are: +// C(name) +// This expands to the name of the C variable or function `name'. +// On Unix BSD systems, this prepends an underscore. +// L(label) +// This expands to the name of a local label, having the name `label'. +// On Unix ELF systems, where there is no underscore, names beginning +// with an alphabetic character are automatically exported, so this +// prepends a dot. Note that when defining a label, the `:' must +// be inside the parentheses, not outside, because otherwise some +// ANSI C preprocessor inserts a space between the label and the `:', +// and some assemblers don't like this. +// DECLARE_FUNCTION(name) +// Declare `name' to be a global function. When assembly language +// code is compiled into a shared library, ELF linkers need to know +// which symbols are functions. +// FUNBEGIN(name) +// Start the assembly language code for the C function `name'. +// FUNEND(name) +// End the assembly language code for the C function 'name'. + +#ifdef ASM_UNDERSCORE +#define C(entrypoint) _##entrypoint +#define L(label) L##label +#else +#define C(entrypoint) entrypoint +#define L(label) .L##label +#endif + +// When assembly language code is compiled into a shared library, ELF linkers +// need to know which symbols are functions. +#if defined(__ELF__) || !defined(ASM_UNDERSCORE) +#define DECLARE_FUNCTION(name) .type C(name),%function +#define FUNEND(name) .size C(name),.-C(name) +#else +#define DECLARE_FUNCTION(name) +#define FUNEND(name) +#endif +#define FUNBEGIN(name) C(name): diff --git a/common/asm-arm.sh b/common/asm-arm.sh new file mode 100755 index 0000000..d166ea9 --- /dev/null +++ b/common/asm-arm.sh @@ -0,0 +1,62 @@ +#!/bin/sh +# Translate the assembler syntax of arm assembler programs +# Usage: asm-arm.sh < riscix-asm-file > portable-asm-file +# The portable-asm-file has to be +# 1. preprocessed, +# 2. grep -v '^ *#line' | grep -v '^#' +# 3. sed -e 's,% ,%,g' -e 's,//,@,g' -e 's,\$,#,g' + +# Copyright (C) 1999-2018 Bruno Haible +# +# 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, see . + +tmpscript1=sed$$tmp1 +tmpscript2=sed$$tmp2 +tmpremove='rm -f $tmpscript1 $tmpscript2' +trap "$tmpremove" 1 2 15 + +cat > $tmpscript1 << \EOF +# ----------- Remove gcc self-identification +/gcc2_compiled/d +/gnu_compiled_c/d +/\.ident/d +EOF + +cat > $tmpscript2 << \EOF +# ----------- Hide comments, to avoid trouble in preprocessing +s,@,//,g +# ----------- Turn # into $, to avoid trouble in preprocessing +s,#,\$,g +# ----------- Global symbols depends on ASM_UNDERSCORE +/[ ]\.req[ ]/!{ +s/^\([A-Za-z0-9_]\+\)/C(\1)/ +} +s/\.L\([A-Za-z0-9_]\+\)/L(\1)/ +s/\.global[ ]\([A-Za-z0-9_]*\)/.global C(\1)/ +# ----------- Introduce macro syntax for assembler pseudo-ops +/\.file\([ ]\+\)/d +/\.section\([ ]\+\).*GNU-stack/d +s/^C(\([A-Za-z0-9_]*\)):/FUNBEGIN(\1)/ +# ----------- Massage the beginning of functions +/\.type/{ +s/\.type[ ]\([A-Za-z0-9_]*\), *function/DECLARE_FUNCTION(\1)/ +} +# ----------- Massage the end of functions +s/\.size[ ]\([A-Za-z0-9_]*\),\(.*\)/FUNEND(\1)/ +EOF + +sed -f $tmpscript1 | \ +sed -f $tmpscript2 + +eval "$tmpremove" diff --git a/common/asm-hppa.h b/common/asm-hppa.h new file mode 100644 index 0000000..ac6c378 --- /dev/null +++ b/common/asm-hppa.h @@ -0,0 +1,73 @@ +// Assembly language support for hppa CPU. +// Bruno Haible 2017-01-23 + +// Copyright (C) 2017-2018 Bruno Haible +// +// 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, see . + +// In order not to have to maintain several copies of the assembly language +// code, we use some macros which expand into the correct syntax. +// These macros are: +// IMPORT_MILLICODE(symbol) +// This expands to an import from the MILLICODE segment, if needed. +// IMPORT_DATA(symbol) +// This expands to an import from the DATA segment, if needed. +// TEXT1(), TEXT2() +// These expand to two lines that switch to the TEXT section/segment. +// GLOBL(symbol) +// This expands to a declaration that the given symbol, defined +// in this file, shall have global visibility. +// DEF(symbol) +// This expands to the declaration of a symbol or label. +// L(label) +// This expands to the name of a local label, having the name `label'. +// DECLARE_FUNCTION(name) +// Declare `name' to be a global function. When assembly language +// code is compiled into a shared library, ELF linkers need to know +// which symbols are functions. +// FUNEND(name) +// End the assembly language code for the C function 'name'. + +#if defined(__ELF__) +/* Linux */ +#define IMPORT_MILLICODE(symbol) +#define IMPORT_DATA(symbol) +#define TEXT1() .text +#define TEXT2() +#define GLOBL(symbol) .globl symbol +#define DEF(symbol) symbol: +#define L(label) .L##label +#define DECLARE_FUNCTION(name) .type name,%function +#define FUNEND(name) .size name,.-name +#else +/* HP-UX */ +#define IMPORT_MILLICODE(symbol) .IMPORT symbol,MILLICODE +#define IMPORT_DATA(symbol) .IMPORT symbol,DATA +#if 1 +#define TEXT1() .SPACE $TEXT$ +#define TEXT2() .SUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY +#else +#define TEXT1() .code +#define TEXT2() +#endif +#define GLOBL(symbol) .EXPORT symbol,ENTRY,PRIV_LEV=3 +#if 1 +#define DEF(symbol) symbol +#else +#define DEF(symbol) .label symbol +#endif +#define L(label) L$##label +#define DECLARE_FUNCTION(name) +#define FUNEND(name) +#endif diff --git a/common/asm-hppa.sh b/common/asm-hppa.sh new file mode 100755 index 0000000..180fd34 --- /dev/null +++ b/common/asm-hppa.sh @@ -0,0 +1,68 @@ +#!/bin/sh +# Translate the assembler syntax of hppa assembler programs +# Usage: asm-hppa.sh < hppalinux-asm-file > portable-asm-file +# The portable-asm-file has to be +# 1. preprocessed, +# 2. grep -v '^ *#line' | grep -v '^#' +# 3. sed -e "s,!,',g" + +# Copyright (C) 2017 Bruno Haible +# +# 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, see . + +tmpscript1=sed$$tmp1 +tmpscript2=sed$$tmp2 +tmpremove='rm -f $tmpscript1 $tmpscript2' +trap "$tmpremove" 1 2 15 + +cat > $tmpscript1 << \EOF +# ----------- Remove #APP/#NO_APP lines and gcc self-identification +/^#APP$/d +/^#NO_APP$/d +/gcc2_compiled/d +/gnu_compiled_c/d +/\.ident/d +EOF + +cat > $tmpscript2 << \EOF +# ----------- Turn ' into !, to avoid trouble in preprocessing +s,',!,g +# ----------- Add some imports +/\.LEVEL/{ +s/$/\ + IMPORT_MILLICODE($$dyncall)/ +} +# ----------- Section switching +s/\.text/TEXT1()\ + TEXT2()/ +# ----------- Declaration of symbols and labels is different +s/^\([A-Za-z0-9_.]\+\):$/DEF(\1)/ +# ----------- Label syntax is different +/\.LEVEL/!{ +s/\.L\([A-Za-z0-9_]\+\)/L(\1)/ +} +# ----------- Introduce macro syntax for assembler pseudo-ops +s/\.globl[ ]\([A-Za-z0-9_]\+\)/GLOBL(\1)/ +# ----------- Massage the beginning of functions +/\.type/{ +s/\.type[ ]\+\([A-Za-z0-9_]*\), *@function/DECLARE_FUNCTION(\1)/ +} +# ----------- Massage the end of functions +s/\.size[ ]\([A-Za-z0-9_]*\),\(.*\)/FUNEND(\1)/ +EOF + +sed -f $tmpscript1 | \ +sed -f $tmpscript2 + +eval "$tmpremove" diff --git a/common/asm-hppa64.h b/common/asm-hppa64.h new file mode 100644 index 0000000..fa653d1 --- /dev/null +++ b/common/asm-hppa64.h @@ -0,0 +1,69 @@ +// Assembly language support for hppa64 CPU. +// Bruno Haible 2017-01-23, 2017-08-05 + +// Copyright (C) 2017-2018 Bruno Haible +// +// 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, see . + +// In order not to have to maintain several copies of the assembly language +// code, we use some macros which expand into the correct syntax. +// These macros are: +// IMPORT_DATA(symbol) +// This expands to an import from the DATA segment, if needed. +// TEXT1(), TEXT2() +// These expand to two lines that switch to the TEXT section/segment. +// GLOBL(symbol) +// This expands to a declaration that the given symbol, defined +// in this file, shall have global visibility. +// DEF(symbol) +// This expands to the declaration of a symbol or label. +// L(label) +// This expands to the name of a local label, having the name `label'. +// DECLARE_FUNCTION(name) +// Declare `name' to be a global function. When assembly language +// code is compiled into a shared library, ELF linkers need to know +// which symbols are functions. +// FUNEND(name) +// End the assembly language code for the C function 'name'. + +#if defined(__ELF__) +/* Linux */ +#define IMPORT_DATA(symbol) +#define TEXT1() .text +#define TEXT2() +#define GLOBL(symbol) .globl symbol +#define DEF(symbol) symbol: +#define L(label) .L##label +#define DECLARE_FUNCTION(name) .type name,%function +#define FUNEND(name) .size name,.-name +#else +/* HP-UX */ +#define IMPORT_DATA(symbol) .IMPORT symbol,DATA +#if 1 +#define TEXT1() .SPACE $TEXT$,SORT=8 +#define TEXT2() .SUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY,SORT=24 +#else +#define TEXT1() .code +#define TEXT2() +#endif +#define GLOBL(symbol) .EXPORT symbol,ENTRY,PRIV_LEV=3 +#if 1 +#define DEF(symbol) symbol +#else +#define DEF(symbol) .label symbol +#endif +#define L(label) L$##label +#define DECLARE_FUNCTION(name) +#define FUNEND(name) +#endif diff --git a/common/asm-hppa64.sh b/common/asm-hppa64.sh new file mode 100755 index 0000000..71d9d26 --- /dev/null +++ b/common/asm-hppa64.sh @@ -0,0 +1,63 @@ +#!/bin/sh +# Translate the assembler syntax of hppa64 assembler programs +# Usage: asm-hppa64.sh < hppalinux-asm-file > portable-asm-file +# The portable-asm-file has to be +# 1. preprocessed, +# 2. grep -v '^ *#line' | grep -v '^#' +# 3. sed -e "s,!,',g" + +# Copyright (C) 2017 Bruno Haible +# +# 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, see . + +tmpscript1=sed$$tmp1 +tmpscript2=sed$$tmp2 +tmpremove='rm -f $tmpscript1 $tmpscript2' +trap "$tmpremove" 1 2 15 + +cat > $tmpscript1 << \EOF +# ----------- Remove #APP/#NO_APP lines and gcc self-identification +/^#APP$/d +/^#NO_APP$/d +/gcc2_compiled/d +/gnu_compiled_c/d +/\.ident/d +EOF + +cat > $tmpscript2 << \EOF +# ----------- Turn ' into !, to avoid trouble in preprocessing +s,',!,g +# ----------- Section switching +s/\.text/TEXT1()\ + TEXT2()/ +# ----------- Declaration of symbols and labels is different +s/^\([A-Za-z0-9_.]\+\):$/DEF(\1)/ +# ----------- Label syntax is different +/\.LEVEL/!{ +s/\.L\([A-Za-z0-9_]\+\)/L(\1)/ +} +# ----------- Introduce macro syntax for assembler pseudo-ops +s/\.globl[ ]\([A-Za-z0-9_]\+\)/GLOBL(\1)/ +# ----------- Massage the beginning of functions +/\.type/{ +s/\.type[ ]\+\([A-Za-z0-9_]*\), *@function/DECLARE_FUNCTION(\1)/ +} +# ----------- Massage the end of functions +s/\.size[ ]\([A-Za-z0-9_]*\),\(.*\)/FUNEND(\1)/ +EOF + +sed -f $tmpscript1 | \ +sed -f $tmpscript2 + +eval "$tmpremove" diff --git a/common/asm-i386.h b/common/asm-i386.h new file mode 100644 index 0000000..ff1baab --- /dev/null +++ b/common/asm-i386.h @@ -0,0 +1,297 @@ +// Assembly language support for i386 CPU. +// Bruno Haible 1997-06-21 + +// Copyright (C) 1997-2018 Bruno Haible +// +// 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, see . + +// An assembly language file for the i386/i486/i586/i686/786 CPUs: +// On Unix, it is preprocessed and then assembled. NB: This file requires +// an ANSI C or C++ preprocessor which understands C++ comments. +// On Windows, with MSVC, it is preprocessed and then compiled with +// optimization. (The MSVC development environment does not have a separate +// assembler, we must use the C compiler's inline asm extension. Compiling +// without optimization pushes the registers %ebx,%esi,%edi onto the stack +// at function entry and pops them at function exit, which is not what we +// want because it affects the %esp offsets of the function arguments.) + +// The assembly language file should +// 1. include a configuration file which defines ASM_UNDERSCORE if appropriate. +// #ifndef _MSC_VER +// #include "config.h" +// #endif +// 2. include this file. +// #include "asm-i386.h" +// 3. define all assembly language code. + +// The three different assembler syntaxes for this CPU are a MAJOR annoyance. +// In order not to have to maintain several copies of the assembly language +// code, we use lots of macros which expand into the correct syntax. +// These macros are: +// C(name) +// This expands to the name of the C variable or function `name'. +// On Unix BSD systems, this prepends an underscore. +// L(label) +// This expands to the name of a local label, having the name `label'. +// On Unix ELF systems, where there is no underscore, names beginning +// with an alphabetic character are automatically exported, so this +// prepends a dot. Note that when defining a label, the `:' must +// be inside the parentheses, not outside, because otherwise some +// ANSI C preprocessor inserts a space between the label and the `:', +// and some assemblers don't like this. +// R(reg) +// This expands to a reference to register `reg'. On Unix, this +// prepends a % charater. +// NUM(value) +// This expands to an immediate value. On Unix, this prepends a $ +// character. +// ADDR(variable) +// This expands to an immediate value, the address of some variable +// or function. On Unix, this prepends a $ character. With MSVC, +// this prepends the keyword "OFFSET". +// About operand sizes: On Unix, a suffix to the instruction specifies the +// size of the operands (for example "movb", "movw", "movl"). With +// MSVC, there is no such suffix. Instead, the assembler infers the +// operand size from the names of the registers ("al" vs. "ax" vs. +// "eax"). This works well in most cases, but in instructions like +// "mul [esi]" the assembler guesses the operand size: "byte" by +// default. So it is better to explicitly specify the operand size +// of memory operands (prefix X1, X2, X4, X8). +// (Side note about Unix assemblers: Some Unix assemblers allow you +// to write "testb %eax,%eax" but silently treat this as +// "testb %al,%al".) +// X1 +// This prefixes a memory reference of 1 byte. +// X2 +// This prefixes a memory reference of 2 bytes. +// X4 +// This prefixes a memory reference of 4 bytes. +// X8 +// This prefixes a memory reference of 8 bytes. +// MEM(base) +// This expands to a memory reference at address `base'. +// MEM_DISP(base,displacement) +// This expands to a memory reference at address `base+displacement'. +// MEM_INDEX(base,index) +// This expands to a memory reference at address `base+index'. +// MEM_SHINDEX(base,index,size) +// This expands to a memory reference at address +// `base+index*size', where `size' is 1, 2, 4, or 8. +// MEM_DISP_SHINDEX0(displacement,index,size) +// This expands to a memory reference at address +// `displacement+index*size', where `size' is 1, 2, 4, or 8. +// MEM_DISP_SHINDEX(base,displacement,index,size) +// This expands to a memory reference at address +// `base+displacement+index*size', where `size' is 1, 2, 4, or 8. +// INDIR(value) +// This expands to an implicit indirection. On Unix, this prepends +// a * character. +// INSN1(mnemonic,size_suffix,dst) +// This expands to an instruction with one operand. +// INSN2(mnemonic,size_suffix,src,dst) +// This expands to an instruction with two operands. In our notation, +// `src' comes first and `dst' second, but they are reversed when +// expanding to Intel syntax. +// INSN2MOVXL(mnemonic,size_suffix,src,dst) +// This expands to an instruction with two operands, of type +// movsbl/movzbl, which in some syntaxes requires a second suffix. +// INSN2SHCL(mnemonic,size_suffix,src,dst) +// This expands to an instruction with two operands, of type +// shrd/shld, which in some syntaxes requires an additional operand +// %cl. +// REP, REPZ +// This expands to a prefix for string instructions. +// _ +// For instructions which don't have a size suffix, like jump +// instructions. Expands to nothing. Needed for MSVC, which has +// problems with empty macro arguments. +// TEXT() +// Switch to the code section. +// ALIGN(log) +// Align to 2^log bytes. +// P2ALIGN(log,max) +// Align to 2^log bytes, but insert at most max bytes. +// GLOBL(name) +// Declare `name' to be a global symbol. +// DECLARE_FUNCTION(name) +// Declare `name' to be a global function. When assembly language +// code is compiled into a shared library, ELF linkers need to know +// which symbols are functions. +// FUNBEGIN(name) +// Start the assembly language code for the C function `name'. +// FUNEND(name,size_expression) +// End the assembly language code for the C function 'name'. + +// Define the C(name) and L(label) macros. +#ifdef _MSC_VER +#define C(entrypoint) entrypoint +#define L(label) L##label +#else +#ifdef ASM_UNDERSCORE +#define C(entrypoint) _##entrypoint +#define L(label) L##label +#else +#define C(entrypoint) entrypoint +#define L(label) .L##label +#endif +#endif + +// Define one of these. +// BSD_SYNTAX for GNU assembler version 2. +// ELF_SYNTAX for SVR4 and Solaris assemblers. +// INTEL_SYNTAX for MS assembler. +// Note: INTEL_SYNTAX is not the same syntax as produced by "gcc masm=intel" +// as there are syntactic differences between that syntax and the one accepted +// by the MS assembler (for R, MEM_DISP, P2ALIGN, FUNBEGIN, FUNEND etc.). +#ifdef _MSC_VER +#define INTEL_SYNTAX +#else +// On Unix, it happens that the ELF systems (ASM_UNDERSCORE not defined) use +// the ELF syntax, while the BSD systems (ASM_UNDERSCORE defined) use the +// BSD syntax. Neat to know, this saves us from enumerating all the systems. +#ifdef ASM_UNDERSCORE +#define BSD_SYNTAX +#else +#define ELF_SYNTAX +#endif +#endif + +#if defined (BSD_SYNTAX) || defined (ELF_SYNTAX) +#define R(r) %r +#define NUM(n) $ n +#define ADDR(a) $##a +#define X1 +#define X2 +#define X4 +#define X8 +#define MEM(base)(R(base)) +#define MEM_DISP(base,displacement)displacement(R(base)) +#define MEM_INDEX(base,index)(R(base),R(index)) +#define MEM_SHINDEX(base,index,size)(R(base),R(index),size) +#define MEM_DISP_SHINDEX0(displacement,index,size)displacement(,R(index),size) +#define MEM_DISP_SHINDEX(base,displacement,index,size)displacement(R(base),R(index),size) +#define INDIR(value)*value +#define INSNCONC(mnemonic,size_suffix)mnemonic##size_suffix +#define INSN1(mnemonic,size_suffix,dst)INSNCONC(mnemonic,size_suffix) dst +#define INSN2(mnemonic,size_suffix,src,dst)INSNCONC(mnemonic,size_suffix) src,dst +#define INSN2MOVXL(mnemonic,size_suffix,src,dst)INSNCONC(mnemonic,size_suffix##l) src,dst +#if defined(__SVR4) /* Solaris */ +#define INSN2SHCL(mnemonic,size_suffix,src,dst)INSNCONC(mnemonic,size_suffix) src,dst +#else +#define INSN2SHCL(mnemonic,size_suffix,src,dst)INSNCONC(mnemonic,size_suffix) R(cl),src,dst +#endif +#if defined(BSD_SYNTAX) || defined(COHERENT) +#define REPZ repe ; +#else +#define REPZ repz ; +#endif +#define REP rep ; +#if defined(BSD_SYNTAX) && !(defined(__CYGWIN__) || defined(__MINGW32__)) +#define ALIGN(log) .align log,0x90 +#endif +#if defined(ELF_SYNTAX) || defined(__CYGWIN__) || defined(__MINGW32__) +#define ALIGN(log) .align 1< portable-asm-file +# The portable-asm-file has to be +# 1. preprocessed, +# 2. grep -v '^ *#line' | grep -v '^#' +# 3. sed -e 's,% ,%,g' -e 's,\. ,.,g' -e 's,@ ,@,g' -e 's,//.*$,,' -e 's/##//g' +# Warning! All comments are stripped. + +# Copyright (C) 1997-2018 Bruno Haible +# +# 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, see . + +tmpscript01=sed$$tmp01 +tmpscript02=sed$$tmp02 +tmpscript03=sed$$tmp03 +tmpscript04=sed$$tmp04 +tmpscript05=sed$$tmp05 +tmpscript06=sed$$tmp06 +tmpscript07=sed$$tmp07 +tmpscript08=sed$$tmp08 +tmpscript09=sed$$tmp09 +tmpscript10=sed$$tmp10 +tmpremove='rm -f $tmpscript01 $tmpscript02 $tmpscript03 $tmpscript04 $tmpscript05 $tmpscript06 $tmpscript07 $tmpscript08 $tmpscript09 $tmpscript10' +trap "$tmpremove" 1 2 15 + +cat > $tmpscript01 << \EOF +# ----------- Strip comments +s,# .*,, +s,[ ][ ]*$,, +EOF + +cat > $tmpscript02 << \EOF +# ----------- Remove #APP/#NO_APP lines and gcc self-identification, add a blank line at the end +/^#APP$/d +/^#NO_APP$/d +/gcc2_compiled/d +/gnu_compiled_c/d +/\.ident/d +EOF + +cat > $tmpscript03 << \EOF +# ----------- Global symbols depends on ASM_UNDERSCORE +s/^\([A-Za-z0-9_]\+\)/C(\1)/ +s/\.L\([A-Za-z0-9_]\+\)/L(\1)/ +# ----------- Massage the beginning of functions +/\.type/{ +s/\.type[ ]\([A-Za-z0-9_]*\), *@function/DECLARE_FUNCTION(\1)/ +} +# ----------- Massage the end of functions +s/\.size[ ]\([A-Za-z0-9_]*\),\(.*\)/FUNEND(\1,\2)/ +# ----------- Introduce conditionals for function references in PIC code +# Note: This is hairy. It assumes that the register clobbered with +# the 'addl $_GLOBAL_OFFSET_TABLE_ ...' instruction is the same as +# the register that the @GOTOFF instructions reference. +/^ addl \$_GLOBAL_OFFSET_TABLE_,/{ +x +s/.*/.LgotGOT/ +x +s/^ addl \$_GLOBAL_OFFSET_TABLE_, *\(%.*\)/#ifdef __ELF__\ + addl $_GLOBAL_OFFSET_TABLE_,\1\ +#else\ +.LgotGOT:\ +#endif/ +} +/^ addl \$_GLOBAL_OFFSET_TABLE_+\[\.-\(.*\)\],/{ +h +s/^ addl \$_GLOBAL_OFFSET_TABLE_+\[\.-\(.*\)\],.*/\1/ +x +s/^ addl \$_GLOBAL_OFFSET_TABLE_+\[\.-\(.*\)\], *\(%.*\)/#ifdef __ELF__\ + addl \$_GLOBAL_OFFSET_TABLE_+[.-\1],\2\ +#endif/ +} +/@GOTOFF(/{ +G +s/^ leal \([A-Za-z0-9_]\+\)@GOTOFF\(.*\)\ +\(.*\)/#ifdef __ELF__\ + leal \1@GOTOFF\2\ +#else\ + leal C(\1)-\3\2\ +#endif/ +} +EOF + +cat > $tmpscript04 << \EOF +# ----------- Introduce macro syntax for operands +s/\([-+0-9A-Z_]\+\)[(]%\(e..\)[)]/MEM_DISP(\2,\1)/g +s/[(]%\(e..\)[)]/MEM(\1)/g +s/\([-+0-9A-Z_]\+\)[(],%\(e..\),\([0-9]*\)[)]/MEM_DISP_SHINDEX0(\1,\2,\3)/g +s/\([-+0-9A-Z_]\+\)[(]%\(e..\),%\(e..\),\([0-9]*\)[)]/MEM_DISP_SHINDEX(\2,\1,\3,\4)/g +s/[(]%\(e..\),%\(e..\),\([0-9]*\)[)]/MEM_SHINDEX(\1,\2,\3)/g +s/[(]%\(e..\),%\(e..\)[)]/MEM_INDEX(\1,\2)/g +EOF + +cat > $tmpscript05 << \EOF +# ----------- Introduce macro syntax for instructions +s/\(push\|pop\|mul\|div\|not\|neg\|inc\|dec\|fld\|fstp\)\(.\)\([ ]\+\)\(.*\)$/INSN1(\1,\2 ,\4)/ +s/\(call\|jmp\|jc\|jnc\|je\|jne\|jz\|jnz\|ja\|jae\|jb\|jbe\|jl\|jge\|js\|jns\)\([ ]\+\)\(.*\)$/INSN1(\1,_ ,\3)/ +s/\(movs\|movz\)\(.\)l\([ ]\+\)\(.*\)$/INSN2MOVXL(\1,\2,\4)/ +s/\(mov\|add\|sub\|adc\|sbb\|xor\|test\|cmp\|rcl\|rcr\|and\|or\|sar\|shr\|shl\|lea\)\(.\)\([ ]\+\)\(.*\)$/INSN2(\1,\2 ,\4)/ +s/\(shld\|shrd\)\(.\)\([ ]\+\)%cl,[ ]*\(.*\)$/INSN2SHCL(\1,\2 ,\4)/ +s/rep[ ];/REP/ +s/repz[ ];/REPZ/ +EOF + +cat > $tmpscript06 << \EOF +# ----------- Add size prefixes to memory references +s/\([(]f[^(,]*,s.*\), *MEM/\1,X4 MEM/g +s/\([(]f[^(,]*,l.*\), *MEM/\1,X8 MEM/g +s/\([(][^(,]*,b.*\), *MEM/\1,X1 MEM/g +s/\([(][^(,]*,w.*\), *MEM/\1,X2 MEM/g +s/\([(][^(,]*,l.*\), *MEM/\1,X4 MEM/g +EOF + +cat > $tmpscript07 << \EOF +# ----------- Introduce macro syntax for register names +s/%\(e..\)/R(\1)/g +s/%\(..\)/R(\1)/g +s/\$\([-0-9]*\)/NUM(\1)/g +EOF + +cat > $tmpscript08 << \EOF +# ----------- Treat table jumps (hairy) +# (Needed because the MSVC inline assembler does not have pseudo-ops. +# Note that we transform a table of absolute addresses with 4 bytes +# per entry into a table of absolute addresses with 8 bytes per entry.) +s/^ \.long \(.*\)$/#ifdef _MSC_VER\ + nop\ + nop\ + push \1\ +#else\ + .long \1\ +#endif/ +s/^ \(INSN1[(]jmp,_[^,]*,\)\*MEM_DISP_SHINDEX0[(]\([^,)]*\),\([^,)]*\),4[)][)]$/#ifdef _MSC_VER\ + INSN2(lea,l ,MEM_DISP_SHINDEX0(\2+8,\3,8),R(\3))\ + INSN2(mov,l ,X4 MEM_DISP(\3,-4),R(\3))\ + INSN1(jmp,_ ,INDIR(R(\3)))\ +#else\ + \1INDIR(MEM_DISP_SHINDEX0(\2,\3,4)))\ +#endif/ +EOF + +cat > $tmpscript09 << \EOF +# ----------- Treat indirect calls +s/\(INSN1[(]\(call\|jmp\),_[^,]*,\)\*\(\(R\)[(][^)]*[)]\)[)]$/\1INDIR(\3))/ +s/\(INSN1[(]\(call\|jmp\),_[^,]*,\)\*\(\(MEM\|MEM_DISP\|C\)[(][^)]*[)]\)[)]$/\1INDIR(X4 \3))/ +EOF + +cat > $tmpscript10 << \EOF +# ----------- Introduce macro syntax for assembler pseudo-ops +/\.file\([ ]\+\)/d +s/\.text/TEXT()/ +s/^\([^#]*\)\.align \(.*\)/\1ALIGN(\2)/ +s/\.p2align \([^,]*\),,\(.*\)/P2ALIGN(\1,\2)/ +s/\.globl\( \+\)\(.*\)$/GLOBL(C(\2))/ +# ----------- Declare global symbols as functions (we have no variables) +s/^C(\([A-Za-z0-9_]*\)):/FUNBEGIN(\1)/ +EOF + +sed -f $tmpscript01 | \ +sed -f $tmpscript02 | \ +(cat - ; echo) | \ +(if [ $# = 1 -a "x$1" = "x-no-C" ] ; then cat - ; else sed -f $tmpscript03 ; fi) | \ +sed -f $tmpscript04 | \ +sed -f $tmpscript05 | \ +sed -f $tmpscript06 | \ +sed -f $tmpscript07 | \ +sed -f $tmpscript08 | \ +sed -f $tmpscript09 | \ +sed -f $tmpscript10 + +eval "$tmpremove" + diff --git a/common/asm-m68k.h b/common/asm-m68k.h new file mode 100644 index 0000000..736a7c3 --- /dev/null +++ b/common/asm-m68k.h @@ -0,0 +1,61 @@ +// Assembly language support for m68k CPU. +// Bruno Haible 1999-05-29 + +// Copyright (C) 1999-2017 Bruno Haible +// +// 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, see . + +// In order not to have to maintain several copies of the assembly language +// code, we use some macros which expand into the correct syntax. +// These macros are: +// C(name) +// This expands to the name of the C variable or function `name'. +// On Unix BSD systems, this prepends an underscore. +// L(label) +// This expands to the name of a local label, having the name `label'. +// On Unix ELF systems, where there is no underscore, names beginning +// with an alphabetic character are automatically exported, so this +// prepends a dot. Note that when defining a label, the `:' must +// be inside the parentheses, not outside, because otherwise some +// ANSI C preprocessor inserts a space between the label and the `:', +// and some assemblers don't like this. +// DECLARE_FUNCTION(name) +// Declare `name' to be a global function. When assembly language +// code is compiled into a shared library, ELF linkers need to know +// which symbols are functions. +// FUNBEGIN(name) +// Start the assembly language code for the C function `name'. +// FUNEND(name) +// End the assembly language code for the C function 'name'. + +#ifdef ASM_UNDERSCORE +// SunOS, NetBSD, OpenBSD, Linux/a.out +#define C(entrypoint) _##entrypoint +#define L(label) L##label +#else +// SVR4, A/UX, AMIX, Atari, Linux/ELF +#define C(entrypoint) entrypoint +#define L(label) .L##label +#endif + +// When assembly language code is compiled into a shared library, ELF linkers +// need to know which symbols are functions. +#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__ELF__) || defined(__svr4__) +#define DECLARE_FUNCTION(name) .type C(name),@function +#define FUNEND(name) .size C(name),.-C(name) +#else +#define DECLARE_FUNCTION(name) +#define FUNEND(name) +#endif +#define FUNBEGIN(name) C(name): diff --git a/common/asm-m68k.sh b/common/asm-m68k.sh new file mode 100755 index 0000000..7912b19 --- /dev/null +++ b/common/asm-m68k.sh @@ -0,0 +1,96 @@ +#!/bin/sh +# Translate the assembler syntax of m68k assembler programs +# Usage: asm-m68k.sh < sunos-asm-file > portable-asm-file +# The portable-asm-file has to be +# 1. preprocessed, +# 2. grep -v '^ *#line' | grep -v '^#' +# 3. sed -e 's,% ,%,g' -e 's,//.*$,,' + +# Copyright (C) 1999-2017 Bruno Haible +# +# 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, see . + +syntax="$1" + +case "$syntax" in + "") echo "missing syntax" 1>&2; exit 1;; + mit | motorola) ;; + *) echo "invalid syntax: $syntax" 1>&2; exit 1;; +esac + +tmpscript1=sed$$tmp1 +tmpscript2=sed$$tmp2 +tmpremove='rm -f $tmpscript1 $tmpscript2' +trap "$tmpremove" 1 2 15 + +cat > $tmpscript1 << \EOF +# ----------- Remove #APP/#NO_APP lines +/^#APP$/d +/^#NO_APP$/d +# ----------- Remove gcc self-identification +/gcc2_compiled/d +/gnu_compiled_c/d +/\.ident/d +EOF + +if test $syntax = mit; then +cat > $tmpscript2 << \EOF +# ----------- Global symbols depends on ASM_UNDERSCORE +s/^L\([A-Za-z0-9_]\+\)/L(\1)/ +s/ L\([A-Za-z0-9_]\+\)/ L(\1)/ +# ----------- Prefix register names with $, to be turned into % later +s/,/, /g +s/\([^A-Za-z0-9_]\)\([ad][0-7]\|sp\|fp[0-7]\|pc\)\([^A-Za-z0-9_]\)/\1$\2\3/g +s/\([^A-Za-z0-9_]\)\([ad][0-7]\|sp\|fp[0-7]\|pc\)$/\1$\2/g +s/, /,/g +# ----------- Declare global symbols as functions (we have no variables) +s/\.globl[ ]_\([A-Za-z0-9_]*\)$/.globl _\1\ + DECLARE_FUNCTION(\1)/ +# ----------- Global symbols depends on ASM_UNDERSCORE +s/_\([A-Za-z0-9_]*\)/C(\1)/ +s/^C(\([A-Za-z0-9_]*\)):/FUNBEGIN(\1)/ +/FUNBEGIN(/{ +h +} +${ +p +s/.*// +x +s/FUNBEGIN/FUNEND/ +} +EOF +fi + +if test $syntax = motorola; then +cat > $tmpscript2 << \EOF +# ----------- Global symbols depends on ASM_UNDERSCORE +s/^\([A-Za-z0-9_]\+\)/C(\1)/ +s/\.L\([A-Za-z0-9_]\+\)/L(\1)/ +s/\.globl[ ]\([A-Za-z0-9_]*\)/.globl C(\1)/ +# ----------- Introduce macro syntax for assembler pseudo-ops +/\.file\([ ]\+\)/d +s/^C(\([A-Za-z0-9_]*\)):/FUNBEGIN(\1)/ +# ----------- Massage the beginning of functions +/\.type/{ +s/\.type[ ]\([A-Za-z0-9_]*\), *@function/DECLARE_FUNCTION(\1)/ +} +# ----------- Massage the end of functions +s/\.size[ ]\([A-Za-z0-9_]*\),\(.*\)/FUNEND(\1)/ +EOF +fi + +sed -f $tmpscript1 | \ +sed -f $tmpscript2 + +eval "$tmpremove" diff --git a/common/asm-mips.h b/common/asm-mips.h new file mode 100644 index 0000000..0d6f20b --- /dev/null +++ b/common/asm-mips.h @@ -0,0 +1,25 @@ +// Assembly language support for mips CPU. +// Bruno Haible 1999-05-29 + +// Copyright (C) 1999-2017 Bruno Haible +// +// 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, see . + +// When assembly language code is compiled into a shared library, ELF linkers +// need to know which symbols are functions. +#if defined(__ELF__) || defined(__NetBSD__) +#define DECLARE_FUNCTION(name) .type name,@function +#else +#define DECLARE_FUNCTION(name) +#endif diff --git a/common/asm-mips.sh b/common/asm-mips.sh new file mode 100755 index 0000000..5f57256 --- /dev/null +++ b/common/asm-mips.sh @@ -0,0 +1,54 @@ +#!/bin/sh +# Translate the assembler syntax of mips assembler programs +# Usage: asm-mips.sh < irix-asm-file > portable-asm-file +# The portable-asm-file has to be +# 1. preprocessed, +# 2. grep -v '^ *#line' | grep -v '^#' +# 3. sed -e 's,% ,%,g' -e 's,//.*$,,' + +# Copyright (C) 1999-2019 Bruno Haible +# +# 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, see . + +tmpscript1=sed$$tmp1 +tmpscript2=sed$$tmp2 +tmpremove='rm -f $tmpscript1 $tmpscript2' +trap "$tmpremove" 1 2 15 + +cat > $tmpscript1 << \EOF +# ----------- Remove gcc self-identification +/gcc2_compiled/d +/gnu_compiled_c/d +/\.ident/d +EOF + +cat > $tmpscript2 << \EOF +# ----------- Remove comments, they would cause trouble in preprocessing +s,#.*$,, +# ----------- Remove assembler pseudo-ops that the IRIX assembler does not understand +/\.section/d +/\.previous/d +/\.abicalls/d +/\.nan/d +/\.module/d +# ----------- Massage the beginning of functions +/\.type/{ +s/\.type[ ]\+\([A-Za-z0-9_]*\), *@function/DECLARE_FUNCTION(\1)/ +} +EOF + +sed -f $tmpscript1 | \ +sed -f $tmpscript2 + +eval "$tmpremove" diff --git a/common/asm-powerpc.sh b/common/asm-powerpc.sh new file mode 100755 index 0000000..432ed7b --- /dev/null +++ b/common/asm-powerpc.sh @@ -0,0 +1,46 @@ +#!/bin/sh +# Translate the assembler syntax of powerpc assembler programs +# Usage: asm-powerpc.sh < powerpclinux-asm-file > portable-asm-file +# The portable-asm-file has to be +# 1. preprocessed, +# 2. grep -v '^ *#line' | grep -v '^#' +# 3. sed -e 's,% ,%,g' -e 's,//.*$,,' + +# Copyright (C) 2017 Bruno Haible +# +# 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, see . + +tmpscript1=sed$$tmp1 +tmpscript2=sed$$tmp2 +tmpremove='rm -f $tmpscript1 $tmpscript2' +trap "$tmpremove" 1 2 15 + +cat > $tmpscript1 << \EOF +# ----------- Remove #APP/#NO_APP lines and gcc self-identification +/^#APP$/d +/^#NO_APP$/d +/gcc2_compiled/d +/gnu_compiled_c/d +/\.ident/d +EOF + +cat > $tmpscript2 << \EOF +# ----------- Introduce macro syntax for assembler pseudo-ops +/\.section\([ ]\+\).*GNU-stack/d +EOF + +sed -f $tmpscript1 | \ +sed -f $tmpscript2 + +eval "$tmpremove" diff --git a/common/asm-riscv.sh b/common/asm-riscv.sh new file mode 100755 index 0000000..5ef6b80 --- /dev/null +++ b/common/asm-riscv.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# Translate the assembler syntax of RISC-V assembler programs +# Usage: asm-riscv.sh < riscvlinux-asm-file > portable-asm-file +# The portable-asm-file has to be +# 1. preprocessed, +# 2. grep -v '^ *#line' | grep -v '^#' +# 3. sed -e 's,% ,%,g' -e 's,//.*$,,' + +# Copyright (C) 2017-2018 Bruno Haible +# +# 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, see . + +tmpscript1=sed$$tmp1 +tmpscript2=sed$$tmp2 +tmpremove='rm -f $tmpscript1 $tmpscript2' +trap "$tmpremove" 1 2 15 + +cat > $tmpscript1 << \EOF +# ----------- Remove gcc self-identification +/gcc2_compiled/d +/gnu_compiled_c/d +/\.ident/d +EOF + +cat > $tmpscript2 << \EOF +# ----------- Introduce macro syntax for assembler pseudo-ops +/\.section\([ ]\+\).*GNU-stack/d +EOF + +sed -f $tmpscript1 | \ +sed -f $tmpscript2 + +eval "$tmpremove" diff --git a/common/asm-s390.sh b/common/asm-s390.sh new file mode 100755 index 0000000..5d9f1e9 --- /dev/null +++ b/common/asm-s390.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# Translate the assembler syntax of s390/s390x assembler programs +# Usage: asm-s390.sh < s390linux-asm-file > portable-asm-file +# The portable-asm-file has to be +# 1. preprocessed, +# 2. grep -v '^ *#line' | grep -v '^#' +# 3. sed -e 's,% ,%,g' -e 's,//.*$,,' + +# Copyright (C) 2017 Bruno Haible +# +# 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, see . + +tmpscript1=sed$$tmp1 +tmpscript2=sed$$tmp2 +tmpremove='rm -f $tmpscript1 $tmpscript2' +trap "$tmpremove" 1 2 15 + +cat > $tmpscript1 << \EOF +# ----------- Remove gcc self-identification +/gcc2_compiled/d +/gnu_compiled_c/d +/\.ident/d +EOF + +cat > $tmpscript2 << \EOF +# ----------- Introduce macro syntax for assembler pseudo-ops +/\.section\([ ]\+\).*GNU-stack/d +EOF + +sed -f $tmpscript1 | \ +sed -f $tmpscript2 + +eval "$tmpremove" diff --git a/common/asm-sparc.h b/common/asm-sparc.h new file mode 100644 index 0000000..40eb787 --- /dev/null +++ b/common/asm-sparc.h @@ -0,0 +1,69 @@ +// Assembly language support for sparc CPU. +// Bruno Haible 1999-05-29 + +// Copyright (C) 1999-2017 Bruno Haible +// +// 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, see . + +// In order not to have to maintain several copies of the assembly language +// code, we use some macros which expand into the correct syntax. +// These macros are: +// C(name) +// This expands to the name of the C variable or function `name'. +// On Unix BSD systems, this prepends an underscore. +// L(label) +// This expands to the name of a local label, having the name `label'. +// On Unix ELF systems, where there is no underscore, names beginning +// with an alphabetic character are automatically exported, so this +// prepends a dot. Note that when defining a label, the `:' must +// be inside the parentheses, not outside, because otherwise some +// ANSI C preprocessor inserts a space between the label and the `:', +// and some assemblers don't like this. +// DECLARE_FUNCTION(name) +// Declare `name' to be a global function. When assembly language +// code is compiled into a shared library, ELF linkers need to know +// which symbols are functions. +// FUNBEGIN(name) +// Start the assembly language code for the C function `name'. +// FUNEND(name) +// End the assembly language code for the C function 'name'. + +#ifdef ASM_UNDERSCORE +// SunOS4, Linux/a.out +#define C(entrypoint) _##entrypoint +#define L(label) L##label +#else +// Solaris, Linux/ELF +#define C(entrypoint) entrypoint +#define L(label) .L##label +#endif + +// When assembly language code is compiled into a shared library, ELF linkers +// need to know which symbols are functions. +#if defined(__NetBSD__) || defined(__OpenBSD__) +#define DECLARE_FUNCTION(name) .type C(name),@function +#define FUNEND(name) .size C(name),.-C(name) +#elif defined(__SVR4) || defined(__ELF__) +// Solaris, Linux/ELF +// Some preprocessors keep the backslash in place, some don't. +// Some complain about the # being not in front of an ANSI C macro. +// Therefore we use a dollar, which will be sed-converted to # later. +#define DECLARE_FUNCTION(name) .type C(name),$function +#define FUNEND(name) .size C(name),.-C(name) +#else +// SunOS4, Linux/a.out +#define DECLARE_FUNCTION(name) +#define FUNEND(name) +#endif +#define FUNBEGIN(name) C(name): diff --git a/common/asm-sparc.sh b/common/asm-sparc.sh new file mode 100755 index 0000000..954ede4 --- /dev/null +++ b/common/asm-sparc.sh @@ -0,0 +1,58 @@ +#!/bin/sh +# Translate the assembler syntax of sparc64 assembler programs +# Usage: asm-sparc.sh < sparclinux-asm-file > portable-asm-file +# The portable-asm-file has to be +# 1. preprocessed, +# 2. grep -v '^ *#line' | grep -v '^#' +# 3. sed -e 's,% ,%,g' -e 's,//.*$,,' -e 's,\$,#,g' -e 's,# ,#,g' + +# Copyright (C) 1999-2017 Bruno Haible +# +# 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, see . + +tmpscript1=sed$$tmp1 +tmpscript2=sed$$tmp2 +tmpremove='rm -f $tmpscript1 $tmpscript2' +trap "$tmpremove" 1 2 15 + +cat > $tmpscript1 << \EOF +# ----------- Remove gcc self-identification +/gcc2_compiled/d +/gnu_compiled_c/d +/\.ident/d +EOF + +cat > $tmpscript2 << \EOF +# ----------- Global symbols depends on ASM_UNDERSCORE +s/^\([A-Za-z0-9_]\+\)/C(\1)/ +s/\.L\([A-Za-z0-9_]\+\)/L(\1)/ +s/\.global[ ]\([A-Za-z0-9_]*\)$/.global C(\1)/ +# ----------- Introduce macro syntax for assembler pseudo-ops +/\.file\([ ]\+\)/d +/\.section\([ ]\+\).*GNU-stack/d +s/^C(\([A-Za-z0-9_]*\)):/FUNBEGIN(\1)/ +# ----------- Massage the beginning of functions +/\.type/{ +s/\.type[ ]\([A-Za-z0-9_]*\), *#function/DECLARE_FUNCTION(\1)/ +} +# ----------- Massage the end of functions +s/\.size[ ]\([A-Za-z0-9_]*\),\(.*\)/FUNEND(\1)/ +# ----------- Turn # into $, to avoid trouble in preprocessing +s,#,\$,g +EOF + +sed -f $tmpscript1 | \ +sed -f $tmpscript2 + +eval "$tmpremove" diff --git a/common/asm-x86_64.h b/common/asm-x86_64.h new file mode 100644 index 0000000..99a51e8 --- /dev/null +++ b/common/asm-x86_64.h @@ -0,0 +1,285 @@ +// Assembly language support for x86_64 CPU. +// Bruno Haible 2016-12-28 + +// Copyright (C) 1997-2018 Bruno Haible +// +// 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, see . + +// In order not to have to maintain several copies of the assembly language +// code, we use some macros which expand into the correct syntax. +// These macros are: +// C(name) +// This expands to the name of the C variable or function `name'. +// On Unix BSD systems, this prepends an underscore. +// L(label) +// This expands to the name of a local label, having the name `label'. +// On Unix ELF systems, where there is no underscore, names beginning +// with an alphabetic character are automatically exported, so this +// prepends a dot. Note that when defining a label, the `:' must +// be inside the parentheses, not outside, because otherwise some +// ANSI C preprocessor inserts a space between the label and the `:', +// and some assemblers don't like this. +// R(reg) +// This expands to a reference to register `reg'. On Unix, this +// prepends a % charater. +// NUM(value) +// This expands to an immediate value. On Unix, this prepends a $ +// character. +// ADDR(variable) +// This expands to an immediate value, the address of some variable +// or function. On Unix, this prepends a $ character. With MSVC, +// this prepends the keyword "OFFSET". +// ADDR_PCRELATIVE(variable) +// This expands to the address of symbol `variable', with program +// counter (%rip) relative addressing. +// About operand sizes: On Unix, a suffix to the instruction specifies the +// size of the operands (for example "movb", "movw", "movl"). With +// MSVC, there is no such suffix. Instead, the assembler infers the +// operand size from the names of the registers ("al" vs. "ax" vs. +// "eax"). This works well in most cases, but in instructions like +// "mul [esi]" the assembler guesses the operand size: "byte" by +// default. So it is better to explicitly specify the operand size +// of memory operands (prefix X1, X2, X4, X8). +// (Side note about Unix assemblers: Some Unix assemblers allow you +// to write "testb %eax,%eax" but silently treat this as +// "testb %al,%al".) +// X1 +// This prefixes a memory reference of 1 byte. +// X2 +// This prefixes a memory reference of 2 bytes. +// X4 +// This prefixes a memory reference of 4 bytes. +// X8 +// This prefixes a memory reference of 8 bytes. +// MEM(base) +// This expands to a memory reference at address `base'. +// MEM_DISP(base,displacement) +// This expands to a memory reference at address `base+displacement'. +// MEM_INDEX(base,index) +// This expands to a memory reference at address `base+index'. +// MEM_SHINDEX(base,index,size) +// This expands to a memory reference at address +// `base+index*size', where `size' is 1, 2, 4, or 8. +// MEM_DISP_SHINDEX0(displacement,index,size) +// This expands to a memory reference at address +// `displacement+index*size', where `size' is 1, 2, 4, or 8. +// MEM_DISP_SHINDEX(base,displacement,index,size) +// This expands to a memory reference at address +// `base+displacement+index*size', where `size' is 1, 2, 4, or 8. +// MEM_PCRELATIVE(variable) +// This expands to a memory reference at symbol `variable', with +// program counter (%rip) relative addressing. +// INDIR(value) +// This expands to an implicit indirection. On Unix, this prepends +// a * character. +// INSN1(mnemonic,size_suffix,dst) +// This expands to an instruction with one operand. +// INSN2(mnemonic,size_suffix,src,dst) +// This expands to an instruction with two operands. In our notation, +// `src' comes first and `dst' second, but they are reversed when +// expanding to Intel syntax. In Intel syntax, size_suffix is omitted. +// INSN2S(mnemonic,size_suffix,src,dst) +// This expands to an instruction with two operands. In our notation, +// `src' comes first and `dst' second, but they are reversed when +// expanding to Intel syntax. In Intel syntax, size_suffix is +// preserved. +// INSN2MOVXL(mnemonic,size_suffix,src,dst) +// This expands to an instruction with two operands, of type +// movsbl/movzbl, which in some syntaxes requires a second suffix. +// INSN2MOVXQ(mnemonic,size_suffix,src,dst) +// This expands to an instruction with two operands, of type +// movsbq/movzbq, which in some syntaxes requires a second suffix. +// INSN2MOVXLQ(mnemonic,size_suffix,src,dst) +// This expands to an instruction with two operands, of type +// movslq/movzlq, which in some syntaxes requires a second suffix. +// _ +// For instructions which don't have a size suffix, like jump +// instructions. Expands to nothing. Needed for MSVC, which has +// problems with empty macro arguments. +// TEXT() +// Switch to the code section. +// P2ALIGN(log,max) +// Align to 2^log bytes, but insert at most max bytes. +// GLOBL(name) +// Declare `name' to be a global symbol. +// DECLARE_FUNCTION(name) +// Declare `name' to be a global function. When assembly language +// code is compiled into a shared library, ELF linkers need to know +// which symbols are functions. +// FUNBEGIN(name) +// Start the assembly language code for the C function `name'. +// FUNEND(name,size_expression) +// End the assembly language code for the C function 'name'. +// EH_FRAME_SECTION +// The arguments to the .section statement that introduces the +// exception handler section (on ELF platforms). + +#ifdef _MSC_VER +// MSVC +#define C(entrypoint) entrypoint +#define L(label) $L##label +#else +#ifdef ASM_UNDERSCORE +// Mac OS X +#define C(entrypoint) _##entrypoint +#define L(label) L##label +#else +// Linux/ELF, Solaris/ELF, Windows with GNU as +#define C(entrypoint) entrypoint +#define L(label) .L##label +#endif +#endif + +// The two syntaxes: +// - ATT_SYNTAX for GNU assembler version 2. +// - INTEL_SYNTAX for MS assembler. +// Note: INTEL_SYNTAX is not the same syntax as produced by "gcc masm=intel" +// as there are syntactic differences between that syntax and the one accepted +// by the MS assembler (for MEM_DISP, INDIR, P2ALIGN, FUNBEGIN, FUNEND etc.). +#ifdef _MSC_VER +// MS assembler +#define R(r) r +#define NUM(n) n +#define ADDR(a) OFFSET a +#define ADDR_PCRELATIVE(a) OFFSET a +#define X1 BYTE PTR +#define X2 WORD PTR +#define X4 DWORD PTR +#define X8 QWORD PTR +#define MEM(base) [base] +#define MEM_DISP(base,displacement) [base+(displacement)] +#define MEM_INDEX(base,index) [base+index] +#define MEM_SHINDEX(base,index,size) [base+index*size] +#define MEM_DISP_SHINDEX0(displacement,index,size) [(displacement)+index*size] +#define MEM_DISP_SHINDEX(base,displacement,index,size) [base+(displacement)+index*size] +#define MEM_PCRELATIVE(variable) variable +#define INDIR(value)value +#define INSNCONC(mnemonic,suffix)mnemonic##suffix +#define INSN1(mnemonic,size_suffix,dst)mnemonic dst +#define INSN2(mnemonic,size_suffix,src,dst)mnemonic dst,src +#define INSN2S(mnemonic,size_suffix,src,dst)INSNCONC(mnemonic,size_suffix) dst,src +#define INSN2MOVXL(mnemonic,size_suffix,src,dst)INSNCONC(mnemonic,x) dst,src +#define INSN2MOVXQ(mnemonic,size_suffix,src,dst)INSNCONC(mnemonic,x) dst,src +#define INSN2MOVXLQ(mnemonic,size_suffix,src,dst)INSNCONC(mnemonic,xd) dst,src +#else +// GNU assembler version 2 +#define R(r) %r +#define NUM(n) $ n +#define ADDR(a) $##a +#define ADDR_PCRELATIVE(a) a(%rip) +#define X1 +#define X2 +#define X4 +#define X8 +#define MEM(base)(R(base)) +#define MEM_DISP(base,displacement)displacement(R(base)) +#define MEM_INDEX(base,index)(R(base),R(index)) +#define MEM_SHINDEX(base,index,size)(R(base),R(index),size) +#define MEM_DISP_SHINDEX0(displacement,index,size)displacement(,R(index),size) +#define MEM_DISP_SHINDEX(base,displacement,index,size)displacement(R(base),R(index),size) +#define MEM_PCRELATIVE(variable) variable(%rip) +#define INDIR(value)*value +#define INSNCONC(mnemonic,size_suffix)mnemonic##size_suffix +#define INSN1(mnemonic,size_suffix,dst)INSNCONC(mnemonic,size_suffix) dst +#define INSN2(mnemonic,size_suffix,src,dst)INSNCONC(mnemonic,size_suffix) src,dst +#define INSN2S(mnemonic,size_suffix,src,dst)INSNCONC(mnemonic,size_suffix) src,dst +#define INSN2MOVXL(mnemonic,size_suffix,src,dst)INSNCONC(mnemonic,size_suffix##l) src,dst +#define INSN2MOVXQ(mnemonic,size_suffix,src,dst)INSNCONC(mnemonic,size_suffix##q) src,dst +#define INSN2MOVXLQ(mnemonic,size_suffix,src,dst)INSNCONC(mnemonic,size_suffix##q) src,dst +#endif + +#define _ + +#ifdef _MSC_VER +// MS assembler +#define TEXT() _TEXT SEGMENT +#else +#define TEXT() .text +#endif + +#ifdef _MSC_VER +// MS assembler +// There is no equivalent for "p2align 4,,7". This comes closest: +#define P2ALIGN(log,max) ALIGN 8 +#else +#if defined __sun +// Solaris +#define P2ALIGN(log,max) .align 1< portable-asm-file +# The portable-asm-file has to be +# 1. preprocessed, +# 2. grep -v '^ *#line' | grep -v '^#' +# 3. sed -e 's,% ,%,g' -e 's,\. ,.,g' -e 's,@ ,@,g' -e 's,//.*$,,' -e 's/##//g' + +# Copyright (C) 1997-2018 Bruno Haible +# +# 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, see . + +tmpscript1=sed$$tmp1 +tmpscript2=sed$$tmp2 +tmpscript3=sed$$tmp3 +tmpscript4=sed$$tmp4 +tmpscript5=sed$$tmp5 +tmpscript6=sed$$tmp6 +tmpscript7=sed$$tmp7 +tmpscript8=sed$$tmp8 +tmpscript9=sed$$tmp9 +tmpremove='rm -f $tmpscript1 $tmpscript2 $tmpscript3 $tmpscript4 $tmpscript5 $tmpscript6 $tmpscript7 $tmpscript8 $tmpscript9' +trap "$tmpremove" 1 2 15 + +cat > $tmpscript1 << \EOF +# ----------- Remove #APP/#NO_APP lines and gcc self-identification +/^#APP$/d +/^#NO_APP$/d +/gcc2_compiled/d +/gnu_compiled_c/d +/\.ident/d +EOF + +cat > $tmpscript2 << \EOF +# ----------- Global symbols depends on ASM_UNDERSCORE +s/^\([A-Za-z0-9_]\+\)/C(\1)/ +s/\.L\([A-Za-z0-9_]\+\)/L(\1)/ +s/\([A-Za-z0-9_]\+\)(%rip)/C(\1)(%rip)/ +# ----------- Massage the beginning of functions +/\.type/{ +s/\.type \([A-Za-z0-9_]*\), *@function/DECLARE_FUNCTION(\1)/ +} +# ----------- Massage the end of functions +s/\.size \([A-Za-z0-9_]*\),\(.*\)/FUNEND(\1,\2)/ +# ----------- Section of frame info for exception handlers +s/\.section \.eh_frame,"a[w]*",@progbits/.section EH_FRAME_SECTION/ +# ----------- Disable the frame info for exception handlers on Solaris +# (as the Solaris linker expects a different format, see +# https://illumos.org/issues/3210) +# Likewise this section does not assemble on Mac OS X 10.5 and on Windows. +/EH_FRAME_SECTION/{ +s/^/#if !(defined __sun || (defined __APPLE__ \&\& defined __MACH__) || (defined _WIN32 || defined __CYGWIN__))\ +/ +} +${ +s/$/\ +#endif/ +} +EOF + +cat > $tmpscript3 << \EOF +# ----------- Introduce macro syntax for operands +s/\([-+0-9A-Z_]\+\)[(]%\(r[abcd]x\|r[sd]i\|r[bs]p\|r[89]\|r1[012345]\)[)]/MEM_DISP(\2,\1)/g +s/\(C[(][A-Za-z0-9_]\+[)]\)[(]%rip[)]/MEM_PCRELATIVE(\1)/g +s/[(]%\(r[abcd]x\|r[sd]i\|r[bs]p\|r[89]\|r1[012345]\)[)]/MEM(\1)/g +s/\([-+0-9A-Z_]\+\)[(],%\(r[abcd]x\|r[sd]i\|r[bs]p\|r[89]\|r1[012345]\),\([0-9]*\)[)]/MEM_DISP_SHINDEX0(\1,\2,\3)/g +s/\([-+0-9A-Z_]\+\)[(]%\(r[abcd]x\|r[sd]i\|r[bs]p\|r[89]\|r1[012345]\),%\(r[abcd]x\|r[sd]i\|r[bs]p\|r[89]\|r1[012345]\),\([0-9]*\)[)]/MEM_DISP_SHINDEX(\2,\1,\3,\4)/g +s/[(]%\(r[abcd]x\|r[sd]i\|r[bs]p\|r[89]\|r1[012345]\),%\(r[abcd]x\|r[sd]i\|r[bs]p\|r[89]\|r1[012345]\),\([0-9]*\)[)]/MEM_SHINDEX(\1,\2,\3)/g +s/[(]%\(r[abcd]x\|r[sd]i\|r[bs]p\|r[89]\|r1[012345]\),%\(r[abcd]x\|r[sd]i\|r[bs]p\|r[89]\|r1[012345]\)[)]/MEM_INDEX(\1,\2)/g +EOF + +cat > $tmpscript4 << \EOF +# ----------- Add size suffix to 'mov' instructions +s/mov\([ ]\+.*, *%\(e[abcd]x\|e[sd]i\|e[bs]p\|r[89]d\|r1[012345]d\)\)$/movl\1/ +# ----------- Introduce macro syntax for instructions +s/\(push\|pop\|mul\|div\|not\|neg\|inc\|dec\)\(.\)\([ ]\+\)\(.*\)$/INSN1(\1,\2 ,\4)/ +s/\(call\|jmp\|jc\|jnc\|je\|jne\|jz\|jnz\|ja\|jae\|jb\|jbe\|jl\|jle\|jg\|jge\|js\|jns\)\([ ]\+\)\(.*\)$/INSN1(\1,_ ,\3)/ +s/\(movs\|movz\)\(.\)l\([ ]\+\)\(.*\)$/INSN2MOVXL(\1,\2,\4)/ +s/\(movs\|movz\)\([bw]\)q\([ ]\+\)\(.*\)$/INSN2MOVXQ(\1,\2,\4)/ +s/\(movs\|movz\)\(l\)q\([ ]\+\)\(.*\)$/INSN2MOVXLQ(\1,\2,\4)/ +s/\(mov\|movlp\|add\|sub\|adc\|sbb\|xor\|xorp\|test\|cmp\|rcl\|rcr\|and\|or\|sar\|sal\|shr\|shl\|lea\)\(.\)\([ ]\+\)\(.*\)$/INSN2(\1,\2 ,\4)/ +s/\(movs\)\([sd]\)\([ ]\+\)\(.*\)$/INSN2S(\1,\2 ,\4)/ +EOF + +cat > $tmpscript5 << \EOF +# ----------- Rewrite lea operand +s/INSN2[(]lea,\([^,]*\), *MEM_PCRELATIVE[(]/INSN2(lea,\1,ADDR_PCRELATIVE(/g +EOF + +cat > $tmpscript6 << \EOF +# ----------- Add size prefixes to memory references +s/\([(][^(,]*,b.*\), *MEM/\1,X1 MEM/g +s/\([(][^(,]*,w.*\), *MEM/\1,X2 MEM/g +s/\([(][^(,]*,[ls].*\), *MEM/\1,X4 MEM/g +s/\([(][^(,]*,[qd].*\), *MEM/\1,X8 MEM/g +EOF + +cat > $tmpscript7 << \EOF +# ----------- Introduce macro syntax for register names +# Cf. https://stackoverflow.com/questions/1753602/ +s/%\([abcd]l\|[sd]il\|[bs]pl\|r[89]b\|r1[012345]b\)/R(\1)/g +s/%\([abcd]x\|[sd]i\|[bs]p\|r[89]w\|r1[012345]w\)/R(\1)/g +s/%\(e[abcd]x\|e[sd]i\|e[bs]p\|r[89]d\|r1[012345]d\)/R(\1)/g +s/%\(r[abcd]x\|r[sd]i\|r[bs]p\|r[89]\|r1[012345]\)/R(\1)/g +s/%\(xmm[0-9]\+\)/R(\1)/g +s/\$\([-0-9]*\)/NUM(\1)/g +EOF + +cat > $tmpscript8 << \EOF +# ----------- Treat indirect calls +s/\(INSN1[(]\(call\|jmp\),_[^,]*,\)\*\(\(R\)[(][^)]*[)]\)[)]$/\1INDIR(\3))/ +s/\(INSN1[(]\(call\|jmp\),_[^,]*,\)\*\(\(MEM\|MEM_DISP\|C\)[(][^)]*[)]\)[)]$/\1INDIR(X8 \3))/ +s/\(INSN1[(]\(call\|jmp\),_[^,]*,\)\*\(MEM_PCRELATIVE[(].*[)]\)[)]$/\1INDIR(X8 \3))/ +EOF + +cat > $tmpscript9 << \EOF +# ----------- Introduce macro syntax for assembler pseudo-ops +/\.file\([ ]\+\)/d +s/\.text/TEXT()/ +s/\.p2align \([^,]*\),,\(.*\)/P2ALIGN(\1,\2)/ +s/\.p2align 3$/P2ALIGN(3,7)/ +s/\.globl\([ ]\+\)\(.*\)$/GLOBL(C(\2))/ +/\.section\([ ]\+\).*GNU-stack/d +# ----------- Declare global symbols as functions (we have no variables) +s/^C(\([A-Za-z0-9_]*\)):/FUNBEGIN(\1)/ +EOF + +sed -f $tmpscript1 | \ +sed -f $tmpscript2 | \ +sed -f $tmpscript3 | \ +sed -f $tmpscript4 | \ +sed -f $tmpscript5 | \ +sed -f $tmpscript6 | \ +sed -f $tmpscript7 | \ +sed -f $tmpscript8 | \ +sed -f $tmpscript9 + +eval "$tmpremove" diff --git a/common/noexecstack-arm.h b/common/noexecstack-arm.h new file mode 100644 index 0000000..29a8aed --- /dev/null +++ b/common/noexecstack-arm.h @@ -0,0 +1,3 @@ +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",%progbits +#endif diff --git a/common/noexecstack.h b/common/noexecstack.h new file mode 100644 index 0000000..e9d1efd --- /dev/null +++ b/common/noexecstack.h @@ -0,0 +1,3 @@ +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/common/structcpy.c b/common/structcpy.c new file mode 100644 index 0000000..a04ce67 --- /dev/null +++ b/common/structcpy.c @@ -0,0 +1,33 @@ +/* copy structs */ + +/* + * Copyright 1995-2005 Bruno Haible + * + * 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, see . + */ + +void __structcpy (void* dest, const void* src, unsigned long size, unsigned long alignment) +{ + if (alignment % sizeof(long)) + { char* d = (char*)dest; + const char* s = (const char*)src; + do { *d++ = *s++; } while (--size > 0); + } + else + /* If the alignment is a multiple of sizeof(long), the size is as well. */ + { long* d = (long*)dest; + const long* s = (const long*)src; + do { *d++ = *s++; } while ((size -= sizeof(long)) > 0); + } +} diff --git a/common/uniq-u.c b/common/uniq-u.c new file mode 100644 index 0000000..1c9ac0a --- /dev/null +++ b/common/uniq-u.c @@ -0,0 +1,277 @@ +/* uniq -- remove duplicate lines from a sorted file + Copyright (C) 1986-2016 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 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, see . */ + +/* Written by Richard Stallman and David MacKenzie. */ +/* 2000-03-22 Trimmed down to the case of "uniq -u" by Bruno Haible. */ + +#include +#include +#include +#include + +/* The name this program was run with. */ +static char *program_name; + +static void +xalloc_fail (void) +{ + fprintf (stderr, "%s: virtual memory exhausted\n", program_name); + exit (1); +} + +/* Allocate N bytes of memory dynamically, with error checking. */ + +void * +xmalloc (size_t n) +{ + void *p; + + p = malloc (n); + if (p == 0) + xalloc_fail (); + return p; +} + +/* Change the size of an allocated block of memory P to N bytes, + with error checking. + If P is NULL, run xmalloc. */ + +void * +xrealloc (void *p, size_t n) +{ + p = realloc (p, n); + if (p == 0) + xalloc_fail (); + return p; +} + +/* A ‘struct linebuffer’ holds a line of text. */ + +struct linebuffer +{ + size_t size; /* Allocated. */ + size_t length; /* Used. */ + char *buffer; +}; + +/* Initialize linebuffer LINEBUFFER for use. */ + +static void +initbuffer (struct linebuffer *linebuffer) +{ + linebuffer->length = 0; + linebuffer->size = 200; + linebuffer->buffer = (char *) xmalloc (linebuffer->size); +} + +/* Read an arbitrarily long line of text from STREAM into LINEBUFFER. + Keep the newline; append a newline if it's the last line of a file + that ends in a non-newline character. Do not null terminate. + Return LINEBUFFER, except at end of file return 0. */ + +static struct linebuffer * +readline (struct linebuffer *linebuffer, FILE *stream) +{ + int c; + char *buffer = linebuffer->buffer; + char *p = linebuffer->buffer; + char *end = buffer + linebuffer->size - 1; /* Sentinel. */ + + if (feof (stream) || ferror (stream)) + return 0; + + do + { + c = getc (stream); + if (c == EOF) + { + if (p == buffer) + return 0; + if (p[-1] == '\n') + break; + c = '\n'; + } + if (p == end) + { + linebuffer->size *= 2; + buffer = (char *) xrealloc (buffer, linebuffer->size); + p = p - linebuffer->buffer + buffer; + linebuffer->buffer = buffer; + end = buffer + linebuffer->size - 1; + } + *p++ = c; + } + while (c != '\n'); + + linebuffer->length = p - buffer; + return linebuffer; +} + +/* Free linebuffer LINEBUFFER's data. */ + +static void +freebuffer (struct linebuffer *linebuffer) +{ + free (linebuffer->buffer); +} + +/* Undefine, to avoid warning about redefinition on some systems. */ +#undef min +#define min(x, y) ((x) < (y) ? (x) : (y)) + +/* Return zero if two strings OLD and NEW match, nonzero if not. + OLD and NEW point not to the beginnings of the lines + but rather to the beginnings of the fields to compare. + OLDLEN and NEWLEN are their lengths. */ + +static int +different (const char *old, const char *new, size_t oldlen, size_t newlen) +{ + int order; + + order = memcmp (old, new, min (oldlen, newlen)); + + if (order == 0) + return oldlen - newlen; + return order; +} + +/* Output the line in linebuffer LINE to stream STREAM + provided that the switches say it should be output. + If requested, print the number of times it occurred, as well; + LINECOUNT + 1 is the number of times that the line occurred. */ + +static void +writeline (const struct linebuffer *line, FILE *stream, int linecount) +{ + if (linecount == 0) + fwrite (line->buffer, 1, line->length, stream); +} + +/* Process input file INFILE with output to OUTFILE. + If either is "-", use the standard I/O stream for it instead. */ + +static void +check_file (const char *infile, const char *outfile) +{ + FILE *istream; + FILE *ostream; + struct linebuffer lb1, lb2; + struct linebuffer *thisline, *prevline, *exch; + char *prevfield, *thisfield; + size_t prevlen, thislen; + int match_count = 0; + + if (!strcmp (infile, "-")) + istream = stdin; + else + istream = fopen (infile, "r"); + if (istream == NULL) + { + fprintf (stderr, "%s: error opening %s\n", program_name, infile); + exit (1); + } + + if (!strcmp (outfile, "-")) + ostream = stdout; + else + ostream = fopen (outfile, "w"); + if (ostream == NULL) + { + fprintf (stderr, "%s: error opening %s\n", program_name, outfile); + exit (1); + } + + thisline = &lb1; + prevline = &lb2; + + initbuffer (thisline); + initbuffer (prevline); + + if (readline (prevline, istream) == 0) + goto closefiles; + prevfield = prevline->buffer; + prevlen = prevline->length; + + while (!feof (istream)) + { + int match; + if (readline (thisline, istream) == 0) + break; + thisfield = thisline->buffer; + thislen = thisline->length; + match = !different (thisfield, prevfield, thislen, prevlen); + + if (match) + ++match_count; + + if (!match) + { + writeline (prevline, ostream, match_count); + exch = prevline; + prevline = thisline; + thisline = exch; + prevfield = thisfield; + prevlen = thislen; + if (!match) + match_count = 0; + } + } + + writeline (prevline, ostream, match_count); + + closefiles: + if (ferror (istream) || fclose (istream) == EOF) + { + fprintf (stderr, "%s: error reading %s\n", program_name, infile); + exit (1); + } + + if (ferror (ostream) || fclose (ostream) == EOF) + { + fprintf (stderr, "%s: error writing %s\n", program_name, outfile); + exit (1); + } + + freebuffer (&lb1); + freebuffer (&lb2); +} + +int +main (int argc, char **argv) +{ + const char *infile = "-"; + const char *outfile = "-"; + int optind = 1; + + program_name = argv[0]; + + if (optind < argc) + infile = argv[optind++]; + + if (optind < argc) + outfile = argv[optind++]; + + if (optind < argc) + { + fprintf (stderr, "%s: too many arguments\n", program_name); + exit (1); + } + + check_file (infile, outfile); + + exit (0); +} diff --git a/config.h.in b/config.h.in new file mode 100644 index 0000000..81bd760 --- /dev/null +++ b/config.h.in @@ -0,0 +1,542 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* CPU and C ABI indicator */ +#ifndef __i386__ +#undef __i386__ +#endif +#ifndef __x86_64_x32__ +#undef __x86_64_x32__ +#endif +#ifndef __x86_64__ +#undef __x86_64__ +#endif +#ifndef __alpha__ +#undef __alpha__ +#endif +#ifndef __arm__ +#undef __arm__ +#endif +#ifndef __armhf__ +#undef __armhf__ +#endif +#ifndef __arm64_ilp32__ +#undef __arm64_ilp32__ +#endif +#ifndef __arm64__ +#undef __arm64__ +#endif +#ifndef __hppa__ +#undef __hppa__ +#endif +#ifndef __hppa64__ +#undef __hppa64__ +#endif +#ifndef __ia64_ilp32__ +#undef __ia64_ilp32__ +#endif +#ifndef __ia64__ +#undef __ia64__ +#endif +#ifndef __m68k__ +#undef __m68k__ +#endif +#ifndef __mips__ +#undef __mips__ +#endif +#ifndef __mipsn32__ +#undef __mipsn32__ +#endif +#ifndef __mips64__ +#undef __mips64__ +#endif +#ifndef __powerpc__ +#undef __powerpc__ +#endif +#ifndef __powerpc64__ +#undef __powerpc64__ +#endif +#ifndef __powerpc64_elfv2__ +#undef __powerpc64_elfv2__ +#endif +#ifndef __riscv32__ +#undef __riscv32__ +#endif +#ifndef __riscv64__ +#undef __riscv64__ +#endif +#ifndef __riscv32_ilp32__ +#undef __riscv32_ilp32__ +#endif +#ifndef __riscv32_ilp32f__ +#undef __riscv32_ilp32f__ +#endif +#ifndef __riscv32_ilp32d__ +#undef __riscv32_ilp32d__ +#endif +#ifndef __riscv64_ilp32__ +#undef __riscv64_ilp32__ +#endif +#ifndef __riscv64_ilp32f__ +#undef __riscv64_ilp32f__ +#endif +#ifndef __riscv64_ilp32d__ +#undef __riscv64_ilp32d__ +#endif +#ifndef __riscv64_lp64__ +#undef __riscv64_lp64__ +#endif +#ifndef __riscv64_lp64f__ +#undef __riscv64_lp64f__ +#endif +#ifndef __riscv64_lp64d__ +#undef __riscv64_lp64d__ +#endif +#ifndef __s390__ +#undef __s390__ +#endif +#ifndef __s390x__ +#undef __s390x__ +#endif +#ifndef __sh__ +#undef __sh__ +#endif +#ifndef __sparc__ +#undef __sparc__ +#endif +#ifndef __sparc64__ +#undef __sparc64__ +#endif + + +/* Define to the number of bits in type 'ptrdiff_t'. */ +#undef BITSIZEOF_PTRDIFF_T + +/* Define to the number of bits in type 'sig_atomic_t'. */ +#undef BITSIZEOF_SIG_ATOMIC_T + +/* Define to the number of bits in type 'size_t'. */ +#undef BITSIZEOF_SIZE_T + +/* Define to the number of bits in type 'wchar_t'. */ +#undef BITSIZEOF_WCHAR_T + +/* Define to the number of bits in type 'wint_t'. */ +#undef BITSIZEOF_WINT_T + +/* whether code in malloc()ed memory is executable */ +#undef CODE_EXECUTABLE + +/* Define to a C preprocessor expression that evaluates to 1 or 0, depending + whether the gnulib module lock shall be considered present. */ +#undef GNULIB_LOCK + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* have getpagesize() */ +#undef HAVE_GETPAGESIZE + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIMITS_H + +/* Define to 1 if the system has the type 'long long int'. */ +#undef HAVE_LONG_LONG_INT + +/* have vm_allocate() and task_self() functions */ +#undef HAVE_MACH_VM + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* have and the mmap() function */ +#undef HAVE_MMAP + +/* defines MAP_ANON and mmaping with MAP_ANON works */ +#undef HAVE_MMAP_ANON + +/* defines MAP_ANONYMOUS and mmaping with MAP_ANONYMOUS works */ +#undef HAVE_MMAP_ANONYMOUS + +/* mmaping of the special device /dev/zero works */ +#undef HAVE_MMAP_DEVZERO + +/* have an mmap() function that, with MAP_SHARED, can make memory pages + executable */ +#undef HAVE_MMAP_SHARED_CAN_EXEC + +/* Define to 1 if you have the `mprotect' function. */ +#undef HAVE_MPROTECT + +/* have an mprotect() function that can make malloc()ed memory pages + executable */ +#undef HAVE_MPROTECT_AFTER_MALLOC_CAN_EXEC + +/* have an mprotect() function that can make mmap()ed memory pages executable + */ +#undef HAVE_MPROTECT_AFTER_MMAP_CAN_EXEC + +/* Define if the defines PTHREAD_MUTEX_RECURSIVE. */ +#undef HAVE_PTHREAD_MUTEX_RECURSIVE + +/* Define if the POSIX multithreading library has read/write locks. */ +#undef HAVE_PTHREAD_RWLOCK + +/* Define if the 'pthread_rwlock_rdlock' function prefers a writer to a + reader. */ +#undef HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER + +/* have and and shared memory works */ +#undef HAVE_SHM + +/* Define to 1 if 'sig_atomic_t' is a signed integer type. */ +#undef HAVE_SIGNED_SIG_ATOMIC_T + +/* Define to 1 if 'wchar_t' is a signed integer type. */ +#undef HAVE_SIGNED_WCHAR_T + +/* Define to 1 if 'wint_t' is a signed integer type. */ +#undef HAVE_SIGNED_WINT_T + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_BITYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_CACHECTL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_INTTYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_IPC_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_PARAM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SHM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SYSMACROS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_THREADS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if the system has the type 'unsigned long long int'. */ +#undef HAVE_UNSIGNED_LONG_LONG_INT + +/* Define to 1 if you have the header file. */ +#undef HAVE_WCHAR_H + +/* Define if you have the 'wint_t' type. */ +#undef HAVE_WINT_T + +/* have a working mprotect() function */ +#undef HAVE_WORKING_MPROTECT + +/* Version number: (major<<8) + minor */ +#undef LIBFFCALL_VERSION + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#undef LT_OBJDIR + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define if the pthread_in_use() detection is hard. */ +#undef PTHREAD_IN_USE_DETECTION_HARD + +/* Define to l, ll, u, ul, ull, etc., as suitable for constants of type + 'ptrdiff_t'. */ +#undef PTRDIFF_T_SUFFIX + +/* return type of getpagesize() */ +#undef RETGETPAGESIZETYPE + +/* Define to l, ll, u, ul, ull, etc., as suitable for constants of type + 'sig_atomic_t'. */ +#undef SIG_ATOMIC_T_SUFFIX + +/* Define to l, ll, u, ul, ull, etc., as suitable for constants of type + 'size_t'. */ +#undef SIZE_T_SUFFIX + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define to the prefix of C symbols at the assembler and linker level, either + an underscore or empty. */ +#undef USER_LABEL_PREFIX + +/* Define if the POSIX multithreading library can be used. */ +#undef USE_POSIX_THREADS + +/* Define if references to the POSIX multithreading library should be made + weak. */ +#undef USE_POSIX_THREADS_WEAK + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# undef _ALL_SOURCE +#endif +/* Enable general extensions on macOS. */ +#ifndef _DARWIN_C_SOURCE +# undef _DARWIN_C_SOURCE +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# undef _GNU_SOURCE +#endif +/* Enable NetBSD extensions on NetBSD. */ +#ifndef _NETBSD_SOURCE +# undef _NETBSD_SOURCE +#endif +/* Enable OpenBSD extensions on NetBSD. */ +#ifndef _OPENBSD_SOURCE +# undef _OPENBSD_SOURCE +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# undef _POSIX_PTHREAD_SEMANTICS +#endif +/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */ +#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__ +# undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__ +#endif +/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */ +#ifndef __STDC_WANT_IEC_60559_BFP_EXT__ +# undef __STDC_WANT_IEC_60559_BFP_EXT__ +#endif +/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */ +#ifndef __STDC_WANT_IEC_60559_DFP_EXT__ +# undef __STDC_WANT_IEC_60559_DFP_EXT__ +#endif +/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */ +#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__ +# undef __STDC_WANT_IEC_60559_FUNCS_EXT__ +#endif +/* Enable extensions specified by ISO/IEC TS 18661-3:2015. */ +#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__ +# undef __STDC_WANT_IEC_60559_TYPES_EXT__ +#endif +/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */ +#ifndef __STDC_WANT_LIB_EXT2__ +# undef __STDC_WANT_LIB_EXT2__ +#endif +/* Enable extensions specified by ISO/IEC 24747:2009. */ +#ifndef __STDC_WANT_MATH_SPEC_FUNCS__ +# undef __STDC_WANT_MATH_SPEC_FUNCS__ +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# undef _TANDEM_SOURCE +#endif +/* Enable X/Open extensions if necessary. HP-UX 11.11 defines + mbstate_t only if _XOPEN_SOURCE is defined to 500, regardless of + whether compiling with -Ae or -D_HPUX_SOURCE=1. */ +#ifndef _XOPEN_SOURCE +# undef _XOPEN_SOURCE +#endif +/* Enable X/Open compliant socket functions that do not require linking + with -lxnet on HP-UX 11.11. */ +#ifndef _HPUX_ALT_XOPEN_SOCKET_API +# undef _HPUX_ALT_XOPEN_SOCKET_API +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# undef __EXTENSIONS__ +#endif + + +/* Define if the native Windows multithreading API can be used. */ +#undef USE_WINDOWS_THREADS + +/* Version number of package */ +#undef VERSION + +/* Define to l, ll, u, ul, ull, etc., as suitable for constants of type + 'wchar_t'. */ +#undef WCHAR_T_SUFFIX + +/* Define to l, ll, u, ul, ull, etc., as suitable for constants of type + 'wint_t'. */ +#undef WINT_T_SUFFIX + +/* Define to 1 if on MINIX. */ +#undef _MINIX + +/* Define to 1 to make NetBSD features available. MINIX 3 needs this. */ +#undef _NETBSD_SOURCE + +/* The _Noreturn keyword of C11. */ +#ifndef _Noreturn +# if (defined __cplusplus \ + && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \ + || (defined _MSC_VER && 1900 <= _MSC_VER))) +# define _Noreturn [[noreturn]] +# elif ((!defined __cplusplus || defined __clang__) \ + && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \ + || 4 < __GNUC__ + (7 <= __GNUC_MINOR__))) + /* _Noreturn works as-is. */ +# elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C +# define _Noreturn __attribute__ ((__noreturn__)) +# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0) +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn +# endif +#endif + + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +#undef _POSIX_1_SOURCE + +/* Define to 1 if you need to in order for 'stat' and other things to work. */ +#undef _POSIX_SOURCE + +/* For standard stat data types on VMS. */ +#undef _USE_STD_STAT + +/* whether floats are returned in integer registers */ +#undef __IREG_FLOAT_RETURN__ + +/* whether small structs are returned in registers */ +#undef __SMALL_STRUCT_RETURN__ + +/* Define to 1 if the system predates C++11. */ +#undef __STDC_CONSTANT_MACROS + +/* Define to 1 if the system predates C++11. */ +#undef __STDC_LIMIT_MACROS + +/* The _GL_ASYNC_SAFE marker should be attached to functions that are + signal handlers (for signals other than SIGABRT, SIGPIPE) or can be + invoked from such signal handlers. Such functions have some restrictions: + * All functions that it calls should be marked _GL_ASYNC_SAFE as well, + or should be listed as async-signal-safe in POSIX + + section 2.4.3. Note that malloc(), sprintf(), and fwrite(), in + particular, are NOT async-signal-safe. + * All memory locations (variables and struct fields) that these functions + access must be marked 'volatile'. This holds for both read and write + accesses. Otherwise the compiler might optimize away stores to and + reads from such locations that occur in the program, depending on its + data flow analysis. For example, when the program contains a loop + that is intended to inspect a variable set from within a signal handler + while (!signal_occurred) + ; + the compiler is allowed to transform this into an endless loop if the + variable 'signal_occurred' is not declared 'volatile'. + Additionally, recall that: + * A signal handler should not modify errno (except if it is a handler + for a fatal signal and ends by raising the same signal again, thus + provoking the termination of the process). If it invokes a function + that may clobber errno, it needs to save and restore the value of + errno. */ +#define _GL_ASYNC_SAFE + + +/* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports + the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of + earlier versions), but does not display it by setting __GNUC_STDC_INLINE__. + __APPLE__ && __MACH__ test for Mac OS X. + __APPLE_CC__ tests for the Apple compiler and its version. + __STDC_VERSION__ tests for the C99 mode. */ +#if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__ +# define __GNUC_STDC_INLINE__ 1 +#endif + +/* Define to `int' if does not define. */ +#undef mode_t + +/* Define to `int' if does not define. */ +#undef pid_t + +/* Define as a signed type of the same size as size_t. */ +#undef ssize_t + +/* Define as a marker that can be attached to declarations that might not + be used. This helps to reduce warnings, such as from + GCC -Wunused-parameter. */ +#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) +# define _GL_UNUSED __attribute__ ((__unused__)) +#else +# define _GL_UNUSED +#endif +/* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name + is a misnomer outside of parameter lists. */ +#define _UNUSED_PARAMETER_ _GL_UNUSED + +/* gcc supports the "unused" attribute on possibly unused labels, and + g++ has since version 4.5. Note to support C++ as well as C, + _GL_UNUSED_LABEL should be used with a trailing ; */ +#if !defined __cplusplus || __GNUC__ > 4 \ + || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) +# define _GL_UNUSED_LABEL _GL_UNUSED +#else +# define _GL_UNUSED_LABEL +#endif + +/* The __pure__ attribute was added in gcc 2.96. */ +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) +# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) +#else +# define _GL_ATTRIBUTE_PURE /* empty */ +#endif + +/* The __const__ attribute was added in gcc 2.95. */ +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) +# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__)) +#else +# define _GL_ATTRIBUTE_CONST /* empty */ +#endif + +/* The __malloc__ attribute was added in gcc 3. */ +#if 3 <= __GNUC__ +# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) +#else +# define _GL_ATTRIBUTE_MALLOC /* empty */ +#endif + diff --git a/configure b/configure new file mode 100755 index 0000000..542e9ff --- /dev/null +++ b/configure @@ -0,0 +1,21711 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.69 for GNU libffcall 2.2. +# +# Report bugs to . +# +# +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. +# +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1 + + test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( + ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' + ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO + ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO + PATH=/empty FPATH=/empty; export PATH FPATH + test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ + || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." + else + $as_echo "$0: Please tell bug-autoconf@gnu.org and +$0: https://savannah.gnu.org/projects/libffcall about your +$0: system, including any error possibly output before this +$0: message. Then install a modern shell, or manually run +$0: the script under such a shell if you do have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + + + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + +SHELL=${CONFIG_SHELL-/bin/sh} + + +test -n "$DJDIR" || exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= + +# Identity of this package. +PACKAGE_NAME='GNU libffcall' +PACKAGE_TARNAME='libffcall' +PACKAGE_VERSION='2.2' +PACKAGE_STRING='GNU libffcall 2.2' +PACKAGE_BUGREPORT='https://savannah.gnu.org/projects/libffcall' +PACKAGE_URL='http://www.gnu.org/software/libffcall/' + +ac_unique_file="trampoline/trampoline.h" +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +gl_use_threads_default= +gl_use_winpthreads_default= +gl_header_list= +ac_subst_vars='gltests_LTLIBOBJS +gltests_LIBOBJS +gl_LTLIBOBJS +gl_LIBOBJS +am__EXEEXT_FALSE +am__EXEEXT_TRUE +LTLIBOBJS +LIBOBJS +gltests_WITNESS +WINDOWS_STAT_INODES +WINDOWS_64_BIT_OFF_T +NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H +NEXT_SYS_TYPES_H +GL_GENERATE_STDNORETURN_H_FALSE +GL_GENERATE_STDNORETURN_H_TRUE +STDNORETURN_H +GL_GENERATE_STDINT_H_FALSE +GL_GENERATE_STDINT_H_TRUE +STDINT_H +HAVE_SYS_INTTYPES_H +HAVE_SYS_BITYPES_H +HAVE_C99_STDINT_H +WINT_T_SUFFIX +WCHAR_T_SUFFIX +SIG_ATOMIC_T_SUFFIX +SIZE_T_SUFFIX +PTRDIFF_T_SUFFIX +HAVE_SIGNED_WINT_T +HAVE_SIGNED_WCHAR_T +HAVE_SIGNED_SIG_ATOMIC_T +BITSIZEOF_WINT_T +BITSIZEOF_WCHAR_T +BITSIZEOF_SIG_ATOMIC_T +BITSIZEOF_SIZE_T +BITSIZEOF_PTRDIFF_T +HAVE_STDINT_H +NEXT_AS_FIRST_DIRECTIVE_STDINT_H +NEXT_STDINT_H +HAVE_SYS_TYPES_H +HAVE_INTTYPES_H +HAVE_WCHAR_H +HAVE_UNSIGNED_LONG_LONG_INT +HAVE_LONG_LONG_INT +GNULIB_OVERRIDES_WINT_T +APPLE_UNIVERSAL_BUILD +LTLIBMULTITHREAD +LIBMULTITHREAD +LTLIBTHREAD +LIBTHREAD +GL_GENERATE_LIMITS_H_FALSE +GL_GENERATE_LIMITS_H_TRUE +LIMITS_H +NEXT_AS_FIRST_DIRECTIVE_LIMITS_H +NEXT_LIMITS_H +PRAGMA_COLUMNS +PRAGMA_SYSTEM_HEADER +INCLUDE_NEXT_AS_FIRST_DIRECTIVE +INCLUDE_NEXT +GL_COND_LIBTOOL_FALSE +GL_COND_LIBTOOL_TRUE +DISABLE_TYPE_BASED_ALIASING +WORKAROUND_BUG_81653 +CPU_OBJECTS +LT_SYS_LIBRARY_PATH +OTOOL64 +OTOOL +LIPO +NMEDIT +DSYMUTIL +MANIFEST_TOOL +ac_ct_AR +LN_S +NM +ac_ct_DUMPBIN +DUMPBIN +LD +FGREP +SED +LIBTOOL +OBJDUMP +DLLTOOL +AS +ENDIANNESS +HOST_CPU_C_ABI +HOST_CPU +host_os +host_vendor +host_cpu +host +build_os +build_vendor +build_cpu +build +LN +IFNOT_MSVC +IF_MSVC +RANLIB +ARFLAGS +AR +IF_CXX +am__fastdepCXX_FALSE +am__fastdepCXX_TRUE +CXXDEPMODE +ANSICXX_FALSE +ANSICXX_TRUE +CXXFLAGS +ac_ct_CXX +CXX +CXX_CHOICE +AS_UNDERSCORE +ASM_SYMBOL_PREFIX +GCC_X_NONE +CC_GCC +EGREP +GREP +CPP +am__fastdepCC_FALSE +am__fastdepCC_TRUE +CCDEPMODE +am__nodep +AMDEPBACKSLASH +AMDEP_FALSE +AMDEP_TRUE +am__quote +am__include +DEPDIR +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC +AM_BACKSLASH +AM_DEFAULT_VERBOSITY +AM_DEFAULT_V +AM_V +am__untar +am__tar +AMTAR +am__leading_dot +SET_MAKE +AWK +mkdir_p +MKDIR_P +INSTALL_STRIP_PROGRAM +STRIP +install_sh +MAKEINFO +AUTOHEADER +AUTOMAKE +AUTOCONF +ACLOCAL +VERSION +PACKAGE +CYGPATH_W +am__isrc +INSTALL_DATA +INSTALL_SCRIPT +INSTALL_PROGRAM +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_URL +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' +ac_subst_files='' +ac_user_opts=' +enable_option_checking +enable_silent_rules +enable_dependency_tracking +enable_c__ +enable_threads +enable_shared +enable_static +with_pic +enable_fast_install +with_aix_soname +with_gnu_ld +with_sysroot +enable_libtool_lock +' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP +CXX +CXXFLAGS +LT_SYS_LIBRARY_PATH' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; + + -without-* | --without-*) + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + as_fn_error $? "missing argument to $ac_option" +fi + +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + as_fn_error $? "working directory cannot be determined" +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + as_fn_error $? "pwd does not report name of working directory" + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures GNU libffcall 2.2 to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking ...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/libffcall] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF + +Program names: + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM run sed PROGRAM on installed program names + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of GNU libffcall 2.2:";; + esac + cat <<\_ACEOF + +Optional Features: + --disable-option-checking ignore unrecognized --enable/--with options + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-silent-rules less verbose build output (undo: "make V=1") + --disable-silent-rules verbose build output (undo: "make V=0") + --enable-dependency-tracking + do not reject slow dependency extractors + --disable-dependency-tracking + speeds up one-time build + --disable-c++ do not build C++ sources + --enable-threads={posix|windows} + specify multithreading API + --disable-threads build without multithread safety + --enable-shared[=PKGS] build shared libraries [default=yes] + --enable-static[=PKGS] build static libraries [default=yes] + --enable-fast-install[=PKGS] + optimize for fast installation [default=yes] + --disable-libtool-lock avoid locking (might break parallel builds) + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use + both] + --with-aix-soname=aix|svr4|both + shared library versioning (aka "SONAME") variant to + provide on AIX, [default=aix]. + --with-gnu-ld assume the C compiler uses GNU ld [default=no] + --with-sysroot[=DIR] Search for dependent libraries within DIR (or the + compiler's sysroot if not specified). + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CPP C preprocessor + CXX C++ compiler command + CXXFLAGS C++ compiler flags + LT_SYS_LIBRARY_PATH + User-defined run-time library search path. + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to . +GNU libffcall home page: . +General help using GNU software: . +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +GNU libffcall configure 2.2 +generated by GNU Autoconf 2.69 + +Copyright (C) 2012 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_c_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if eval \${$3+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.i conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} +( $as_echo "## ---------------------------------------------------------- ## +## Report this to https://savannah.gnu.org/projects/libffcall ## +## ---------------------------------------------------------- ##" + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_mongrel + +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_compile + +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link + +# ac_fn_c_check_func LINENO FUNC VAR +# ---------------------------------- +# Tests whether FUNC exists, setting the cache variable VAR accordingly +ac_fn_c_check_func () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Define $2 to an innocuous variant, in case declares $2. + For example, HP-UX 11i declares gettimeofday. */ +#define $2 innocuous_$2 + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $2 (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $2 + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $2 (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$2 || defined __stub___$2 +choke me +#endif + +int +main () +{ +return $2 (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_func + +# ac_fn_c_check_type LINENO TYPE VAR INCLUDES +# ------------------------------------------- +# Tests whether TYPE exists after having included INCLUDES, setting cache +# variable VAR accordingly. +ac_fn_c_check_type () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=no" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof ($2)) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof (($2))) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + eval "$3=yes" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_type + +# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES +# -------------------------------------------- +# Tries to find the compile-time value of EXPR in a program that includes +# INCLUDES, setting VAR accordingly. Returns whether the value could be +# computed +ac_fn_c_compute_int () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= 0)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_lo=0 ac_mid=0 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=$ac_mid; break +else + as_fn_arith $ac_mid + 1 && ac_lo=$as_val + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) < 0)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=-1 ac_mid=-1 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_lo=$ac_mid; break +else + as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + ac_lo= ac_hi= +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=$ac_mid +else + as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in #(( +?*) eval "$3=\$ac_lo"; ac_retval=0 ;; +'') ac_retval=1 ;; +esac + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +static long int longval () { return $2; } +static unsigned long int ulongval () { return $2; } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (($2) < 0) + { + long int i = longval (); + if (i != ($2)) + return 1; + fprintf (f, "%ld", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ($2)) + return 1; + fprintf (f, "%lu", i); + } + /* Do not output a trailing newline, as this causes \r\n confusion + on some platforms. */ + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + echo >>conftest.val; read $3 config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by GNU libffcall $as_me 2.2, which was +generated by GNU Autoconf 2.69. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" + done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; + 2) + as_fn_append ac_configure_args1 " '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + as_fn_append ac_configure_args " '$ac_arg'" + ;; + esac + done +done +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + $as_echo "## ---------------- ## +## Cache variables. ## +## ---------------- ##" + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + $as_echo "## ----------------- ## +## Output variables. ## +## ----------------- ##" + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + $as_echo "## ------------------- ## +## File substitutions. ## +## ------------------- ##" + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + $as_echo "## ----------- ## +## confdefs.h. ## +## ----------- ##" + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +$as_echo "/* confdefs.h */" > confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE +if test -n "$CONFIG_SITE"; then + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac +elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +else + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site +fi +for ac_site_file in "$ac_site_file1" "$ac_site_file2" +do + test "x$ac_site_file" = xNONE && continue + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5; } + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +gl_header_list="$gl_header_list limits.h" +gl_header_list="$gl_header_list threads.h" +gl_header_list="$gl_header_list wchar.h" +gl_header_list="$gl_header_list stdint.h" +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) as_fn_append ac_configure_args " '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 +fi +## -------------------- ## +## Main body of script. ## +## -------------------- ## + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +ac_aux_dir= +for ac_dir in build-aux "$srcdir"/build-aux; do + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + as_fn_error $? "cannot find install-sh, install.sh, or shtool in build-aux \"$srcdir\"/build-aux" "$LINENO" 5 +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + +am__api_version='1.15' + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +# Reject install programs that cannot install multiple files. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 +$as_echo_n "checking for a BSD-compatible install... " >&6; } +if test -z "$INSTALL"; then +if ${ac_cv_path_install+:} false; then : + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in #(( + ./ | .// | /[cC]/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + rm -rf conftest.one conftest.two conftest.dir + echo one > conftest.one + echo two > conftest.two + mkdir conftest.dir + if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && + test -s conftest.one && test -s conftest.two && + test -s conftest.dir/conftest.one && + test -s conftest.dir/conftest.two + then + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + fi + done + done + ;; +esac + + done +IFS=$as_save_IFS + +rm -rf conftest.one conftest.two conftest.dir + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 +$as_echo "$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 +$as_echo_n "checking whether build environment is sane... " >&6; } +# Reject unsafe characters in $srcdir or the absolute working directory +# name. Accept space and tab only in the latter. +am_lf=' +' +case `pwd` in + *[\\\"\#\$\&\'\`$am_lf]*) + as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; +esac +case $srcdir in + *[\\\"\#\$\&\'\`$am_lf\ \ ]*) + as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;; +esac + +# Do 'set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + am_has_slept=no + for am_try in 1 2; do + echo "timestamp, slept: $am_has_slept" > conftest.file + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + as_fn_error $? "ls -t appears to fail. Make sure there is not a broken + alias in your environment" "$LINENO" 5 + fi + if test "$2" = conftest.file || test $am_try -eq 2; then + break + fi + # Just in case. + sleep 1 + am_has_slept=yes + done + test "$2" = conftest.file + ) +then + # Ok. + : +else + as_fn_error $? "newly created file is older than distributed files! +Check your system clock" "$LINENO" 5 +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +# If we didn't sleep, we still need to ensure time stamps of config.status and +# generated files are strictly newer. +am_sleep_pid= +if grep 'slept: no' conftest.file >/dev/null 2>&1; then + ( sleep 1 ) & + am_sleep_pid=$! +fi + +rm -f conftest.file + +test "$program_prefix" != NONE && + program_transform_name="s&^&$program_prefix&;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s&\$&$program_suffix&;$program_transform_name" +# Double any \ or $. +# By default was `s,x,x', remove it if useless. +ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' +program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` + +# Expand $ac_aux_dir to an absolute path. +am_aux_dir=`cd "$ac_aux_dir" && pwd` + +if test x"${MISSING+set}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; + *) + MISSING="\${SHELL} $am_aux_dir/missing" ;; + esac +fi +# Use eval to expand $SHELL +if eval "$MISSING --is-lightweight"; then + am_missing_run="$MISSING " +else + am_missing_run= + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 +$as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} +fi + +if test x"${install_sh+set}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; + *) + install_sh="\${SHELL} $am_aux_dir/install-sh" + esac +fi + +# Installed binaries are usually stripped using 'strip' when the user +# run "make install-strip". However 'strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the 'STRIP' environment variable to overrule this program. +if test "$cross_compiling" != no; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_STRIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 +$as_echo "$STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_STRIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_STRIP="strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 +$as_echo "$ac_ct_STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 +$as_echo_n "checking for a thread-safe mkdir -p... " >&6; } +if test -z "$MKDIR_P"; then + if ${ac_cv_path_mkdir+:} false; then : + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in mkdir gmkdir; do + for ac_exec_ext in '' $ac_executable_extensions; do + as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue + case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( + 'mkdir (GNU coreutils) '* | \ + 'mkdir (coreutils) '* | \ + 'mkdir (fileutils) '4.1*) + ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext + break 3;; + esac + done + done + done +IFS=$as_save_IFS + +fi + + test -d ./--version && rmdir ./--version + if test "${ac_cv_path_mkdir+set}" = set; then + MKDIR_P="$ac_cv_path_mkdir -p" + else + # As a last resort, use the slow shell script. Don't cache a + # value for MKDIR_P within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + MKDIR_P="$ac_install_sh -d" + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 +$as_echo "$MKDIR_P" >&6; } + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AWK+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AWK="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 +$as_echo "$AWK" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$AWK" && break +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +set x ${MAKE-make} +ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + SET_MAKE= +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + +rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null + +# Check whether --enable-silent-rules was given. +if test "${enable_silent_rules+set}" = set; then : + enableval=$enable_silent_rules; +fi + +case $enable_silent_rules in # ((( + yes) AM_DEFAULT_VERBOSITY=0;; + no) AM_DEFAULT_VERBOSITY=1;; + *) AM_DEFAULT_VERBOSITY=1;; +esac +am_make=${MAKE-make} +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 +$as_echo_n "checking whether $am_make supports nested variables... " >&6; } +if ${am_cv_make_support_nested_variables+:} false; then : + $as_echo_n "(cached) " >&6 +else + if $as_echo 'TRUE=$(BAR$(V)) +BAR0=false +BAR1=true +V=1 +am__doit: + @$(TRUE) +.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then + am_cv_make_support_nested_variables=yes +else + am_cv_make_support_nested_variables=no +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 +$as_echo "$am_cv_make_support_nested_variables" >&6; } +if test $am_cv_make_support_nested_variables = yes; then + AM_V='$(V)' + AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' +else + AM_V=$AM_DEFAULT_VERBOSITY + AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY +fi +AM_BACKSLASH='\' + +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + am__isrc=' -I$(srcdir)' + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 + fi +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi + + +# Define the identity of the package. + PACKAGE='libffcall' + VERSION='2.2' + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE "$PACKAGE" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define VERSION "$VERSION" +_ACEOF + +# Some tools Automake needs. + +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} + + +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} + + +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} + + +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} + + +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} + +# For better backward compatibility. To be removed once Automake 1.9.x +# dies out for good. For more background, see: +# +# +mkdir_p='$(MKDIR_P)' + +# We need awk for the "check" target (and possibly the TAP driver). The +# system "awk" is bad on some platforms. +# Always define AMTAR for backward compatibility. Yes, it's still used +# in the wild :-( We should find a proper way to deprecate it ... +AMTAR='$${TAR-tar}' + + +# We'll loop over all known methods to create a tar archive until one works. +_am_tools='gnutar pax cpio none' + +am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' + + + + + + +# POSIX will say in a future version that running "rm -f" with no argument +# is OK; and we want to be able to make that assumption in our Makefile +# recipes. So use an aggressive probe to check that the usage we want is +# actually supported "in the wild" to an acceptable degree. +# See automake bug#10828. +# To make any issue more visible, cause the running configure to be aborted +# by default if the 'rm' program in use doesn't match our expectations; the +# user can still override this though. +if rm -f && rm -fr && rm -rf; then : OK; else + cat >&2 <<'END' +Oops! + +Your 'rm' program seems unable to run without file operands specified +on the command line, even when the '-f' option is present. This is contrary +to the behaviour of most rm programs out there, and not conforming with +the upcoming POSIX standard: + +Please tell bug-automake@gnu.org about your system, including the value +of your $PATH and any error possibly output before this message. This +can help us improve future automake versions. + +END + if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then + echo 'Configuration will proceed anyway, since you have set the' >&2 + echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 + echo >&2 + else + cat >&2 <<'END' +Aborting the configuration process, to ensure you take notice of the issue. + +You can download and install GNU coreutils to get an 'rm' implementation +that behaves properly: . + +If you want to complete the configuration process using your problematic +'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM +to "yes", and re-run configure. + +END + as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 + fi +fi + + + + +ac_config_headers="$ac_config_headers config.h" + +ac_config_headers="$ac_config_headers ffcall-version.h:ffcall-version.in.h" + + +ac_config_files="$ac_config_files Makefile" + +ac_config_files="$ac_config_files gnulib-lib/Makefile" + +ac_config_files="$ac_config_files avcall/Makefile" + +ac_config_files="$ac_config_files vacall/Makefile" + +ac_config_files="$ac_config_files trampoline/Makefile" + +ac_config_files="$ac_config_files callback/Makefile" + +ac_config_files="$ac_config_files callback/vacall_r/Makefile" + +ac_config_files="$ac_config_files callback/trampoline_r/Makefile" + + + +sed_extract_major='/^[0-9]/{s/^\([0-9]*\).*/\1/p;q;} +i\ +0 +q +' +sed_extract_minor='/^[0-9][0-9]*[.][0-9]/{s/^[0-9]*[.]\([0-9]*\).*/\1/p;q;} +i\ +0 +q +' + +version_major=`echo "${PACKAGE_VERSION}" | sed -n -e "$sed_extract_major"` +version_minor=`echo "${PACKAGE_VERSION}" | sed -n -e "$sed_extract_minor"` +HEXVERSION=`printf '0x%02X%02X' $version_major $version_minor` + +cat >>confdefs.h <<_ACEOF +#define LIBFFCALL_VERSION $HEXVERSION +_ACEOF + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +set x ${MAKE-make} +ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + SET_MAKE= +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { { ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +ac_exeext=$ac_cv_exeext + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details" "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if ${ac_cv_objext+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if ${ac_cv_c_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if ${ac_cv_prog_cc_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +struct stat; +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 +$as_echo_n "checking whether $CC understands -c and -o together... " >&6; } +if ${am_cv_prog_cc_c_o+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF + # Make sure it works both with $CC and with simple cc. + # Following AC_PROG_CC_C_O, we do the test twice because some + # compilers refuse to overwrite an existing .o file with -o, + # though they will create one. + am_cv_prog_cc_c_o=yes + for am_i in 1 2; do + if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 + ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } \ + && test -f conftest2.$ac_objext; then + : OK + else + am_cv_prog_cc_c_o=no + break + fi + done + rm -f core conftest* + unset am_i +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 +$as_echo "$am_cv_prog_cc_c_o" >&6; } +if test "$am_cv_prog_cc_c_o" != yes; then + # Losing compiler, so override with the script. + # FIXME: It is wrong to rewrite CC. + # But if we don't then we get into trouble of one sort or another. + # A longer-term fix would be to have automake use am__CC in this case, + # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" + CC="$am_aux_dir/compile $CC" +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +DEPDIR="${am__leading_dot}deps" + +ac_config_commands="$ac_config_commands depfiles" + + +am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo this is the am__doit target +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 +$as_echo_n "checking for style of include used by $am_make... " >&6; } +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# Ignore all kinds of additional output from 'make'. +case `$am_make -s -f confmf 2> /dev/null` in #( +*the\ am__doit\ target*) + am__include=include + am__quote= + _am_result=GNU + ;; +esac +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + case `$am_make -s -f confmf 2> /dev/null` in #( + *the\ am__doit\ target*) + am__include=.include + am__quote="\"" + _am_result=BSD + ;; + esac +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 +$as_echo "$_am_result" >&6; } +rm -f confinc confmf + +# Check whether --enable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then : + enableval=$enable_dependency_tracking; +fi + +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' + am__nodep='_no' +fi + if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +fi + + + +depcc="$CC" am_compiler_list= + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 +$as_echo_n "checking dependency style of $depcc... " >&6; } +if ${am_cv_CC_dependencies_compiler_type+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named 'D' -- because '-MD' means "put the output + # in D". + rm -rf conftest.dir + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + am__universal=false + case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with + # Solaris 10 /bin/sh. + echo '/* dummy */' > sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with '-c' and '-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle '-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs. + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # After this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested. + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvc7 | msvc7msys | msvisualcpp | msvcmsys) + # This compiler won't grok '-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 +$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then + am__fastdepCC_TRUE= + am__fastdepCC_FALSE='#' +else + am__fastdepCC_TRUE='#' + am__fastdepCC_FALSE= +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if ${ac_cv_path_GREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_GREP" || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_EGREP" || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +if test $ac_cv_c_compiler_gnu = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC needs -traditional" >&5 +$as_echo_n "checking whether $CC needs -traditional... " >&6; } +if ${ac_cv_prog_gcc_traditional+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_pattern="Autoconf.*'x'" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +Autoconf TIOCGETP +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "$ac_pattern" >/dev/null 2>&1; then : + ac_cv_prog_gcc_traditional=yes +else + ac_cv_prog_gcc_traditional=no +fi +rm -f conftest* + + + if test $ac_cv_prog_gcc_traditional = no; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +Autoconf TCGETA +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "$ac_pattern" >/dev/null 2>&1; then : + ac_cv_prog_gcc_traditional=yes +fi +rm -f conftest* + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_gcc_traditional" >&5 +$as_echo "$ac_cv_prog_gcc_traditional" >&6; } + if test $ac_cv_prog_gcc_traditional = yes; then + CC="$CC -traditional" + fi +fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether using GNU C" >&5 +$as_echo_n "checking whether using GNU C... " >&6; } +if ${cl_cv_prog_cc_gcc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __GNUC__ + yes + #endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "yes" >/dev/null 2>&1; then : + cl_cv_prog_cc_gcc=yes +else + cl_cv_prog_cc_gcc=no +fi +rm -f conftest* + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cl_cv_prog_cc_gcc" >&5 +$as_echo "$cl_cv_prog_cc_gcc" >&6; } + if test $cl_cv_prog_cc_gcc = yes; then + CC_GCC=true + GCC_X_NONE='-x none' + else + CC_GCC=false + GCC_X_NONE='' + fi + + + + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef _MSC_VER +MicrosoftCompiler +#endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "MicrosoftCompiler" >/dev/null 2>&1; then : + gl_asmext='asm' + gl_c_asm_opt='-c -Fa' + +else + gl_asmext='s' + gl_c_asm_opt='-S' + +fi +rm -f conftest* + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C symbols are prefixed with underscore at the linker level" >&5 +$as_echo_n "checking whether C symbols are prefixed with underscore at the linker level... " >&6; } +if ${gl_cv_prog_as_underscore+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat > conftest.c <&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } >/dev/null 2>&1 + if LC_ALL=C $EGREP '(^|[^a-zA-Z0-9_])_foo([^a-zA-Z0-9_]|$)' conftest.$gl_asmext >/dev/null; then + gl_cv_prog_as_underscore=yes + else + gl_cv_prog_as_underscore=no + fi + rm -f conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_prog_as_underscore" >&5 +$as_echo "$gl_cv_prog_as_underscore" >&6; } + if test $gl_cv_prog_as_underscore = yes; then + USER_LABEL_PREFIX=_ + else + USER_LABEL_PREFIX= + fi + +cat >>confdefs.h <<_ACEOF +#define USER_LABEL_PREFIX $USER_LABEL_PREFIX +_ACEOF + + ASM_SYMBOL_PREFIX='"'${USER_LABEL_PREFIX}'"' + + + + + if test "$USER_LABEL_PREFIX" = '_'; then + AS_UNDERSCORE=true + else + AS_UNDERSCORE=false + fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use C++" >&5 +$as_echo_n "checking whether to use C++... " >&6; } + # Check whether --enable-c++ was given. +if test "${enable_c__+set}" = set; then : + enableval=$enable_c__; CXX_CHOICE="$enableval" +else + CXX_CHOICE=yes +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX_CHOICE" >&5 +$as_echo "$CXX_CHOICE" >&6; } + + + + + + if test "$CXX_CHOICE" = no; then + CXX=no + fi + if test -z "$CXX"; then + if test -n "$CCC"; then + CXX="$CCC" + else + if test -n "$ac_tool_prefix"; then + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CXX=$ac_cv_prog_CXX +if test -n "$CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 +$as_echo "$CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CXX" && break + done +fi +if test -z "$CXX"; then + ac_ct_CXX=$CXX + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CXX"; then + ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CXX="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CXX=$ac_cv_prog_ac_ct_CXX +if test -n "$ac_ct_CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 +$as_echo "$ac_ct_CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CXX" && break +done + + if test "x$ac_ct_CXX" = x; then + CXX=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CXX=$ac_ct_CXX + fi +fi + + fi + fi + if test "$CXX" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5 +$as_echo_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works... " >&6; } + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + echo 'int main () { return 0; }' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 + (eval $ac_link) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s conftest$ac_exeext; then + gl_cv_prog_ansicxx_works=yes + if (./conftest; exit) 2>/dev/null; then + gl_cv_prog_ansicxx_cross=no + else + gl_cv_prog_ansicxx_cross=yes + fi + else + gl_cv_prog_ansicxx_works=no + fi + rm -fr conftest* + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_prog_ansicxx_works" >&5 +$as_echo "$gl_cv_prog_ansicxx_works" >&6; } + if test $gl_cv_prog_ansicxx_works = no; then + CXX=no + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler supports namespaces" >&5 +$as_echo_n "checking whether the C++ compiler supports namespaces... " >&6; } + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + cat < conftest.$ac_ext +#include +namespace test { using namespace std; } +std::ostream* ptr; +int main () { return 0; } +EOF + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 + (eval $ac_link) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s conftest$ac_exeext; then + gl_cv_prog_ansicxx_namespaces=yes + else + gl_cv_prog_ansicxx_namespaces=no + fi + rm -fr conftest* + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_prog_ansicxx_namespaces" >&5 +$as_echo "$gl_cv_prog_ansicxx_namespaces" >&6; } + if test $gl_cv_prog_ansicxx_namespaces = no; then + CXX=no + fi + fi + fi + + + + if test "$CXX" != no; then + ANSICXX_TRUE= + ANSICXX_FALSE='#' +else + ANSICXX_TRUE='#' + ANSICXX_FALSE= +fi + + + if test "$CXX" != no; then + +depcc="$CXX" am_compiler_list= + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 +$as_echo_n "checking dependency style of $depcc... " >&6; } +if ${am_cv_CXX_dependencies_compiler_type+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named 'D' -- because '-MD' means "put the output + # in D". + rm -rf conftest.dir + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CXX_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + am__universal=false + case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with + # Solaris 10 /bin/sh. + echo '/* dummy */' > sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with '-c' and '-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle '-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs. + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # After this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested. + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvc7 | msvc7msys | msvisualcpp | msvcmsys) + # This compiler won't grok '-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CXX_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CXX_dependencies_compiler_type=none +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 +$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } +CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then + am__fastdepCXX_TRUE= + am__fastdepCXX_FALSE='#' +else + am__fastdepCXX_TRUE='#' + am__fastdepCXX_FALSE= +fi + + + else + if false; then + am__fastdepCXX_TRUE= + am__fastdepCXX_FALSE='#' +else + am__fastdepCXX_TRUE='#' + am__fastdepCXX_FALSE= +fi + + fi + +if test "$CXX" != no; then + IF_CXX='' +else + IF_CXX='# ' +fi + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Minix Amsterdam compiler" >&5 +$as_echo_n "checking for Minix Amsterdam compiler... " >&6; } +if ${gl_cv_c_amsterdam_compiler+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef __ACK__ +Amsterdam +#endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "Amsterdam" >/dev/null 2>&1; then : + gl_cv_c_amsterdam_compiler=yes +else + gl_cv_c_amsterdam_compiler=no +fi +rm -f conftest* + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_c_amsterdam_compiler" >&5 +$as_echo "$gl_cv_c_amsterdam_compiler" >&6; } + + if test $gl_cv_c_amsterdam_compiler = yes; then + if test -z "$AR"; then + AR='cc -c.a' + fi + if test -z "$ARFLAGS"; then + ARFLAGS='-o' + fi + else + : + fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. +set dummy ${ac_tool_prefix}ar; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AR+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AR="${ac_tool_prefix}ar" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AR=$ac_cv_prog_AR +if test -n "$AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 +$as_echo "$AR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_AR"; then + ac_ct_AR=$AR + # Extract the first word of "ar", so it can be a program name with args. +set dummy ar; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_AR+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_AR"; then + ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_AR="ar" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_AR=$ac_cv_prog_ac_ct_AR +if test -n "$ac_ct_AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 +$as_echo "$ac_ct_AR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_AR" = x; then + AR="ar" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + AR=$ac_ct_AR + fi +else + AR="$ac_cv_prog_AR" +fi + + if test -z "$ARFLAGS"; then + ARFLAGS='cr' + fi + + + + if test -z "$RANLIB"; then + if test $gl_cv_c_amsterdam_compiler = yes; then + RANLIB=':' + else + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_RANLIB+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 +$as_echo "$RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 +$as_echo "$ac_ct_RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_RANLIB" = x; then + RANLIB=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + RANLIB=$ac_ct_RANLIB + fi +else + RANLIB="$ac_cv_prog_RANLIB" +fi + + fi + fi + + + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef _MSC_VER +MicrosoftCompiler +#endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "MicrosoftCompiler" >/dev/null 2>&1; then : + IF_MSVC='' + IFNOT_MSVC='# ' + +else + IF_MSVC='# ' + IFNOT_MSVC='' + +fi +rm -f conftest* + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to make hard links" >&5 +$as_echo_n "checking how to make hard links... " >&6; } +if ${cl_cv_prog_LN+:} false; then : + $as_echo_n "(cached) " >&6 +else + rm -f conftestdata conftestfile + echo data > conftestfile + if ln conftestfile conftestdata 2>/dev/null; then + cl_cv_prog_LN=ln + else + cl_cv_prog_LN="cp -p" + fi + rm -f conftestdata conftestfile + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cl_cv_prog_LN" >&5 +$as_echo "$cl_cv_prog_LN" >&6; } + LN="$cl_cv_prog_LN" + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default" +if test "x$ac_cv_header_minix_config_h" = xyes; then : + MINIX=yes +else + MINIX= +fi + + + if test "$MINIX" = yes; then + +$as_echo "#define _POSIX_SOURCE 1" >>confdefs.h + + +$as_echo "#define _POSIX_1_SOURCE 2" >>confdefs.h + + +$as_echo "#define _MINIX 1" >>confdefs.h + + +$as_echo "#define _NETBSD_SOURCE 1" >>confdefs.h + + fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5 +$as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; } +if ${ac_cv_safe_to_define___extensions__+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +# define __EXTENSIONS__ 1 + $ac_includes_default +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_safe_to_define___extensions__=yes +else + ac_cv_safe_to_define___extensions__=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5 +$as_echo "$ac_cv_safe_to_define___extensions__" >&6; } + test $ac_cv_safe_to_define___extensions__ = yes && + $as_echo "#define __EXTENSIONS__ 1" >>confdefs.h + + $as_echo "#define _ALL_SOURCE 1" >>confdefs.h + + $as_echo "#define _DARWIN_C_SOURCE 1" >>confdefs.h + + $as_echo "#define _GNU_SOURCE 1" >>confdefs.h + + $as_echo "#define _NETBSD_SOURCE 1" >>confdefs.h + + $as_echo "#define _OPENBSD_SOURCE 1" >>confdefs.h + + $as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h + + $as_echo "#define __STDC_WANT_IEC_60559_ATTRIBS_EXT__ 1" >>confdefs.h + + $as_echo "#define __STDC_WANT_IEC_60559_BFP_EXT__ 1" >>confdefs.h + + $as_echo "#define __STDC_WANT_IEC_60559_DFP_EXT__ 1" >>confdefs.h + + $as_echo "#define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1" >>confdefs.h + + $as_echo "#define __STDC_WANT_IEC_60559_TYPES_EXT__ 1" >>confdefs.h + + $as_echo "#define __STDC_WANT_LIB_EXT2__ 1" >>confdefs.h + + $as_echo "#define __STDC_WANT_MATH_SPEC_FUNCS__ 1" >>confdefs.h + + $as_echo "#define _TANDEM_SOURCE 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether _XOPEN_SOURCE should be defined" >&5 +$as_echo_n "checking whether _XOPEN_SOURCE should be defined... " >&6; } +if ${ac_cv_should_define__xopen_source+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_should_define__xopen_source=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + mbstate_t x; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #define _XOPEN_SOURCE 500 + #include + mbstate_t x; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_should_define__xopen_source=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_should_define__xopen_source" >&5 +$as_echo "$ac_cv_should_define__xopen_source" >&6; } + test $ac_cv_should_define__xopen_source = yes && + $as_echo "#define _XOPEN_SOURCE 500" >>confdefs.h + + $as_echo "#define _HPUX_ALT_XOPEN_SOCKET_API 1" >>confdefs.h + + + + + + + + + +# Make sure we can run config.sub. +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 +$as_echo_n "checking build system type... " >&6; } +if ${ac_cv_build+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && + as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 +$as_echo "$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 +$as_echo_n "checking host system type... " >&6; } +if ${ac_cv_host+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 +$as_echo "$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; +esac +host=$ac_cv_host +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac + + + + + + + + + # Check whether --enable-threads was given. +if test "${enable_threads+set}" = set; then : + enableval=$enable_threads; gl_use_threads=$enableval +else + if test -n "$gl_use_threads_default"; then + gl_use_threads="$gl_use_threads_default" + else + case "$host_os" in + osf*) gl_use_threads=no ;; + cygwin*) + case `uname -r` in + 1.[0-5].*) gl_use_threads=no ;; + *) gl_use_threads=yes ;; + esac + ;; + mingw*) + case "$gl_use_winpthreads_default" in + yes) gl_use_threads=posix ;; + no) gl_use_threads=windows ;; + *) gl_use_threads=yes ;; + esac + ;; + *) gl_use_threads=yes ;; + esac + fi + +fi + + if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then + # For using : + case "$host_os" in + osf*) + # On OSF/1, the compiler needs the flag -D_REENTRANT so that it + # groks . cc also understands the flag -pthread, but + # we don't use it because 1. gcc-2.95 doesn't understand -pthread, + # 2. putting a flag into CPPFLAGS that has an effect on the linker + # causes the AC_LINK_IFELSE test below to succeed unexpectedly, + # leading to wrong values of LIBTHREAD and LTLIBTHREAD. + CPPFLAGS="$CPPFLAGS -D_REENTRANT" + ;; + esac + # Some systems optimize for single-threaded programs by default, and + # need special flags to disable these optimizations. For example, the + # definition of 'errno' in . + case "$host_os" in + aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;; + solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;; + esac + fi + + + + # Pre-early section. + + + + + # Code from module absolute-header: + # Code from module ansi-c++-opt: + # Code from module extensions: + # Code from module havelib: + # Code from module host-cpu-c-abi: + # Code from module include_next: + # Code from module limits-h: + # Code from module lock: + # Code from module longlong: + # Code from module multiarch: + # Code from module nocrash: + # Code from module snippet/_Noreturn: + # Code from module ssize_t: + # Code from module stdint: + # Code from module stdnoreturn: + # Code from module sys_types: + # Code from module threadlib: + + + + # Code from module windows-mutex: + # Code from module windows-once: + # Code from module windows-recmutex: + # Code from module windows-rwlock: + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking host CPU and C ABI" >&5 +$as_echo_n "checking host CPU and C ABI... " >&6; } +if ${gl_cv_host_cpu_c_abi+:} false; then : + $as_echo_n "(cached) " >&6 +else + case "$host_cpu" in + + i[4567]86 ) + gl_cv_host_cpu_c_abi=i386 + ;; + + x86_64 ) + # On x86_64 systems, the C compiler may be generating code in one of + # these ABIs: + # - 64-bit instruction set, 64-bit pointers, 64-bit 'long': x86_64. + # - 64-bit instruction set, 64-bit pointers, 32-bit 'long': x86_64 + # with native Windows (mingw, MSVC). + # - 64-bit instruction set, 32-bit pointers, 32-bit 'long': x86_64-x32. + # - 32-bit instruction set, 32-bit pointers, 32-bit 'long': i386. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if (defined __x86_64__ || defined __amd64__ \ + || defined _M_X64 || defined _M_AMD64) + int ok; + #else + error fail + #endif + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined __ILP32__ || defined _ILP32 + int ok; + #else + error fail + #endif + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_host_cpu_c_abi=x86_64-x32 +else + gl_cv_host_cpu_c_abi=x86_64 +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +else + gl_cv_host_cpu_c_abi=i386 +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ;; + + alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] ) + gl_cv_host_cpu_c_abi=alpha + ;; + + arm* | aarch64 ) + # Assume arm with EABI. + # On arm64 systems, the C compiler may be generating code in one of + # these ABIs: + # - aarch64 instruction set, 64-bit pointers, 64-bit 'long': arm64. + # - aarch64 instruction set, 32-bit pointers, 32-bit 'long': arm64-ilp32. + # - 32-bit instruction set, 32-bit pointers, 32-bit 'long': arm or armhf. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __aarch64__ + int ok; + #else + error fail + #endif + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined __ILP32__ || defined _ILP32 + int ok; + #else + error fail + #endif + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_host_cpu_c_abi=arm64-ilp32 +else + gl_cv_host_cpu_c_abi=arm64 +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +else + # Don't distinguish little-endian and big-endian arm, since they + # don't require different machine code for simple operations and + # since the user can distinguish them through the preprocessor + # defines __ARMEL__ vs. __ARMEB__. + # But distinguish arm which passes floating-point arguments and + # return values in integer registers (r0, r1, ...) - this is + # gcc -mfloat-abi=soft or gcc -mfloat-abi=softfp - from arm which + # passes them in float registers (s0, s1, ...) and double registers + # (d0, d1, ...) - this is gcc -mfloat-abi=hard. GCC 4.6 or newer + # sets the preprocessor defines __ARM_PCS (for the first case) and + # __ARM_PCS_VFP (for the second case), but older GCC does not. + echo 'double ddd; void func (double dd) { ddd = dd; }' > conftest.c + # Look for a reference to the register d0 in the .s file. + { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $gl_c_asm_opt conftest.c' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } >/dev/null 2>&1 + if LC_ALL=C grep 'd0,' conftest.$gl_asmext >/dev/null; then + gl_cv_host_cpu_c_abi=armhf + else + gl_cv_host_cpu_c_abi=arm + fi + rm -f conftest* + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ;; + + hppa1.0 | hppa1.1 | hppa2.0* | hppa64 ) + # On hppa, the C compiler may be generating 32-bit code or 64-bit + # code. In the latter case, it defines _LP64 and __LP64__. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __LP64__ + int ok; + #else + error fail + #endif + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_host_cpu_c_abi=hppa64 +else + gl_cv_host_cpu_c_abi=hppa +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ;; + + ia64* ) + # On ia64 on HP-UX, the C compiler may be generating 64-bit code or + # 32-bit code. In the latter case, it defines _ILP32. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef _ILP32 + int ok; + #else + error fail + #endif + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_host_cpu_c_abi=ia64-ilp32 +else + gl_cv_host_cpu_c_abi=ia64 +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ;; + + mips* ) + # We should also check for (_MIPS_SZPTR == 64), but gcc keeps this + # at 32. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined _MIPS_SZLONG && (_MIPS_SZLONG == 64) + int ok; + #else + error fail + #endif + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_host_cpu_c_abi=mips64 +else + # In the n32 ABI, _ABIN32 is defined, _ABIO32 is not defined (but + # may later get defined by ), and _MIPS_SIM == _ABIN32. + # In the 32 ABI, _ABIO32 is defined, _ABIN32 is not defined (but + # may later get defined by ), and _MIPS_SIM == _ABIO32. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if (_MIPS_SIM == _ABIN32) + int ok; + #else + error fail + #endif + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_host_cpu_c_abi=mipsn32 +else + gl_cv_host_cpu_c_abi=mips +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ;; + + powerpc* ) + # Different ABIs are in use on AIX vs. Mac OS X vs. Linux,*BSD. + # No need to distinguish them here; the caller may distinguish + # them based on the OS. + # On powerpc64 systems, the C compiler may still be generating + # 32-bit code. And on powerpc-ibm-aix systems, the C compiler may + # be generating 64-bit code. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined __powerpc64__ || defined _ARCH_PPC64 + int ok; + #else + error fail + #endif + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + # On powerpc64, there are two ABIs on Linux: The AIX compatible + # one and the ELFv2 one. The latter defines _CALL_ELF=2. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined _CALL_ELF && _CALL_ELF == 2 + int ok; + #else + error fail + #endif + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_host_cpu_c_abi=powerpc64-elfv2 +else + gl_cv_host_cpu_c_abi=powerpc64 +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +else + gl_cv_host_cpu_c_abi=powerpc +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ;; + + rs6000 ) + gl_cv_host_cpu_c_abi=powerpc + ;; + + riscv32 | riscv64 ) + # There are 2 architectures (with variants): rv32* and rv64*. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if __riscv_xlen == 64 + int ok; + #else + error fail + #endif + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + cpu=riscv64 +else + cpu=riscv32 +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + # There are 6 ABIs: ilp32, ilp32f, ilp32d, lp64, lp64f, lp64d. + # Size of 'long' and 'void *': + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined __LP64__ + int ok; + #else + error fail + #endif + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + main_abi=lp64 +else + main_abi=ilp32 +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + # Float ABIs: + # __riscv_float_abi_double: + # 'float' and 'double' are passed in floating-point registers. + # __riscv_float_abi_single: + # 'float' are passed in floating-point registers. + # __riscv_float_abi_soft: + # No values are passed in floating-point registers. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined __riscv_float_abi_double + int ok; + #else + error fail + #endif + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + float_abi=d +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined __riscv_float_abi_single + int ok; + #else + error fail + #endif + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + float_abi=f +else + float_abi='' +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + gl_cv_host_cpu_c_abi="${cpu}-${main_abi}${float_abi}" + ;; + + s390* ) + # On s390x, the C compiler may be generating 64-bit (= s390x) code + # or 31-bit (= s390) code. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined __LP64__ || defined __s390x__ + int ok; + #else + error fail + #endif + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_host_cpu_c_abi=s390x +else + gl_cv_host_cpu_c_abi=s390 +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ;; + + sparc | sparc64 ) + # UltraSPARCs running Linux have `uname -m` = "sparc64", but the + # C compiler still generates 32-bit code. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined __sparcv9 || defined __arch64__ + int ok; + #else + error fail + #endif + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_host_cpu_c_abi=sparc64 +else + gl_cv_host_cpu_c_abi=sparc +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ;; + + *) + gl_cv_host_cpu_c_abi="$host_cpu" + ;; + esac + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_host_cpu_c_abi" >&5 +$as_echo "$gl_cv_host_cpu_c_abi" >&6; } + + HOST_CPU=`echo "$gl_cv_host_cpu_c_abi" | sed -e 's/-.*//'` + HOST_CPU_C_ABI="$gl_cv_host_cpu_c_abi" + + + + # This was + # AC_DEFINE_UNQUOTED([__${HOST_CPU}__]) + # AC_DEFINE_UNQUOTED([__${HOST_CPU_C_ABI}__]) + # earlier, but KAI C++ 3.2d doesn't like this. + sed -e 's/-/_/g' >> confdefs.h <&5 +$as_echo_n "checking endianness... " >&6; } +if ${ffcall_cv_endianness+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined __ARMEL__ + yes + #endif +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "yes" >/dev/null 2>&1; then : + ffcall_cv_endianness=little +else + ffcall_cv_endianness=big +fi +rm -f conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ffcall_cv_endianness" >&5 +$as_echo "$ffcall_cv_endianness" >&6; } + ;; + mips* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking endianness" >&5 +$as_echo_n "checking endianness... " >&6; } +if ${ffcall_cv_endianness+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Compilers on IRIX define only _MIPSEB as indicator. + # Compilers on Linux define _MIPSEB, __MIPSEB__, __MIPSEB or - in + # the opposite case - _MIPSEL, __MIPSEL__, __MIPSEL. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined _MIPSEB + yes + #endif +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "yes" >/dev/null 2>&1; then : + ffcall_cv_endianness=big +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined _MIPSEL + yes + #endif +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "yes" >/dev/null 2>&1; then : + ffcall_cv_endianness=little +else + ffcall_cv_endianness=unknown +fi +rm -f conftest* + +fi +rm -f conftest* + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ffcall_cv_endianness" >&5 +$as_echo "$ffcall_cv_endianness" >&6; } + ;; + powerpc*) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking endianness" >&5 +$as_echo_n "checking endianness... " >&6; } +if ${ffcall_cv_endianness+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Compilers on AIX and Linux define _BIG_ENDIAN, __BIG_ENDIAN__ or + # - in the opposite case - _LITTLE_ENDIAN, __LITTLE_ENDIAN__. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined _BIG_ENDIAN + yes + #endif +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "yes" >/dev/null 2>&1; then : + ffcall_cv_endianness=big +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined _LITTLE_ENDIAN + yes + #endif +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "yes" >/dev/null 2>&1; then : + ffcall_cv_endianness=little +else + ffcall_cv_endianness=unknown +fi +rm -f conftest* + +fi +rm -f conftest* + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ffcall_cv_endianness" >&5 +$as_echo "$ffcall_cv_endianness" >&6; } + ;; + *) ffcall_cv_endianness=known ;; + esac + case "$ffcall_cv_endianness" in + big) ENDIANNESS='eb' ;; + little) ENDIANNESS='el' ;; + *) ENDIANNESS='' ;; + esac + + + +PACKAGE=libffcall +case `pwd` in + *\ * | *\ *) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 +$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; +esac + + + +macro_version='2.4.6' +macro_revision='2.4.6' + + + + + + + + + + + + + +ltmain=$ac_aux_dir/ltmain.sh + +# Backslashify metacharacters that are still active within +# double-quoted strings. +sed_quote_subst='s/\(["`$\\]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\(["`\\]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to delay expansion of an escaped single quote. +delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' + +ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 +$as_echo_n "checking how to print strings... " >&6; } +# Test print first, because it will be a builtin if present. +if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ + test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then + ECHO='print -r --' +elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then + ECHO='printf %s\n' +else + # Use this function as a fallback that always works. + func_fallback_echo () + { + eval 'cat <<_LTECHO_EOF +$1 +_LTECHO_EOF' + } + ECHO='func_fallback_echo' +fi + +# func_echo_all arg... +# Invoke $ECHO with all args, space-separated. +func_echo_all () +{ + $ECHO "" +} + +case $ECHO in + printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 +$as_echo "printf" >&6; } ;; + print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 +$as_echo "print -r" >&6; } ;; + *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 +$as_echo "cat" >&6; } ;; +esac + + + + + + + + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 +$as_echo_n "checking for a sed that does not truncate output... " >&6; } +if ${ac_cv_path_SED+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ + for ac_i in 1 2 3 4 5 6 7; do + ac_script="$ac_script$as_nl$ac_script" + done + echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed + { ac_script=; unset ac_script;} + if test -z "$SED"; then + ac_path_SED_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_SED" || continue +# Check for GNU ac_path_SED and select it if it is found. + # Check for GNU $ac_path_SED +case `"$ac_path_SED" --version 2>&1` in +*GNU*) + ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo '' >> "conftest.nl" + "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_SED_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_SED="$ac_path_SED" + ac_path_SED_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_SED_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_SED"; then + as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 + fi +else + ac_cv_path_SED=$SED +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 +$as_echo "$ac_cv_path_SED" >&6; } + SED="$ac_cv_path_SED" + rm -f conftest.sed + +test -z "$SED" && SED=sed +Xsed="$SED -e 1s/^X//" + + + + + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 +$as_echo_n "checking for fgrep... " >&6; } +if ${ac_cv_path_FGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 + then ac_cv_path_FGREP="$GREP -F" + else + if test -z "$FGREP"; then + ac_path_FGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in fgrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_FGREP" || continue +# Check for GNU ac_path_FGREP and select it if it is found. + # Check for GNU $ac_path_FGREP +case `"$ac_path_FGREP" --version 2>&1` in +*GNU*) + ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'FGREP' >> "conftest.nl" + "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_FGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_FGREP="$ac_path_FGREP" + ac_path_FGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_FGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_FGREP"; then + as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_FGREP=$FGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 +$as_echo "$ac_cv_path_FGREP" >&6; } + FGREP="$ac_cv_path_FGREP" + + +test -z "$GREP" && GREP=grep + + + + + + + + + + + + + + + + + + + +# Check whether --with-gnu-ld was given. +if test "${with_gnu_ld+set}" = set; then : + withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes +else + with_gnu_ld=no +fi + +ac_prog=ld +if test yes = "$GCC"; then + # Check if gcc -print-prog-name=ld gives a path. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 +$as_echo_n "checking for ld used by $CC... " >&6; } + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return, which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [\\/]* | ?:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` + while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do + ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD=$ac_prog + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test yes = "$with_gnu_ld"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 +$as_echo_n "checking for GNU ld... " >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 +$as_echo_n "checking for non-GNU ld... " >&6; } +fi +if ${lt_cv_path_LD+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$LD"; then + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD=$ac_dir/$ac_prog + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &5 +$as_echo "$LD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } +if ${lt_cv_prog_gnu_ld+:} false; then : + $as_echo_n "(cached) " >&6 +else + # I'd rather use --version here, but apparently some GNU lds only accept -v. +case `$LD -v 2>&1 &5 +$as_echo "$lt_cv_prog_gnu_ld" >&6; } +with_gnu_ld=$lt_cv_prog_gnu_ld + + + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 +$as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } +if ${lt_cv_path_NM+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM=$NM +else + lt_nm_to_check=${ac_tool_prefix}nm + if test -n "$ac_tool_prefix" && test "$build" = "$host"; then + lt_nm_to_check="$lt_nm_to_check nm" + fi + for lt_tmp_nm in $lt_nm_to_check; do + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + tmp_nm=$ac_dir/$lt_tmp_nm + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the 'sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty + case $build_os in + mingw*) lt_bad_file=conftest.nm/nofile ;; + *) lt_bad_file=/dev/null ;; + esac + case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in + *$lt_bad_file* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break 2 + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break 2 + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + ;; + esac + fi + done + IFS=$lt_save_ifs + done + : ${lt_cv_path_NM=no} +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 +$as_echo "$lt_cv_path_NM" >&6; } +if test no != "$lt_cv_path_NM"; then + NM=$lt_cv_path_NM +else + # Didn't find any BSD compatible name lister, look for dumpbin. + if test -n "$DUMPBIN"; then : + # Let the user override the test. + else + if test -n "$ac_tool_prefix"; then + for ac_prog in dumpbin "link -dump" + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_DUMPBIN+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$DUMPBIN"; then + ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +DUMPBIN=$ac_cv_prog_DUMPBIN +if test -n "$DUMPBIN"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 +$as_echo "$DUMPBIN" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$DUMPBIN" && break + done +fi +if test -z "$DUMPBIN"; then + ac_ct_DUMPBIN=$DUMPBIN + for ac_prog in dumpbin "link -dump" +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_DUMPBIN"; then + ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN +if test -n "$ac_ct_DUMPBIN"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 +$as_echo "$ac_ct_DUMPBIN" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_DUMPBIN" && break +done + + if test "x$ac_ct_DUMPBIN" = x; then + DUMPBIN=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + DUMPBIN=$ac_ct_DUMPBIN + fi +fi + + case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in + *COFF*) + DUMPBIN="$DUMPBIN -symbols -headers" + ;; + *) + DUMPBIN=: + ;; + esac + fi + + if test : != "$DUMPBIN"; then + NM=$DUMPBIN + fi +fi +test -z "$NM" && NM=nm + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 +$as_echo_n "checking the name lister ($NM) interface... " >&6; } +if ${lt_cv_nm_interface+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_nm_interface="BSD nm" + echo "int some_variable = 0;" > conftest.$ac_ext + (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) + (eval "$ac_compile" 2>conftest.err) + cat conftest.err >&5 + (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) + cat conftest.err >&5 + (eval echo "\"\$as_me:$LINENO: output\"" >&5) + cat conftest.out >&5 + if $GREP 'External.*some_variable' conftest.out > /dev/null; then + lt_cv_nm_interface="MS dumpbin" + fi + rm -f conftest* +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 +$as_echo "$lt_cv_nm_interface" >&6; } + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 +$as_echo_n "checking whether ln -s works... " >&6; } +LN_S=$as_ln_s +if test "$LN_S" = "ln -s"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 +$as_echo "no, using $LN_S" >&6; } +fi + +# find the maximum length of command line arguments +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 +$as_echo_n "checking the maximum length of command line arguments... " >&6; } +if ${lt_cv_sys_max_cmd_len+:} false; then : + $as_echo_n "(cached) " >&6 +else + i=0 + teststring=ABCD + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + + cygwin* | mingw* | cegcc*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + + mint*) + # On MiNT this can take a long time and run out of memory. + lt_cv_sys_max_cmd_len=8192; + ;; + + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*) + # This has been around since 386BSD, at least. Likely further. + if test -x /sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` + elif test -x /usr/sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` + else + lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs + fi + # And add a safety zone + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + ;; + + interix*) + # We know the value 262144 and hardcode it with a safety zone (like BSD) + lt_cv_sys_max_cmd_len=196608 + ;; + + os2*) + # The test takes a long time on OS/2. + lt_cv_sys_max_cmd_len=8192 + ;; + + osf*) + # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure + # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not + # nice to cause kernel panics so lets avoid the loop below. + # First set a reasonable default. + lt_cv_sys_max_cmd_len=16384 + # + if test -x /sbin/sysconfig; then + case `/sbin/sysconfig -q proc exec_disable_arg_limit` in + *1*) lt_cv_sys_max_cmd_len=-1 ;; + esac + fi + ;; + sco3.2v5*) + lt_cv_sys_max_cmd_len=102400 + ;; + sysv5* | sco5v6* | sysv4.2uw2*) + kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` + if test -n "$kargmax"; then + lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` + else + lt_cv_sys_max_cmd_len=32768 + fi + ;; + *) + lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` + if test -n "$lt_cv_sys_max_cmd_len" && \ + test undefined != "$lt_cv_sys_max_cmd_len"; then + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + else + # Make teststring a little bigger before we do anything with it. + # a 1K string should be a reasonable start. + for i in 1 2 3 4 5 6 7 8; do + teststring=$teststring$teststring + done + SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} + # If test is not a shell built-in, we'll probably end up computing a + # maximum length that is only half of the actual maximum length, but + # we can't tell. + while { test X`env echo "$teststring$teststring" 2>/dev/null` \ + = "X$teststring$teststring"; } >/dev/null 2>&1 && + test 17 != "$i" # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + # Only check the string length outside the loop. + lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` + teststring= + # Add a significant safety factor because C++ compilers can tack on + # massive amounts of additional arguments before passing them to the + # linker. It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + fi + ;; + esac + +fi + +if test -n "$lt_cv_sys_max_cmd_len"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 +$as_echo "$lt_cv_sys_max_cmd_len" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 +$as_echo "none" >&6; } +fi +max_cmd_len=$lt_cv_sys_max_cmd_len + + + + + + +: ${CP="cp -f"} +: ${MV="mv -f"} +: ${RM="rm -f"} + +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + lt_unset=unset +else + lt_unset=false +fi + + + + + +# test EBCDIC or ASCII +case `echo X|tr X '\101'` in + A) # ASCII based system + # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr + lt_SP2NL='tr \040 \012' + lt_NL2SP='tr \015\012 \040\040' + ;; + *) # EBCDIC based system + lt_SP2NL='tr \100 \n' + lt_NL2SP='tr \r\n \100\100' + ;; +esac + + + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 +$as_echo_n "checking how to convert $build file names to $host format... " >&6; } +if ${lt_cv_to_host_file_cmd+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $host in + *-*-mingw* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 + ;; + *-*-cygwin* ) + lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 + ;; + * ) # otherwise, assume *nix + lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 + ;; + esac + ;; + *-*-cygwin* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin + ;; + *-*-cygwin* ) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; + * ) # otherwise, assume *nix + lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin + ;; + esac + ;; + * ) # unhandled hosts (and "normal" native builds) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; +esac + +fi + +to_host_file_cmd=$lt_cv_to_host_file_cmd +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 +$as_echo "$lt_cv_to_host_file_cmd" >&6; } + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 +$as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } +if ${lt_cv_to_tool_file_cmd+:} false; then : + $as_echo_n "(cached) " >&6 +else + #assume ordinary cross tools, or native build. +lt_cv_to_tool_file_cmd=func_convert_file_noop +case $host in + *-*-mingw* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 + ;; + esac + ;; +esac + +fi + +to_tool_file_cmd=$lt_cv_to_tool_file_cmd +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 +$as_echo "$lt_cv_to_tool_file_cmd" >&6; } + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 +$as_echo_n "checking for $LD option to reload object files... " >&6; } +if ${lt_cv_ld_reload_flag+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_ld_reload_flag='-r' +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 +$as_echo "$lt_cv_ld_reload_flag" >&6; } +reload_flag=$lt_cv_ld_reload_flag +case $reload_flag in +"" | " "*) ;; +*) reload_flag=" $reload_flag" ;; +esac +reload_cmds='$LD$reload_flag -o $output$reload_objs' +case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + if test yes != "$GCC"; then + reload_cmds=false + fi + ;; + darwin*) + if test yes = "$GCC"; then + reload_cmds='$LTCC $LTCFLAGS -nostdlib $wl-r -o $output$reload_objs' + else + reload_cmds='$LD$reload_flag -o $output$reload_objs' + fi + ;; +esac + + + + + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. +set dummy ${ac_tool_prefix}objdump; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_OBJDUMP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$OBJDUMP"; then + ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +OBJDUMP=$ac_cv_prog_OBJDUMP +if test -n "$OBJDUMP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 +$as_echo "$OBJDUMP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OBJDUMP"; then + ac_ct_OBJDUMP=$OBJDUMP + # Extract the first word of "objdump", so it can be a program name with args. +set dummy objdump; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_OBJDUMP"; then + ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_OBJDUMP="objdump" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP +if test -n "$ac_ct_OBJDUMP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 +$as_echo "$ac_ct_OBJDUMP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_OBJDUMP" = x; then + OBJDUMP="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OBJDUMP=$ac_ct_OBJDUMP + fi +else + OBJDUMP="$ac_cv_prog_OBJDUMP" +fi + +test -z "$OBJDUMP" && OBJDUMP=objdump + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 +$as_echo_n "checking how to recognize dependent libraries... " >&6; } +if ${lt_cv_deplibs_check_method+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_file_magic_cmd='$MAGIC_CMD' +lt_cv_file_magic_test_file= +lt_cv_deplibs_check_method='unknown' +# Need to set the preceding variable on all platforms that support +# interlibrary dependencies. +# 'none' -- dependencies not supported. +# 'unknown' -- same as none, but documents that we really don't know. +# 'pass_all' -- all dependencies passed with no checks. +# 'test_compile' -- check by making test program. +# 'file_magic [[regex]]' -- check by looking for files in library path +# that responds to the $file_magic_cmd with a given extended regex. +# If you have 'file' or equivalent on your system and you're not sure +# whether 'pass_all' will *always* work, you probably want this one. + +case $host_os in +aix[4-9]*) + lt_cv_deplibs_check_method=pass_all + ;; + +beos*) + lt_cv_deplibs_check_method=pass_all + ;; + +bsdi[45]*) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' + lt_cv_file_magic_cmd='/usr/bin/file -L' + lt_cv_file_magic_test_file=/shlib/libc.so + ;; + +cygwin*) + # func_win32_libid is a shell function defined in ltmain.sh + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + ;; + +mingw* | pw32*) + # Base MSYS/MinGW do not provide the 'file' command needed by + # func_win32_libid shell function, so use a weaker test based on 'objdump', + # unless we find 'file', for example because we are cross-compiling. + if ( file / ) >/dev/null 2>&1; then + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + else + # Keep this pattern in sync with the one in func_win32_libid. + lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' + lt_cv_file_magic_cmd='$OBJDUMP -f' + fi + ;; + +cegcc*) + # use the weaker test based on 'objdump'. See mingw*. + lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + ;; + +darwin* | rhapsody*) + lt_cv_deplibs_check_method=pass_all + ;; + +freebsd* | dragonfly*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +haiku*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20* | hpux11*) + lt_cv_file_magic_cmd=/usr/bin/file + case $host_cpu in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl + ;; + *) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +interix[3-9]*) + # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be glibc/ELF. +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +*nto* | *qnx*) + lt_cv_deplibs_check_method=pass_all + ;; + +openbsd* | bitrig*) + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' + fi + ;; + +osf3* | osf4* | osf5*) + lt_cv_deplibs_check_method=pass_all + ;; + +rdos*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.3*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + pc) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; + +tpf*) + lt_cv_deplibs_check_method=pass_all + ;; +os2*) + lt_cv_deplibs_check_method=pass_all + ;; +esac + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 +$as_echo "$lt_cv_deplibs_check_method" >&6; } + +file_magic_glob= +want_nocaseglob=no +if test "$build" = "$host"; then + case $host_os in + mingw* | pw32*) + if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then + want_nocaseglob=yes + else + file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` + fi + ;; + esac +fi + +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown + + + + + + + + + + + + + + + + + + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. +set dummy ${ac_tool_prefix}dlltool; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_DLLTOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$DLLTOOL"; then + ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +DLLTOOL=$ac_cv_prog_DLLTOOL +if test -n "$DLLTOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 +$as_echo "$DLLTOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_DLLTOOL"; then + ac_ct_DLLTOOL=$DLLTOOL + # Extract the first word of "dlltool", so it can be a program name with args. +set dummy dlltool; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_DLLTOOL"; then + ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_DLLTOOL="dlltool" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL +if test -n "$ac_ct_DLLTOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 +$as_echo "$ac_ct_DLLTOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_DLLTOOL" = x; then + DLLTOOL="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + DLLTOOL=$ac_ct_DLLTOOL + fi +else + DLLTOOL="$ac_cv_prog_DLLTOOL" +fi + +test -z "$DLLTOOL" && DLLTOOL=dlltool + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 +$as_echo_n "checking how to associate runtime and link libraries... " >&6; } +if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_sharedlib_from_linklib_cmd='unknown' + +case $host_os in +cygwin* | mingw* | pw32* | cegcc*) + # two different shell functions defined in ltmain.sh; + # decide which one to use based on capabilities of $DLLTOOL + case `$DLLTOOL --help 2>&1` in + *--identify-strict*) + lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib + ;; + *) + lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback + ;; + esac + ;; +*) + # fallback: assume linklib IS sharedlib + lt_cv_sharedlib_from_linklib_cmd=$ECHO + ;; +esac + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 +$as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } +sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd +test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO + + + + + + + +if test -n "$ac_tool_prefix"; then + for ac_prog in ar + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AR+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AR="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AR=$ac_cv_prog_AR +if test -n "$AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 +$as_echo "$AR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$AR" && break + done +fi +if test -z "$AR"; then + ac_ct_AR=$AR + for ac_prog in ar +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_AR+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_AR"; then + ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_AR="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_AR=$ac_cv_prog_ac_ct_AR +if test -n "$ac_ct_AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 +$as_echo "$ac_ct_AR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_AR" && break +done + + if test "x$ac_ct_AR" = x; then + AR="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + AR=$ac_ct_AR + fi +fi + +: ${AR=ar} +: ${AR_FLAGS=cru} + + + + + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 +$as_echo_n "checking for archiver @FILE support... " >&6; } +if ${lt_cv_ar_at_file+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_ar_at_file=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + echo conftest.$ac_objext > conftest.lst + lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 + (eval $lt_ar_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if test 0 -eq "$ac_status"; then + # Ensure the archiver fails upon bogus file names. + rm -f conftest.$ac_objext libconftest.a + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 + (eval $lt_ar_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if test 0 -ne "$ac_status"; then + lt_cv_ar_at_file=@ + fi + fi + rm -f conftest.* libconftest.a + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 +$as_echo "$lt_cv_ar_at_file" >&6; } + +if test no = "$lt_cv_ar_at_file"; then + archiver_list_spec= +else + archiver_list_spec=$lt_cv_ar_at_file +fi + + + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_STRIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 +$as_echo "$STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_STRIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_STRIP="strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 +$as_echo "$ac_ct_STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + +test -z "$STRIP" && STRIP=: + + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_RANLIB+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 +$as_echo "$RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 +$as_echo "$ac_ct_RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_RANLIB" = x; then + RANLIB=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + RANLIB=$ac_ct_RANLIB + fi +else + RANLIB="$ac_cv_prog_RANLIB" +fi + +test -z "$RANLIB" && RANLIB=: + + + + + + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + bitrig* | openbsd*) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" + ;; + *) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" +fi + +case $host_os in + darwin*) + lock_old_archive_extraction=yes ;; + *) + lock_old_archive_extraction=no ;; +esac + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# Check for command to grab the raw symbol name followed by C symbol from nm. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 +$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } +if ${lt_cv_sys_global_symbol_pipe+:} false; then : + $as_echo_n "(cached) " >&6 +else + +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[BCDEGRST]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([_A-Za-z][_A-Za-z0-9]*\)' + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[BCDT]' + ;; +cygwin* | mingw* | pw32* | cegcc*) + symcode='[ABCDGISTW]' + ;; +hpux*) + if test ia64 = "$host_cpu"; then + symcode='[ABCDEGRST]' + fi + ;; +irix* | nonstopux*) + symcode='[BCDEGRST]' + ;; +osf*) + symcode='[BCDEGQRST]' + ;; +solaris*) + symcode='[BCDRT]' + ;; +sco3.2v5*) + symcode='[DT]' + ;; +sysv4.2uw2*) + symcode='[DT]' + ;; +sysv5* | sco5v6* | unixware* | OpenUNIX*) + symcode='[ABDT]' + ;; +sysv4) + symcode='[DFNSTU]' + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[ABCDGIRSTW]' ;; +esac + +if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Gets list of data symbols to import. + lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'" + # Adjust the below global symbol transforms to fixup imported variables. + lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" + lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" + lt_c_name_lib_hook="\ + -e 's/^I .* \(lib.*\)$/ {\"\1\", (void *) 0},/p'\ + -e 's/^I .* \(.*\)$/ {\"lib\1\", (void *) 0},/p'" +else + # Disable hooks by default. + lt_cv_sys_global_symbol_to_import= + lt_cdecl_hook= + lt_c_name_hook= + lt_c_name_lib_hook= +fi + +# Transform an extracted symbol line into a proper C declaration. +# Some systems (esp. on ia64) link data and code symbols differently, +# so use this general approach. +lt_cv_sys_global_symbol_to_cdecl="sed -n"\ +$lt_cdecl_hook\ +" -e 's/^T .* \(.*\)$/extern int \1();/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n"\ +$lt_c_name_hook\ +" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" + +# Transform an extracted symbol line into symbol name with lib prefix and +# symbol address. +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\ +$lt_c_name_lib_hook\ +" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ +" -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"lib\1\", (void *) \&\1},/p'" + +# Handle CRLF in mingw tool chain +opt_cr= +case $build_os in +mingw*) + opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# Try without a prefix underscore, then with it. +for ac_symprfx in "" "_"; do + + # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. + symxfrm="\\1 $ac_symprfx\\2 \\2" + + # Write the raw and C identifiers. + if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Fake it for dumpbin and say T for any non-static function, + # D for any global variable and I for any imported variable. + # Also find C++ and __fastcall symbols from MSVC++, + # which start with @ or ?. + lt_cv_sys_global_symbol_pipe="$AWK '"\ +" {last_section=section; section=\$ 3};"\ +" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ +" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ +" /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\ +" /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\ +" /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\ +" \$ 0!~/External *\|/{next};"\ +" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ +" {if(hide[section]) next};"\ +" {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\ +" {split(\$ 0,a,/\||\r/); split(a[2],s)};"\ +" s[1]~/^[@?]/{print f,s[1],s[1]; next};"\ +" s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ +" ' prfx=^$ac_symprfx" + else + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" + fi + lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" + + # Check to see that the pipe works correctly. + pipe_works=no + + rm -f conftest* + cat > conftest.$ac_ext <<_LT_EOF +#ifdef __cplusplus +extern "C" { +#endif +char nm_test_var; +void nm_test_func(void); +void nm_test_func(void){} +#ifdef __cplusplus +} +#endif +int main(){nm_test_var='a';nm_test_func();return(0);} +_LT_EOF + + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + # Now try to grab the symbols. + nlist=conftest.nm + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 + (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if $GREP ' nm_test_var$' "$nlist" >/dev/null; then + if $GREP ' nm_test_func$' "$nlist" >/dev/null; then + cat <<_LT_EOF > conftest.$ac_ext +/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ +#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE +/* DATA imports from DLLs on WIN32 can't be const, because runtime + relocations are performed -- see ld's documentation on pseudo-relocs. */ +# define LT_DLSYM_CONST +#elif defined __osf__ +/* This system does not cope well with relocations in const data. */ +# define LT_DLSYM_CONST +#else +# define LT_DLSYM_CONST const +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +_LT_EOF + # Now generate the symbol file. + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' + + cat <<_LT_EOF >> conftest.$ac_ext + +/* The mapping between symbol names and symbols. */ +LT_DLSYM_CONST struct { + const char *name; + void *address; +} +lt__PROGRAM__LTX_preloaded_symbols[] = +{ + { "@PROGRAM@", (void *) 0 }, +_LT_EOF + $SED "s/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext + cat <<\_LT_EOF >> conftest.$ac_ext + {0, (void *) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt__PROGRAM__LTX_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif +_LT_EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + lt_globsym_save_LIBS=$LIBS + lt_globsym_save_CFLAGS=$CFLAGS + LIBS=conftstm.$ac_objext + CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 + (eval $ac_link) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s conftest$ac_exeext; then + pipe_works=yes + fi + LIBS=$lt_globsym_save_LIBS + CFLAGS=$lt_globsym_save_CFLAGS + else + echo "cannot find nm_test_func in $nlist" >&5 + fi + else + echo "cannot find nm_test_var in $nlist" >&5 + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 + fi + else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + fi + rm -rf conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test yes = "$pipe_works"; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done + +fi + +if test -z "$lt_cv_sys_global_symbol_pipe"; then + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 +$as_echo "failed" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; } +fi + +# Response file support. +if test "$lt_cv_nm_interface" = "MS dumpbin"; then + nm_file_list_spec='@' +elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then + nm_file_list_spec='@' +fi + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 +$as_echo_n "checking for sysroot... " >&6; } + +# Check whether --with-sysroot was given. +if test "${with_sysroot+set}" = set; then : + withval=$with_sysroot; +else + with_sysroot=no +fi + + +lt_sysroot= +case $with_sysroot in #( + yes) + if test yes = "$GCC"; then + lt_sysroot=`$CC --print-sysroot 2>/dev/null` + fi + ;; #( + /*) + lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` + ;; #( + no|'') + ;; #( + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_sysroot" >&5 +$as_echo "$with_sysroot" >&6; } + as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 + ;; +esac + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 +$as_echo "${lt_sysroot:-no}" >&6; } + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a working dd" >&5 +$as_echo_n "checking for a working dd... " >&6; } +if ${ac_cv_path_lt_DD+:} false; then : + $as_echo_n "(cached) " >&6 +else + printf 0123456789abcdef0123456789abcdef >conftest.i +cat conftest.i conftest.i >conftest2.i +: ${lt_DD:=$DD} +if test -z "$lt_DD"; then + ac_path_lt_DD_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in dd; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_lt_DD="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_lt_DD" || continue +if "$ac_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then + cmp -s conftest.i conftest.out \ + && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=: +fi + $ac_path_lt_DD_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_lt_DD"; then + : + fi +else + ac_cv_path_lt_DD=$lt_DD +fi + +rm -f conftest.i conftest2.i conftest.out +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_lt_DD" >&5 +$as_echo "$ac_cv_path_lt_DD" >&6; } + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to truncate binary pipes" >&5 +$as_echo_n "checking how to truncate binary pipes... " >&6; } +if ${lt_cv_truncate_bin+:} false; then : + $as_echo_n "(cached) " >&6 +else + printf 0123456789abcdef0123456789abcdef >conftest.i +cat conftest.i conftest.i >conftest2.i +lt_cv_truncate_bin= +if "$ac_cv_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then + cmp -s conftest.i conftest.out \ + && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1" +fi +rm -f conftest.i conftest2.i conftest.out +test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q" +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_truncate_bin" >&5 +$as_echo "$lt_cv_truncate_bin" >&6; } + + + + + + + +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +func_cc_basename () +{ + for cc_temp in $*""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac + done + func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` +} + +# Check whether --enable-libtool-lock was given. +if test "${enable_libtool_lock+set}" = set; then : + enableval=$enable_libtool_lock; +fi + +test no = "$enable_libtool_lock" || enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out what ABI is being produced by ac_compile, and set mode + # options accordingly. + echo 'int i;' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE=32 + ;; + *ELF-64*) + HPUX_IA64_MODE=64 + ;; + esac + fi + rm -rf conftest* + ;; +*-*-irix6*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. + echo '#line '$LINENO' "configure"' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + if test yes = "$lt_cv_prog_gnu_ld"; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + fi + rm -rf conftest* + ;; + +mips64*-*linux*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. + echo '#line '$LINENO' "configure"' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + emul=elf + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + emul="${emul}32" + ;; + *64-bit*) + emul="${emul}64" + ;; + esac + case `/usr/bin/file conftest.$ac_objext` in + *MSB*) + emul="${emul}btsmip" + ;; + *LSB*) + emul="${emul}ltsmip" + ;; + esac + case `/usr/bin/file conftest.$ac_objext` in + *N32*) + emul="${emul}n32" + ;; + esac + LD="${LD-ld} -m $emul" + fi + rm -rf conftest* + ;; + +x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ +s390*-*linux*|s390*-*tpf*|sparc*-*linux*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. Note that the listed cases only cover the + # situations where additional linker options are needed (such as when + # doing 32-bit compilation for a host where ld defaults to 64-bit, or + # vice versa); the common cases where no linker options are needed do + # not appear in the list. + echo 'int i;' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + case `/usr/bin/file conftest.o` in + *32-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_i386_fbsd" + ;; + x86_64-*linux*) + case `/usr/bin/file conftest.o` in + *x86-64*) + LD="${LD-ld} -m elf32_x86_64" + ;; + *) + LD="${LD-ld} -m elf_i386" + ;; + esac + ;; + powerpc64le-*linux*) + LD="${LD-ld} -m elf32lppclinux" + ;; + powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_x86_64_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + powerpcle-*linux*) + LD="${LD-ld} -m elf64lppc" + ;; + powerpc-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*|s390*-*tpf*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS -belf" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 +$as_echo_n "checking whether the C compiler needs -belf... " >&6; } +if ${lt_cv_cc_needs_belf+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + lt_cv_cc_needs_belf=yes +else + lt_cv_cc_needs_belf=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 +$as_echo "$lt_cv_cc_needs_belf" >&6; } + if test yes != "$lt_cv_cc_needs_belf"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS=$SAVE_CFLAGS + fi + ;; +*-*solaris*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. + echo 'int i;' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + case `/usr/bin/file conftest.o` in + *64-bit*) + case $lt_cv_prog_gnu_ld in + yes*) + case $host in + i?86-*-solaris*|x86_64-*-solaris*) + LD="${LD-ld} -m elf_x86_64" + ;; + sparc*-*-solaris*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + # GNU ld 2.21 introduced _sol2 emulations. Use them if available. + if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then + LD=${LD-ld}_sol2 + fi + ;; + *) + if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then + LD="${LD-ld} -64" + fi + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; +esac + +need_locks=$enable_libtool_lock + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. +set dummy ${ac_tool_prefix}mt; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_MANIFEST_TOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$MANIFEST_TOOL"; then + ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL +if test -n "$MANIFEST_TOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 +$as_echo "$MANIFEST_TOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_MANIFEST_TOOL"; then + ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL + # Extract the first word of "mt", so it can be a program name with args. +set dummy mt; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_MANIFEST_TOOL"; then + ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL +if test -n "$ac_ct_MANIFEST_TOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 +$as_echo "$ac_ct_MANIFEST_TOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_MANIFEST_TOOL" = x; then + MANIFEST_TOOL=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL + fi +else + MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" +fi + +test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 +$as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } +if ${lt_cv_path_mainfest_tool+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_path_mainfest_tool=no + echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 + $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out + cat conftest.err >&5 + if $GREP 'Manifest Tool' conftest.out > /dev/null; then + lt_cv_path_mainfest_tool=yes + fi + rm -f conftest* +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 +$as_echo "$lt_cv_path_mainfest_tool" >&6; } +if test yes != "$lt_cv_path_mainfest_tool"; then + MANIFEST_TOOL=: +fi + + + + + + + case $host_os in + rhapsody* | darwin*) + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. +set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_DSYMUTIL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$DSYMUTIL"; then + ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +DSYMUTIL=$ac_cv_prog_DSYMUTIL +if test -n "$DSYMUTIL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 +$as_echo "$DSYMUTIL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_DSYMUTIL"; then + ac_ct_DSYMUTIL=$DSYMUTIL + # Extract the first word of "dsymutil", so it can be a program name with args. +set dummy dsymutil; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_DSYMUTIL"; then + ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL +if test -n "$ac_ct_DSYMUTIL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 +$as_echo "$ac_ct_DSYMUTIL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_DSYMUTIL" = x; then + DSYMUTIL=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + DSYMUTIL=$ac_ct_DSYMUTIL + fi +else + DSYMUTIL="$ac_cv_prog_DSYMUTIL" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. +set dummy ${ac_tool_prefix}nmedit; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_NMEDIT+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$NMEDIT"; then + ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +NMEDIT=$ac_cv_prog_NMEDIT +if test -n "$NMEDIT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 +$as_echo "$NMEDIT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_NMEDIT"; then + ac_ct_NMEDIT=$NMEDIT + # Extract the first word of "nmedit", so it can be a program name with args. +set dummy nmedit; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_NMEDIT"; then + ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_NMEDIT="nmedit" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT +if test -n "$ac_ct_NMEDIT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 +$as_echo "$ac_ct_NMEDIT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_NMEDIT" = x; then + NMEDIT=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + NMEDIT=$ac_ct_NMEDIT + fi +else + NMEDIT="$ac_cv_prog_NMEDIT" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. +set dummy ${ac_tool_prefix}lipo; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_LIPO+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$LIPO"; then + ac_cv_prog_LIPO="$LIPO" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_LIPO="${ac_tool_prefix}lipo" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +LIPO=$ac_cv_prog_LIPO +if test -n "$LIPO"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 +$as_echo "$LIPO" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_LIPO"; then + ac_ct_LIPO=$LIPO + # Extract the first word of "lipo", so it can be a program name with args. +set dummy lipo; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_LIPO+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_LIPO"; then + ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_LIPO="lipo" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO +if test -n "$ac_ct_LIPO"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 +$as_echo "$ac_ct_LIPO" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_LIPO" = x; then + LIPO=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + LIPO=$ac_ct_LIPO + fi +else + LIPO="$ac_cv_prog_LIPO" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. +set dummy ${ac_tool_prefix}otool; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_OTOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$OTOOL"; then + ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_OTOOL="${ac_tool_prefix}otool" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +OTOOL=$ac_cv_prog_OTOOL +if test -n "$OTOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 +$as_echo "$OTOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OTOOL"; then + ac_ct_OTOOL=$OTOOL + # Extract the first word of "otool", so it can be a program name with args. +set dummy otool; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_OTOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_OTOOL"; then + ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_OTOOL="otool" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL +if test -n "$ac_ct_OTOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 +$as_echo "$ac_ct_OTOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_OTOOL" = x; then + OTOOL=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OTOOL=$ac_ct_OTOOL + fi +else + OTOOL="$ac_cv_prog_OTOOL" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. +set dummy ${ac_tool_prefix}otool64; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_OTOOL64+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$OTOOL64"; then + ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +OTOOL64=$ac_cv_prog_OTOOL64 +if test -n "$OTOOL64"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 +$as_echo "$OTOOL64" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OTOOL64"; then + ac_ct_OTOOL64=$OTOOL64 + # Extract the first word of "otool64", so it can be a program name with args. +set dummy otool64; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_OTOOL64"; then + ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_OTOOL64="otool64" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 +if test -n "$ac_ct_OTOOL64"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 +$as_echo "$ac_ct_OTOOL64" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_OTOOL64" = x; then + OTOOL64=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OTOOL64=$ac_ct_OTOOL64 + fi +else + OTOOL64="$ac_cv_prog_OTOOL64" +fi + + + + + + + + + + + + + + + + + + + + + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 +$as_echo_n "checking for -single_module linker flag... " >&6; } +if ${lt_cv_apple_cc_single_mod+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_apple_cc_single_mod=no + if test -z "$LT_MULTI_MODULE"; then + # By default we will add the -single_module flag. You can override + # by either setting the environment variable LT_MULTI_MODULE + # non-empty at configure time, or by adding -multi_module to the + # link flags. + rm -rf libconftest.dylib* + echo "int foo(void){return 1;}" > conftest.c + echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ +-dynamiclib -Wl,-single_module conftest.c" >&5 + $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ + -dynamiclib -Wl,-single_module conftest.c 2>conftest.err + _lt_result=$? + # If there is a non-empty error log, and "single_module" + # appears in it, assume the flag caused a linker warning + if test -s conftest.err && $GREP single_module conftest.err; then + cat conftest.err >&5 + # Otherwise, if the output was created with a 0 exit code from + # the compiler, it worked. + elif test -f libconftest.dylib && test 0 = "$_lt_result"; then + lt_cv_apple_cc_single_mod=yes + else + cat conftest.err >&5 + fi + rm -rf libconftest.dylib* + rm -f conftest.* + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 +$as_echo "$lt_cv_apple_cc_single_mod" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 +$as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } +if ${lt_cv_ld_exported_symbols_list+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_ld_exported_symbols_list=no + save_LDFLAGS=$LDFLAGS + echo "_main" > conftest.sym + LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + lt_cv_ld_exported_symbols_list=yes +else + lt_cv_ld_exported_symbols_list=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$save_LDFLAGS + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 +$as_echo "$lt_cv_ld_exported_symbols_list" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 +$as_echo_n "checking for -force_load linker flag... " >&6; } +if ${lt_cv_ld_force_load+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_ld_force_load=no + cat > conftest.c << _LT_EOF +int forced_loaded() { return 2;} +_LT_EOF + echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 + $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 + echo "$AR cru libconftest.a conftest.o" >&5 + $AR cru libconftest.a conftest.o 2>&5 + echo "$RANLIB libconftest.a" >&5 + $RANLIB libconftest.a 2>&5 + cat > conftest.c << _LT_EOF +int main() { return 0;} +_LT_EOF + echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 + $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err + _lt_result=$? + if test -s conftest.err && $GREP force_load conftest.err; then + cat conftest.err >&5 + elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then + lt_cv_ld_force_load=yes + else + cat conftest.err >&5 + fi + rm -f conftest.err libconftest.a conftest conftest.c + rm -rf conftest.dSYM + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 +$as_echo "$lt_cv_ld_force_load" >&6; } + case $host_os in + rhapsody* | darwin1.[012]) + _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; + darwin1.*) + _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; + darwin*) # darwin 5.x on + # if running on 10.5 or later, the deployment target defaults + # to the OS version, if on x86, and 10.4, the deployment + # target defaults to 10.4. Don't you love it? + case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in + 10.0,*86*-darwin8*|10.0,*-darwin[91]*) + _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; + 10.[012][,.]*) + _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; + 10.*) + _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; + esac + ;; + esac + if test yes = "$lt_cv_apple_cc_single_mod"; then + _lt_dar_single_mod='$single_module' + fi + if test yes = "$lt_cv_ld_exported_symbols_list"; then + _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym' + else + _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib' + fi + if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then + _lt_dsymutil='~$DSYMUTIL $lib || :' + else + _lt_dsymutil= + fi + ;; + esac + +# func_munge_path_list VARIABLE PATH +# ----------------------------------- +# VARIABLE is name of variable containing _space_ separated list of +# directories to be munged by the contents of PATH, which is string +# having a format: +# "DIR[:DIR]:" +# string "DIR[ DIR]" will be prepended to VARIABLE +# ":DIR[:DIR]" +# string "DIR[ DIR]" will be appended to VARIABLE +# "DIRP[:DIRP]::[DIRA:]DIRA" +# string "DIRP[ DIRP]" will be prepended to VARIABLE and string +# "DIRA[ DIRA]" will be appended to VARIABLE +# "DIR[:DIR]" +# VARIABLE will be replaced by "DIR[ DIR]" +func_munge_path_list () +{ + case x$2 in + x) + ;; + *:) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\" + ;; + x:*) + eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\" + ;; + *::*) + eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" + eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\" + ;; + *) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\" + ;; + esac +} + +for ac_header in dlfcn.h +do : + ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default +" +if test "x$ac_cv_header_dlfcn_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_DLFCN_H 1 +_ACEOF + +fi + +done + + + + + +# Set options +enable_win32_dll=yes + +case $host in +*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args. +set dummy ${ac_tool_prefix}as; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AS+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AS"; then + ac_cv_prog_AS="$AS" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AS="${ac_tool_prefix}as" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AS=$ac_cv_prog_AS +if test -n "$AS"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AS" >&5 +$as_echo "$AS" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_AS"; then + ac_ct_AS=$AS + # Extract the first word of "as", so it can be a program name with args. +set dummy as; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_AS+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_AS"; then + ac_cv_prog_ac_ct_AS="$ac_ct_AS" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_AS="as" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_AS=$ac_cv_prog_ac_ct_AS +if test -n "$ac_ct_AS"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AS" >&5 +$as_echo "$ac_ct_AS" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_AS" = x; then + AS="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + AS=$ac_ct_AS + fi +else + AS="$ac_cv_prog_AS" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. +set dummy ${ac_tool_prefix}dlltool; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_DLLTOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$DLLTOOL"; then + ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +DLLTOOL=$ac_cv_prog_DLLTOOL +if test -n "$DLLTOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 +$as_echo "$DLLTOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_DLLTOOL"; then + ac_ct_DLLTOOL=$DLLTOOL + # Extract the first word of "dlltool", so it can be a program name with args. +set dummy dlltool; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_DLLTOOL"; then + ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_DLLTOOL="dlltool" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL +if test -n "$ac_ct_DLLTOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 +$as_echo "$ac_ct_DLLTOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_DLLTOOL" = x; then + DLLTOOL="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + DLLTOOL=$ac_ct_DLLTOOL + fi +else + DLLTOOL="$ac_cv_prog_DLLTOOL" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. +set dummy ${ac_tool_prefix}objdump; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_OBJDUMP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$OBJDUMP"; then + ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +OBJDUMP=$ac_cv_prog_OBJDUMP +if test -n "$OBJDUMP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 +$as_echo "$OBJDUMP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OBJDUMP"; then + ac_ct_OBJDUMP=$OBJDUMP + # Extract the first word of "objdump", so it can be a program name with args. +set dummy objdump; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_OBJDUMP"; then + ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_OBJDUMP="objdump" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP +if test -n "$ac_ct_OBJDUMP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 +$as_echo "$ac_ct_OBJDUMP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_OBJDUMP" = x; then + OBJDUMP="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OBJDUMP=$ac_ct_OBJDUMP + fi +else + OBJDUMP="$ac_cv_prog_OBJDUMP" +fi + + ;; +esac + +test -z "$AS" && AS=as + + + + + +test -z "$DLLTOOL" && DLLTOOL=dlltool + + + + + +test -z "$OBJDUMP" && OBJDUMP=objdump + + + + + + + + enable_dlopen=no + + + + # Check whether --enable-shared was given. +if test "${enable_shared+set}" = set; then : + enableval=$enable_shared; p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for pkg in $enableval; do + IFS=$lt_save_ifs + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS=$lt_save_ifs + ;; + esac +else + enable_shared=yes +fi + + + + + + + + + + # Check whether --enable-static was given. +if test "${enable_static+set}" = set; then : + enableval=$enable_static; p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for pkg in $enableval; do + IFS=$lt_save_ifs + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS=$lt_save_ifs + ;; + esac +else + enable_static=yes +fi + + + + + + + + + + +# Check whether --with-pic was given. +if test "${with_pic+set}" = set; then : + withval=$with_pic; lt_p=${PACKAGE-default} + case $withval in + yes|no) pic_mode=$withval ;; + *) + pic_mode=default + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for lt_pkg in $withval; do + IFS=$lt_save_ifs + if test "X$lt_pkg" = "X$lt_p"; then + pic_mode=yes + fi + done + IFS=$lt_save_ifs + ;; + esac +else + pic_mode=default +fi + + + + + + + + + # Check whether --enable-fast-install was given. +if test "${enable_fast_install+set}" = set; then : + enableval=$enable_fast_install; p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for pkg in $enableval; do + IFS=$lt_save_ifs + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS=$lt_save_ifs + ;; + esac +else + enable_fast_install=yes +fi + + + + + + + + + shared_archive_member_spec= +case $host,$enable_shared in +power*-*-aix[5-9]*,yes) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking which variant of shared library versioning to provide" >&5 +$as_echo_n "checking which variant of shared library versioning to provide... " >&6; } + +# Check whether --with-aix-soname was given. +if test "${with_aix_soname+set}" = set; then : + withval=$with_aix_soname; case $withval in + aix|svr4|both) + ;; + *) + as_fn_error $? "Unknown argument to --with-aix-soname" "$LINENO" 5 + ;; + esac + lt_cv_with_aix_soname=$with_aix_soname +else + if ${lt_cv_with_aix_soname+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_with_aix_soname=aix +fi + + with_aix_soname=$lt_cv_with_aix_soname +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_aix_soname" >&5 +$as_echo "$with_aix_soname" >&6; } + if test aix != "$with_aix_soname"; then + # For the AIX way of multilib, we name the shared archive member + # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o', + # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File. + # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag, + # the AIX toolchain works better with OBJECT_MODE set (default 32). + if test 64 = "${OBJECT_MODE-32}"; then + shared_archive_member_spec=shr_64 + else + shared_archive_member_spec=shr + fi + fi + ;; +*) + with_aix_soname=aix + ;; +esac + + + + + + + + + + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS=$ltmain + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +test -z "$LN_S" && LN_S="ln -s" + + + + + + + + + + + + + + +if test -n "${ZSH_VERSION+set}"; then + setopt NO_GLOB_SUBST +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 +$as_echo_n "checking for objdir... " >&6; } +if ${lt_cv_objdir+:} false; then : + $as_echo_n "(cached) " >&6 +else + rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 +$as_echo "$lt_cv_objdir" >&6; } +objdir=$lt_cv_objdir + + + + + +cat >>confdefs.h <<_ACEOF +#define LT_OBJDIR "$lt_cv_objdir/" +_ACEOF + + + + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test set != "${COLLECT_NAMES+set}"; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Global variables: +ofile=libtool +can_build_shared=yes + +# All known linkers require a '.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a + +with_gnu_ld=$lt_cv_prog_gnu_ld + +old_CC=$CC +old_CFLAGS=$CFLAGS + +# Set sane defaults for various variables +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS +test -z "$LD" && LD=ld +test -z "$ac_objext" && ac_objext=o + +func_cc_basename $compiler +cc_basename=$func_cc_basename_result + + +# Only perform the check for file, if the check method requires it +test -z "$MAGIC_CMD" && MAGIC_CMD=file +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 +$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } +if ${lt_cv_path_MAGIC_CMD+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $MAGIC_CMD in +[\\/*] | ?:[\\/]*) + lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD=$MAGIC_CMD + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR + ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" + for ac_dir in $ac_dummy; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/${ac_tool_prefix}file"; then + lt_cv_path_MAGIC_CMD=$ac_dir/"${ac_tool_prefix}file" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD=$lt_cv_path_MAGIC_CMD + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<_LT_EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +_LT_EOF + fi ;; + esac + fi + break + fi + done + IFS=$lt_save_ifs + MAGIC_CMD=$lt_save_MAGIC_CMD + ;; +esac +fi + +MAGIC_CMD=$lt_cv_path_MAGIC_CMD +if test -n "$MAGIC_CMD"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 +$as_echo "$MAGIC_CMD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + + +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 +$as_echo_n "checking for file... " >&6; } +if ${lt_cv_path_MAGIC_CMD+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $MAGIC_CMD in +[\\/*] | ?:[\\/]*) + lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD=$MAGIC_CMD + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR + ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" + for ac_dir in $ac_dummy; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/file"; then + lt_cv_path_MAGIC_CMD=$ac_dir/"file" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD=$lt_cv_path_MAGIC_CMD + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<_LT_EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +_LT_EOF + fi ;; + esac + fi + break + fi + done + IFS=$lt_save_ifs + MAGIC_CMD=$lt_save_MAGIC_CMD + ;; +esac +fi + +MAGIC_CMD=$lt_cv_path_MAGIC_CMD +if test -n "$MAGIC_CMD"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 +$as_echo "$MAGIC_CMD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + else + MAGIC_CMD=: + fi +fi + + fi + ;; +esac + +# Use C for the default configuration in the libtool script + +lt_save_CC=$CC +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +objext=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}' + + + + + + + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + +# Save the default compiler, since it gets overwritten when the other +# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. +compiler_DEFAULT=$CC + +# save warnings/boilerplate of simple test code +ac_outfile=conftest.$ac_objext +echo "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$RM conftest* + +ac_outfile=conftest.$ac_objext +echo "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$RM -r conftest* + + +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... +if test -n "$compiler"; then + +lt_prog_compiler_no_builtin_flag= + +if test yes = "$GCC"; then + case $cc_basename in + nvcc*) + lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; + *) + lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; + esac + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 +$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } +if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_rtti_exceptions=no + ac_outfile=conftest.$ac_objext + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="-fno-rtti -fno-exceptions" ## exclude from sc_useless_quotes_in_assignment + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_rtti_exceptions=yes + fi + fi + $RM conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 +$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } + +if test yes = "$lt_cv_prog_compiler_rtti_exceptions"; then + lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" +else + : +fi + +fi + + + + + + + lt_prog_compiler_wl= +lt_prog_compiler_pic= +lt_prog_compiler_static= + + + if test yes = "$GCC"; then + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_static='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test ia64 = "$host_cpu"; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + fi + lt_prog_compiler_pic='-fPIC' + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + lt_prog_compiler_pic='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the '-m68020' flag to GCC prevents building anything better, + # like '-m68040'. + lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + lt_prog_compiler_pic='-DDLL_EXPORT' + case $host_os in + os2*) + lt_prog_compiler_static='$wl-static' + ;; + esac + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic='-fno-common' + ;; + + haiku*) + # PIC is the default for Haiku. + # The "-static" flag exists, but is broken. + lt_prog_compiler_static= + ;; + + hpux*) + # PIC is the default for 64-bit PA HP-UX, but not for 32-bit + # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag + # sets the default TLS model and affects inlining. + case $host_cpu in + hppa*64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic='-fPIC' + ;; + esac + ;; + + interix[3-9]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + lt_prog_compiler_can_build_shared=no + enable_shared=no + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + lt_prog_compiler_pic='-fPIC -shared' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic=-Kconform_pic + fi + ;; + + *) + lt_prog_compiler_pic='-fPIC' + ;; + esac + + case $cc_basename in + nvcc*) # Cuda Compiler Driver 2.2 + lt_prog_compiler_wl='-Xlinker ' + if test -n "$lt_prog_compiler_pic"; then + lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" + fi + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + lt_prog_compiler_wl='-Wl,' + if test ia64 = "$host_cpu"; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + else + lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic='-fno-common' + case $cc_basename in + nagfor*) + # NAG Fortran compiler + lt_prog_compiler_wl='-Wl,-Wl,,' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' + ;; + esac + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic='-DDLL_EXPORT' + case $host_os in + os2*) + lt_prog_compiler_static='$wl-static' + ;; + esac + ;; + + hpux9* | hpux10* | hpux11*) + lt_prog_compiler_wl='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + lt_prog_compiler_static='$wl-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + lt_prog_compiler_wl='-Wl,' + # PIC (with -KPIC) is the default. + lt_prog_compiler_static='-non_shared' + ;; + + linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + case $cc_basename in + # old Intel for x86_64, which still supported -KPIC. + ecc*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-static' + ;; + # icc used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + icc* | ifort*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; + # Lahey Fortran 8.1. + lf95*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='--shared' + lt_prog_compiler_static='--static' + ;; + nagfor*) + # NAG Fortran compiler + lt_prog_compiler_wl='-Wl,-Wl,,' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' + ;; + tcc*) + # Fabrice Bellard et al's Tiny C Compiler + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; + pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fpic' + lt_prog_compiler_static='-Bstatic' + ;; + ccc*) + lt_prog_compiler_wl='-Wl,' + # All Alpha code is PIC. + lt_prog_compiler_static='-non_shared' + ;; + xl* | bgxl* | bgf* | mpixl*) + # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-qpic' + lt_prog_compiler_static='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) + # Sun Fortran 8.3 passes all unrecognized flags to the linker + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='' + ;; + *Sun\ F* | *Sun*Fortran*) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='-Qoption ld ' + ;; + *Sun\ C*) + # Sun C 5.9 + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='-Wl,' + ;; + *Intel*\ [CF]*Compiler*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; + *Portland\ Group*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fpic' + lt_prog_compiler_static='-Bstatic' + ;; + esac + ;; + esac + ;; + + newsos6) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + lt_prog_compiler_pic='-fPIC -shared' + ;; + + osf3* | osf4* | osf5*) + lt_prog_compiler_wl='-Wl,' + # All OSF/1 code is PIC. + lt_prog_compiler_static='-non_shared' + ;; + + rdos*) + lt_prog_compiler_static='-non_shared' + ;; + + solaris*) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + case $cc_basename in + f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) + lt_prog_compiler_wl='-Qoption ld ';; + *) + lt_prog_compiler_wl='-Wl,';; + esac + ;; + + sunos4*) + lt_prog_compiler_wl='-Qoption ld ' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic='-Kconform_pic' + lt_prog_compiler_static='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + unicos*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_can_build_shared=no + ;; + + uts4*) + lt_prog_compiler_pic='-pic' + lt_prog_compiler_static='-Bstatic' + ;; + + *) + lt_prog_compiler_can_build_shared=no + ;; + esac + fi + +case $host_os in + # For platforms that do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic= + ;; + *) + lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" + ;; +esac + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 +$as_echo_n "checking for $compiler option to produce PIC... " >&6; } +if ${lt_cv_prog_compiler_pic+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_pic=$lt_prog_compiler_pic +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 +$as_echo "$lt_cv_prog_compiler_pic" >&6; } +lt_prog_compiler_pic=$lt_cv_prog_compiler_pic + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$lt_prog_compiler_pic"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 +$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } +if ${lt_cv_prog_compiler_pic_works+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_pic_works=no + ac_outfile=conftest.$ac_objext + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic -DPIC" ## exclude from sc_useless_quotes_in_assignment + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_pic_works=yes + fi + fi + $RM conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 +$as_echo "$lt_cv_prog_compiler_pic_works" >&6; } + +if test yes = "$lt_cv_prog_compiler_pic_works"; then + case $lt_prog_compiler_pic in + "" | " "*) ;; + *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; + esac +else + lt_prog_compiler_pic= + lt_prog_compiler_can_build_shared=no +fi + +fi + + + + + + + + + + + +# +# Check to make sure the static flag actually works. +# +wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 +$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } +if ${lt_cv_prog_compiler_static_works+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_static_works=no + save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS $lt_tmp_static_flag" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_static_works=yes + fi + else + lt_cv_prog_compiler_static_works=yes + fi + fi + $RM -r conftest* + LDFLAGS=$save_LDFLAGS + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 +$as_echo "$lt_cv_prog_compiler_static_works" >&6; } + +if test yes = "$lt_cv_prog_compiler_static_works"; then + : +else + lt_prog_compiler_static= +fi + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 +$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if ${lt_cv_prog_compiler_c_o+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_c_o=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o=yes + fi + fi + chmod u+w . 2>&5 + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 +$as_echo "$lt_cv_prog_compiler_c_o" >&6; } + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 +$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if ${lt_cv_prog_compiler_c_o+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_c_o=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o=yes + fi + fi + chmod u+w . 2>&5 + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 +$as_echo "$lt_cv_prog_compiler_c_o" >&6; } + + + + +hard_links=nottested +if test no = "$lt_cv_prog_compiler_c_o" && test no != "$need_locks"; then + # do not overwrite the value of need_locks provided by the user + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 +$as_echo_n "checking if we can lock with hard links... " >&6; } + hard_links=yes + $RM conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 +$as_echo "$hard_links" >&6; } + if test no = "$hard_links"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5 +$as_echo "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;} + need_locks=warn + fi +else + need_locks=no +fi + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } + + runpath_var= + allow_undefined_flag= + always_export_symbols=no + archive_cmds= + archive_expsym_cmds= + compiler_needs_object=no + enable_shared_with_static_runtimes=no + export_dynamic_flag_spec= + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + hardcode_automatic=no + hardcode_direct=no + hardcode_direct_absolute=no + hardcode_libdir_flag_spec= + hardcode_libdir_separator= + hardcode_minus_L=no + hardcode_shlibpath_var=unsupported + inherit_rpath=no + link_all_deplibs=unknown + module_cmds= + module_expsym_cmds= + old_archive_from_new_cmds= + old_archive_from_expsyms_cmds= + thread_safe_flag_spec= + whole_archive_flag_spec= + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + include_expsyms= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ' (' and ')$', so one must not match beginning or + # end of line. Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc', + # as well as any symbol that contains 'd'. + exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + # Exclude shared library initialization/finalization symbols. + extract_expsyms_cmds= + + case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test yes != "$GCC"; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd* | bitrig*) + with_gnu_ld=no + ;; + esac + + ld_shlibs=yes + + # On some targets, GNU ld is compatible enough with the native linker + # that we're better off using the native interface for both. + lt_use_gnu_ld_interface=no + if test yes = "$with_gnu_ld"; then + case $host_os in + aix*) + # The AIX port of GNU ld has always aspired to compatibility + # with the native linker. However, as the warning in the GNU ld + # block says, versions before 2.19.5* couldn't really create working + # shared libraries, regardless of the interface used. + case `$LD -v 2>&1` in + *\ \(GNU\ Binutils\)\ 2.19.5*) ;; + *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; + *\ \(GNU\ Binutils\)\ [3-9]*) ;; + *) + lt_use_gnu_ld_interface=yes + ;; + esac + ;; + *) + lt_use_gnu_ld_interface=yes + ;; + esac + fi + + if test yes = "$lt_use_gnu_ld_interface"; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='$wl' + + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + export_dynamic_flag_spec='$wl--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' + else + whole_archive_flag_spec= + fi + supports_anon_versioning=no + case `$LD -v | $SED -e 's/(^)\+)\s\+//' 2>&1` in + *GNU\ gold*) supports_anon_versioning=yes ;; + *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + + # See if GNU ld supports shared libraries. + case $host_os in + aix[3-9]*) + # On AIX/PPC, the GNU linker is very broken + if test ia64 != "$host_cpu"; then + ld_shlibs=no + cat <<_LT_EOF 1>&2 + +*** Warning: the GNU linker, at least up to release 2.19, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to install binutils +*** 2.20 or above, or modify your PATH so that a non-GNU linker is found. +*** You will then need to restart the configuration process. + +_LT_EOF + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='' + ;; + m68k) + archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + esac + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + else + ld_shlibs=no + fi + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + export_dynamic_flag_spec='$wl--export-all-symbols' + allow_undefined_flag=unsupported + always_export_symbols=no + enable_shared_with_static_runtimes=yes + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' + exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file, use it as + # is; otherwise, prepend EXPORTS... + archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + ld_shlibs=no + fi + ;; + + haiku*) + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + link_all_deplibs=yes + ;; + + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + allow_undefined_flag=unsupported + shrext_cmds=.dll + archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + enable_shared_with_static_runtimes=yes + ;; + + interix[3-9]*) + hardcode_direct=no + hardcode_shlibpath_var=no + hardcode_libdir_flag_spec='$wl-rpath,$libdir' + export_dynamic_flag_spec='$wl-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + archive_expsym_cmds='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) + tmp_diet=no + if test linux-dietlibc = "$host_os"; then + case $cc_basename in + diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) + esac + fi + if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ + && test no = "$tmp_diet" + then + tmp_addflag=' $pic_flag' + tmp_sharedflag='-shared' + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; + pgf77* | pgf90* | pgf95* | pgfortran*) + # Portland Group f77 and f90 compilers + whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 + tmp_addflag=' -i_dynamic' ;; + efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 + tmp_addflag=' -i_dynamic -nofor_main' ;; + ifc* | ifort*) # Intel Fortran compiler + tmp_addflag=' -nofor_main' ;; + lf95*) # Lahey Fortran 8.1 + whole_archive_flag_spec= + tmp_sharedflag='--shared' ;; + nagfor*) # NAGFOR 5.3 + tmp_sharedflag='-Wl,-shared' ;; + xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) + tmp_sharedflag='-qmkshrobj' + tmp_addflag= ;; + nvcc*) # Cuda Compiler Driver 2.2 + whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + compiler_needs_object=yes + ;; + esac + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) # Sun C 5.9 + whole_archive_flag_spec='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + compiler_needs_object=yes + tmp_sharedflag='-G' ;; + *Sun\ F*) # Sun Fortran 8.3 + tmp_sharedflag='-G' ;; + esac + archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + + if test yes = "$supports_anon_versioning"; then + archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' + fi + + case $cc_basename in + tcc*) + export_dynamic_flag_spec='-rdynamic' + ;; + xlf* | bgf* | bgxlf* | mpixlf*) + # IBM XL Fortran 10.1 on PPC cannot create shared libs itself + whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' + if test yes = "$supports_anon_versioning"; then + archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' + fi + ;; + esac + else + ld_shlibs=no + fi + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris*) + if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + cat <<_LT_EOF 1>&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) + ld_shlibs=no + cat <<_LT_EOF 1>&2 + +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot +*** reliably create shared libraries on SCO systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.16.91.0.3 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + ;; + *) + # For security reasons, it is highly recommended that you always + # use absolute paths for naming shared libraries, and exclude the + # DT_RUNPATH tag from executables and libraries. But doing so + # requires that you compile everything twice, which is a pain. + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + ;; + + sunos4*) + archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + *) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + + if test no = "$ld_shlibs"; then + runpath_var= + hardcode_libdir_flag_spec= + export_dynamic_flag_spec= + whole_archive_flag_spec= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + allow_undefined_flag=unsupported + always_export_symbols=yes + archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + + aix[4-9]*) + if test ia64 = "$host_cpu"; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag= + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to GNU nm, but means don't demangle to AIX nm. + # Without the "-l" option, or with the "-B" option, AIX nm treats + # weak defined symbols like other global defined symbols, whereas + # GNU nm marks them as "W". + # While the 'weak' keyword is ignored in the Export File, we need + # it in the Import File for the 'aix-soname' feature, so we have + # to replace the "-B" option with "-P" for AIX nm. + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' + else + export_symbols_cmds='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # have runtime linking enabled, and use it for executables. + # For shared libraries, we enable/disable runtime linking + # depending on the kind of the shared library created - + # when "with_aix_soname,aix_use_runtimelinking" is: + # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables + # "aix,yes" lib.so shared, rtl:yes, for executables + # lib.a static archive + # "both,no" lib.so.V(shr.o) shared, rtl:yes + # lib.a(lib.so.V) shared, rtl:no, for executables + # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a(lib.so.V) shared, rtl:no + # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a static archive + case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) + for ld_flag in $LDFLAGS; do + if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then + aix_use_runtimelinking=yes + break + fi + done + if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then + # With aix-soname=svr4, we create the lib.so.V shared archives only, + # so we don't have lib.a shared libs to link our executables. + # We have to force runtime linking in this case. + aix_use_runtimelinking=yes + LDFLAGS="$LDFLAGS -Wl,-brtl" + fi + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + archive_cmds='' + hardcode_direct=yes + hardcode_direct_absolute=yes + hardcode_libdir_separator=':' + link_all_deplibs=yes + file_list_spec='$wl-f,' + case $with_aix_soname,$aix_use_runtimelinking in + aix,*) ;; # traditional, no import file + svr4,* | *,yes) # use import file + # The Import File defines what to hardcode. + hardcode_direct=no + hardcode_direct_absolute=no + ;; + esac + + if test yes = "$GCC"; then + case $host_os in aix4.[012]|aix4.[012].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`$CC -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + hardcode_direct=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + ;; + esac + shared_flag='-shared' + if test yes = "$aix_use_runtimelinking"; then + shared_flag="$shared_flag "'$wl-G' + fi + # Need to ensure runtime linking is disabled for the traditional + # shared library, or the linker may eventually find shared libraries + # /with/ Import File - we do not want to mix them. + shared_flag_aix='-shared' + shared_flag_svr4='-shared $wl-G' + else + # not using gcc + if test ia64 = "$host_cpu"; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test yes = "$aix_use_runtimelinking"; then + shared_flag='$wl-G' + else + shared_flag='$wl-bM:SRE' + fi + shared_flag_aix='$wl-bM:SRE' + shared_flag_svr4='$wl-G' + fi + fi + + export_dynamic_flag_spec='$wl-bexpall' + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + always_export_symbols=yes + if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag='-berok' + # Determine the default libpath from the value encoded in an + # empty executable. + if test set = "${lt_cv_aix_libpath+set}"; then + aix_libpath=$lt_cv_aix_libpath +else + if ${lt_cv_aix_libpath_+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + + lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\([^ ]*\) *$/\1/ + p + } + }' + lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + # Check for a 64-bit object if we didn't find anything. + if test -z "$lt_cv_aix_libpath_"; then + lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + fi +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + if test -z "$lt_cv_aix_libpath_"; then + lt_cv_aix_libpath_=/usr/lib:/lib + fi + +fi + + aix_libpath=$lt_cv_aix_libpath_ +fi + + hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath" + archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag + else + if test ia64 = "$host_cpu"; then + hardcode_libdir_flag_spec='$wl-R $libdir:/usr/lib:/lib' + allow_undefined_flag="-z nodefs" + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + if test set = "${lt_cv_aix_libpath+set}"; then + aix_libpath=$lt_cv_aix_libpath +else + if ${lt_cv_aix_libpath_+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + + lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\([^ ]*\) *$/\1/ + p + } + }' + lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + # Check for a 64-bit object if we didn't find anything. + if test -z "$lt_cv_aix_libpath_"; then + lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + fi +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + if test -z "$lt_cv_aix_libpath_"; then + lt_cv_aix_libpath_=/usr/lib:/lib + fi + +fi + + aix_libpath=$lt_cv_aix_libpath_ +fi + + hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + no_undefined_flag=' $wl-bernotok' + allow_undefined_flag=' $wl-berok' + if test yes = "$with_gnu_ld"; then + # We only use this code for GNU lds that support --whole-archive. + whole_archive_flag_spec='$wl--whole-archive$convenience $wl--no-whole-archive' + else + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec='$convenience' + fi + archive_cmds_need_lc=yes + archive_expsym_cmds='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' + # -brtl affects multiple linker settings, -berok does not and is overridden later + compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([, ]\\)%-berok\\1%g"`' + if test svr4 != "$with_aix_soname"; then + # This is similar to how AIX traditionally builds its shared libraries. + archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' + fi + if test aix != "$with_aix_soname"; then + archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' + else + # used by -dlpreopen to get the symbols + archive_expsym_cmds="$archive_expsym_cmds"'~$MV $output_objdir/$realname.d/$soname $output_objdir' + fi + archive_expsym_cmds="$archive_expsym_cmds"'~$RM -r $output_objdir/$realname.d' + fi + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='' + ;; + m68k) + archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + esac + ;; + + bsdi[45]*) + export_dynamic_flag_spec=-rdynamic + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + case $cc_basename in + cl*) + # Native MSVC + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + always_export_symbols=yes + file_list_spec='@' + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=.dll + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' + archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then + cp "$export_symbols" "$output_objdir/$soname.def"; + echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; + else + $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; + fi~ + $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ + linknames=' + # The linker will not automatically build a static lib if we build a DLL. + # _LT_TAGVAR(old_archive_from_new_cmds, )='true' + enable_shared_with_static_runtimes=yes + exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' + # Don't use ranlib + old_postinstall_cmds='chmod 644 $oldlib' + postlink_cmds='lt_outputfile="@OUTPUT@"~ + lt_tool_outputfile="@TOOL_OUTPUT@"~ + case $lt_outputfile in + *.exe|*.EXE) ;; + *) + lt_outputfile=$lt_outputfile.exe + lt_tool_outputfile=$lt_tool_outputfile.exe + ;; + esac~ + if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then + $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; + $RM "$lt_outputfile.manifest"; + fi' + ;; + *) + # Assume MSVC wrapper + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=.dll + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_from_new_cmds='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' + enable_shared_with_static_runtimes=yes + ;; + esac + ;; + + darwin* | rhapsody*) + + + archive_cmds_need_lc=no + hardcode_direct=no + hardcode_automatic=yes + hardcode_shlibpath_var=unsupported + if test yes = "$lt_cv_ld_force_load"; then + whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' + + else + whole_archive_flag_spec='' + fi + link_all_deplibs=yes + allow_undefined_flag=$_lt_dar_allow_undefined + case $cc_basename in + ifort*|nagfor*) _lt_dar_can_shared=yes ;; + *) _lt_dar_can_shared=$GCC ;; + esac + if test yes = "$_lt_dar_can_shared"; then + output_verbose_link_cmd=func_echo_all + archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" + module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" + archive_expsym_cmds="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" + module_expsym_cmds="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" + + else + ld_shlibs=no + fi + + ;; + + dgux*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2.*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | dragonfly*) + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + hpux9*) + if test yes = "$GCC"; then + archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' + else + archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' + fi + hardcode_libdir_flag_spec='$wl+b $wl$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + export_dynamic_flag_spec='$wl-E' + ;; + + hpux10*) + if test yes,no = "$GCC,$with_gnu_ld"; then + archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test no = "$with_gnu_ld"; then + hardcode_libdir_flag_spec='$wl+b $wl$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + hardcode_direct_absolute=yes + export_dynamic_flag_spec='$wl-E' + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + fi + ;; + + hpux11*) + if test yes,no = "$GCC,$with_gnu_ld"; then + case $host_cpu in + hppa*64*) + archive_cmds='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case $host_cpu in + hppa*64*) + archive_cmds='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + + # Older versions of the 11.00 compiler do not understand -b yet + # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 +$as_echo_n "checking if $CC understands -b... " >&6; } +if ${lt_cv_prog_compiler__b+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler__b=no + save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -b" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler__b=yes + fi + else + lt_cv_prog_compiler__b=yes + fi + fi + $RM -r conftest* + LDFLAGS=$save_LDFLAGS + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 +$as_echo "$lt_cv_prog_compiler__b" >&6; } + +if test yes = "$lt_cv_prog_compiler__b"; then + archive_cmds='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' +else + archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' +fi + + ;; + esac + fi + if test no = "$with_gnu_ld"; then + hardcode_libdir_flag_spec='$wl+b $wl$libdir' + hardcode_libdir_separator=: + + case $host_cpu in + hppa*64*|ia64*) + hardcode_direct=no + hardcode_shlibpath_var=no + ;; + *) + hardcode_direct=yes + hardcode_direct_absolute=yes + export_dynamic_flag_spec='$wl-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test yes = "$GCC"; then + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + # Try to use the -exported_symbol ld option, if it does not + # work, assume that -exports_file does not work either and + # implicitly export all symbols. + # This should be the same for all languages, so no per-tag cache variable. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 +$as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } +if ${lt_cv_irix_exported_symbol+:} false; then : + $as_echo_n "(cached) " >&6 +else + save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int foo (void) { return 0; } +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + lt_cv_irix_exported_symbol=yes +else + lt_cv_irix_exported_symbol=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$save_LDFLAGS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 +$as_echo "$lt_cv_irix_exported_symbol" >&6; } + if test yes = "$lt_cv_irix_exported_symbol"; then + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' + fi + else + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib' + fi + archive_cmds_need_lc='no' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + hardcode_libdir_separator=: + inherit_rpath=yes + link_all_deplibs=yes + ;; + + linux*) + case $cc_basename in + tcc*) + # Fabrice Bellard et al's Tiny C Compiler + ld_shlibs=yes + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + newsos6) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + hardcode_libdir_separator=: + hardcode_shlibpath_var=no + ;; + + *nto* | *qnx*) + ;; + + openbsd* | bitrig*) + if test -f /usr/libexec/ld.so; then + hardcode_direct=yes + hardcode_shlibpath_var=no + hardcode_direct_absolute=yes + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols' + hardcode_libdir_flag_spec='$wl-rpath,$libdir' + export_dynamic_flag_spec='$wl-E' + else + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='$wl-rpath,$libdir' + fi + else + ld_shlibs=no + fi + ;; + + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + allow_undefined_flag=unsupported + shrext_cmds=.dll + archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + enable_shared_with_static_runtimes=yes + ;; + + osf3*) + if test yes = "$GCC"; then + allow_undefined_flag=' $wl-expect_unresolved $wl\*' + archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + fi + archive_cmds_need_lc='no' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + hardcode_libdir_separator=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test yes = "$GCC"; then + allow_undefined_flag=' $wl-expect_unresolved $wl\*' + archive_cmds='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp' + + # Both c and cxx compiler support -rpath directly + hardcode_libdir_flag_spec='-rpath $libdir' + fi + archive_cmds_need_lc='no' + hardcode_libdir_separator=: + ;; + + solaris*) + no_undefined_flag=' -z defs' + if test yes = "$GCC"; then + wlarc='$wl' + archive_cmds='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + else + case `$CC -V 2>&1` in + *"Compilers 5.0"*) + wlarc='' + archive_cmds='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' + ;; + *) + wlarc='$wl' + archive_cmds='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + ;; + esac + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_shlibpath_var=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands '-z linker_flag'. GCC discards it without '$wl', + # but is careful enough not to reorder. + # Supported since Solaris 2.6 (maybe 2.5.1?) + if test yes = "$GCC"; then + whole_archive_flag_spec='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' + else + whole_archive_flag_spec='-z allextract$convenience -z defaultextract' + fi + ;; + esac + link_all_deplibs=yes + ;; + + sunos4*) + if test sequent = "$host_vendor"; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + archive_cmds='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + sysv4) + case $host_vendor in + sni) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' + reload_cmds='$CC -r -o $output$reload_objs' + hardcode_direct=no + ;; + motorola) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + ;; + + sysv4.3*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + export_dynamic_flag_spec='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs=yes + fi + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) + no_undefined_flag='$wl-z,text' + archive_cmds_need_lc=no + hardcode_shlibpath_var=no + runpath_var='LD_RUN_PATH' + + if test yes = "$GCC"; then + archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We CANNOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + no_undefined_flag='$wl-z,text' + allow_undefined_flag='$wl-z,nodefs' + archive_cmds_need_lc=no + hardcode_shlibpath_var=no + hardcode_libdir_flag_spec='$wl-R,$libdir' + hardcode_libdir_separator=':' + link_all_deplibs=yes + export_dynamic_flag_spec='$wl-Bexport' + runpath_var='LD_RUN_PATH' + + if test yes = "$GCC"; then + archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + uts4*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + *) + ld_shlibs=no + ;; + esac + + if test sni = "$host_vendor"; then + case $host in + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + export_dynamic_flag_spec='$wl-Blargedynsym' + ;; + esac + fi + fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 +$as_echo "$ld_shlibs" >&6; } +test no = "$ld_shlibs" && can_build_shared=no + +with_gnu_ld=$with_gnu_ld + + + + + + + + + + + + + + + +# +# Do we need to explicitly link libc? +# +case "x$archive_cmds_need_lc" in +x|xyes) + # Assume -lc should be added + archive_cmds_need_lc=yes + + if test yes,yes = "$GCC,$enable_shared"; then + case $archive_cmds in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 +$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } +if ${lt_cv_archive_cmds_need_lc+:} false; then : + $as_echo_n "(cached) " >&6 +else + $RM conftest* + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl + pic_flag=$lt_prog_compiler_pic + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag + allow_undefined_flag= + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 + (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + then + lt_cv_archive_cmds_need_lc=no + else + lt_cv_archive_cmds_need_lc=yes + fi + allow_undefined_flag=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $RM conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 +$as_echo "$lt_cv_archive_cmds_need_lc" >&6; } + archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc + ;; + esac + fi + ;; +esac + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 +$as_echo_n "checking dynamic linker characteristics... " >&6; } + +if test yes = "$GCC"; then + case $host_os in + darwin*) lt_awk_arg='/^libraries:/,/LR/' ;; + *) lt_awk_arg='/^libraries:/' ;; + esac + case $host_os in + mingw* | cegcc*) lt_sed_strip_eq='s|=\([A-Za-z]:\)|\1|g' ;; + *) lt_sed_strip_eq='s|=/|/|g' ;; + esac + lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` + case $lt_search_path_spec in + *\;*) + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` + ;; + *) + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` + ;; + esac + # Ok, now we have the path, separated by spaces, we can step through it + # and add multilib dir if necessary... + lt_tmp_lt_search_path_spec= + lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` + # ...but if some path component already ends with the multilib dir we assume + # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer). + case "$lt_multi_os_dir; $lt_search_path_spec " in + "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*) + lt_multi_os_dir= + ;; + esac + for lt_sys_path in $lt_search_path_spec; do + if test -d "$lt_sys_path$lt_multi_os_dir"; then + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir" + elif test -n "$lt_multi_os_dir"; then + test -d "$lt_sys_path" && \ + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" + fi + done + lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' +BEGIN {RS = " "; FS = "/|\n";} { + lt_foo = ""; + lt_count = 0; + for (lt_i = NF; lt_i > 0; lt_i--) { + if ($lt_i != "" && $lt_i != ".") { + if ($lt_i == "..") { + lt_count++; + } else { + if (lt_count == 0) { + lt_foo = "/" $lt_i lt_foo; + } else { + lt_count--; + } + } + } + } + if (lt_foo != "") { lt_freq[lt_foo]++; } + if (lt_freq[lt_foo] == 1) { print lt_foo; } +}'` + # AWK program above erroneously prepends '/' to C:/dos/paths + # for these hosts. + case $host_os in + mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ + $SED 's|/\([A-Za-z]:\)|\1|g'` ;; + esac + sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=.so +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + + + +case $host_os in +aix3*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='$libname$release$shared_ext$major' + ;; + +aix[4-9]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test ia64 = "$host_cpu"; then + # AIX 5 supports IA64 + library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line '#! .'. This would cause the generated library to + # depend on '.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[01] | aix4.[01].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # Using Import Files as archive members, it is possible to support + # filename-based versioning of shared library archives on AIX. While + # this would work for both with and without runtime linking, it will + # prevent static linking of such archives. So we do filename-based + # shared library versioning with .so extension only, which is used + # when both runtime linking and shared linking is enabled. + # Unfortunately, runtime linking may impact performance, so we do + # not want this to be the default eventually. Also, we use the + # versioned .so libs for executables only if there is the -brtl + # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only. + # To allow for filename-based versioning support, we need to create + # libNAME.so.V as an archive file, containing: + # *) an Import File, referring to the versioned filename of the + # archive as well as the shared archive member, telling the + # bitwidth (32 or 64) of that shared object, and providing the + # list of exported symbols of that shared object, eventually + # decorated with the 'weak' keyword + # *) the shared object with the F_LOADONLY flag set, to really avoid + # it being seen by the linker. + # At run time we better use the real file rather than another symlink, + # but for link time we create the symlink libNAME.so -> libNAME.so.V + + case $with_aix_soname,$aix_use_runtimelinking in + # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + aix,yes) # traditional libtool + dynamic_linker='AIX unversionable lib.so' + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + ;; + aix,no) # traditional AIX only + dynamic_linker='AIX lib.a(lib.so.V)' + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='$libname$release.a $libname.a' + soname_spec='$libname$release$shared_ext$major' + ;; + svr4,*) # full svr4 only + dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o)" + library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' + # We do not specify a path in Import Files, so LIBPATH fires. + shlibpath_overrides_runpath=yes + ;; + *,yes) # both, prefer svr4 + dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o), lib.a(lib.so.V)" + library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' + # unpreferred sharedlib libNAME.a needs extra handling + postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"' + postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"' + # We do not specify a path in Import Files, so LIBPATH fires. + shlibpath_overrides_runpath=yes + ;; + *,no) # both, prefer aix + dynamic_linker="AIX lib.a(lib.so.V), lib.so.V($shared_archive_member_spec.o)" + library_names_spec='$libname$release.a $libname.a' + soname_spec='$libname$release$shared_ext$major' + # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling + postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)' + postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"' + ;; + esac + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + case $host_cpu in + powerpc) + # Since July 2007 AmigaOS4 officially supports .so libraries. + # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + ;; + m68k) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + esac + ;; + +beos*) + library_names_spec='$libname$shared_ext' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[45]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32* | cegcc*) + version_type=windows + shrext_cmds=.dll + need_version=no + need_lib_prefix=no + + case $GCC,$cc_basename in + yes,*) + # gcc + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" + ;; + mingw* | cegcc*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + ;; + esac + dynamic_linker='Win32 ld.exe' + ;; + + *,cl*) + # Native MSVC + libname_spec='$name' + soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + library_names_spec='$libname.dll.lib' + + case $build_os in + mingw*) + sys_lib_search_path_spec= + lt_save_ifs=$IFS + IFS=';' + for lt_path in $LIB + do + IFS=$lt_save_ifs + # Let DOS variable expansion print the short 8.3 style file name. + lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` + sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" + done + IFS=$lt_save_ifs + # Convert to MSYS style. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` + ;; + cygwin*) + # Convert to unix form, then to dos form, then back to unix form + # but this time dos style (no spaces!) so that the unix form looks + # like /cygdrive/c/PROGRA~1:/cygdr... + sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` + sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` + sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + ;; + *) + sys_lib_search_path_spec=$LIB + if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + # FIXME: find the short name or the path components, as spaces are + # common. (e.g. "Program Files" -> "PROGRA~1") + ;; + esac + + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + dynamic_linker='Win32 link.exe' + ;; + + *) + # Assume MSVC wrapper + library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib' + dynamic_linker='Win32 ld.exe' + ;; + esac + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' + soname_spec='$libname$release$major$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' + + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[23].*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2.*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[01]* | freebsdelf3.[01]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ + freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + *) # from 4.6 on, and DragonFly + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +haiku*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + dynamic_linker="$host_os runtime_loader" + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LIBRARY_PATH + shlibpath_overrides_runpath=no + sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + if test 32 = "$HPUX_IA64_MODE"; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + sys_lib_dlsearch_path_spec=/usr/lib/hpux32 + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + sys_lib_dlsearch_path_spec=/usr/lib/hpux64 + fi + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555, ... + postinstall_cmds='chmod 555 $lib' + # or fails outright, so override atomically: + install_override_mode=555 + ;; + +interix[3-9]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test yes = "$lt_cv_prog_gnu_ld"; then + version_type=linux # correct to gnu/linux during the next big refactor + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='$libname$release$shared_ext$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff" + sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +linux*android*) + version_type=none # Android doesn't support versioned libraries. + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext' + soname_spec='$libname$release$shared_ext' + finish_cmds= + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + dynamic_linker='Android linker' + # Don't embed -rpath directories since the linker doesn't support them. + hardcode_libdir_flag_spec='-L$libdir' + ;; + +# This must be glibc/ELF. +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + + # Some binutils ld are patched to set DT_RUNPATH + if ${lt_cv_shlibpath_overrides_runpath+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_shlibpath_overrides_runpath=no + save_LDFLAGS=$LDFLAGS + save_libdir=$libdir + eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ + LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : + lt_cv_shlibpath_overrides_runpath=yes +fi +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$save_LDFLAGS + libdir=$save_libdir + +fi + + shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Ideally, we could use ldconfig to report *all* directores which are + # searched for libraries, however this is still not possible. Aside from not + # being certain /sbin/ldconfig is available, command + # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64, + # even though it is searched at run-time. Try to do the best guess by + # appending ld.so.conf contents (and includes) to the search path. + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +*nto* | *qnx*) + version_type=qnx + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='ldqnx.so' + ;; + +openbsd* | bitrig*) + version_type=sunos + sys_lib_dlsearch_path_spec=/usr/lib + need_lib_prefix=no + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + need_version=no + else + need_version=yes + fi + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +os2*) + libname_spec='$name' + version_type=windows + shrext_cmds=.dll + need_version=no + need_lib_prefix=no + # OS/2 can only load a DLL with a base name of 8 characters or less. + soname_spec='`test -n "$os2dllname" && libname="$os2dllname"; + v=$($ECHO $release$versuffix | tr -d .-); + n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _); + $ECHO $n$v`$shared_ext' + library_names_spec='${libname}_dll.$libext' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=BEGINLIBPATH + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='$libname$release$shared_ext$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + +rdos*) + dynamic_linker=no + ;; + +solaris*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test yes = "$with_gnu_ld"; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec; then + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext' + soname_spec='$libname$shared_ext.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=sco + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + if test yes = "$with_gnu_ld"; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +tpf*) + # TPF is a cross-target only. Preferred cross-host = GNU/Linux. + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +uts4*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 +$as_echo "$dynamic_linker" >&6; } +test no = "$dynamic_linker" && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test yes = "$GCC"; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then + sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec +fi + +if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then + sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec +fi + +# remember unaugmented sys_lib_dlsearch_path content for libtool script decls... +configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec + +# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code +func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH" + +# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool +configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 +$as_echo_n "checking how to hardcode library paths into programs... " >&6; } +hardcode_action= +if test -n "$hardcode_libdir_flag_spec" || + test -n "$runpath_var" || + test yes = "$hardcode_automatic"; then + + # We can hardcode non-existent directories. + if test no != "$hardcode_direct" && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, )" && + test no != "$hardcode_minus_L"; then + # Linking always hardcodes the temporary library directory. + hardcode_action=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action=unsupported +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 +$as_echo "$hardcode_action" >&6; } + +if test relink = "$hardcode_action" || + test yes = "$inherit_rpath"; then + # Fast installation is not supported + enable_fast_install=no +elif test yes = "$shlibpath_overrides_runpath" || + test no = "$enable_shared"; then + # Fast installation is not necessary + enable_fast_install=needless +fi + + + + + + + if test yes != "$enable_dlopen"; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen=load_add_on + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32* | cegcc*) + lt_cv_dlopen=LoadLibrary + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen=dlopen + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 +$as_echo_n "checking for dlopen in -ldl... " >&6; } +if ${ac_cv_lib_dl_dlopen+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_dl_dlopen=yes +else + ac_cv_lib_dl_dlopen=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 +$as_echo "$ac_cv_lib_dl_dlopen" >&6; } +if test "x$ac_cv_lib_dl_dlopen" = xyes; then : + lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl +else + + lt_cv_dlopen=dyld + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + +fi + + ;; + + tpf*) + # Don't try to run any link tests for TPF. We know it's impossible + # because TPF is a cross-compiler, and we know how we open DSOs. + lt_cv_dlopen=dlopen + lt_cv_dlopen_libs= + lt_cv_dlopen_self=no + ;; + + *) + ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" +if test "x$ac_cv_func_shl_load" = xyes; then : + lt_cv_dlopen=shl_load +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 +$as_echo_n "checking for shl_load in -ldld... " >&6; } +if ${ac_cv_lib_dld_shl_load+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char shl_load (); +int +main () +{ +return shl_load (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_dld_shl_load=yes +else + ac_cv_lib_dld_shl_load=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 +$as_echo "$ac_cv_lib_dld_shl_load" >&6; } +if test "x$ac_cv_lib_dld_shl_load" = xyes; then : + lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld +else + ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" +if test "x$ac_cv_func_dlopen" = xyes; then : + lt_cv_dlopen=dlopen +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 +$as_echo_n "checking for dlopen in -ldl... " >&6; } +if ${ac_cv_lib_dl_dlopen+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_dl_dlopen=yes +else + ac_cv_lib_dl_dlopen=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 +$as_echo "$ac_cv_lib_dl_dlopen" >&6; } +if test "x$ac_cv_lib_dl_dlopen" = xyes; then : + lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 +$as_echo_n "checking for dlopen in -lsvld... " >&6; } +if ${ac_cv_lib_svld_dlopen+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsvld $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_svld_dlopen=yes +else + ac_cv_lib_svld_dlopen=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 +$as_echo "$ac_cv_lib_svld_dlopen" >&6; } +if test "x$ac_cv_lib_svld_dlopen" = xyes; then : + lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 +$as_echo_n "checking for dld_link in -ldld... " >&6; } +if ${ac_cv_lib_dld_dld_link+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dld_link (); +int +main () +{ +return dld_link (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_dld_dld_link=yes +else + ac_cv_lib_dld_dld_link=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 +$as_echo "$ac_cv_lib_dld_dld_link" >&6; } +if test "x$ac_cv_lib_dld_dld_link" = xyes; then : + lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld +fi + + +fi + + +fi + + +fi + + +fi + + +fi + + ;; + esac + + if test no = "$lt_cv_dlopen"; then + enable_dlopen=no + else + enable_dlopen=yes + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS=$CPPFLAGS + test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS=$LDFLAGS + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS=$LIBS + LIBS="$lt_cv_dlopen_libs $LIBS" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 +$as_echo_n "checking whether a program can dlopen itself... " >&6; } +if ${lt_cv_dlopen_self+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test yes = "$cross_compiling"; then : + lt_cv_dlopen_self=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +#line $LINENO "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +/* When -fvisibility=hidden is used, assume the code has been annotated + correspondingly for the symbols needed. */ +#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) +int fnord () __attribute__((visibility("default"))); +#endif + +int fnord () { return 42; } +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else + { + if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + else puts (dlerror ()); + } + /* dlclose (self); */ + } + else + puts (dlerror ()); + + return status; +} +_LT_EOF + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 + (eval $ac_link) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then + (./conftest; exit; ) >&5 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; + x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self=no + fi +fi +rm -fr conftest* + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 +$as_echo "$lt_cv_dlopen_self" >&6; } + + if test yes = "$lt_cv_dlopen_self"; then + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 +$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } +if ${lt_cv_dlopen_self_static+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test yes = "$cross_compiling"; then : + lt_cv_dlopen_self_static=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +#line $LINENO "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +/* When -fvisibility=hidden is used, assume the code has been annotated + correspondingly for the symbols needed. */ +#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) +int fnord () __attribute__((visibility("default"))); +#endif + +int fnord () { return 42; } +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else + { + if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + else puts (dlerror ()); + } + /* dlclose (self); */ + } + else + puts (dlerror ()); + + return status; +} +_LT_EOF + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 + (eval $ac_link) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then + (./conftest; exit; ) >&5 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self_static=no + fi +fi +rm -fr conftest* + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 +$as_echo "$lt_cv_dlopen_self_static" >&6; } + fi + + CPPFLAGS=$save_CPPFLAGS + LDFLAGS=$save_LDFLAGS + LIBS=$save_LIBS + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi + + + + + + + + + + + + + + + + + +striplib= +old_striplib= +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 +$as_echo_n "checking whether stripping libraries is possible... " >&6; } +if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP"; then + striplib="$STRIP -x" + old_striplib="$STRIP -S" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + fi + ;; + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + ;; + esac +fi + + + + + + + + + + + + + # Report what library types will actually be built + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 +$as_echo_n "checking if libtool supports shared libraries... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 +$as_echo "$can_build_shared" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 +$as_echo_n "checking whether to build shared libraries... " >&6; } + test no = "$can_build_shared" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test yes = "$enable_shared" && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + + aix[4-9]*) + if test ia64 != "$host_cpu"; then + case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in + yes,aix,yes) ;; # shared object as lib.so file only + yes,svr4,*) ;; # shared object as lib.so archive member only + yes,*) enable_static=no ;; # shared object in lib.a archive as well + esac + fi + ;; + esac + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 +$as_echo "$enable_shared" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 +$as_echo_n "checking whether to build static libraries... " >&6; } + # Make sure either enable_shared or enable_static is yes. + test yes = "$enable_shared" || enable_static=yes + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 +$as_echo "$enable_static" >&6; } + + + + +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +CC=$lt_save_CC + + + + + + + + + + + + + + + + ac_config_commands="$ac_config_commands libtool" + + + + +# Only expand once: + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether small structs are returned in registers" >&5 +$as_echo_n "checking whether small structs are returned in registers... " >&6; } +if ${ffcall_cv_c_struct_return_small+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + case "$HOST_CPU_C_ABI" in + alpha) ffcall_cv_c_struct_return_small="guessing no" ;; + arm | armhf | arm64) ffcall_cv_c_struct_return_small="guessing yes" ;; + hppa | hppa64) ffcall_cv_c_struct_return_small="guessing yes" ;; + i386) + case "$host_os" in + cygwin* | darwin* | mingw*) ffcall_cv_c_struct_return_small="guessing yes" ;; + linux* | solaris*) ffcall_cv_c_struct_return_small="guessing no" ;; + *) ffcall_cv_c_struct_return_small="guessing no" ;; + esac + ;; + ia64) ffcall_cv_c_struct_return_small="guessing yes" ;; + mips | mipsn32) ffcall_cv_c_struct_return_small="guessing no" ;; + mips64) ffcall_cv_c_struct_return_small="guessing yes" ;; + powerpc | powerpc64) ffcall_cv_c_struct_return_small="guessing no" ;; + powerpc64-elfv2) ffcall_cv_c_struct_return_small="guessing yes" ;; + s390 | s390x) ffcall_cv_c_struct_return_small="guessing no" ;; + sparc) ffcall_cv_c_struct_return_small="guessing no" ;; + sparc64) ffcall_cv_c_struct_return_small="guessing yes" ;; + x86_64) ffcall_cv_c_struct_return_small="guessing yes" ;; + *) ffcall_cv_c_struct_return_small="guessing no" ;; + esac + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#if defined __MACH__ && defined __APPLE__ +/* Avoid a crash on Mac OS X. */ +#include +#include +#include +#include +#include +#include +/* The exception port on which our thread listens. */ +static mach_port_t our_exception_port; +/* The main function of the thread listening for exceptions of type + EXC_BAD_ACCESS. */ +static void * +mach_exception_thread (void *arg) +{ + /* Buffer for a message to be received. */ + struct { + mach_msg_header_t head; + mach_msg_body_t msgh_body; + char data[1024]; + } msg; + mach_msg_return_t retval; + /* Wait for a message on the exception port. */ + retval = mach_msg (&msg.head, MACH_RCV_MSG | MACH_RCV_LARGE, 0, sizeof (msg), + our_exception_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (retval != MACH_MSG_SUCCESS) + abort (); + exit (1); +} +static void +nocrash_init (void) +{ + mach_port_t self = mach_task_self (); + /* Allocate a port on which the thread shall listen for exceptions. */ + if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port) + == KERN_SUCCESS) { + /* See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/mach_port_insert_right.html. */ + if (mach_port_insert_right (self, our_exception_port, our_exception_port, + MACH_MSG_TYPE_MAKE_SEND) + == KERN_SUCCESS) { + /* The exceptions we want to catch. Only EXC_BAD_ACCESS is interesting + for us. */ + exception_mask_t mask = EXC_MASK_BAD_ACCESS; + /* Create the thread listening on the exception port. */ + pthread_attr_t attr; + pthread_t thread; + if (pthread_attr_init (&attr) == 0 + && pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) == 0 + && pthread_create (&thread, &attr, mach_exception_thread, NULL) == 0) { + pthread_attr_destroy (&attr); + /* Replace the exception port info for these exceptions with our own. + Note that we replace the exception port for the entire task, not only + for a particular thread. This has the effect that when our exception + port gets the message, the thread specific exception port has already + been asked, and we don't need to bother about it. + See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/task_set_exception_ports.html. */ + task_set_exception_ports (self, mask, our_exception_port, + EXCEPTION_DEFAULT, MACHINE_THREAD_STATE); + } + } + } +} +#elif defined _WIN32 && ! defined __CYGWIN__ +/* Avoid a crash on native Windows. */ +#define WIN32_LEAN_AND_MEAN +#include +#include +static LONG WINAPI +exception_filter (EXCEPTION_POINTERS *ExceptionInfo) +{ + switch (ExceptionInfo->ExceptionRecord->ExceptionCode) + { + case EXCEPTION_ACCESS_VIOLATION: + case EXCEPTION_IN_PAGE_ERROR: + case EXCEPTION_STACK_OVERFLOW: + case EXCEPTION_GUARD_PAGE: + case EXCEPTION_PRIV_INSTRUCTION: + case EXCEPTION_ILLEGAL_INSTRUCTION: + case EXCEPTION_DATATYPE_MISALIGNMENT: + case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: + case EXCEPTION_NONCONTINUABLE_EXCEPTION: + exit (1); + } + return EXCEPTION_CONTINUE_SEARCH; +} +static void +nocrash_init (void) +{ + SetUnhandledExceptionFilter ((LPTOP_LEVEL_EXCEPTION_FILTER) exception_filter); +} +#else +/* Avoid a crash on POSIX systems. */ +#include +#include +/* A POSIX signal handler. */ +static void +exception_handler (int sig) +{ + _exit (1); +} +static void +nocrash_init (void) +{ +#ifdef SIGSEGV + signal (SIGSEGV, exception_handler); +#endif +#ifdef SIGBUS + signal (SIGBUS, exception_handler); +#endif +} +#endif + + typedef struct { long x; } foo; + long y; + foo foofun () { foo f; f.x = y; return f; } + long (*fun) () = (long (*) ()) foofun; + int main() + { nocrash_init(); + y = 37; if ((*fun)() != 37) return 1; + y = 55; if ((*fun)() != 55) return 1; + return 0; + } + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ffcall_cv_c_struct_return_small=yes +else + ffcall_cv_c_struct_return_small=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ffcall_cv_c_struct_return_small" >&5 +$as_echo "$ffcall_cv_c_struct_return_small" >&6; } + case "$ffcall_cv_c_struct_return_small" in + *yes) +$as_echo "#define __SMALL_STRUCT_RETURN__ /**/" >>confdefs.h + ;; + *no) ;; + esac + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether floats are returned in integer registers" >&5 +$as_echo_n "checking whether floats are returned in integer registers... " >&6; } +if ${ffcall_cv_c_float_return_ireg+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + ffcall_cv_c_float_return_ireg="guessing no" + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#if defined __MACH__ && defined __APPLE__ +/* Avoid a crash on Mac OS X. */ +#include +#include +#include +#include +#include +#include +/* The exception port on which our thread listens. */ +static mach_port_t our_exception_port; +/* The main function of the thread listening for exceptions of type + EXC_BAD_ACCESS. */ +static void * +mach_exception_thread (void *arg) +{ + /* Buffer for a message to be received. */ + struct { + mach_msg_header_t head; + mach_msg_body_t msgh_body; + char data[1024]; + } msg; + mach_msg_return_t retval; + /* Wait for a message on the exception port. */ + retval = mach_msg (&msg.head, MACH_RCV_MSG | MACH_RCV_LARGE, 0, sizeof (msg), + our_exception_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (retval != MACH_MSG_SUCCESS) + abort (); + exit (1); +} +static void +nocrash_init (void) +{ + mach_port_t self = mach_task_self (); + /* Allocate a port on which the thread shall listen for exceptions. */ + if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port) + == KERN_SUCCESS) { + /* See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/mach_port_insert_right.html. */ + if (mach_port_insert_right (self, our_exception_port, our_exception_port, + MACH_MSG_TYPE_MAKE_SEND) + == KERN_SUCCESS) { + /* The exceptions we want to catch. Only EXC_BAD_ACCESS is interesting + for us. */ + exception_mask_t mask = EXC_MASK_BAD_ACCESS; + /* Create the thread listening on the exception port. */ + pthread_attr_t attr; + pthread_t thread; + if (pthread_attr_init (&attr) == 0 + && pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) == 0 + && pthread_create (&thread, &attr, mach_exception_thread, NULL) == 0) { + pthread_attr_destroy (&attr); + /* Replace the exception port info for these exceptions with our own. + Note that we replace the exception port for the entire task, not only + for a particular thread. This has the effect that when our exception + port gets the message, the thread specific exception port has already + been asked, and we don't need to bother about it. + See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/task_set_exception_ports.html. */ + task_set_exception_ports (self, mask, our_exception_port, + EXCEPTION_DEFAULT, MACHINE_THREAD_STATE); + } + } + } +} +#elif defined _WIN32 && ! defined __CYGWIN__ +/* Avoid a crash on native Windows. */ +#define WIN32_LEAN_AND_MEAN +#include +#include +static LONG WINAPI +exception_filter (EXCEPTION_POINTERS *ExceptionInfo) +{ + switch (ExceptionInfo->ExceptionRecord->ExceptionCode) + { + case EXCEPTION_ACCESS_VIOLATION: + case EXCEPTION_IN_PAGE_ERROR: + case EXCEPTION_STACK_OVERFLOW: + case EXCEPTION_GUARD_PAGE: + case EXCEPTION_PRIV_INSTRUCTION: + case EXCEPTION_ILLEGAL_INSTRUCTION: + case EXCEPTION_DATATYPE_MISALIGNMENT: + case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: + case EXCEPTION_NONCONTINUABLE_EXCEPTION: + exit (1); + } + return EXCEPTION_CONTINUE_SEARCH; +} +static void +nocrash_init (void) +{ + SetUnhandledExceptionFilter ((LPTOP_LEVEL_EXCEPTION_FILTER) exception_filter); +} +#else +/* Avoid a crash on POSIX systems. */ +#include +#include +/* A POSIX signal handler. */ +static void +exception_handler (int sig) +{ + _exit (1); +} +static void +nocrash_init (void) +{ +#ifdef SIGSEGV + signal (SIGSEGV, exception_handler); +#endif +#ifdef SIGBUS + signal (SIGBUS, exception_handler); +#endif +} +#endif + + float x = (float)1.2; + float y = (float)1.3; + float fun () { return x*y; } + int main() + { nocrash_init(); + {int val = (* (int (*) ()) fun) (); + return !(val == 0x3FC7AE15 || val == 0x15AEC73F); + }} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ffcall_cv_c_float_return_ireg=yes +else + ffcall_cv_c_float_return_ireg=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ffcall_cv_c_float_return_ireg" >&5 +$as_echo "$ffcall_cv_c_float_return_ireg" >&6; } + case "$ffcall_cv_c_float_return_ireg" in + *yes) +$as_echo "#define __IREG_FLOAT_RETURN__ /**/" >>confdefs.h + ;; + *no) ;; + esac + + +for ac_header in unistd_h +do : + ac_fn_c_check_header_mongrel "$LINENO" "unistd_h" "ac_cv_header_unistd_h" "$ac_includes_default" +if test "x$ac_cv_header_unistd_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_UNISTD_H 1 +_ACEOF + +fi + +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getpagesize" >&5 +$as_echo_n "checking for getpagesize... " >&6; } +if ${cl_cv_func_getpagesize+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef HAVE_UNISTD_H + #include + #include + #endif + +int +main () +{ +getpagesize(); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + cl_cv_func_getpagesize=yes +else + cl_cv_func_getpagesize=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cl_cv_func_getpagesize" >&5 +$as_echo "$cl_cv_func_getpagesize" >&6; } + if test $cl_cv_func_getpagesize = yes; then : + + +$as_echo "#define HAVE_GETPAGESIZE /**/" >>confdefs.h + + have_getpagesize=1 + +fi + + + if test -n "$have_getpagesize"; then + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getpagesize declaration" >&5 +$as_echo_n "checking for getpagesize declaration... " >&6; } + if ${cl_cv_proto_getpagesize+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #ifdef HAVE_UNISTD_H + #include + #endif + +extern +#ifdef __cplusplus +"C" +#endif + +int getpagesize(); + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + cl_cv_proto_getpagesize_ret="int" +else + cl_cv_proto_getpagesize_ret="size_t" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + + cl_cv_proto_getpagesize="extern $cl_cv_proto_getpagesize_ret getpagesize (void);" +fi + + cl_cv_proto_getpagesize=`echo "$cl_cv_proto_getpagesize" | tr -s ' ' | sed -e 's/( /(/'` + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${ac_t:- + }$cl_cv_proto_getpagesize" >&5 +$as_echo "${ac_t:- + }$cl_cv_proto_getpagesize" >&6; } + + +cat >>confdefs.h <<_ACEOF +#define RETGETPAGESIZETYPE $cl_cv_proto_getpagesize_ret +_ACEOF + + else + for ac_header in sys/param.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "sys/param.h" "ac_cv_header_sys_param_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_param_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYS_PARAM_H 1 +_ACEOF + +fi + +done + + fi + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for vm_allocate" >&5 +$as_echo_n "checking for vm_allocate... " >&6; } +if ${cl_cv_func_vm+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +vm_allocate(); task_self(); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + cl_cv_func_vm=yes +else + cl_cv_func_vm=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cl_cv_func_vm" >&5 +$as_echo "$cl_cv_func_vm" >&6; } + if test $cl_cv_func_vm = yes; then : + +$as_echo "#define HAVE_MACH_VM /**/" >>confdefs.h + +fi + + + + + + ac_fn_c_check_header_mongrel "$LINENO" "sys/mman.h" "ac_cv_header_sys_mman_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_mman_h" = xyes; then : + +else + no_mmap=1 +fi + + + if test -z "$no_mmap"; then + ac_fn_c_check_func "$LINENO" "mmap" "ac_cv_func_mmap" +if test "x$ac_cv_func_mmap" = xyes; then : + +else + no_mmap=1 +fi + + if test -z "$no_mmap"; then + +$as_echo "#define HAVE_MMAP /**/" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working mmap" >&5 +$as_echo_n "checking for working mmap... " >&6; } +if ${ffcall_cv_func_mmap_works+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test $cross_compiling = no; then + mmap_prog_1=' + #include + #ifdef HAVE_UNISTD_H + #include + #endif + #include + #include + #include + int main () + { + ' + mmap_prog_2=' + if (mmap(NULL,0x100000,PROT_READ|PROT_WRITE,flags,fd,0) == (void*)-1) + exit(1); + exit(0); + } + ' + if test "$cross_compiling" = yes; then : + : + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#if defined __MACH__ && defined __APPLE__ +/* Avoid a crash on Mac OS X. */ +#include +#include +#include +#include +#include +#include +/* The exception port on which our thread listens. */ +static mach_port_t our_exception_port; +/* The main function of the thread listening for exceptions of type + EXC_BAD_ACCESS. */ +static void * +mach_exception_thread (void *arg) +{ + /* Buffer for a message to be received. */ + struct { + mach_msg_header_t head; + mach_msg_body_t msgh_body; + char data[1024]; + } msg; + mach_msg_return_t retval; + /* Wait for a message on the exception port. */ + retval = mach_msg (&msg.head, MACH_RCV_MSG | MACH_RCV_LARGE, 0, sizeof (msg), + our_exception_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (retval != MACH_MSG_SUCCESS) + abort (); + exit (1); +} +static void +nocrash_init (void) +{ + mach_port_t self = mach_task_self (); + /* Allocate a port on which the thread shall listen for exceptions. */ + if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port) + == KERN_SUCCESS) { + /* See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/mach_port_insert_right.html. */ + if (mach_port_insert_right (self, our_exception_port, our_exception_port, + MACH_MSG_TYPE_MAKE_SEND) + == KERN_SUCCESS) { + /* The exceptions we want to catch. Only EXC_BAD_ACCESS is interesting + for us. */ + exception_mask_t mask = EXC_MASK_BAD_ACCESS; + /* Create the thread listening on the exception port. */ + pthread_attr_t attr; + pthread_t thread; + if (pthread_attr_init (&attr) == 0 + && pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) == 0 + && pthread_create (&thread, &attr, mach_exception_thread, NULL) == 0) { + pthread_attr_destroy (&attr); + /* Replace the exception port info for these exceptions with our own. + Note that we replace the exception port for the entire task, not only + for a particular thread. This has the effect that when our exception + port gets the message, the thread specific exception port has already + been asked, and we don't need to bother about it. + See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/task_set_exception_ports.html. */ + task_set_exception_ports (self, mask, our_exception_port, + EXCEPTION_DEFAULT, MACHINE_THREAD_STATE); + } + } + } +} +#elif defined _WIN32 && ! defined __CYGWIN__ +/* Avoid a crash on native Windows. */ +#define WIN32_LEAN_AND_MEAN +#include +#include +static LONG WINAPI +exception_filter (EXCEPTION_POINTERS *ExceptionInfo) +{ + switch (ExceptionInfo->ExceptionRecord->ExceptionCode) + { + case EXCEPTION_ACCESS_VIOLATION: + case EXCEPTION_IN_PAGE_ERROR: + case EXCEPTION_STACK_OVERFLOW: + case EXCEPTION_GUARD_PAGE: + case EXCEPTION_PRIV_INSTRUCTION: + case EXCEPTION_ILLEGAL_INSTRUCTION: + case EXCEPTION_DATATYPE_MISALIGNMENT: + case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: + case EXCEPTION_NONCONTINUABLE_EXCEPTION: + exit (1); + } + return EXCEPTION_CONTINUE_SEARCH; +} +static void +nocrash_init (void) +{ + SetUnhandledExceptionFilter ((LPTOP_LEVEL_EXCEPTION_FILTER) exception_filter); +} +#else +/* Avoid a crash on POSIX systems. */ +#include +#include +/* A POSIX signal handler. */ +static void +exception_handler (int sig) +{ + _exit (1); +} +static void +nocrash_init (void) +{ +#ifdef SIGSEGV + signal (SIGSEGV, exception_handler); +#endif +#ifdef SIGBUS + signal (SIGBUS, exception_handler); +#endif +} +#endif + + $mmap_prog_1 + int flags = MAP_ANON | MAP_PRIVATE; + int fd = -1; + nocrash_init(); + $mmap_prog_2 + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + have_mmap_anon=1 + ffcall_cv_func_mmap_anon=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + if test "$cross_compiling" = yes; then : + : + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#if defined __MACH__ && defined __APPLE__ +/* Avoid a crash on Mac OS X. */ +#include +#include +#include +#include +#include +#include +/* The exception port on which our thread listens. */ +static mach_port_t our_exception_port; +/* The main function of the thread listening for exceptions of type + EXC_BAD_ACCESS. */ +static void * +mach_exception_thread (void *arg) +{ + /* Buffer for a message to be received. */ + struct { + mach_msg_header_t head; + mach_msg_body_t msgh_body; + char data[1024]; + } msg; + mach_msg_return_t retval; + /* Wait for a message on the exception port. */ + retval = mach_msg (&msg.head, MACH_RCV_MSG | MACH_RCV_LARGE, 0, sizeof (msg), + our_exception_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (retval != MACH_MSG_SUCCESS) + abort (); + exit (1); +} +static void +nocrash_init (void) +{ + mach_port_t self = mach_task_self (); + /* Allocate a port on which the thread shall listen for exceptions. */ + if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port) + == KERN_SUCCESS) { + /* See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/mach_port_insert_right.html. */ + if (mach_port_insert_right (self, our_exception_port, our_exception_port, + MACH_MSG_TYPE_MAKE_SEND) + == KERN_SUCCESS) { + /* The exceptions we want to catch. Only EXC_BAD_ACCESS is interesting + for us. */ + exception_mask_t mask = EXC_MASK_BAD_ACCESS; + /* Create the thread listening on the exception port. */ + pthread_attr_t attr; + pthread_t thread; + if (pthread_attr_init (&attr) == 0 + && pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) == 0 + && pthread_create (&thread, &attr, mach_exception_thread, NULL) == 0) { + pthread_attr_destroy (&attr); + /* Replace the exception port info for these exceptions with our own. + Note that we replace the exception port for the entire task, not only + for a particular thread. This has the effect that when our exception + port gets the message, the thread specific exception port has already + been asked, and we don't need to bother about it. + See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/task_set_exception_ports.html. */ + task_set_exception_ports (self, mask, our_exception_port, + EXCEPTION_DEFAULT, MACHINE_THREAD_STATE); + } + } + } +} +#elif defined _WIN32 && ! defined __CYGWIN__ +/* Avoid a crash on native Windows. */ +#define WIN32_LEAN_AND_MEAN +#include +#include +static LONG WINAPI +exception_filter (EXCEPTION_POINTERS *ExceptionInfo) +{ + switch (ExceptionInfo->ExceptionRecord->ExceptionCode) + { + case EXCEPTION_ACCESS_VIOLATION: + case EXCEPTION_IN_PAGE_ERROR: + case EXCEPTION_STACK_OVERFLOW: + case EXCEPTION_GUARD_PAGE: + case EXCEPTION_PRIV_INSTRUCTION: + case EXCEPTION_ILLEGAL_INSTRUCTION: + case EXCEPTION_DATATYPE_MISALIGNMENT: + case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: + case EXCEPTION_NONCONTINUABLE_EXCEPTION: + exit (1); + } + return EXCEPTION_CONTINUE_SEARCH; +} +static void +nocrash_init (void) +{ + SetUnhandledExceptionFilter ((LPTOP_LEVEL_EXCEPTION_FILTER) exception_filter); +} +#else +/* Avoid a crash on POSIX systems. */ +#include +#include +/* A POSIX signal handler. */ +static void +exception_handler (int sig) +{ + _exit (1); +} +static void +nocrash_init (void) +{ +#ifdef SIGSEGV + signal (SIGSEGV, exception_handler); +#endif +#ifdef SIGBUS + signal (SIGBUS, exception_handler); +#endif +} +#endif + + $mmap_prog_1 + int flags = MAP_ANONYMOUS | MAP_PRIVATE; + int fd = -1; + nocrash_init(); + $mmap_prog_2 + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + have_mmap_anon=1 + ffcall_cv_func_mmap_anonymous=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + if test "$cross_compiling" = yes; then : + : + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#if defined __MACH__ && defined __APPLE__ +/* Avoid a crash on Mac OS X. */ +#include +#include +#include +#include +#include +#include +/* The exception port on which our thread listens. */ +static mach_port_t our_exception_port; +/* The main function of the thread listening for exceptions of type + EXC_BAD_ACCESS. */ +static void * +mach_exception_thread (void *arg) +{ + /* Buffer for a message to be received. */ + struct { + mach_msg_header_t head; + mach_msg_body_t msgh_body; + char data[1024]; + } msg; + mach_msg_return_t retval; + /* Wait for a message on the exception port. */ + retval = mach_msg (&msg.head, MACH_RCV_MSG | MACH_RCV_LARGE, 0, sizeof (msg), + our_exception_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (retval != MACH_MSG_SUCCESS) + abort (); + exit (1); +} +static void +nocrash_init (void) +{ + mach_port_t self = mach_task_self (); + /* Allocate a port on which the thread shall listen for exceptions. */ + if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port) + == KERN_SUCCESS) { + /* See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/mach_port_insert_right.html. */ + if (mach_port_insert_right (self, our_exception_port, our_exception_port, + MACH_MSG_TYPE_MAKE_SEND) + == KERN_SUCCESS) { + /* The exceptions we want to catch. Only EXC_BAD_ACCESS is interesting + for us. */ + exception_mask_t mask = EXC_MASK_BAD_ACCESS; + /* Create the thread listening on the exception port. */ + pthread_attr_t attr; + pthread_t thread; + if (pthread_attr_init (&attr) == 0 + && pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) == 0 + && pthread_create (&thread, &attr, mach_exception_thread, NULL) == 0) { + pthread_attr_destroy (&attr); + /* Replace the exception port info for these exceptions with our own. + Note that we replace the exception port for the entire task, not only + for a particular thread. This has the effect that when our exception + port gets the message, the thread specific exception port has already + been asked, and we don't need to bother about it. + See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/task_set_exception_ports.html. */ + task_set_exception_ports (self, mask, our_exception_port, + EXCEPTION_DEFAULT, MACHINE_THREAD_STATE); + } + } + } +} +#elif defined _WIN32 && ! defined __CYGWIN__ +/* Avoid a crash on native Windows. */ +#define WIN32_LEAN_AND_MEAN +#include +#include +static LONG WINAPI +exception_filter (EXCEPTION_POINTERS *ExceptionInfo) +{ + switch (ExceptionInfo->ExceptionRecord->ExceptionCode) + { + case EXCEPTION_ACCESS_VIOLATION: + case EXCEPTION_IN_PAGE_ERROR: + case EXCEPTION_STACK_OVERFLOW: + case EXCEPTION_GUARD_PAGE: + case EXCEPTION_PRIV_INSTRUCTION: + case EXCEPTION_ILLEGAL_INSTRUCTION: + case EXCEPTION_DATATYPE_MISALIGNMENT: + case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: + case EXCEPTION_NONCONTINUABLE_EXCEPTION: + exit (1); + } + return EXCEPTION_CONTINUE_SEARCH; +} +static void +nocrash_init (void) +{ + SetUnhandledExceptionFilter ((LPTOP_LEVEL_EXCEPTION_FILTER) exception_filter); +} +#else +/* Avoid a crash on POSIX systems. */ +#include +#include +/* A POSIX signal handler. */ +static void +exception_handler (int sig) +{ + _exit (1); +} +static void +nocrash_init (void) +{ +#ifdef SIGSEGV + signal (SIGSEGV, exception_handler); +#endif +#ifdef SIGBUS + signal (SIGBUS, exception_handler); +#endif +} +#endif + + $mmap_prog_1 + #ifndef MAP_FILE + #define MAP_FILE 0 + #endif + int flags = MAP_FILE | MAP_PRIVATE; + int fd = open("/dev/zero",O_RDONLY,0666); + if (fd<0) + exit(1); + nocrash_init(); + $mmap_prog_2 + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + have_mmap_devzero=1 + ffcall_cv_func_mmap_devzero=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + if test -n "$have_mmap_anon" -o -n "$have_mmap_devzero"; then + ffcall_cv_func_mmap_works=yes + else + ffcall_cv_func_mmap_works=no + fi + else + case "$host_os" in + aix* | cygwin* | darwin* | hpux* | irix* | linux* | solaris*) + ffcall_cv_func_mmap_works="guessing yes" ;; + *) + ffcall_cv_func_mmap_works="guessing no" ;; + esac + case "$host_os" in + aix* | cygwin* | darwin* | linux* | solaris*) + ffcall_cv_func_mmap_anon="guessing yes" ;; + *) + ffcall_cv_func_mmap_anon="guessing no" ;; + esac + case "$host_os" in + aix* | cygwin* | hpux* | linux* | solaris*) + ffcall_cv_func_mmap_anonymous="guessing yes" ;; + *) + ffcall_cv_func_mmap_anonymous="guessing no" ;; + esac + case "$host_os" in + aix* | cygwin* | hpux* | irix* | linux* | solaris*) + ffcall_cv_func_mmap_devzero="guessing yes" ;; + *) + ffcall_cv_func_mmap_devzero="guessing no" ;; + esac + fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ffcall_cv_func_mmap_works" >&5 +$as_echo "$ffcall_cv_func_mmap_works" >&6; } + case "$ffcall_cv_func_mmap_anon" in + *yes) + +$as_echo "#define HAVE_MMAP_ANON /**/" >>confdefs.h + + ;; + esac + case "$ffcall_cv_func_mmap_anonymous" in + *yes) + +$as_echo "#define HAVE_MMAP_ANONYMOUS /**/" >>confdefs.h + + ;; + esac + case "$ffcall_cv_func_mmap_devzero" in + *yes) + +$as_echo "#define HAVE_MMAP_DEVZERO /**/" >>confdefs.h + + ;; + esac + fi + fi + + + + + + for ac_func in mprotect +do : + ac_fn_c_check_func "$LINENO" "mprotect" "ac_cv_func_mprotect" +if test "x$ac_cv_func_mprotect" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_MPROTECT 1 +_ACEOF + +fi +done + + if test $ac_cv_func_mprotect = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working mprotect" >&5 +$as_echo_n "checking for working mprotect... " >&6; } +if ${cl_cv_func_mprotect_works+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test $cross_compiling = no; then + mprotect_prog=' + #include + /* declare malloc() */ + #include + #ifdef HAVE_UNISTD_H + #include + #endif + /* declare getpagesize() and mprotect() */ + #include + #ifndef HAVE_GETPAGESIZE + #include + #define getpagesize() PAGESIZE + #else + extern +#ifdef __cplusplus +"C" +#endif + + RETGETPAGESIZETYPE getpagesize (void); + #endif + char foo; + int main () + { + unsigned long pagesize = getpagesize(); + #define page_align(address) (char*)((unsigned long)(address) & -pagesize) + ' + if test "$cross_compiling" = yes; then : + no_mprotect=1 + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$mprotect_prog + if ((pagesize-1) & pagesize) exit(1); + exit(0); + } + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + no_mprotect=1 +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + mprotect_prog="$mprotect_prog"' + char* area = (char*) malloc(6*pagesize); + char* fault_address = area + pagesize*7/2; + ' + if test -z "$no_mprotect"; then + if test "$cross_compiling" = yes; then : + : + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#if defined __MACH__ && defined __APPLE__ +/* Avoid a crash on Mac OS X. */ +#include +#include +#include +#include +#include +#include +/* The exception port on which our thread listens. */ +static mach_port_t our_exception_port; +/* The main function of the thread listening for exceptions of type + EXC_BAD_ACCESS. */ +static void * +mach_exception_thread (void *arg) +{ + /* Buffer for a message to be received. */ + struct { + mach_msg_header_t head; + mach_msg_body_t msgh_body; + char data[1024]; + } msg; + mach_msg_return_t retval; + /* Wait for a message on the exception port. */ + retval = mach_msg (&msg.head, MACH_RCV_MSG | MACH_RCV_LARGE, 0, sizeof (msg), + our_exception_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (retval != MACH_MSG_SUCCESS) + abort (); + exit (1); +} +static void +nocrash_init (void) +{ + mach_port_t self = mach_task_self (); + /* Allocate a port on which the thread shall listen for exceptions. */ + if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port) + == KERN_SUCCESS) { + /* See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/mach_port_insert_right.html. */ + if (mach_port_insert_right (self, our_exception_port, our_exception_port, + MACH_MSG_TYPE_MAKE_SEND) + == KERN_SUCCESS) { + /* The exceptions we want to catch. Only EXC_BAD_ACCESS is interesting + for us. */ + exception_mask_t mask = EXC_MASK_BAD_ACCESS; + /* Create the thread listening on the exception port. */ + pthread_attr_t attr; + pthread_t thread; + if (pthread_attr_init (&attr) == 0 + && pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) == 0 + && pthread_create (&thread, &attr, mach_exception_thread, NULL) == 0) { + pthread_attr_destroy (&attr); + /* Replace the exception port info for these exceptions with our own. + Note that we replace the exception port for the entire task, not only + for a particular thread. This has the effect that when our exception + port gets the message, the thread specific exception port has already + been asked, and we don't need to bother about it. + See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/task_set_exception_ports.html. */ + task_set_exception_ports (self, mask, our_exception_port, + EXCEPTION_DEFAULT, MACHINE_THREAD_STATE); + } + } + } +} +#elif defined _WIN32 && ! defined __CYGWIN__ +/* Avoid a crash on native Windows. */ +#define WIN32_LEAN_AND_MEAN +#include +#include +static LONG WINAPI +exception_filter (EXCEPTION_POINTERS *ExceptionInfo) +{ + switch (ExceptionInfo->ExceptionRecord->ExceptionCode) + { + case EXCEPTION_ACCESS_VIOLATION: + case EXCEPTION_IN_PAGE_ERROR: + case EXCEPTION_STACK_OVERFLOW: + case EXCEPTION_GUARD_PAGE: + case EXCEPTION_PRIV_INSTRUCTION: + case EXCEPTION_ILLEGAL_INSTRUCTION: + case EXCEPTION_DATATYPE_MISALIGNMENT: + case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: + case EXCEPTION_NONCONTINUABLE_EXCEPTION: + exit (1); + } + return EXCEPTION_CONTINUE_SEARCH; +} +static void +nocrash_init (void) +{ + SetUnhandledExceptionFilter ((LPTOP_LEVEL_EXCEPTION_FILTER) exception_filter); +} +#else +/* Avoid a crash on POSIX systems. */ +#include +#include +/* A POSIX signal handler. */ +static void +exception_handler (int sig) +{ + _exit (1); +} +static void +nocrash_init (void) +{ +#ifdef SIGSEGV + signal (SIGSEGV, exception_handler); +#endif +#ifdef SIGBUS + signal (SIGBUS, exception_handler); +#endif +} +#endif + + $mprotect_prog + nocrash_init(); + if (mprotect(page_align(fault_address),pagesize,PROT_NONE) < 0) + exit(0); + foo = *fault_address; /* this should cause an exception or signal */ + exit(0); + } + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + no_mprotect=1 +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + fi + if test -z "$no_mprotect"; then + if test "$cross_compiling" = yes; then : + : + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#if defined __MACH__ && defined __APPLE__ +/* Avoid a crash on Mac OS X. */ +#include +#include +#include +#include +#include +#include +/* The exception port on which our thread listens. */ +static mach_port_t our_exception_port; +/* The main function of the thread listening for exceptions of type + EXC_BAD_ACCESS. */ +static void * +mach_exception_thread (void *arg) +{ + /* Buffer for a message to be received. */ + struct { + mach_msg_header_t head; + mach_msg_body_t msgh_body; + char data[1024]; + } msg; + mach_msg_return_t retval; + /* Wait for a message on the exception port. */ + retval = mach_msg (&msg.head, MACH_RCV_MSG | MACH_RCV_LARGE, 0, sizeof (msg), + our_exception_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (retval != MACH_MSG_SUCCESS) + abort (); + exit (1); +} +static void +nocrash_init (void) +{ + mach_port_t self = mach_task_self (); + /* Allocate a port on which the thread shall listen for exceptions. */ + if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port) + == KERN_SUCCESS) { + /* See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/mach_port_insert_right.html. */ + if (mach_port_insert_right (self, our_exception_port, our_exception_port, + MACH_MSG_TYPE_MAKE_SEND) + == KERN_SUCCESS) { + /* The exceptions we want to catch. Only EXC_BAD_ACCESS is interesting + for us. */ + exception_mask_t mask = EXC_MASK_BAD_ACCESS; + /* Create the thread listening on the exception port. */ + pthread_attr_t attr; + pthread_t thread; + if (pthread_attr_init (&attr) == 0 + && pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) == 0 + && pthread_create (&thread, &attr, mach_exception_thread, NULL) == 0) { + pthread_attr_destroy (&attr); + /* Replace the exception port info for these exceptions with our own. + Note that we replace the exception port for the entire task, not only + for a particular thread. This has the effect that when our exception + port gets the message, the thread specific exception port has already + been asked, and we don't need to bother about it. + See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/task_set_exception_ports.html. */ + task_set_exception_ports (self, mask, our_exception_port, + EXCEPTION_DEFAULT, MACHINE_THREAD_STATE); + } + } + } +} +#elif defined _WIN32 && ! defined __CYGWIN__ +/* Avoid a crash on native Windows. */ +#define WIN32_LEAN_AND_MEAN +#include +#include +static LONG WINAPI +exception_filter (EXCEPTION_POINTERS *ExceptionInfo) +{ + switch (ExceptionInfo->ExceptionRecord->ExceptionCode) + { + case EXCEPTION_ACCESS_VIOLATION: + case EXCEPTION_IN_PAGE_ERROR: + case EXCEPTION_STACK_OVERFLOW: + case EXCEPTION_GUARD_PAGE: + case EXCEPTION_PRIV_INSTRUCTION: + case EXCEPTION_ILLEGAL_INSTRUCTION: + case EXCEPTION_DATATYPE_MISALIGNMENT: + case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: + case EXCEPTION_NONCONTINUABLE_EXCEPTION: + exit (1); + } + return EXCEPTION_CONTINUE_SEARCH; +} +static void +nocrash_init (void) +{ + SetUnhandledExceptionFilter ((LPTOP_LEVEL_EXCEPTION_FILTER) exception_filter); +} +#else +/* Avoid a crash on POSIX systems. */ +#include +#include +/* A POSIX signal handler. */ +static void +exception_handler (int sig) +{ + _exit (1); +} +static void +nocrash_init (void) +{ +#ifdef SIGSEGV + signal (SIGSEGV, exception_handler); +#endif +#ifdef SIGBUS + signal (SIGBUS, exception_handler); +#endif +} +#endif + + $mprotect_prog + nocrash_init(); + if (mprotect(page_align(fault_address),pagesize,PROT_NONE) < 0) + exit(0); + *fault_address = 'z'; /* this should cause an exception or signal */ + exit(0); + } + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + no_mprotect=1 +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + fi + if test -z "$no_mprotect"; then + if test "$cross_compiling" = yes; then : + : + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#if defined __MACH__ && defined __APPLE__ +/* Avoid a crash on Mac OS X. */ +#include +#include +#include +#include +#include +#include +/* The exception port on which our thread listens. */ +static mach_port_t our_exception_port; +/* The main function of the thread listening for exceptions of type + EXC_BAD_ACCESS. */ +static void * +mach_exception_thread (void *arg) +{ + /* Buffer for a message to be received. */ + struct { + mach_msg_header_t head; + mach_msg_body_t msgh_body; + char data[1024]; + } msg; + mach_msg_return_t retval; + /* Wait for a message on the exception port. */ + retval = mach_msg (&msg.head, MACH_RCV_MSG | MACH_RCV_LARGE, 0, sizeof (msg), + our_exception_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (retval != MACH_MSG_SUCCESS) + abort (); + exit (1); +} +static void +nocrash_init (void) +{ + mach_port_t self = mach_task_self (); + /* Allocate a port on which the thread shall listen for exceptions. */ + if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port) + == KERN_SUCCESS) { + /* See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/mach_port_insert_right.html. */ + if (mach_port_insert_right (self, our_exception_port, our_exception_port, + MACH_MSG_TYPE_MAKE_SEND) + == KERN_SUCCESS) { + /* The exceptions we want to catch. Only EXC_BAD_ACCESS is interesting + for us. */ + exception_mask_t mask = EXC_MASK_BAD_ACCESS; + /* Create the thread listening on the exception port. */ + pthread_attr_t attr; + pthread_t thread; + if (pthread_attr_init (&attr) == 0 + && pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) == 0 + && pthread_create (&thread, &attr, mach_exception_thread, NULL) == 0) { + pthread_attr_destroy (&attr); + /* Replace the exception port info for these exceptions with our own. + Note that we replace the exception port for the entire task, not only + for a particular thread. This has the effect that when our exception + port gets the message, the thread specific exception port has already + been asked, and we don't need to bother about it. + See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/task_set_exception_ports.html. */ + task_set_exception_ports (self, mask, our_exception_port, + EXCEPTION_DEFAULT, MACHINE_THREAD_STATE); + } + } + } +} +#elif defined _WIN32 && ! defined __CYGWIN__ +/* Avoid a crash on native Windows. */ +#define WIN32_LEAN_AND_MEAN +#include +#include +static LONG WINAPI +exception_filter (EXCEPTION_POINTERS *ExceptionInfo) +{ + switch (ExceptionInfo->ExceptionRecord->ExceptionCode) + { + case EXCEPTION_ACCESS_VIOLATION: + case EXCEPTION_IN_PAGE_ERROR: + case EXCEPTION_STACK_OVERFLOW: + case EXCEPTION_GUARD_PAGE: + case EXCEPTION_PRIV_INSTRUCTION: + case EXCEPTION_ILLEGAL_INSTRUCTION: + case EXCEPTION_DATATYPE_MISALIGNMENT: + case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: + case EXCEPTION_NONCONTINUABLE_EXCEPTION: + exit (1); + } + return EXCEPTION_CONTINUE_SEARCH; +} +static void +nocrash_init (void) +{ + SetUnhandledExceptionFilter ((LPTOP_LEVEL_EXCEPTION_FILTER) exception_filter); +} +#else +/* Avoid a crash on POSIX systems. */ +#include +#include +/* A POSIX signal handler. */ +static void +exception_handler (int sig) +{ + _exit (1); +} +static void +nocrash_init (void) +{ +#ifdef SIGSEGV + signal (SIGSEGV, exception_handler); +#endif +#ifdef SIGBUS + signal (SIGBUS, exception_handler); +#endif +} +#endif + + $mprotect_prog + nocrash_init(); + if (mprotect(page_align(fault_address),pagesize,PROT_READ) < 0) + exit(0); + *fault_address = 'z'; /* this should cause an exception or signal */ + exit(0); + } + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + no_mprotect=1 +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + fi + if test -z "$no_mprotect"; then + if test "$cross_compiling" = yes; then : + : + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#if defined __MACH__ && defined __APPLE__ +/* Avoid a crash on Mac OS X. */ +#include +#include +#include +#include +#include +#include +/* The exception port on which our thread listens. */ +static mach_port_t our_exception_port; +/* The main function of the thread listening for exceptions of type + EXC_BAD_ACCESS. */ +static void * +mach_exception_thread (void *arg) +{ + /* Buffer for a message to be received. */ + struct { + mach_msg_header_t head; + mach_msg_body_t msgh_body; + char data[1024]; + } msg; + mach_msg_return_t retval; + /* Wait for a message on the exception port. */ + retval = mach_msg (&msg.head, MACH_RCV_MSG | MACH_RCV_LARGE, 0, sizeof (msg), + our_exception_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (retval != MACH_MSG_SUCCESS) + abort (); + exit (1); +} +static void +nocrash_init (void) +{ + mach_port_t self = mach_task_self (); + /* Allocate a port on which the thread shall listen for exceptions. */ + if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port) + == KERN_SUCCESS) { + /* See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/mach_port_insert_right.html. */ + if (mach_port_insert_right (self, our_exception_port, our_exception_port, + MACH_MSG_TYPE_MAKE_SEND) + == KERN_SUCCESS) { + /* The exceptions we want to catch. Only EXC_BAD_ACCESS is interesting + for us. */ + exception_mask_t mask = EXC_MASK_BAD_ACCESS; + /* Create the thread listening on the exception port. */ + pthread_attr_t attr; + pthread_t thread; + if (pthread_attr_init (&attr) == 0 + && pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) == 0 + && pthread_create (&thread, &attr, mach_exception_thread, NULL) == 0) { + pthread_attr_destroy (&attr); + /* Replace the exception port info for these exceptions with our own. + Note that we replace the exception port for the entire task, not only + for a particular thread. This has the effect that when our exception + port gets the message, the thread specific exception port has already + been asked, and we don't need to bother about it. + See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/task_set_exception_ports.html. */ + task_set_exception_ports (self, mask, our_exception_port, + EXCEPTION_DEFAULT, MACHINE_THREAD_STATE); + } + } + } +} +#elif defined _WIN32 && ! defined __CYGWIN__ +/* Avoid a crash on native Windows. */ +#define WIN32_LEAN_AND_MEAN +#include +#include +static LONG WINAPI +exception_filter (EXCEPTION_POINTERS *ExceptionInfo) +{ + switch (ExceptionInfo->ExceptionRecord->ExceptionCode) + { + case EXCEPTION_ACCESS_VIOLATION: + case EXCEPTION_IN_PAGE_ERROR: + case EXCEPTION_STACK_OVERFLOW: + case EXCEPTION_GUARD_PAGE: + case EXCEPTION_PRIV_INSTRUCTION: + case EXCEPTION_ILLEGAL_INSTRUCTION: + case EXCEPTION_DATATYPE_MISALIGNMENT: + case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: + case EXCEPTION_NONCONTINUABLE_EXCEPTION: + exit (1); + } + return EXCEPTION_CONTINUE_SEARCH; +} +static void +nocrash_init (void) +{ + SetUnhandledExceptionFilter ((LPTOP_LEVEL_EXCEPTION_FILTER) exception_filter); +} +#else +/* Avoid a crash on POSIX systems. */ +#include +#include +/* A POSIX signal handler. */ +static void +exception_handler (int sig) +{ + _exit (1); +} +static void +nocrash_init (void) +{ +#ifdef SIGSEGV + signal (SIGSEGV, exception_handler); +#endif +#ifdef SIGBUS + signal (SIGBUS, exception_handler); +#endif +} +#endif + + $mprotect_prog + nocrash_init(); + if (mprotect(page_align(fault_address),pagesize,PROT_READ) < 0) + exit(1); + if (mprotect(page_align(fault_address),pagesize,PROT_READ|PROT_WRITE) < 0) + exit(1); + *fault_address = 'z'; /* this should not cause an exception or signal */ + exit(0); + } + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + no_mprotect=1 +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + fi + if test -z "$no_mprotect"; then + cl_cv_func_mprotect_works=yes + else + cl_cv_func_mprotect_works=no + fi + else + case "$host_os" in + aix* | cygwin* | darwin* | hpux* | irix* | linux* | solaris*) + cl_cv_func_mprotect_works="guessing yes" ;; + mingw*) + cl_cv_func_mprotect_works="guessing no" ;; + *) + cl_cv_func_mprotect_works="guessing no" ;; + esac + fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cl_cv_func_mprotect_works" >&5 +$as_echo "$cl_cv_func_mprotect_works" >&6; } + case "$cl_cv_func_mprotect_works" in + *yes) + +$as_echo "#define HAVE_WORKING_MPROTECT /**/" >>confdefs.h + + ;; + esac + fi + + + + for ac_header in sys/shm.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "sys/shm.h" "ac_cv_header_sys_shm_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_shm_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYS_SHM_H 1 +_ACEOF + +fi + +done + + if test $ac_cv_header_sys_shm_h = yes; then + for ac_header in sys/ipc.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "sys/ipc.h" "ac_cv_header_sys_ipc_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_ipc_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYS_IPC_H 1 +_ACEOF + +fi + +done + + fi + + + + + + if test $ac_cv_header_sys_shm_h = yes -a "$ac_cv_header_sys_ipc_h" = yes; then + # This test is from Marcus Daniels + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working shared memory" >&5 +$as_echo_n "checking for working shared memory... " >&6; } +if ${cl_cv_sys_shm_works+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + case "$host" in + mips*-*-linux*) cl_cv_sys_shm_works="guessing no" ;; + *-*-linux*) cl_cv_sys_shm_works="guessing yes" ;; + *-*-solaris*) cl_cv_sys_shm_works="guessing yes" ;; + *-*-irix*) cl_cv_sys_shm_works="guessing yes" ;; + *) cl_cv_sys_shm_works="guessing no" ;; + esac + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + #include + #include + /* try attaching a single segment to multiple addresses */ + #define segsize 0x10000 + #define attaches 128 + #define base_addr 0x01000000 + int main () + { + int shmid; + int i; + char* addr; + char* result; + if ((shmid = shmget(IPC_PRIVATE,segsize,0400)) < 0) + exit(1); + for (i=0, addr = (char*)0x01000000; i&5 +$as_echo "$cl_cv_sys_shm_works" >&6; } + fi + case "$cl_cv_sys_shm_works" in + *yes) + have_shm=1 + +$as_echo "#define HAVE_SHM /**/" >>confdefs.h + + for ac_header in sys/sysmacros.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "sys/sysmacros.h" "ac_cv_header_sys_sysmacros_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_sysmacros_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYS_SYSMACROS_H 1 +_ACEOF + +fi + +done + + ;; + *) ;; + esac + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether code in malloc()ed memory is executable" >&5 +$as_echo_n "checking whether code in malloc()ed memory is executable... " >&6; } +if ${ffcall_cv_codeexec+:} false; then : + $as_echo_n "(cached) " >&6 +else + case "$HOST_CPU_C_ABI--$host_os" in + hppa--* | hppa64--* | powerpc--aix* | powerpc64--* | ia64--*) + ffcall_cv_codeexec="irrelevant" + ;; + arm64--freebsd*) + ffcall_cv_codeexec=no + ;; + *) + if test "$cross_compiling" = yes; then : + case "$host_os" in + cygwin*) + case "$HOST_CPU_C_ABI" in + i386) + ffcall_cv_codeexec="guessing yes" ;; + x86_64) + ffcall_cv_codeexec="guessing no" ;; + *) + ffcall_cv_codeexec="guessing no" ;; + esac + ;; + darwin*) + case "$HOST_CPU_C_ABI" in + i386 | powerpc) + ffcall_cv_codeexec="guessing yes" ;; + x86_64) + ffcall_cv_codeexec="guessing no" ;; + *) + ffcall_cv_codeexec="guessing no" ;; + esac + ;; + irix*) + ffcall_cv_codeexec="guessing no" ;; + linux*) + case "$HOST_CPU_C_ABI" in + alpha | ia64) + ffcall_cv_codeexec="guessing yes" ;; + arm | armhf | arm64 | i386 | mips* | s390 | s390x | sparc | sparc64 | x86_64*) + ffcall_cv_codeexec="guessing no" ;; + *) + ffcall_cv_codeexec="guessing no" ;; + esac + ;; + solaris*) + case "$HOST_CPU_C_ABI" in + i386 | sparc | sparc64) + ffcall_cv_codeexec="guessing yes" ;; + x86_64) + ffcall_cv_codeexec="guessing no" ;; + *) + ffcall_cv_codeexec="guessing no" ;; + esac + ;; + *) + ffcall_cv_codeexec="guessing no" ;; + esac + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#if defined __MACH__ && defined __APPLE__ +/* Avoid a crash on Mac OS X. */ +#include +#include +#include +#include +#include +#include +/* The exception port on which our thread listens. */ +static mach_port_t our_exception_port; +/* The main function of the thread listening for exceptions of type + EXC_BAD_ACCESS. */ +static void * +mach_exception_thread (void *arg) +{ + /* Buffer for a message to be received. */ + struct { + mach_msg_header_t head; + mach_msg_body_t msgh_body; + char data[1024]; + } msg; + mach_msg_return_t retval; + /* Wait for a message on the exception port. */ + retval = mach_msg (&msg.head, MACH_RCV_MSG | MACH_RCV_LARGE, 0, sizeof (msg), + our_exception_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (retval != MACH_MSG_SUCCESS) + abort (); + exit (1); +} +static void +nocrash_init (void) +{ + mach_port_t self = mach_task_self (); + /* Allocate a port on which the thread shall listen for exceptions. */ + if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port) + == KERN_SUCCESS) { + /* See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/mach_port_insert_right.html. */ + if (mach_port_insert_right (self, our_exception_port, our_exception_port, + MACH_MSG_TYPE_MAKE_SEND) + == KERN_SUCCESS) { + /* The exceptions we want to catch. Only EXC_BAD_ACCESS is interesting + for us. */ + exception_mask_t mask = EXC_MASK_BAD_ACCESS; + /* Create the thread listening on the exception port. */ + pthread_attr_t attr; + pthread_t thread; + if (pthread_attr_init (&attr) == 0 + && pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) == 0 + && pthread_create (&thread, &attr, mach_exception_thread, NULL) == 0) { + pthread_attr_destroy (&attr); + /* Replace the exception port info for these exceptions with our own. + Note that we replace the exception port for the entire task, not only + for a particular thread. This has the effect that when our exception + port gets the message, the thread specific exception port has already + been asked, and we don't need to bother about it. + See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/task_set_exception_ports.html. */ + task_set_exception_ports (self, mask, our_exception_port, + EXCEPTION_DEFAULT, MACHINE_THREAD_STATE); + } + } + } +} +#elif defined _WIN32 && ! defined __CYGWIN__ +/* Avoid a crash on native Windows. */ +#define WIN32_LEAN_AND_MEAN +#include +#include +static LONG WINAPI +exception_filter (EXCEPTION_POINTERS *ExceptionInfo) +{ + switch (ExceptionInfo->ExceptionRecord->ExceptionCode) + { + case EXCEPTION_ACCESS_VIOLATION: + case EXCEPTION_IN_PAGE_ERROR: + case EXCEPTION_STACK_OVERFLOW: + case EXCEPTION_GUARD_PAGE: + case EXCEPTION_PRIV_INSTRUCTION: + case EXCEPTION_ILLEGAL_INSTRUCTION: + case EXCEPTION_DATATYPE_MISALIGNMENT: + case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: + case EXCEPTION_NONCONTINUABLE_EXCEPTION: + exit (1); + } + return EXCEPTION_CONTINUE_SEARCH; +} +static void +nocrash_init (void) +{ + SetUnhandledExceptionFilter ((LPTOP_LEVEL_EXCEPTION_FILTER) exception_filter); +} +#else +/* Avoid a crash on POSIX systems. */ +#include +#include +/* A POSIX signal handler. */ +static void +exception_handler (int sig) +{ + _exit (1); +} +static void +nocrash_init (void) +{ +#ifdef SIGSEGV + signal (SIGSEGV, exception_handler); +#endif +#ifdef SIGBUS + signal (SIGBUS, exception_handler); +#endif +} +#endif + + #include + /* declare malloc() */ + #include + int fun () { return 31415926; } + int main () + { nocrash_init(); + {long size = (char*)&main - (char*)&fun; + char* funcopy = (char*) malloc(size); + int i; + for (i = 0; i < size; i++) { funcopy[i] = ((char*)&fun)[i]; } + return !((*(int(*)())funcopy)() == 31415926); + }} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ffcall_cv_codeexec=yes +else + ffcall_cv_codeexec=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + ;; + esac + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ffcall_cv_codeexec" >&5 +$as_echo "$ffcall_cv_codeexec" >&6; } + case "$ffcall_cv_codeexec" in + *yes | irrelevant) +$as_echo "#define CODE_EXECUTABLE /**/" >>confdefs.h + ;; + *no) ;; + esac + + + + + + + case "$ffcall_cv_codeexec" in + *yes | irrelevant) ;; + *) + case "$ac_cv_func_mprotect--$cl_cv_func_mprotect_works" in + yes--*yes) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mprotect can make malloc()ed memory executable" >&5 +$as_echo_n "checking whether mprotect can make malloc()ed memory executable... " >&6; } +if ${ffcall_cv_malloc_mprotect_can_exec+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" != yes -a -d /etc/selinux; then + ffcall_cv_malloc_mprotect_can_exec='determined by SELinux at runtime' + else + if test "$cross_compiling" = yes; then : + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run test program while cross compiling +See \`config.log' for more details" "$LINENO" 5; } +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + #ifdef HAVE_UNISTD_H + #include + #endif + #include + /* declare getpagesize() and mprotect() */ + #include + #ifndef HAVE_GETPAGESIZE + #include + #define getpagesize() PAGESIZE + #else + extern +#ifdef __cplusplus +"C" +#endif + + RETGETPAGESIZETYPE getpagesize (void); + #endif + int + main () + { + unsigned int pagesize = getpagesize (); + char *p = (char *) malloc (50); + int ret; + if (p == (char*) -1) + /* malloc is not working as expected. */ + return 1; + p[5] = 0x77; + ret = mprotect (p - ((unsigned int) p & (pagesize - 1)), pagesize, PROT_READ | PROT_WRITE | PROT_EXEC); + if (ret < 0 + && (errno == EACCES || errno == ENOMEM + #ifdef ENOTSUP + || errno == ENOTSUP + #endif + ) ) + /* mprotect is forbidden to make malloc()ed pages executable that were writable earlier. */ + return 2; + return 0; + } + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ffcall_cv_malloc_mprotect_can_exec=yes +else + case "$host_os" in + linux*) + ffcall_cv_malloc_mprotect_can_exec='determined by SELinux at runtime' ;; + aix* | cygwin* | darwin* | irix* | solaris*) + ffcall_cv_malloc_mprotect_can_exec="guessing yes" ;; + *) + ffcall_cv_malloc_mprotect_can_exec="guessing no" ;; + esac + +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ffcall_cv_malloc_mprotect_can_exec" >&5 +$as_echo "$ffcall_cv_malloc_mprotect_can_exec" >&6; } + case "$ffcall_cv_malloc_mprotect_can_exec" in + *yes) MPROTECT_AFTER_MALLOC_CAN_EXEC=1 ;; + *no) MPROTECT_AFTER_MALLOC_CAN_EXEC=0 ;; + *runtime*) MPROTECT_AFTER_MALLOC_CAN_EXEC='-1' ;; + esac + +cat >>confdefs.h <<_ACEOF +#define HAVE_MPROTECT_AFTER_MALLOC_CAN_EXEC $MPROTECT_AFTER_MALLOC_CAN_EXEC +_ACEOF + + case "$ffcall_cv_malloc_mprotect_can_exec" in + *yes) ;; + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mprotect can make mmap()ed memory executable" >&5 +$as_echo_n "checking whether mprotect can make mmap()ed memory executable... " >&6; } +if ${ffcall_cv_mmap_mprotect_can_exec+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" != yes -a -d /etc/selinux; then + ffcall_cv_mmap_mprotect_can_exec='determined by SELinux at runtime' + else + if test "$cross_compiling" = yes; then : + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run test program while cross compiling +See \`config.log' for more details" "$LINENO" 5; } +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + #ifdef HAVE_UNISTD_H + #include + #endif + #include + /* declare getpagesize() and mprotect() */ + #include + #ifndef HAVE_GETPAGESIZE + #include + #define getpagesize() PAGESIZE + #else + extern +#ifdef __cplusplus +"C" +#endif + + RETGETPAGESIZETYPE getpagesize (void); + #endif + #ifndef MAP_FILE + #define MAP_FILE 0 + #endif + #ifndef MAP_VARIABLE + #define MAP_VARIABLE 0 + #endif + int + main () + { + unsigned int pagesize = getpagesize (); + char *p; + int ret; + #if defined HAVE_MMAP_ANON + p = (char *) mmap (NULL, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | MAP_VARIABLE, -1, 0); + #elif defined HAVE_MMAP_ANONYMOUS + p = (char *) mmap (NULL, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_VARIABLE, -1, 0); + #elif defined HAVE_MMAP_DEVZERO + int zero_fd = open("/dev/zero", O_RDONLY, 0666); + if (zero_fd < 0) + return 1; + p = (char *) mmap (NULL, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FILE | MAP_VARIABLE, zero_fd, 0); + #else + ?? + #endif + if (p == (char*) -1) + /* mmap is not working as expected. */ + return 1; + p[5] = 0x77; + ret = mprotect (p, pagesize, PROT_READ | PROT_WRITE | PROT_EXEC); + if (ret < 0 + && (errno == EACCES || errno == ENOMEM + #ifdef ENOTSUP + || errno == ENOTSUP + #endif + ) ) + /* mprotect is forbidden to make mmap()ed pages executable that were writable earlier. */ + return 2; + return 0; + } + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ffcall_cv_mmap_mprotect_can_exec=yes +else + case "$host_os" in + linux*) ffcall_cv_mmap_mprotect_can_exec='determined by SELinux at runtime' ;; + *) ffcall_cv_mmap_mprotect_can_exec="guessing no" ;; + esac + +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ffcall_cv_mmap_mprotect_can_exec" >&5 +$as_echo "$ffcall_cv_mmap_mprotect_can_exec" >&6; } + case "$ffcall_cv_mmap_mprotect_can_exec" in + *yes) MPROTECT_AFTER_MMAP_CAN_EXEC=1 ;; + *no) MPROTECT_AFTER_MMAP_CAN_EXEC=0 ;; + *runtime*) MPROTECT_AFTER_MMAP_CAN_EXEC='-1' ;; + esac + +cat >>confdefs.h <<_ACEOF +#define HAVE_MPROTECT_AFTER_MMAP_CAN_EXEC $MPROTECT_AFTER_MMAP_CAN_EXEC +_ACEOF + + case "$ffcall_cv_mmap_mprotect_can_exec" in + *yes) ;; + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a shared mmap can make memory pages executable" >&5 +$as_echo_n "checking whether a shared mmap can make memory pages executable... " >&6; } +if ${ffcall_cv_mmap_shared_can_exec+:} false; then : + $as_echo_n "(cached) " >&6 +else + filename="/tmp/trampdata$$.data" + if test "$cross_compiling" = yes; then : + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run test program while cross compiling +See \`config.log' for more details" "$LINENO" 5; } +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + #ifdef HAVE_UNISTD_H + #include + #endif + /* declare getpagesize() and mmap() */ + #include + #ifndef HAVE_GETPAGESIZE + #include + #define getpagesize() PAGESIZE + #else + extern +#ifdef __cplusplus +"C" +#endif + + RETGETPAGESIZETYPE getpagesize (void); + #endif + #ifndef MAP_FILE + #define MAP_FILE 0 + #endif + #ifndef MAP_VARIABLE + #define MAP_VARIABLE 0 + #endif + int + main () + { + unsigned int pagesize = getpagesize (); + int fd; + char *pw; + char *px; + fd = open ("$filename", O_CREAT | O_RDWR | O_TRUNC, 0700); + if (fd < 0) + return 1; + if (ftruncate (fd, pagesize) < 0) + return 2; + pw = (char *) mmap (NULL, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FILE | MAP_VARIABLE, fd, 0); + if (pw == (char*) -1) + return 3; + pw[5] = 0xc3; + px = (char *) mmap (NULL, pagesize, PROT_READ | PROT_EXEC, MAP_SHARED | MAP_FILE | MAP_VARIABLE, fd, 0); + if (px == (char*) -1) + return 4; + if ((char)px[5] != (char)0xc3) + return 5; + /* On i386 and x86_64 this is a 'ret' instruction that we can invoke. */ + #if (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_) || (defined __x86_64__ || defined __amd64__) + ((void (*) (void)) (px + 5)) (); + #endif + return 0; + } + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ffcall_cv_mmap_shared_can_exec=yes +else + ffcall_cv_mmap_shared_can_exec="guessing yes" + +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + rm -f "$filename" + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ffcall_cv_mmap_shared_can_exec" >&5 +$as_echo "$ffcall_cv_mmap_shared_can_exec" >&6; } + case "$ffcall_cv_mmap_shared_can_exec" in + *yes) + +$as_echo "#define HAVE_MMAP_SHARED_CAN_EXEC /**/" >>confdefs.h + + ;; + esac + ;; + esac + ;; + esac + ;; + esac + ;; + esac + + +CPU_OBJECTS='' +if test ${HOST_CPU_C_ABI} = hppa -o ${HOST_CPU_C_ABI} = hppa64 -o ${HOST_CPU_C_ABI} = powerpc64 -o ${HOST_CPU_C_ABI} = ia64; then + CPU_OBJECTS="$CPU_OBJECTS "'tramp-$(CPU).lo' +fi +if test ${HOST_CPU_C_ABI} = powerpc; then + case "${host_os}" in + aix*) CPU_OBJECTS="$CPU_OBJECTS "'tramp-$(CPU).lo' ;; + *) ;; + esac +fi +if test ${HOST_CPU_C_ABI} = sparc -o ${HOST_CPU_C_ABI} = sparc64 -o ${HOST_CPU_C_ABI} = alpha -o ${HOST_CPU_C_ABI} = hppa -o ${HOST_CPU_C_ABI} = hppa64 -o ${HOST_CPU_C_ABI} = powerpc64-elfv2; then + CPU_OBJECTS="$CPU_OBJECTS "'cache-$(CPU).lo' +fi +if test ${HOST_CPU_C_ABI} = powerpc; then + case "${host_os}" in + aix*) ;; + *) CPU_OBJECTS="$CPU_OBJECTS "'cache-$(CPU).lo' ;; + esac +fi + +case "${HOST_CPU_C_ABI}" in + mips* | riscv*) + for ac_header in sys/cachectl.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "sys/cachectl.h" "ac_cv_header_sys_cachectl_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_cachectl_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYS_CACHECTL_H 1 +_ACEOF + +fi + +done + + ;; +esac + +WORKAROUND_BUG_81653='' +if test ${HOST_CPU_C_ABI} = sparc && test -n "$GCC"; then + gcc_version=`LC_ALL=C ${CC} -v 2>&1 | grep version | sed -n -e '$p' | sed -e 's/.*version //g' -e 's/gcc //'` + case "$gcc_version" in + 2.* | 3.0-3*) ;; + *) WORKAROUND_BUG_81653='-fno-pie' ;; + esac +fi + + +if test -n "$GCC"; then + DISABLE_TYPE_BASED_ALIASING='-fno-strict-aliasing' +else + case "$host_os" in + aix*) DISABLE_TYPE_BASED_ALIASING='-qalias=noansi' + ;; + *) + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __SUNPRO_C + yes + #endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "yes" >/dev/null 2>&1; then : + DISABLE_TYPE_BASED_ALIASING='-xalias_level=weak' + +else + DISABLE_TYPE_BASED_ALIASING='' +fi +rm -f conftest* + + ;; + esac +fi + + + + + + + + + LIBC_FATAL_STDERR_=1 + export LIBC_FATAL_STDERR_ + + + + + + if test "$CXX_CHOICE" = no; then + CXX=no + fi + if test -z "$CXX"; then + if test -n "$CCC"; then + CXX="$CCC" + else + if test -n "$ac_tool_prefix"; then + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CXX=$ac_cv_prog_CXX +if test -n "$CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 +$as_echo "$CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CXX" && break + done +fi +if test -z "$CXX"; then + ac_ct_CXX=$CXX + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CXX"; then + ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CXX="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CXX=$ac_cv_prog_ac_ct_CXX +if test -n "$ac_ct_CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 +$as_echo "$ac_ct_CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CXX" && break +done + + if test "x$ac_ct_CXX" = x; then + CXX=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CXX=$ac_ct_CXX + fi +fi + + fi + fi + if test "$CXX" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5 +$as_echo_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works... " >&6; } + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + echo 'int main () { return 0; }' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 + (eval $ac_link) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s conftest$ac_exeext; then + gl_cv_prog_ansicxx_works=yes + if (./conftest; exit) 2>/dev/null; then + gl_cv_prog_ansicxx_cross=no + else + gl_cv_prog_ansicxx_cross=yes + fi + else + gl_cv_prog_ansicxx_works=no + fi + rm -fr conftest* + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_prog_ansicxx_works" >&5 +$as_echo "$gl_cv_prog_ansicxx_works" >&6; } + if test $gl_cv_prog_ansicxx_works = no; then + CXX=no + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler supports namespaces" >&5 +$as_echo_n "checking whether the C++ compiler supports namespaces... " >&6; } + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + cat < conftest.$ac_ext +#include +namespace test { using namespace std; } +std::ostream* ptr; +int main () { return 0; } +EOF + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 + (eval $ac_link) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s conftest$ac_exeext; then + gl_cv_prog_ansicxx_namespaces=yes + else + gl_cv_prog_ansicxx_namespaces=no + fi + rm -fr conftest* + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_prog_ansicxx_namespaces" >&5 +$as_echo "$gl_cv_prog_ansicxx_namespaces" >&6; } + if test $gl_cv_prog_ansicxx_namespaces = no; then + CXX=no + fi + fi + fi + + + + if test "$CXX" != no; then + ANSICXX_TRUE= + ANSICXX_FALSE='#' +else + ANSICXX_TRUE='#' + ANSICXX_FALSE= +fi + + + if test "$CXX" != no; then + +depcc="$CXX" am_compiler_list= + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 +$as_echo_n "checking dependency style of $depcc... " >&6; } +if ${am_cv_CXX_dependencies_compiler_type+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named 'D' -- because '-MD' means "put the output + # in D". + rm -rf conftest.dir + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CXX_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + am__universal=false + case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with + # Solaris 10 /bin/sh. + echo '/* dummy */' > sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with '-c' and '-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle '-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs. + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # After this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested. + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvc7 | msvc7msys | msvisualcpp | msvcmsys) + # This compiler won't grok '-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CXX_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CXX_dependencies_compiler_type=none +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 +$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } +CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then + am__fastdepCXX_TRUE= + am__fastdepCXX_FALSE='#' +else + am__fastdepCXX_TRUE='#' + am__fastdepCXX_FALSE= +fi + + + else + if false; then + am__fastdepCXX_TRUE= + am__fastdepCXX_FALSE='#' +else + am__fastdepCXX_TRUE='#' + am__fastdepCXX_FALSE= +fi + + fi + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the preprocessor supports include_next" >&5 +$as_echo_n "checking whether the preprocessor supports include_next... " >&6; } +if ${gl_cv_have_include_next+:} false; then : + $as_echo_n "(cached) " >&6 +else + rm -rf conftestd1a conftestd1b conftestd2 + mkdir conftestd1a conftestd1b conftestd2 + cat < conftestd1a/conftest.h +#define DEFINED_IN_CONFTESTD1 +#include_next +#ifdef DEFINED_IN_CONFTESTD2 +int foo; +#else +#error "include_next doesn't work" +#endif +EOF + cat < conftestd1b/conftest.h +#define DEFINED_IN_CONFTESTD1 +#include +#include_next +#ifdef DEFINED_IN_CONFTESTD2 +int foo; +#else +#error "include_next doesn't work" +#endif +EOF + cat < conftestd2/conftest.h +#ifndef DEFINED_IN_CONFTESTD1 +#error "include_next test doesn't work" +#endif +#define DEFINED_IN_CONFTESTD2 +EOF + gl_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_have_include_next=yes +else + CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_have_include_next=buggy +else + gl_cv_have_include_next=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CPPFLAGS="$gl_save_CPPFLAGS" + rm -rf conftestd1a conftestd1b conftestd2 + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_have_include_next" >&5 +$as_echo "$gl_cv_have_include_next" >&6; } + PRAGMA_SYSTEM_HEADER= + if test $gl_cv_have_include_next = yes; then + INCLUDE_NEXT=include_next + INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next + if test -n "$GCC"; then + PRAGMA_SYSTEM_HEADER='#pragma GCC system_header' + fi + else + if test $gl_cv_have_include_next = buggy; then + INCLUDE_NEXT=include + INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next + else + INCLUDE_NEXT=include + INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include + fi + fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether system header files limit the line length" >&5 +$as_echo_n "checking whether system header files limit the line length... " >&6; } +if ${gl_cv_pragma_columns+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef __TANDEM +choke me +#endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "choke me" >/dev/null 2>&1; then : + gl_cv_pragma_columns=yes +else + gl_cv_pragma_columns=no +fi +rm -f conftest* + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_pragma_columns" >&5 +$as_echo "$gl_cv_pragma_columns" >&6; } + if test $gl_cv_pragma_columns = yes; then + PRAGMA_COLUMNS="#pragma COLUMNS 10000" + else + PRAGMA_COLUMNS= + fi + + + + + + + for ac_header in $gl_header_list +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + + + + + + + + + + : + + + + + + + + + if test $gl_cv_have_include_next = yes; then + gl_cv_next_limits_h='<'limits.h'>' + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 +$as_echo_n "checking absolute name of ... " >&6; } +if ${gl_cv_next_limits_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + + if test $ac_cv_header_limits_h = yes; then + + + + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + + case "$host_os" in + mingw*) + gl_dirsep_regex='[/\\]' + ;; + *) + gl_dirsep_regex='\/' + ;; + esac + gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' + gl_header_literal_regex=`echo 'limits.h' \ + | sed -e "$gl_make_literal_regex_sed"` + gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ + s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ + s|^/[^/]|//&| + p + q + }' + + gl_cv_absolute_limits_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n "$gl_absolute_header_sed"` + + gl_header=$gl_cv_absolute_limits_h + gl_cv_next_limits_h='"'$gl_header'"' + else + gl_cv_next_limits_h='<'limits.h'>' + fi + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_limits_h" >&5 +$as_echo "$gl_cv_next_limits_h" >&6; } + fi + NEXT_LIMITS_H=$gl_cv_next_limits_h + + if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then + # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' + gl_next_as_first_directive='<'limits.h'>' + else + # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' + gl_next_as_first_directive=$gl_cv_next_limits_h + fi + NEXT_AS_FIRST_DIRECTIVE_LIMITS_H=$gl_next_as_first_directive + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether limits.h has LLONG_MAX, WORD_BIT, ULLONG_WIDTH etc." >&5 +$as_echo_n "checking whether limits.h has LLONG_MAX, WORD_BIT, ULLONG_WIDTH etc.... " >&6; } +if ${gl_cv_header_limits_width+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifndef __STDC_WANT_IEC_60559_BFP_EXT__ + #define __STDC_WANT_IEC_60559_BFP_EXT__ 1 + #endif + #include + long long llm = LLONG_MAX; + int wb = WORD_BIT; + int ullw = ULLONG_WIDTH; + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_header_limits_width=yes +else + gl_cv_header_limits_width=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_limits_width" >&5 +$as_echo "$gl_cv_header_limits_width" >&6; } + if test "$gl_cv_header_limits_width" = yes; then + LIMITS_H= + else + LIMITS_H=limits.h + fi + + if test -n "$LIMITS_H"; then + GL_GENERATE_LIMITS_H_TRUE= + GL_GENERATE_LIMITS_H_FALSE='#' +else + GL_GENERATE_LIMITS_H_TRUE='#' + GL_GENERATE_LIMITS_H_FALSE= +fi + + + + + + + + + + gl_threads_api=none + LIBTHREAD= + LTLIBTHREAD= + LIBMULTITHREAD= + LTLIBMULTITHREAD= + if test "$gl_use_threads" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether imported symbols can be declared weak" >&5 +$as_echo_n "checking whether imported symbols can be declared weak... " >&6; } +if ${gl_cv_have_weak+:} false; then : + $as_echo_n "(cached) " >&6 +else + gl_cv_have_weak=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +extern void xyzzy (); +#pragma weak xyzzy +int +main () +{ +xyzzy(); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + gl_cv_have_weak=maybe +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + if test $gl_cv_have_weak = maybe; then + if test "$cross_compiling" = yes; then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __ELF__ + Extensible Linking Format + #endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "Extensible Linking Format" >/dev/null 2>&1; then : + gl_cv_have_weak="guessing yes" +else + gl_cv_have_weak="guessing no" +fi +rm -f conftest* + + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#pragma weak fputs +int main () +{ + return (fputs == NULL); +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_have_weak=yes +else + gl_cv_have_weak=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + fi + case " $LDFLAGS " in + *" -static "*) gl_cv_have_weak=no ;; + esac + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_have_weak" >&5 +$as_echo "$gl_cv_have_weak" >&6; } + if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then + + : + + + + + + : + fi + if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then + # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that + # it groks . It's added above, in gl_THREADLIB_EARLY_BODY. + ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" +if test "x$ac_cv_header_pthread_h" = xyes; then : + gl_have_pthread_h=yes +else + gl_have_pthread_h=no +fi + + + if test "$gl_have_pthread_h" = yes; then + # Other possible tests: + # -lpthreads (FSU threads, PCthreads) + # -lgthreads + gl_have_pthread= + # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist + # in libc. IRIX 6.5 has the first one in both libc and libpthread, but + # the second one only in libpthread, and lock.c needs it. + # + # If -pthread works, prefer it to -lpthread, since Ubuntu 14.04 + # needs -pthread for some reason. See: + # https://lists.gnu.org/r/bug-gnulib/2014-09/msg00023.html + save_LIBS=$LIBS + for gl_pthread in '' '-pthread'; do + LIBS="$LIBS $gl_pthread" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + pthread_mutex_t m; + pthread_mutexattr_t ma; + +int +main () +{ +pthread_mutex_lock (&m); + pthread_mutexattr_init (&ma); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + gl_have_pthread=yes + LIBTHREAD=$gl_pthread LTLIBTHREAD=$gl_pthread + LIBMULTITHREAD=$gl_pthread LTLIBMULTITHREAD=$gl_pthread +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS=$save_LIBS + test -n "$gl_have_pthread" && break + done + + # Test for libpthread by looking for pthread_kill. (Not pthread_self, + # since it is defined as a macro on OSF/1.) + if test -n "$gl_have_pthread" && test -z "$LIBTHREAD"; then + # The program links fine without libpthread. But it may actually + # need to link with libpthread in order to create multiple threads. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_kill in -lpthread" >&5 +$as_echo_n "checking for pthread_kill in -lpthread... " >&6; } +if ${ac_cv_lib_pthread_pthread_kill+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpthread $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pthread_kill (); +int +main () +{ +return pthread_kill (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_pthread_pthread_kill=yes +else + ac_cv_lib_pthread_pthread_kill=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_kill" >&5 +$as_echo "$ac_cv_lib_pthread_pthread_kill" >&6; } +if test "x$ac_cv_lib_pthread_pthread_kill" = xyes; then : + LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread + # On Solaris and HP-UX, most pthread functions exist also in libc. + # Therefore pthread_in_use() needs to actually try to create a + # thread: pthread_create from libc will fail, whereas + # pthread_create will actually create a thread. + # On Solaris 10 or newer, this test is no longer needed, because + # libc contains the fully functional pthread functions. + case "$host_os" in + solaris | solaris2.1-9 | solaris2.1-9.* | hpux*) + +$as_echo "#define PTHREAD_IN_USE_DETECTION_HARD 1" >>confdefs.h + + esac + +fi + + elif test -z "$gl_have_pthread"; then + # Some library is needed. Try libpthread and libc_r. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_kill in -lpthread" >&5 +$as_echo_n "checking for pthread_kill in -lpthread... " >&6; } +if ${ac_cv_lib_pthread_pthread_kill+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpthread $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pthread_kill (); +int +main () +{ +return pthread_kill (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_pthread_pthread_kill=yes +else + ac_cv_lib_pthread_pthread_kill=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_kill" >&5 +$as_echo "$ac_cv_lib_pthread_pthread_kill" >&6; } +if test "x$ac_cv_lib_pthread_pthread_kill" = xyes; then : + gl_have_pthread=yes + LIBTHREAD=-lpthread LTLIBTHREAD=-lpthread + LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread +fi + + if test -z "$gl_have_pthread"; then + # For FreeBSD 4. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_kill in -lc_r" >&5 +$as_echo_n "checking for pthread_kill in -lc_r... " >&6; } +if ${ac_cv_lib_c_r_pthread_kill+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lc_r $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pthread_kill (); +int +main () +{ +return pthread_kill (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_c_r_pthread_kill=yes +else + ac_cv_lib_c_r_pthread_kill=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_r_pthread_kill" >&5 +$as_echo "$ac_cv_lib_c_r_pthread_kill" >&6; } +if test "x$ac_cv_lib_c_r_pthread_kill" = xyes; then : + gl_have_pthread=yes + LIBTHREAD=-lc_r LTLIBTHREAD=-lc_r + LIBMULTITHREAD=-lc_r LTLIBMULTITHREAD=-lc_r +fi + + fi + fi + if test -n "$gl_have_pthread"; then + gl_threads_api=posix + +$as_echo "#define USE_POSIX_THREADS 1" >>confdefs.h + + if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then + if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then + +$as_echo "#define USE_POSIX_THREADS_WEAK 1" >>confdefs.h + + LIBTHREAD= + LTLIBTHREAD= + fi + fi + fi + fi + fi + if test -z "$gl_have_pthread"; then + case "$gl_use_threads" in + yes | windows | win32) # The 'win32' is for backward compatibility. + if { case "$host_os" in + mingw*) true;; + *) false;; + esac + }; then + gl_threads_api=windows + +$as_echo "#define USE_WINDOWS_THREADS 1" >>confdefs.h + + fi + ;; + esac + fi + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for multithread API to use" >&5 +$as_echo_n "checking for multithread API to use... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_threads_api" >&5 +$as_echo "$gl_threads_api" >&6; } + + + + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for unsigned long long int" >&5 +$as_echo_n "checking for unsigned long long int... " >&6; } +if ${ac_cv_type_unsigned_long_long_int+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_type_unsigned_long_long_int=yes + if test "x${ac_cv_prog_cc_c99-no}" = xno; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + /* For now, do not test the preprocessor; as of 2007 there are too many + implementations with broken preprocessors. Perhaps this can + be revisited in 2012. In the meantime, code should not expect + #if to work with literals wider than 32 bits. */ + /* Test literals. */ + long long int ll = 9223372036854775807ll; + long long int nll = -9223372036854775807LL; + unsigned long long int ull = 18446744073709551615ULL; + /* Test constant expressions. */ + typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll) + ? 1 : -1)]; + typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1 + ? 1 : -1)]; + int i = 63; +int +main () +{ +/* Test availability of runtime routines for shift and division. */ + long long int llmax = 9223372036854775807ll; + unsigned long long int ullmax = 18446744073709551615ull; + return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i) + | (llmax / ll) | (llmax % ll) + | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i) + | (ullmax / ull) | (ullmax % ull)); + ; + return 0; +} + +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + +else + ac_cv_type_unsigned_long_long_int=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_unsigned_long_long_int" >&5 +$as_echo "$ac_cv_type_unsigned_long_long_int" >&6; } + if test $ac_cv_type_unsigned_long_long_int = yes; then + +$as_echo "#define HAVE_UNSIGNED_LONG_LONG_INT 1" >>confdefs.h + + fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for long long int" >&5 +$as_echo_n "checking for long long int... " >&6; } +if ${ac_cv_type_long_long_int+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_type_long_long_int=yes + if test "x${ac_cv_prog_cc_c99-no}" = xno; then + ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int + if test $ac_cv_type_long_long_int = yes; then + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #ifndef LLONG_MAX + # define HALF \ + (1LL << (sizeof (long long int) * CHAR_BIT - 2)) + # define LLONG_MAX (HALF - 1 + HALF) + #endif +int +main () +{ +long long int n = 1; + int i; + for (i = 0; ; i++) + { + long long int m = n << i; + if (m >> i != n) + return 1; + if (LLONG_MAX / 2 < m) + break; + } + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_type_long_long_int=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_long_long_int" >&5 +$as_echo "$ac_cv_type_long_long_int" >&6; } + if test $ac_cv_type_long_long_int = yes; then + +$as_echo "#define HAVE_LONG_LONG_INT 1" >>confdefs.h + + fi + + + gl_cv_c_multiarch=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifndef __APPLE_CC__ + not a universal capable compiler + #endif + typedef int dummy; + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + arch= + prev= + for word in ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do + if test -n "$prev"; then + case $word in + i?86 | x86_64 | ppc | ppc64) + if test -z "$arch" || test "$arch" = "$word"; then + arch="$word" + else + gl_cv_c_multiarch=yes + fi + ;; + esac + prev= + else + if test "x$word" = "x-arch"; then + prev=arch + fi + fi + done + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if test $gl_cv_c_multiarch = yes; then + APPLE_UNIVERSAL_BUILD=1 + else + APPLE_UNIVERSAL_BUILD=0 + fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for wint_t" >&5 +$as_echo_n "checking for wint_t... " >&6; } +if ${gt_cv_c_wint_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Tru64 with Desktop Toolkit C has a bug: must be included before + . + BSD/OS 4.0.1 has a bug: , and must be included + before . */ +#include +#include +#include +#include + wint_t foo = (wchar_t)'\0'; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gt_cv_c_wint_t=yes +else + gt_cv_c_wint_t=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_c_wint_t" >&5 +$as_echo "$gt_cv_c_wint_t" >&6; } + if test $gt_cv_c_wint_t = yes; then + +$as_echo "#define HAVE_WINT_T 1" >>confdefs.h + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether wint_t is too small" >&5 +$as_echo_n "checking whether wint_t is too small... " >&6; } +if ${gl_cv_type_wint_t_too_small+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Tru64 with Desktop Toolkit C has a bug: must be included before + . + BSD/OS 4.0.1 has a bug: , and must be + included before . */ +#if !(defined __GLIBC__ && !defined __UCLIBC__) +# include +# include +# include +#endif +#include + int verify[sizeof (wint_t) < sizeof (int) ? -1 : 1]; + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_type_wint_t_too_small=no +else + gl_cv_type_wint_t_too_small=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_type_wint_t_too_small" >&5 +$as_echo "$gl_cv_type_wint_t_too_small" >&6; } + if test $gl_cv_type_wint_t_too_small = yes; then + GNULIB_OVERRIDES_WINT_T=1 + else + GNULIB_OVERRIDES_WINT_T=0 + fi + else + GNULIB_OVERRIDES_WINT_T=0 + fi + + + + + + + + + + + + + + + + + + + if test $ac_cv_type_long_long_int = yes; then + HAVE_LONG_LONG_INT=1 + else + HAVE_LONG_LONG_INT=0 + fi + + + if test $ac_cv_type_unsigned_long_long_int = yes; then + HAVE_UNSIGNED_LONG_LONG_INT=1 + else + HAVE_UNSIGNED_LONG_LONG_INT=0 + fi + + + + : + + + + + + if test $ac_cv_header_wchar_h = yes; then + HAVE_WCHAR_H=1 + else + HAVE_WCHAR_H=0 + fi + + + if test $ac_cv_header_inttypes_h = yes; then + HAVE_INTTYPES_H=1 + else + HAVE_INTTYPES_H=0 + fi + + + if test $ac_cv_header_sys_types_h = yes; then + HAVE_SYS_TYPES_H=1 + else + HAVE_SYS_TYPES_H=0 + fi + + + + + + + + + : + + + + + + + + + if test $gl_cv_have_include_next = yes; then + gl_cv_next_stdint_h='<'stdint.h'>' + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 +$as_echo_n "checking absolute name of ... " >&6; } +if ${gl_cv_next_stdint_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + + if test $ac_cv_header_stdint_h = yes; then + + + + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + + case "$host_os" in + mingw*) + gl_dirsep_regex='[/\\]' + ;; + *) + gl_dirsep_regex='\/' + ;; + esac + gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' + gl_header_literal_regex=`echo 'stdint.h' \ + | sed -e "$gl_make_literal_regex_sed"` + gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ + s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ + s|^/[^/]|//&| + p + q + }' + + gl_cv_absolute_stdint_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n "$gl_absolute_header_sed"` + + gl_header=$gl_cv_absolute_stdint_h + gl_cv_next_stdint_h='"'$gl_header'"' + else + gl_cv_next_stdint_h='<'stdint.h'>' + fi + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stdint_h" >&5 +$as_echo "$gl_cv_next_stdint_h" >&6; } + fi + NEXT_STDINT_H=$gl_cv_next_stdint_h + + if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then + # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' + gl_next_as_first_directive='<'stdint.h'>' + else + # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' + gl_next_as_first_directive=$gl_cv_next_stdint_h + fi + NEXT_AS_FIRST_DIRECTIVE_STDINT_H=$gl_next_as_first_directive + + + + + if test $ac_cv_header_stdint_h = yes; then + HAVE_STDINT_H=1 + else + HAVE_STDINT_H=0 + fi + + + if test $ac_cv_header_stdint_h = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stdint.h conforms to C99" >&5 +$as_echo_n "checking whether stdint.h conforms to C99... " >&6; } +if ${gl_cv_header_working_stdint_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + gl_cv_header_working_stdint_h=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */ +#define __STDC_CONSTANT_MACROS 1 +#define __STDC_LIMIT_MACROS 1 +#include +/* Dragonfly defines WCHAR_MIN, WCHAR_MAX only in . */ +#if !(defined WCHAR_MIN && defined WCHAR_MAX) +#error "WCHAR_MIN, WCHAR_MAX not defined in " +#endif + + + /* BSD/OS 4.0.1 has a bug: , and must be + included before . */ + #include + #include + #if HAVE_WCHAR_H + # include + # include + # include + #endif + + +#ifdef INT8_MAX +int8_t a1 = INT8_MAX; +int8_t a1min = INT8_MIN; +#endif +#ifdef INT16_MAX +int16_t a2 = INT16_MAX; +int16_t a2min = INT16_MIN; +#endif +#ifdef INT32_MAX +int32_t a3 = INT32_MAX; +int32_t a3min = INT32_MIN; +#endif +#ifdef INT64_MAX +int64_t a4 = INT64_MAX; +int64_t a4min = INT64_MIN; +#endif +#ifdef UINT8_MAX +uint8_t b1 = UINT8_MAX; +#else +typedef int b1[(unsigned char) -1 != 255 ? 1 : -1]; +#endif +#ifdef UINT16_MAX +uint16_t b2 = UINT16_MAX; +#endif +#ifdef UINT32_MAX +uint32_t b3 = UINT32_MAX; +#endif +#ifdef UINT64_MAX +uint64_t b4 = UINT64_MAX; +#endif +int_least8_t c1 = INT8_C (0x7f); +int_least8_t c1max = INT_LEAST8_MAX; +int_least8_t c1min = INT_LEAST8_MIN; +int_least16_t c2 = INT16_C (0x7fff); +int_least16_t c2max = INT_LEAST16_MAX; +int_least16_t c2min = INT_LEAST16_MIN; +int_least32_t c3 = INT32_C (0x7fffffff); +int_least32_t c3max = INT_LEAST32_MAX; +int_least32_t c3min = INT_LEAST32_MIN; +int_least64_t c4 = INT64_C (0x7fffffffffffffff); +int_least64_t c4max = INT_LEAST64_MAX; +int_least64_t c4min = INT_LEAST64_MIN; +uint_least8_t d1 = UINT8_C (0xff); +uint_least8_t d1max = UINT_LEAST8_MAX; +uint_least16_t d2 = UINT16_C (0xffff); +uint_least16_t d2max = UINT_LEAST16_MAX; +uint_least32_t d3 = UINT32_C (0xffffffff); +uint_least32_t d3max = UINT_LEAST32_MAX; +uint_least64_t d4 = UINT64_C (0xffffffffffffffff); +uint_least64_t d4max = UINT_LEAST64_MAX; +int_fast8_t e1 = INT_FAST8_MAX; +int_fast8_t e1min = INT_FAST8_MIN; +int_fast16_t e2 = INT_FAST16_MAX; +int_fast16_t e2min = INT_FAST16_MIN; +int_fast32_t e3 = INT_FAST32_MAX; +int_fast32_t e3min = INT_FAST32_MIN; +int_fast64_t e4 = INT_FAST64_MAX; +int_fast64_t e4min = INT_FAST64_MIN; +uint_fast8_t f1 = UINT_FAST8_MAX; +uint_fast16_t f2 = UINT_FAST16_MAX; +uint_fast32_t f3 = UINT_FAST32_MAX; +uint_fast64_t f4 = UINT_FAST64_MAX; +#ifdef INTPTR_MAX +intptr_t g = INTPTR_MAX; +intptr_t gmin = INTPTR_MIN; +#endif +#ifdef UINTPTR_MAX +uintptr_t h = UINTPTR_MAX; +#endif +intmax_t i = INTMAX_MAX; +uintmax_t j = UINTMAX_MAX; + +/* Check that SIZE_MAX has the correct type, if possible. */ +#if 201112 <= __STDC_VERSION__ +int k = _Generic (SIZE_MAX, size_t: 0); +#elif (2 <= __GNUC__ || defined __IBM__TYPEOF__ \ + || (0x5110 <= __SUNPRO_C && !__STDC__)) +extern size_t k; +extern __typeof__ (SIZE_MAX) k; +#endif + +#include /* for CHAR_BIT */ +#define TYPE_MINIMUM(t) \ + ((t) ((t) 0 < (t) -1 ? (t) 0 : ~ TYPE_MAXIMUM (t))) +#define TYPE_MAXIMUM(t) \ + ((t) ((t) 0 < (t) -1 \ + ? (t) -1 \ + : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1))) +struct s { + int check_PTRDIFF: + PTRDIFF_MIN == TYPE_MINIMUM (ptrdiff_t) + && PTRDIFF_MAX == TYPE_MAXIMUM (ptrdiff_t) + ? 1 : -1; + /* Detect bug in FreeBSD 6.0 / ia64. */ + int check_SIG_ATOMIC: + SIG_ATOMIC_MIN == TYPE_MINIMUM (sig_atomic_t) + && SIG_ATOMIC_MAX == TYPE_MAXIMUM (sig_atomic_t) + ? 1 : -1; + int check_SIZE: SIZE_MAX == TYPE_MAXIMUM (size_t) ? 1 : -1; + int check_WCHAR: + WCHAR_MIN == TYPE_MINIMUM (wchar_t) + && WCHAR_MAX == TYPE_MAXIMUM (wchar_t) + ? 1 : -1; + /* Detect bug in mingw. */ + int check_WINT: + WINT_MIN == TYPE_MINIMUM (wint_t) + && WINT_MAX == TYPE_MAXIMUM (wint_t) + ? 1 : -1; + + /* Detect bugs in glibc 2.4 and Solaris 10 stdint.h, among others. */ + int check_UINT8_C: + (-1 < UINT8_C (0)) == (-1 < (uint_least8_t) 0) ? 1 : -1; + int check_UINT16_C: + (-1 < UINT16_C (0)) == (-1 < (uint_least16_t) 0) ? 1 : -1; + + /* Detect bugs in OpenBSD 3.9 stdint.h. */ +#ifdef UINT8_MAX + int check_uint8: (uint8_t) -1 == UINT8_MAX ? 1 : -1; +#endif +#ifdef UINT16_MAX + int check_uint16: (uint16_t) -1 == UINT16_MAX ? 1 : -1; +#endif +#ifdef UINT32_MAX + int check_uint32: (uint32_t) -1 == UINT32_MAX ? 1 : -1; +#endif +#ifdef UINT64_MAX + int check_uint64: (uint64_t) -1 == UINT64_MAX ? 1 : -1; +#endif + int check_uint_least8: (uint_least8_t) -1 == UINT_LEAST8_MAX ? 1 : -1; + int check_uint_least16: (uint_least16_t) -1 == UINT_LEAST16_MAX ? 1 : -1; + int check_uint_least32: (uint_least32_t) -1 == UINT_LEAST32_MAX ? 1 : -1; + int check_uint_least64: (uint_least64_t) -1 == UINT_LEAST64_MAX ? 1 : -1; + int check_uint_fast8: (uint_fast8_t) -1 == UINT_FAST8_MAX ? 1 : -1; + int check_uint_fast16: (uint_fast16_t) -1 == UINT_FAST16_MAX ? 1 : -1; + int check_uint_fast32: (uint_fast32_t) -1 == UINT_FAST32_MAX ? 1 : -1; + int check_uint_fast64: (uint_fast64_t) -1 == UINT_FAST64_MAX ? 1 : -1; + int check_uintptr: (uintptr_t) -1 == UINTPTR_MAX ? 1 : -1; + int check_uintmax: (uintmax_t) -1 == UINTMAX_MAX ? 1 : -1; + int check_size: (size_t) -1 == SIZE_MAX ? 1 : -1; +}; + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + if test "$cross_compiling" = yes; then : + case "$host_os" in + # Guess yes on native Windows. + mingw*) gl_cv_header_working_stdint_h="guessing yes" ;; + # In general, assume it works. + *) gl_cv_header_working_stdint_h="guessing yes" ;; + esac + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */ +#define __STDC_CONSTANT_MACROS 1 +#define __STDC_LIMIT_MACROS 1 +#include + + + /* BSD/OS 4.0.1 has a bug: , and must be + included before . */ + #include + #include + #if HAVE_WCHAR_H + # include + # include + # include + #endif + + +#include +#include +#define MVAL(macro) MVAL1(macro) +#define MVAL1(expression) #expression +static const char *macro_values[] = + { +#ifdef INT8_MAX + MVAL (INT8_MAX), +#endif +#ifdef INT16_MAX + MVAL (INT16_MAX), +#endif +#ifdef INT32_MAX + MVAL (INT32_MAX), +#endif +#ifdef INT64_MAX + MVAL (INT64_MAX), +#endif +#ifdef UINT8_MAX + MVAL (UINT8_MAX), +#endif +#ifdef UINT16_MAX + MVAL (UINT16_MAX), +#endif +#ifdef UINT32_MAX + MVAL (UINT32_MAX), +#endif +#ifdef UINT64_MAX + MVAL (UINT64_MAX), +#endif + NULL + }; + +int +main () +{ + + const char **mv; + for (mv = macro_values; *mv != NULL; mv++) + { + const char *value = *mv; + /* Test whether it looks like a cast expression. */ + if (strncmp (value, "((unsigned int)"/*)*/, 15) == 0 + || strncmp (value, "((unsigned short)"/*)*/, 17) == 0 + || strncmp (value, "((unsigned char)"/*)*/, 16) == 0 + || strncmp (value, "((int)"/*)*/, 6) == 0 + || strncmp (value, "((signed short)"/*)*/, 15) == 0 + || strncmp (value, "((signed char)"/*)*/, 14) == 0) + return mv - macro_values + 1; + } + return 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_header_working_stdint_h=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_working_stdint_h" >&5 +$as_echo "$gl_cv_header_working_stdint_h" >&6; } + fi + + HAVE_C99_STDINT_H=0 + HAVE_SYS_BITYPES_H=0 + HAVE_SYS_INTTYPES_H=0 + STDINT_H=stdint.h + case "$gl_cv_header_working_stdint_h" in + *yes) + HAVE_C99_STDINT_H=1 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stdint.h predates C++11" >&5 +$as_echo_n "checking whether stdint.h predates C++11... " >&6; } +if ${gl_cv_header_stdint_predates_cxx11_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + gl_cv_header_stdint_predates_cxx11_h=yes + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */ +#include + + + /* BSD/OS 4.0.1 has a bug: , and must be + included before . */ + #include + #include + #if HAVE_WCHAR_H + # include + # include + # include + #endif + + +intmax_t im = INTMAX_MAX; +int32_t i32 = INT32_C (0x7fffffff); + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_header_stdint_predates_cxx11_h=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_stdint_predates_cxx11_h" >&5 +$as_echo "$gl_cv_header_stdint_predates_cxx11_h" >&6; } + + if test "$gl_cv_header_stdint_predates_cxx11_h" = yes; then + +$as_echo "#define __STDC_CONSTANT_MACROS 1" >>confdefs.h + + +$as_echo "#define __STDC_LIMIT_MACROS 1" >>confdefs.h + + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stdint.h has UINTMAX_WIDTH etc." >&5 +$as_echo_n "checking whether stdint.h has UINTMAX_WIDTH etc.... " >&6; } +if ${gl_cv_header_stdint_width+:} false; then : + $as_echo_n "(cached) " >&6 +else + gl_cv_header_stdint_width=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + /* Work if build is not clean. */ + #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 + #ifndef __STDC_WANT_IEC_60559_BFP_EXT__ + #define __STDC_WANT_IEC_60559_BFP_EXT__ 1 + #endif + #include + + /* BSD/OS 4.0.1 has a bug: , and must be + included before . */ + #include + #include + #if HAVE_WCHAR_H + # include + # include + # include + #endif + + int iw = UINTMAX_WIDTH; + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_header_stdint_width=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_stdint_width" >&5 +$as_echo "$gl_cv_header_stdint_width" >&6; } + if test "$gl_cv_header_stdint_width" = yes; then + STDINT_H= + fi + ;; + *) + for ac_header in sys/inttypes.h sys/bitypes.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + if test $ac_cv_header_sys_inttypes_h = yes; then + HAVE_SYS_INTTYPES_H=1 + fi + if test $ac_cv_header_sys_bitypes_h = yes; then + HAVE_SYS_BITYPES_H=1 + fi + + + if test $APPLE_UNIVERSAL_BUILD = 0; then + + + for gltype in ptrdiff_t size_t ; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for bit size of $gltype" >&5 +$as_echo_n "checking for bit size of $gltype... " >&6; } +if eval \${gl_cv_bitsizeof_${gltype}+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "sizeof ($gltype) * CHAR_BIT" "result" " + /* BSD/OS 4.0.1 has a bug: , and must be + included before . */ + #include + #include + #if HAVE_WCHAR_H + # include + # include + # include + #endif + +#include "; then : + +else + result=unknown +fi + + eval gl_cv_bitsizeof_${gltype}=\$result + +fi +eval ac_res=\$gl_cv_bitsizeof_${gltype} + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval result=\$gl_cv_bitsizeof_${gltype} + if test $result = unknown; then + result=0 + fi + GLTYPE=`echo "$gltype" | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'` + cat >>confdefs.h <<_ACEOF +#define BITSIZEOF_${GLTYPE} $result +_ACEOF + + eval BITSIZEOF_${GLTYPE}=\$result + done + + + fi + + + for gltype in sig_atomic_t wchar_t wint_t ; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for bit size of $gltype" >&5 +$as_echo_n "checking for bit size of $gltype... " >&6; } +if eval \${gl_cv_bitsizeof_${gltype}+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "sizeof ($gltype) * CHAR_BIT" "result" " + /* BSD/OS 4.0.1 has a bug: , and must be + included before . */ + #include + #include + #if HAVE_WCHAR_H + # include + # include + # include + #endif + +#include "; then : + +else + result=unknown +fi + + eval gl_cv_bitsizeof_${gltype}=\$result + +fi +eval ac_res=\$gl_cv_bitsizeof_${gltype} + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval result=\$gl_cv_bitsizeof_${gltype} + if test $result = unknown; then + result=0 + fi + GLTYPE=`echo "$gltype" | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'` + cat >>confdefs.h <<_ACEOF +#define BITSIZEOF_${GLTYPE} $result +_ACEOF + + eval BITSIZEOF_${GLTYPE}=\$result + done + + + + + for gltype in sig_atomic_t wchar_t wint_t ; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $gltype is signed" >&5 +$as_echo_n "checking whether $gltype is signed... " >&6; } +if eval \${gl_cv_type_${gltype}_signed+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + /* BSD/OS 4.0.1 has a bug: , and must be + included before . */ + #include + #include + #if HAVE_WCHAR_H + # include + # include + # include + #endif + + int verify[2 * (($gltype) -1 < ($gltype) 0) - 1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + result=yes +else + result=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + eval gl_cv_type_${gltype}_signed=\$result + +fi +eval ac_res=\$gl_cv_type_${gltype}_signed + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval result=\$gl_cv_type_${gltype}_signed + GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'` + if test "$result" = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_SIGNED_${GLTYPE} 1 +_ACEOF + + eval HAVE_SIGNED_${GLTYPE}=1 + else + eval HAVE_SIGNED_${GLTYPE}=0 + fi + done + + + gl_cv_type_ptrdiff_t_signed=yes + gl_cv_type_size_t_signed=no + if test $APPLE_UNIVERSAL_BUILD = 0; then + + + for gltype in ptrdiff_t size_t ; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $gltype integer literal suffix" >&5 +$as_echo_n "checking for $gltype integer literal suffix... " >&6; } +if eval \${gl_cv_type_${gltype}_suffix+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval gl_cv_type_${gltype}_suffix=no + eval result=\$gl_cv_type_${gltype}_signed + if test "$result" = yes; then + glsufu= + else + glsufu=u + fi + for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do + case $glsuf in + '') gltype1='int';; + l) gltype1='long int';; + ll) gltype1='long long int';; + i64) gltype1='__int64';; + u) gltype1='unsigned int';; + ul) gltype1='unsigned long int';; + ull) gltype1='unsigned long long int';; + ui64)gltype1='unsigned __int64';; + esac + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + /* BSD/OS 4.0.1 has a bug: , and must be + included before . */ + #include + #include + #if HAVE_WCHAR_H + # include + # include + # include + #endif + + extern $gltype foo; + extern $gltype1 foo; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval gl_cv_type_${gltype}_suffix=\$glsuf +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + eval result=\$gl_cv_type_${gltype}_suffix + test "$result" != no && break + done +fi +eval ac_res=\$gl_cv_type_${gltype}_suffix + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'` + eval result=\$gl_cv_type_${gltype}_suffix + test "$result" = no && result= + eval ${GLTYPE}_SUFFIX=\$result + cat >>confdefs.h <<_ACEOF +#define ${GLTYPE}_SUFFIX $result +_ACEOF + + done + + + fi + + + for gltype in sig_atomic_t wchar_t wint_t ; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $gltype integer literal suffix" >&5 +$as_echo_n "checking for $gltype integer literal suffix... " >&6; } +if eval \${gl_cv_type_${gltype}_suffix+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval gl_cv_type_${gltype}_suffix=no + eval result=\$gl_cv_type_${gltype}_signed + if test "$result" = yes; then + glsufu= + else + glsufu=u + fi + for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do + case $glsuf in + '') gltype1='int';; + l) gltype1='long int';; + ll) gltype1='long long int';; + i64) gltype1='__int64';; + u) gltype1='unsigned int';; + ul) gltype1='unsigned long int';; + ull) gltype1='unsigned long long int';; + ui64)gltype1='unsigned __int64';; + esac + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + /* BSD/OS 4.0.1 has a bug: , and must be + included before . */ + #include + #include + #if HAVE_WCHAR_H + # include + # include + # include + #endif + + extern $gltype foo; + extern $gltype1 foo; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval gl_cv_type_${gltype}_suffix=\$glsuf +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + eval result=\$gl_cv_type_${gltype}_suffix + test "$result" != no && break + done +fi +eval ac_res=\$gl_cv_type_${gltype}_suffix + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'` + eval result=\$gl_cv_type_${gltype}_suffix + test "$result" = no && result= + eval ${GLTYPE}_SUFFIX=\$result + cat >>confdefs.h <<_ACEOF +#define ${GLTYPE}_SUFFIX $result +_ACEOF + + done + + + + if test $GNULIB_OVERRIDES_WINT_T = 1; then + BITSIZEOF_WINT_T=32 + fi + + ;; + esac + + + + LIMITS_H='limits.h' + if test -n "$LIMITS_H"; then + GL_GENERATE_LIMITS_H_TRUE= + GL_GENERATE_LIMITS_H_FALSE='#' +else + GL_GENERATE_LIMITS_H_TRUE='#' + GL_GENERATE_LIMITS_H_FALSE= +fi + + + + + + + + if test -n "$STDINT_H"; then + GL_GENERATE_STDINT_H_TRUE= + GL_GENERATE_STDINT_H_FALSE='#' +else + GL_GENERATE_STDINT_H_TRUE='#' + GL_GENERATE_STDINT_H_FALSE= +fi + + + + +ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default" +if test "x$ac_cv_type_pid_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define pid_t int +_ACEOF + +fi + +ac_fn_c_check_type "$LINENO" "mode_t" "ac_cv_type_mode_t" "$ac_includes_default" +if test "x$ac_cv_type_mode_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define mode_t int +_ACEOF + +fi + + + + WINDOWS_64_BIT_OFF_T=0 + + + + + +$as_echo "#define _USE_STD_STAT 1" >>confdefs.h + + + + + + + + + + + + if test $gl_cv_have_include_next = yes; then + gl_cv_next_sys_types_h='<'sys/types.h'>' + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 +$as_echo_n "checking absolute name of ... " >&6; } +if ${gl_cv_next_sys_types_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + + + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + + case "$host_os" in + mingw*) + gl_dirsep_regex='[/\\]' + ;; + *) + gl_dirsep_regex='\/' + ;; + esac + gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' + gl_header_literal_regex=`echo 'sys/types.h' \ + | sed -e "$gl_make_literal_regex_sed"` + gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ + s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ + s|^/[^/]|//&| + p + q + }' + + gl_cv_absolute_sys_types_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n "$gl_absolute_header_sed"` + + gl_header=$gl_cv_absolute_sys_types_h + gl_cv_next_sys_types_h='"'$gl_header'"' + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_sys_types_h" >&5 +$as_echo "$gl_cv_next_sys_types_h" >&6; } + fi + NEXT_SYS_TYPES_H=$gl_cv_next_sys_types_h + + if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then + # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' + gl_next_as_first_directive='<'sys/types.h'>' + else + # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' + gl_next_as_first_directive=$gl_cv_next_sys_types_h + fi + NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H=$gl_next_as_first_directive + + + + + + + + + + + + + WINDOWS_STAT_INODES=0 + + + + + if true; then + GL_COND_LIBTOOL_TRUE= + GL_COND_LIBTOOL_FALSE='#' +else + GL_COND_LIBTOOL_TRUE='#' + GL_COND_LIBTOOL_FALSE= +fi + + gl_cond_libtool=true + gl_m4_base='gnulib-m4' + + + + + + + + + + gl_source_base='gnulib-lib' + + + + + + if test "$gl_threads_api" = posix; then + # OSF/1 4.0 and Mac OS X 10.1 lack the pthread_rwlock_t type and the + # pthread_rwlock_* functions. + has_rwlock=false + ac_fn_c_check_type "$LINENO" "pthread_rwlock_t" "ac_cv_type_pthread_rwlock_t" "#include +" +if test "x$ac_cv_type_pthread_rwlock_t" = xyes; then : + has_rwlock=true + +$as_echo "#define HAVE_PTHREAD_RWLOCK 1" >>confdefs.h + +fi + + if $has_rwlock; then + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthread_rwlock_rdlock prefers a writer to a reader" >&5 +$as_echo_n "checking whether pthread_rwlock_rdlock prefers a writer to a reader... " >&6; } +if ${gl_cv_pthread_rwlock_rdlock_prefer_writer+:} false; then : + $as_echo_n "(cached) " >&6 +else + save_LIBS="$LIBS" + LIBS="$LIBS $LIBMULTITHREAD" + if test "$cross_compiling" = yes; then : + gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing yes" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include + +#define SUCCEED() exit (0) +#define FAILURE() exit (1) +#define UNEXPECTED(n) (exit (10 + (n))) + +/* The main thread creates the waiting writer and the requesting reader threads + in the default way; this guarantees that they have the same priority. + We can reuse the main thread as first reader thread. */ + +static pthread_rwlock_t lock; +static pthread_t reader1; +static pthread_t writer; +static pthread_t reader2; +static pthread_t timer; +/* Used to pass control from writer to reader2 and from reader2 to timer, + as in a relay race. + Passing control from one running thread to another running thread + is most likely faster than to create the second thread. */ +static pthread_mutex_t baton; + +static void * +timer_func (void *ignored) +{ + /* Step 13 (can be before or after step 12): + The timer thread takes the baton, then waits a moment to make sure + it can tell whether the second reader thread is blocked at step 12. */ + if (pthread_mutex_lock (&baton)) + UNEXPECTED (13); + usleep (100000); + /* By the time we get here, it's clear that the second reader thread is + blocked at step 12. This is the desired behaviour. */ + SUCCEED (); +} + +static void * +reader2_func (void *ignored) +{ + int err; + + /* Step 8 (can be before or after step 7): + The second reader thread takes the baton, then waits a moment to make sure + the writer thread has reached step 7. */ + if (pthread_mutex_lock (&baton)) + UNEXPECTED (8); + usleep (100000); + /* Step 9: The second reader thread requests the lock. */ + err = pthread_rwlock_tryrdlock (&lock); + if (err == 0) + FAILURE (); + else if (err != EBUSY) + UNEXPECTED (9); + /* Step 10: Launch a timer, to test whether the next call blocks. */ + if (pthread_create (&timer, NULL, timer_func, NULL)) + UNEXPECTED (10); + /* Step 11: Release the baton. */ + if (pthread_mutex_unlock (&baton)) + UNEXPECTED (11); + /* Step 12: The second reader thread requests the lock. */ + err = pthread_rwlock_rdlock (&lock); + if (err == 0) + FAILURE (); + else + UNEXPECTED (12); +} + +static void * +writer_func (void *ignored) +{ + /* Step 4: Take the baton, so that the second reader thread does not go ahead + too early. */ + if (pthread_mutex_lock (&baton)) + UNEXPECTED (4); + /* Step 5: Create the second reader thread. */ + if (pthread_create (&reader2, NULL, reader2_func, NULL)) + UNEXPECTED (5); + /* Step 6: Release the baton. */ + if (pthread_mutex_unlock (&baton)) + UNEXPECTED (6); + /* Step 7: The writer thread requests the lock. */ + if (pthread_rwlock_wrlock (&lock)) + UNEXPECTED (7); + return NULL; +} + +int +main () +{ + reader1 = pthread_self (); + + /* Step 1: The main thread initializes the lock and the baton. */ + if (pthread_rwlock_init (&lock, NULL)) + UNEXPECTED (1); + if (pthread_mutex_init (&baton, NULL)) + UNEXPECTED (1); + /* Step 2: The main thread acquires the lock as a reader. */ + if (pthread_rwlock_rdlock (&lock)) + UNEXPECTED (2); + /* Step 3: Create the writer thread. */ + if (pthread_create (&writer, NULL, writer_func, NULL)) + UNEXPECTED (3); + /* Job done. Go to sleep. */ + for (;;) + { + sleep (1); + } +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_pthread_rwlock_rdlock_prefer_writer=yes +else + gl_cv_pthread_rwlock_rdlock_prefer_writer=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + LIBS="$save_LIBS" + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_pthread_rwlock_rdlock_prefer_writer" >&5 +$as_echo "$gl_cv_pthread_rwlock_rdlock_prefer_writer" >&6; } + case "$gl_cv_pthread_rwlock_rdlock_prefer_writer" in + *yes) + +$as_echo "#define HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER 1" >>confdefs.h + + ;; + esac + + fi + # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include +int +main () +{ + +#if __FreeBSD__ == 4 +error "No, in FreeBSD 4.0 recursive mutexes actually don't work." +#elif (defined __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ \ + && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070) +error "No, in Mac OS X < 10.7 recursive mutexes actually don't work." +#else +int x = (int)PTHREAD_MUTEX_RECURSIVE; +return !x; +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +$as_echo "#define HAVE_PTHREAD_MUTEX_RECURSIVE 1" >>confdefs.h + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi + : + + + +cat >>confdefs.h <<_ACEOF +#define GNULIB_LOCK 1 +_ACEOF + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ssize_t" >&5 +$as_echo_n "checking for ssize_t... " >&6; } +if ${gt_cv_ssize_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +int x = sizeof (ssize_t *) + sizeof (ssize_t); + return !x; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gt_cv_ssize_t=yes +else + gt_cv_ssize_t=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_ssize_t" >&5 +$as_echo "$gt_cv_ssize_t" >&6; } + if test $gt_cv_ssize_t = no; then + +$as_echo "#define ssize_t int" >>confdefs.h + + fi + + + + + case "$host_os" in + cygwin*) + STDNORETURN_H='stdnoreturn.h' + ;; + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working stdnoreturn.h" >&5 +$as_echo_n "checking for working stdnoreturn.h... " >&6; } +if ${gl_cv_header_working_stdnoreturn_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + /* Do not check for 'noreturn' after the return type. + C11 allows it, but it's rarely done that way + and circa-2012 bleeding-edge GCC rejects it when given + -Werror=old-style-declaration. */ + noreturn void foo1 (void) { exit (0); } + _Noreturn void foo2 (void) { exit (0); } + int testit (int argc, char **argv) + { + if (argc & 1) + return 0; + (argv[0][0] ? foo1 : foo2) (); + } + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_header_working_stdnoreturn_h=yes +else + gl_cv_header_working_stdnoreturn_h=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_working_stdnoreturn_h" >&5 +$as_echo "$gl_cv_header_working_stdnoreturn_h" >&6; } + if test $gl_cv_header_working_stdnoreturn_h = yes; then + STDNORETURN_H='' + else + STDNORETURN_H='stdnoreturn.h' + fi + ;; + esac + + if test -n "$STDNORETURN_H"; then + GL_GENERATE_STDNORETURN_H_TRUE= + GL_GENERATE_STDNORETURN_H_FALSE='#' +else + GL_GENERATE_STDNORETURN_H_TRUE='#' + GL_GENERATE_STDNORETURN_H_FALSE= +fi + + + + + + + case "$host_os" in + mingw*) + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS windows-mutex.$ac_objext" + + ;; + esac + + case "$host_os" in + mingw*) + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS windows-once.$ac_objext" + + ;; + esac + + case "$host_os" in + mingw*) + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS windows-recmutex.$ac_objext" + + ;; + esac + + case "$host_os" in + mingw*) + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS windows-rwlock.$ac_objext" + + ;; + esac + # End of code from modules + + + + + + + + + + gltests_libdeps= + gltests_ltlibdeps= + + + + + + + + + + gl_source_base='tests' + gltests_WITNESS=IN_`echo "${PACKAGE-$PACKAGE_TARNAME}" | LC_ALL=C tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'`_GNULIB_TESTS + + gl_module_indicator_condition=$gltests_WITNESS + + + + + + + + + + + +extrasub="$extrasub"' +/@subdir@/{ +h +g +s/@subdir@/gnulib-lib/g +p +g +s/@subdir@/avcall/g +p +g +s/@subdir@/vacall/g +p +g +s/@subdir@/trampoline/g +p +g +s/@subdir@/callback/g +p +d +} +' +extrasub="$extrasub"' +/@callback_subdir@/{ +h +g +s/@callback_subdir@/vacall_r/g +p +g +s/@callback_subdir@/trampoline_r/g +p +d +} +' + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + if test "x$cache_file" != "x/dev/null"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +U= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 +$as_echo_n "checking that generated files are newer than configure... " >&6; } + if test -n "$am_sleep_pid"; then + # Hide warnings about reused PIDs. + wait $am_sleep_pid 2>/dev/null + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 +$as_echo "done" >&6; } + if test -n "$EXEEXT"; then + am__EXEEXT_TRUE= + am__EXEEXT_FALSE='#' +else + am__EXEEXT_TRUE='#' + am__EXEEXT_FALSE= +fi + +if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then + as_fn_error $? "conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then + as_fn_error $? "conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${ANSICXX_TRUE}" && test -z "${ANSICXX_FALSE}"; then + as_fn_error $? "conditional \"ANSICXX\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then + as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then + as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${GL_COND_LIBTOOL_TRUE}" && test -z "${GL_COND_LIBTOOL_FALSE}"; then + as_fn_error $? "conditional \"GL_COND_LIBTOOL\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${ANSICXX_TRUE}" && test -z "${ANSICXX_FALSE}"; then + as_fn_error $? "conditional \"ANSICXX\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then + as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then + as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${GL_GENERATE_LIMITS_H_TRUE}" && test -z "${GL_GENERATE_LIMITS_H_FALSE}"; then + as_fn_error $? "conditional \"GL_GENERATE_LIMITS_H\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${GL_GENERATE_LIMITS_H_TRUE}" && test -z "${GL_GENERATE_LIMITS_H_FALSE}"; then + as_fn_error $? "conditional \"GL_GENERATE_LIMITS_H\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${GL_GENERATE_STDINT_H_TRUE}" && test -z "${GL_GENERATE_STDINT_H_FALSE}"; then + as_fn_error $? "conditional \"GL_GENERATE_STDINT_H\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${GL_GENERATE_STDNORETURN_H_TRUE}" && test -z "${GL_GENERATE_STDNORETURN_H_FALSE}"; then + as_fn_error $? "conditional \"GL_GENERATE_STDNORETURN_H\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi + + gl_libobjs= + gl_ltlibobjs= + if test -n "$gl_LIBOBJS"; then + # Remove the extension. + sed_drop_objext='s/\.o$//;s/\.obj$//' + for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do + gl_libobjs="$gl_libobjs $i.$ac_objext" + gl_ltlibobjs="$gl_ltlibobjs $i.lo" + done + fi + gl_LIBOBJS=$gl_libobjs + + gl_LTLIBOBJS=$gl_ltlibobjs + + + + gltests_libobjs= + gltests_ltlibobjs= + if test -n "$gltests_LIBOBJS"; then + # Remove the extension. + sed_drop_objext='s/\.o$//;s/\.obj$//' + for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do + gltests_libobjs="$gltests_libobjs $i.$ac_objext" + gltests_ltlibobjs="$gltests_ltlibobjs $i.lo" + done + fi + gltests_LIBOBJS=$gltests_libobjs + + gltests_LTLIBOBJS=$gltests_ltlibobjs + + + +: "${CONFIG_STATUS=./config.status}" +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by GNU libffcall $as_me 2.2, which was +generated by GNU Autoconf 2.69. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + +case $ac_config_headers in *" +"*) set x $ac_config_headers; shift; ac_config_headers=$*;; +esac + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" +config_commands="$ac_config_commands" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Configuration commands: +$config_commands + +Report bugs to . +GNU libffcall home page: . +General help using GNU software: ." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" +ac_cs_version="\\ +GNU libffcall config.status 2.2 +configured by $0, generated by GNU Autoconf 2.69, + with options \\"\$ac_cs_config\\" + +Copyright (C) 2012 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +INSTALL='$INSTALL' +MKDIR_P='$MKDIR_P' +AWK='$AWK' +test -n "\$AWK" || AWK=awk +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_HEADERS " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + as_fn_error $? "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; + --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# +# INIT-COMMANDS +# +AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" + + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +sed_quote_subst='$sed_quote_subst' +double_quote_subst='$double_quote_subst' +delay_variable_subst='$delay_variable_subst' +macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' +macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' +AS='`$ECHO "$AS" | $SED "$delay_single_quote_subst"`' +DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' +OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' +enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' +enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' +pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' +enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' +shared_archive_member_spec='`$ECHO "$shared_archive_member_spec" | $SED "$delay_single_quote_subst"`' +SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' +ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' +PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' +host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' +host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' +host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' +build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' +build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' +build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' +SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' +Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' +GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' +EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' +FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' +LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' +NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' +LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' +max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' +ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' +exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' +lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' +lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' +lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' +lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' +lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' +reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' +reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' +deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' +file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' +file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' +want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' +sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' +AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' +AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' +archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' +STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' +RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' +old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' +old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' +old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' +lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' +CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' +CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' +compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' +GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_import='`$ECHO "$lt_cv_sys_global_symbol_to_import" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' +lt_cv_nm_interface='`$ECHO "$lt_cv_nm_interface" | $SED "$delay_single_quote_subst"`' +nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' +lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' +lt_cv_truncate_bin='`$ECHO "$lt_cv_truncate_bin" | $SED "$delay_single_quote_subst"`' +objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' +MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' +lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' +need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' +MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' +DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' +NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' +LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' +OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' +OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' +libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' +shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' +extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' +archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' +enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' +export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' +whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' +compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' +old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' +old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' +archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' +archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' +module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' +module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' +with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' +allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' +no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' +hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' +hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' +hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' +hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' +hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' +hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' +hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' +inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' +link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' +always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' +export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' +exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' +include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' +prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' +postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' +file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' +variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' +need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' +need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' +version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' +runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' +shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' +shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' +libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' +library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' +soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' +install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' +postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' +postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' +finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' +finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' +hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' +sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' +configure_time_dlsearch_path='`$ECHO "$configure_time_dlsearch_path" | $SED "$delay_single_quote_subst"`' +configure_time_lt_sys_library_path='`$ECHO "$configure_time_lt_sys_library_path" | $SED "$delay_single_quote_subst"`' +hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' +enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' +enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' +enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' +old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' +striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' + +LTCC='$LTCC' +LTCFLAGS='$LTCFLAGS' +compiler='$compiler_DEFAULT' + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +\$1 +_LTECHO_EOF' +} + +# Quote evaled strings. +for var in AS \ +DLLTOOL \ +OBJDUMP \ +SHELL \ +ECHO \ +PATH_SEPARATOR \ +SED \ +GREP \ +EGREP \ +FGREP \ +LD \ +NM \ +LN_S \ +lt_SP2NL \ +lt_NL2SP \ +reload_flag \ +deplibs_check_method \ +file_magic_cmd \ +file_magic_glob \ +want_nocaseglob \ +sharedlib_from_linklib_cmd \ +AR \ +AR_FLAGS \ +archiver_list_spec \ +STRIP \ +RANLIB \ +CC \ +CFLAGS \ +compiler \ +lt_cv_sys_global_symbol_pipe \ +lt_cv_sys_global_symbol_to_cdecl \ +lt_cv_sys_global_symbol_to_import \ +lt_cv_sys_global_symbol_to_c_name_address \ +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ +lt_cv_nm_interface \ +nm_file_list_spec \ +lt_cv_truncate_bin \ +lt_prog_compiler_no_builtin_flag \ +lt_prog_compiler_pic \ +lt_prog_compiler_wl \ +lt_prog_compiler_static \ +lt_cv_prog_compiler_c_o \ +need_locks \ +MANIFEST_TOOL \ +DSYMUTIL \ +NMEDIT \ +LIPO \ +OTOOL \ +OTOOL64 \ +shrext_cmds \ +export_dynamic_flag_spec \ +whole_archive_flag_spec \ +compiler_needs_object \ +with_gnu_ld \ +allow_undefined_flag \ +no_undefined_flag \ +hardcode_libdir_flag_spec \ +hardcode_libdir_separator \ +exclude_expsyms \ +include_expsyms \ +file_list_spec \ +variables_saved_for_relink \ +libname_spec \ +library_names_spec \ +soname_spec \ +install_override_mode \ +finish_eval \ +old_striplib \ +striplib; do + case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in + *[\\\\\\\`\\"\\\$]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +# Double-quote double-evaled strings. +for var in reload_cmds \ +old_postinstall_cmds \ +old_postuninstall_cmds \ +old_archive_cmds \ +extract_expsyms_cmds \ +old_archive_from_new_cmds \ +old_archive_from_expsyms_cmds \ +archive_cmds \ +archive_expsym_cmds \ +module_cmds \ +module_expsym_cmds \ +export_symbols_cmds \ +prelink_cmds \ +postlink_cmds \ +postinstall_cmds \ +postuninstall_cmds \ +finish_cmds \ +sys_lib_search_path_spec \ +configure_time_dlsearch_path \ +configure_time_lt_sys_library_path; do + case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in + *[\\\\\\\`\\"\\\$]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +ac_aux_dir='$ac_aux_dir' + +# See if we are running on zsh, and set the options that allow our +# commands through without removal of \ escapes INIT. +if test -n "\${ZSH_VERSION+set}"; then + setopt NO_GLOB_SUBST +fi + + + PACKAGE='$PACKAGE' + VERSION='$VERSION' + RM='$RM' + ofile='$ofile' + + + + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + "ffcall-version.h") CONFIG_HEADERS="$CONFIG_HEADERS ffcall-version.h:ffcall-version.in.h" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "gnulib-lib/Makefile") CONFIG_FILES="$CONFIG_FILES gnulib-lib/Makefile" ;; + "avcall/Makefile") CONFIG_FILES="$CONFIG_FILES avcall/Makefile" ;; + "vacall/Makefile") CONFIG_FILES="$CONFIG_FILES vacall/Makefile" ;; + "trampoline/Makefile") CONFIG_FILES="$CONFIG_FILES trampoline/Makefile" ;; + "callback/Makefile") CONFIG_FILES="$CONFIG_FILES callback/Makefile" ;; + "callback/vacall_r/Makefile") CONFIG_FILES="$CONFIG_FILES callback/vacall_r/Makefile" ;; + "callback/trampoline_r/Makefile") CONFIG_FILES="$CONFIG_FILES callback/trampoline_r/Makefile" ;; + "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= ac_tmp= + trap 'exit_status=$? + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +_ACEOF + + +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\)..*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\)..*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' >$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 +_ACEOF + +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// +s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" + +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$ac_tmp/defines.awk" <<\_ACAWK || +BEGIN { +_ACEOF + +# Transform confdefs.h into an awk script `defines.awk', embedded as +# here-document in config.status, that substitutes the proper values into +# config.h.in to produce config.h. + +# Create a delimiter string that does not exist in confdefs.h, to ease +# handling of long lines. +ac_delim='%!_!# ' +for ac_last_try in false false :; do + ac_tt=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_tt"; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +# For the awk script, D is an array of macro values keyed by name, +# likewise P contains macro parameters if any. Preserve backslash +# newline sequences. + +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +sed -n ' +s/.\{148\}/&'"$ac_delim"'/g +t rset +:rset +s/^[ ]*#[ ]*define[ ][ ]*/ / +t def +d +:def +s/\\$// +t bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3"/p +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p +d +:bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3\\\\\\n"\\/p +t cont +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p +t cont +d +:cont +n +s/.\{148\}/&'"$ac_delim"'/g +t clear +:clear +s/\\$// +t bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/"/p +d +:bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p +b cont +' >$CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { + line = \$ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$ac_tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac + ac_MKDIR_P=$MKDIR_P + case $MKDIR_P in + [\\/$]* | ?:[\\/]* ) ;; + */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; + esac +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +s&@MKDIR_P@&$ac_MKDIR_P&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&2;} + + rm -f "$ac_tmp/stdin" + case $ac_file in + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + esac \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$ac_tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + fi + else + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 + fi +# Compute "$ac_file"'s index in $config_headers. +_am_arg="$ac_file" +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $_am_arg | $_am_arg:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || +$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$_am_arg" : 'X\(//\)[^/]' \| \ + X"$_am_arg" : 'X\(//\)$' \| \ + X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$_am_arg" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'`/stamp-h$_am_stamp_count + ;; + + :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 +$as_echo "$as_me: executing $ac_file commands" >&6;} + ;; + esac + + + case $ac_file$ac_mode in + "depfiles":C) test x"$AMDEP_TRUE" != x"" || { + # Older Autoconf quotes --file arguments for eval, but not when files + # are listed without --file. Let's play safe and only enable the eval + # if we detect the quoting. + case $CONFIG_FILES in + *\'*) eval set x "$CONFIG_FILES" ;; + *) set x $CONFIG_FILES ;; + esac + shift + for mf + do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named 'Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # Grep'ing the whole file is not good either: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then + dirpart=`$as_dirname -- "$mf" || +$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$mf" : 'X\(//\)[^/]' \| \ + X"$mf" : 'X\(//\)$' \| \ + X"$mf" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$mf" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running 'make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "$am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`$as_dirname -- "$file" || +$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$file" : 'X\(//\)[^/]' \| \ + X"$file" : 'X\(//\)$' \| \ + X"$file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir=$dirpart/$fdir; as_fn_mkdir_p + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done + done +} + ;; + "libtool":C) + + # See if we are running on zsh, and set the options that allow our + # commands through without removal of \ escapes. + if test -n "${ZSH_VERSION+set}"; then + setopt NO_GLOB_SUBST + fi + + cfgfile=${ofile}T + trap "$RM \"$cfgfile\"; exit 1" 1 2 15 + $RM "$cfgfile" + + cat <<_LT_EOF >> "$cfgfile" +#! $SHELL +# Generated automatically by $as_me ($PACKAGE) $VERSION +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# NOTE: Changes made to this file will be lost: look at ltmain.sh. + +# Provide generalized library-building support services. +# Written by Gordon Matzigkeit, 1996 + +# Copyright (C) 2014 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# GNU Libtool 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 of the License, or +# (at your option) any later version. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program or library that is built +# using GNU Libtool, you may include this file under the same +# distribution terms that you use for the rest of that program. +# +# GNU Libtool 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, see . + + +# The names of the tagged configurations supported by this script. +available_tags='' + +# Configured defaults for sys_lib_dlsearch_path munging. +: \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"} + +# ### BEGIN LIBTOOL CONFIG + +# Which release of libtool.m4 was used? +macro_version=$macro_version +macro_revision=$macro_revision + +# Assembler program. +AS=$lt_AS + +# DLL creation program. +DLLTOOL=$lt_DLLTOOL + +# Object dumper program. +OBJDUMP=$lt_OBJDUMP + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# What type of objects to build. +pic_mode=$pic_mode + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# Shared archive member basename,for filename based shared library versioning on AIX. +shared_archive_member_spec=$shared_archive_member_spec + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# An echo program that protects backslashes. +ECHO=$lt_ECHO + +# The PATH separator for the build system. +PATH_SEPARATOR=$lt_PATH_SEPARATOR + +# The host system. +host_alias=$host_alias +host=$host +host_os=$host_os + +# The build system. +build_alias=$build_alias +build=$build +build_os=$build_os + +# A sed program that does not truncate output. +SED=$lt_SED + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="\$SED -e 1s/^X//" + +# A grep program that handles long lines. +GREP=$lt_GREP + +# An ERE matcher. +EGREP=$lt_EGREP + +# A literal string matcher. +FGREP=$lt_FGREP + +# A BSD- or MS-compatible name lister. +NM=$lt_NM + +# Whether we need soft or hard links. +LN_S=$lt_LN_S + +# What is the maximum length of a command? +max_cmd_len=$max_cmd_len + +# Object file suffix (normally "o"). +objext=$ac_objext + +# Executable file suffix (normally ""). +exeext=$exeext + +# whether the shell understands "unset". +lt_unset=$lt_unset + +# turn spaces into newlines. +SP2NL=$lt_lt_SP2NL + +# turn newlines into spaces. +NL2SP=$lt_lt_NL2SP + +# convert \$build file names to \$host format. +to_host_file_cmd=$lt_cv_to_host_file_cmd + +# convert \$build files to toolchain format. +to_tool_file_cmd=$lt_cv_to_tool_file_cmd + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method = "file_magic". +file_magic_cmd=$lt_file_magic_cmd + +# How to find potential files when deplibs_check_method = "file_magic". +file_magic_glob=$lt_file_magic_glob + +# Find potential files using nocaseglob when deplibs_check_method = "file_magic". +want_nocaseglob=$lt_want_nocaseglob + +# Command to associate shared and link libraries. +sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd + +# The archiver. +AR=$lt_AR + +# Flags to create an archive. +AR_FLAGS=$lt_AR_FLAGS + +# How to feed a file listing to the archiver. +archiver_list_spec=$lt_archiver_list_spec + +# A symbol stripping program. +STRIP=$lt_STRIP + +# Commands used to install an old-style archive. +RANLIB=$lt_RANLIB +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Whether to use a lock for old archive extraction. +lock_old_archive_extraction=$lock_old_archive_extraction + +# A C compiler. +LTCC=$lt_CC + +# LTCC compiler flags. +LTCFLAGS=$lt_CFLAGS + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration. +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm into a list of symbols to manually relocate. +global_symbol_to_import=$lt_lt_cv_sys_global_symbol_to_import + +# Transform the output of nm in a C name address pair. +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# Transform the output of nm in a C name address pair when lib prefix is needed. +global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix + +# The name lister interface. +nm_interface=$lt_lt_cv_nm_interface + +# Specify filename containing input files for \$NM. +nm_file_list_spec=$lt_nm_file_list_spec + +# The root where to search for dependent libraries,and where our libraries should be installed. +lt_sysroot=$lt_sysroot + +# Command to truncate a binary pipe. +lt_truncate_bin=$lt_lt_cv_truncate_bin + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# Used to examine libraries when file_magic_cmd begins with "file". +MAGIC_CMD=$MAGIC_CMD + +# Must we lock files when doing compilation? +need_locks=$lt_need_locks + +# Manifest tool. +MANIFEST_TOOL=$lt_MANIFEST_TOOL + +# Tool to manipulate archived DWARF debug symbol files on Mac OS X. +DSYMUTIL=$lt_DSYMUTIL + +# Tool to change global to local symbols on Mac OS X. +NMEDIT=$lt_NMEDIT + +# Tool to manipulate fat objects and archives on Mac OS X. +LIPO=$lt_LIPO + +# ldd/readelf like tool for Mach-O binaries on Mac OS X. +OTOOL=$lt_OTOOL + +# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. +OTOOL64=$lt_OTOOL64 + +# Old archive suffix (normally "a"). +libext=$libext + +# Shared library suffix (normally ".so"). +shrext_cmds=$lt_shrext_cmds + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at link time. +variables_saved_for_relink=$lt_variables_saved_for_relink + +# Do we need the "lib" prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Library versioning type. +version_type=$version_type + +# Shared library runtime path variable. +runpath_var=$runpath_var + +# Shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Permission mode override for installation of shared libraries. +install_override_mode=$lt_install_override_mode + +# Command to use after installation of a shared archive. +postinstall_cmds=$lt_postinstall_cmds + +# Command to use after uninstallation of a shared archive. +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# As "finish_cmds", except a single script fragment to be evaled but +# not shown. +finish_eval=$lt_finish_eval + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Compile-time system search path for libraries. +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Detected run-time system search path for libraries. +sys_lib_dlsearch_path_spec=$lt_configure_time_dlsearch_path + +# Explicit LT_SYS_LIBRARY_PATH set during ./configure time. +configure_time_lt_sys_library_path=$lt_configure_time_lt_sys_library_path + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + + +# The linker used to build libraries. +LD=$lt_LD + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# Commands used to build an old-style archive. +old_archive_cmds=$lt_old_archive_cmds + +# A language specific compiler. +CC=$lt_compiler + +# Is the compiler the GNU compiler? +with_gcc=$GCC + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc + +# Whether or not to disallow shared libs when runtime libs are static. +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec + +# Whether the compiler copes with passing no objects directly. +compiler_needs_object=$lt_compiler_needs_object + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds + +# Commands used to build a shared archive. +archive_cmds=$lt_archive_cmds +archive_expsym_cmds=$lt_archive_expsym_cmds + +# Commands used to build a loadable module if different from building +# a shared archive. +module_cmds=$lt_module_cmds +module_expsym_cmds=$lt_module_expsym_cmds + +# Whether we are building with GNU ld or not. +with_gnu_ld=$lt_with_gnu_ld + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag + +# Flag that enforces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec + +# Whether we need a single "-rpath" flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator + +# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes +# DIR into the resulting binary. +hardcode_direct=$hardcode_direct + +# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes +# DIR into the resulting binary and the resulting library dependency is +# "absolute",i.e impossible to change by setting \$shlibpath_var if the +# library is relocated. +hardcode_direct_absolute=$hardcode_direct_absolute + +# Set to "yes" if using the -LDIR flag during linking hardcodes DIR +# into the resulting binary. +hardcode_minus_L=$hardcode_minus_L + +# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR +# into the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var + +# Set to "yes" if building a shared library automatically hardcodes DIR +# into the library and all subsequent libraries and executables linked +# against it. +hardcode_automatic=$hardcode_automatic + +# Set to yes if linker adds runtime paths of dependent libraries +# to runtime path list. +inherit_rpath=$inherit_rpath + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs + +# Set to "yes" if exported symbols are required. +always_export_symbols=$always_export_symbols + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms + +# Commands necessary for linking programs (against libraries) with templates. +prelink_cmds=$lt_prelink_cmds + +# Commands necessary for finishing linking programs. +postlink_cmds=$lt_postlink_cmds + +# Specify filename containing input files. +file_list_spec=$lt_file_list_spec + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action + +# ### END LIBTOOL CONFIG + +_LT_EOF + + cat <<'_LT_EOF' >> "$cfgfile" + +# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE + +# func_munge_path_list VARIABLE PATH +# ----------------------------------- +# VARIABLE is name of variable containing _space_ separated list of +# directories to be munged by the contents of PATH, which is string +# having a format: +# "DIR[:DIR]:" +# string "DIR[ DIR]" will be prepended to VARIABLE +# ":DIR[:DIR]" +# string "DIR[ DIR]" will be appended to VARIABLE +# "DIRP[:DIRP]::[DIRA:]DIRA" +# string "DIRP[ DIRP]" will be prepended to VARIABLE and string +# "DIRA[ DIRA]" will be appended to VARIABLE +# "DIR[:DIR]" +# VARIABLE will be replaced by "DIR[ DIR]" +func_munge_path_list () +{ + case x$2 in + x) + ;; + *:) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\" + ;; + x:*) + eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\" + ;; + *::*) + eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" + eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\" + ;; + *) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\" + ;; + esac +} + + +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +func_cc_basename () +{ + for cc_temp in $*""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac + done + func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` +} + + +# ### END FUNCTIONS SHARED WITH CONFIGURE + +_LT_EOF + + case $host_os in + aix3*) + cat <<\_LT_EOF >> "$cfgfile" +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test set != "${COLLECT_NAMES+set}"; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +_LT_EOF + ;; + esac + + +ltmain=$ac_aux_dir/ltmain.sh + + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '$q' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" + + ;; + + esac +done # for ac_tag + + +as_fn_exit 0 +_ACEOF +ac_clean_files=$ac_clean_files_save + +test $ac_write_fail = 0 || + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || as_fn_exit 1 +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi + diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..dc10be1 --- /dev/null +++ b/configure.ac @@ -0,0 +1,229 @@ +dnl AUTOCONF configuration for LIBFFCALL +dnl Copyright 1995-2019 Bruno Haible +dnl Copyright 2003-2010 Sam Steingold +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 2 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program. If not, see . +dnl + +AC_INIT([GNU libffcall],m4_normalize(m4_esyscmd([cat VERSION])),[https://savannah.gnu.org/projects/libffcall],[libffcall]) +AC_CONFIG_AUX_DIR([build-aux]) +AM_INIT_AUTOMAKE([]) + +AC_CONFIG_SRCDIR([trampoline/trampoline.h]) + +AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_HEADERS([ffcall-version.h:ffcall-version.in.h]) + +AC_CONFIG_FILES([Makefile]) +AC_CONFIG_FILES([gnulib-lib/Makefile]) +AC_CONFIG_FILES([avcall/Makefile]) +AC_CONFIG_FILES([vacall/Makefile]) +AC_CONFIG_FILES([trampoline/Makefile]) +AC_CONFIG_FILES([callback/Makefile]) +AC_CONFIG_FILES([callback/vacall_r/Makefile]) +AC_CONFIG_FILES([callback/trampoline_r/Makefile]) + +dnl Substitutable version number. +changequote(,) +sed_extract_major='/^[0-9]/{s/^\([0-9]*\).*/\1/p;q;} +i\ +0 +q +' +sed_extract_minor='/^[0-9][0-9]*[.][0-9]/{s/^[0-9]*[.]\([0-9]*\).*/\1/p;q;} +i\ +0 +q +' +changequote([,]) +version_major=`echo "${PACKAGE_VERSION}" | sed -n -e "$sed_extract_major"` +version_minor=`echo "${PACKAGE_VERSION}" | sed -n -e "$sed_extract_minor"` +HEXVERSION=`printf '0x%02X%02X' $version_major $version_minor` +AC_DEFINE_UNQUOTED([LIBFFCALL_VERSION], [$HEXVERSION], [Version number: (major<<8) + minor]) + +AC_PROG_MAKE_SET + +dnl The libraries are built in C. +AC_PROG_CC +AC_PROG_CPP +AC_PROG_GCC_TRADITIONAL +CL_CC_GCC +CL_AS_UNDERSCORE +dnl But some tests use C++. +gl_PROG_ANSI_CXX([CXX], [ANSICXX]) +if test "$CXX" != no; then + IF_CXX='' +else + IF_CXX='# ' +fi +AC_SUBST([IF_CXX]) + +dnl For a 64-bit build on AIX, AC_PROG_RANLIB is not sufficient. +gl_PROG_AR_RANLIB + +dnl The Makefiles have a few special rules for MSVC. +AC_EGREP_CPP([MicrosoftCompiler], + [ +#ifdef _MSC_VER +MicrosoftCompiler +#endif + ], + [IF_MSVC='' + IFNOT_MSVC='# ' + ], + [IF_MSVC='# ' + IFNOT_MSVC='' + ]) +AC_SUBST([IF_MSVC]) +AC_SUBST([IFNOT_MSVC]) + +AC_PROG_INSTALL +CL_PROG_LN + +gl_EARLY + +gl_HOST_CPU_C_ABI +FFCALL_ENDIANNESS + +PACKAGE=libffcall +LT_INIT([win32-dll]) + +dnl Checks for avcall, vacall, vacall_r. +FFCALL_SMALL_STRUCT_RETURN +FFCALL_IREG_FLOAT_RETURN + +dnl Checks for trampoline, trampoline_r. +AC_CHECK_HEADERS([unistd_h]) +AC_HEADER_STDC +CL_GETPAGESIZE +CL_MACH_VM +FFCALL_MMAP +FFCALL_MPROTECT +CL_SHM_H +CL_SHM +FFCALL_CODEEXEC +FFCALL_CODEEXEC_PAX + +dnl List of object files for trampoline, trampoline_r. +CPU_OBJECTS='' +if test ${HOST_CPU_C_ABI} = hppa -o ${HOST_CPU_C_ABI} = hppa64 -o ${HOST_CPU_C_ABI} = powerpc64 -o ${HOST_CPU_C_ABI} = ia64; then + CPU_OBJECTS="$CPU_OBJECTS "'tramp-$(CPU).lo' +fi +if test ${HOST_CPU_C_ABI} = powerpc; then + case "${host_os}" in + aix*) CPU_OBJECTS="$CPU_OBJECTS "'tramp-$(CPU).lo' ;; + *) ;; + esac +fi +if test ${HOST_CPU_C_ABI} = sparc -o ${HOST_CPU_C_ABI} = sparc64 -o ${HOST_CPU_C_ABI} = alpha -o ${HOST_CPU_C_ABI} = hppa -o ${HOST_CPU_C_ABI} = hppa64 -o ${HOST_CPU_C_ABI} = powerpc64-elfv2; then + CPU_OBJECTS="$CPU_OBJECTS "'cache-$(CPU).lo' +fi +if test ${HOST_CPU_C_ABI} = powerpc; then + case "${host_os}" in + aix*) ;; + *) CPU_OBJECTS="$CPU_OBJECTS "'cache-$(CPU).lo' ;; + esac +fi +AC_SUBST([CPU_OBJECTS]) +case "${HOST_CPU_C_ABI}" in + mips* | riscv*) + AC_CHECK_HEADERS([sys/cachectl.h]) + ;; +esac + +dnl Work around GCC bug : +dnl GCC, configured with --enable-default-pie on SPARC, miscompiles hand-written +dnl .s files that happen to access global variables. The recommended workaround +dnl is to use '#ifdef __PIC__' in the .s file; this works fine on 64-bit SPARC. +dnl On 32-bit SPARC, however, the resulting executable is still broken. The +dnl workaround here is to use -fno-pie. This option is available in gcc >= 3.4. +WORKAROUND_BUG_81653='' +if test ${HOST_CPU_C_ABI} = sparc && test -n "$GCC"; then + gcc_version=`LC_ALL=C ${CC} -v 2>&1 | grep version | sed -n -e '$p' | sed -e 's/.*version //g' -e 's/gcc //'` + case "$gcc_version" in + 2.* | 3.[0-3]*) ;; + *) WORKAROUND_BUG_81653='-fno-pie' ;; + esac +fi +AC_SUBST([WORKAROUND_BUG_81653]) + +dnl Some parts of avcall and vacall need to interpret memory words as 'float' +dnl or 'double' entities. This violates the strict type-based aliasing rules +dnl of C. In other words, we still use C as a portable assembler, but now the +dnl compilers want to outsmart us. There are two ways to tell them not to do +dnl this: to use union types, or specific compiler options. I prefer to do it +dnl through compiler options, because union types produce trouble with +dnl alignments. +if test -n "$GCC"; then + DISABLE_TYPE_BASED_ALIASING='-fno-strict-aliasing' +else + case "$host_os" in + aix*) dnl for xlc + DISABLE_TYPE_BASED_ALIASING='-qalias=noansi' + ;; + *) + AC_EGREP_CPP([yes], + [#ifdef __SUNPRO_C + yes + #endif + ], + [dnl for SUNWspro cc + DISABLE_TYPE_BASED_ALIASING='-xalias_level=weak' + ], + [DISABLE_TYPE_BASED_ALIASING='']) + ;; + esac +fi +AC_SUBST([DISABLE_TYPE_BASED_ALIASING]) + +gl_INIT + +dnl This piece of sed script replaces every line containing '@subdir@' +dnl by several consecutive lines, each referencing one subdir. +extrasub="$extrasub"' +/@subdir@/{ +h +g +s/@subdir@/gnulib-lib/g +p +g +s/@subdir@/avcall/g +p +g +s/@subdir@/vacall/g +p +g +s/@subdir@/trampoline/g +p +g +s/@subdir@/callback/g +p +d +} +' +dnl Likewise for the callback subdirectory. +extrasub="$extrasub"' +/@callback_subdir@/{ +h +g +s/@callback_subdir@/vacall_r/g +p +g +s/@callback_subdir@/trampoline_r/g +p +d +} +' + +AC_OUTPUT diff --git a/dummy/ffcall-version.h b/dummy/ffcall-version.h new file mode 100644 index 0000000..1635283 --- /dev/null +++ b/dummy/ffcall-version.h @@ -0,0 +1 @@ +/* This file is intentionally empty. */ diff --git a/ffcall-abi.h b/ffcall-abi.h new file mode 100644 index 0000000..117fd65 --- /dev/null +++ b/ffcall-abi.h @@ -0,0 +1,251 @@ +/* + * Copyright 2017-2019 Bruno Haible + * + * 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, see . + */ + +/* Define some canonical CPU and ABI indicators. + References: + - host-cpu-c-abi.m4 from gnulib + - https://sourceforge.net/p/predef/wiki/Architectures/ + - GCC source code: definitions of macro TARGET_CPU_CPP_BUILTINS + - clang source code: defineMacro invocations in Basic/Targets.cpp, + especially in getTargetDefines methods. + Limitation: Unlike host-cpu-c-abi.m4, this preprocessor-based approach + can not reliably distinguish __arm__ and __armhf__. + */ + +#ifndef __i386__ +#if defined(__i386__) /* GCC, clang */ || defined(__i386) /* Sun C */ || defined(_M_IX86) /* MSVC */ +#define __i386__ 1 +#endif +#endif + +#ifndef __m68k__ +#if defined(__m68k__) /* GCC */ +#define __m68k__ 1 +#endif +#endif + +/* On mips, there are three ABIs: + - 32 or o32: It defines _MIPS_SIM == _ABIO32 and _MIPS_SZLONG == 32. + - n32: It defines _MIPS_SIM == _ABIN32 and _MIPS_SZLONG == 32. + - 64: It defines _MIPS_SZLONG == 64. + */ +/* Note: When __mipsn32__ or __mips64__ is defined, __mips__ may or may not be + defined as well. To test for the MIPS o32 ABI, use + #if defined(__mips__) && !defined(__mipsn32__) && !defined(__mips64__) + */ +/* To distinguish little-endian and big-endian arm, use the preprocessor + defines _MIPSEB vs. _MIPSEL. */ +#ifndef __mips__ +#if defined(__mips) /* GCC, clang, IRIX cc */ /* Note: GCC, clang also define __mips__. */ +#define __mips__ 1 +#endif +#endif +#ifndef __mipsn32__ +#if defined(__mips__) && (_MIPS_SIM == _ABIN32) +#define __mipsn32__ 1 +#endif +#endif +#ifndef __mips64__ +#if defined(__mips__) && defined(_MIPS_SZLONG) && (_MIPS_SZLONG == 64) +#define __mips64__ 1 +#endif +#endif + +/* Note: When __sparc64__ is defined, __sparc__ may or may not be defined as + well. To test for the SPARC 32-bit ABI, use + #if defined(__sparc__) && !defined(__sparc64__) + */ +#ifndef __sparc__ +#if defined(__sparc) /* GCC, clang, Sun C */ /* Note: GCC, clang also define __sparc__. */ +#define __sparc__ 1 +#endif +#endif +#ifndef __sparc64__ +#if defined(__sparcv9) /* GCC/Solaris, Sun C */ || defined(__arch64__) /* GCC/Linux */ +#define __sparc64__ 1 +#endif +#endif + +#ifndef __alpha__ +#if defined(__alpha) /* GCC, DEC C */ /* Note: GCC also defines __alpha__. */ +#define __alpha__ 1 +#endif +#endif + +/* On hppa, the C compiler may be generating 32-bit code or 64-bit code. + In the latter case, it defines _LP64 and __LP64__. + */ +/* Note: When __hppa64__ is defined, __hppa__ may or may not be defined as well. + To test for the HP-PA 32-bit ABI, use + #if defined(__hppa__) && !defined(__hppa64__) + */ +#ifndef __hppa__ +#if defined(__hppa) /* GCC, HP C */ /* Note: GCC also defines __hppa__. */ +#define __hppa__ 1 +#endif +#endif +#ifndef __hppa64__ +#if defined(__hppa__) && defined(__LP64__) +#define __hppa64__ 1 +#endif +#endif + +/* Distinguish arm which passes floating-point arguments and return values + in integer registers (r0, r1, ...) - this is gcc -mfloat-abi=soft or + gcc -mfloat-abi=softfp - from arm which passes them in float registers + (s0, s1, ...) and double registers (d0, d1, ...) - this is + gcc -mfloat-abi=hard. GCC 4.6 or newer sets the preprocessor defines + __ARM_PCS (for the first case) and __ARM_PCS_VFP (for the second case), + but older GCC does not. */ +/* Note: When __armhf__ is defined, __arm__ may or may not be defined as well. + To test for the ARM ABI that does not use floating-point registers for + parameter passing, use + #if defined(__arm__) && !defined(__armhf__) + */ +/* To distinguish little-endian and big-endian arm, use the preprocessor + defines __ARMEL__ vs. __ARMEB__. */ +#ifndef __arm__ +#if defined(__arm__) /* GCC, clang */ || defined(_M_ARM) /* MSVC */ +#define __arm__ 1 +#endif +#endif +#ifndef __armhf__ +#if defined(__arm__) && defined(__ARM_PCS_VFP) /* GCC */ +#define __armhf__ 1 +#endif +#endif + +/* On arm64 systems, the C compiler may be generating code in one of these ABIs: + - aarch64 instruction set, 64-bit pointers, 64-bit 'long': arm64. + - aarch64 instruction set, 32-bit pointers, 32-bit 'long': arm64-ilp32. + - 32-bit instruction set, 32-bit pointers, 32-bit 'long': arm or armhf + (see above). + */ +/* Note: When __arm64_ilp32__ is defined, __arm64__ may or may not be defined as + well. To test for the arm64 64-bit ABI, use + #if defined(__arm64__) && !defined(__arm64_ilp32__) + */ +/* To distinguish little-endian and big-endian arm64, use the preprocessor + defines __AARCH64EL__ vs. __AARCH64EB__. */ +#ifndef __arm64__ +#if defined(__aarch64__) /* GCC, clang */ || defined(_M_ARM64) /* MSVC */ +#define __arm64__ 1 +#endif +#endif +#ifndef __arm64_ilp32__ +#if defined(__arm64__) && (defined(__ILP32__) || defined (_ILP32)) +#define __arm64_ilp32__ 1 +#endif +#endif + +/* On powerpc and powerpc64, different ABIs are in use on AIX vs. Mac OS X vs. + Linux,*BSD. To distinguish them, use the OS dependent defines + #if defined(_AIX) + #if (defined(__MACH__) && defined(__APPLE__)) + #if !(defined(_AIX) || (defined(__MACH__) && defined(__APPLE__))) + */ +/* On powerpc64, there are two ABIs on Linux: The AIX compatible one and the + ELFv2 one. The latter defines _CALL_ELF=2. + */ +/* Note: When __powerpc64__ is defined, __powerpc__ may or may not be defined as + well. To test for the SPARC 32-bit ABI, use + #if defined(__powerpc__) && !defined(__powerpc64__) + Note: When __powerpc64_elfv2__ is defined, __powerpc64__ may or may not be + defined as well. To test for the SPARC 32-bit ABI, use + #if defined(__powerpc64__) && !defined(__powerpc64_elfv2__) + */ +#ifndef __powerpc__ +#if defined(_ARCH_PPC) /* GCC, XLC */ /* Note: On AIX, Linux also __powerpc__ is defined; whereas on Mac OS X also __ppc__ is defined. On AIX also _IBMR2 is defined. */ +#define __powerpc__ 1 +#endif +#endif +#ifndef __powerpc64__ +#if defined(_ARCH_PPC64) /* GCC, XLC */ /* Note: On Linux, also __powerpc64__ is defined. */ +#define __powerpc64__ 1 +#endif +#endif +#ifndef __powerpc64_elfv2__ +#if defined(__powerpc64__) && defined(_CALL_ELF) && _CALL_ELF == 2 +#define __powerpc64_elfv2__ 1 +#endif +#endif + +/* On ia64 on HP-UX, the C compiler may be generating 64-bit code or 32-bit + code. In the latter case, it defines _ILP32. + */ +/* Note: When __ia64_ilp32__ is defined, __ia64__ may or may not be defined as + well. To test for the ia64 64-bit ABI, use + #if defined(__ia64__) && !defined(__ia64_ilp32__) + */ +#ifndef __ia64__ +#if defined(__ia64__) /* GCC, HP C */ /* Note: GCC, HP C also define __ia64. */ +#define __ia64__ 1 +#endif +#endif +#ifndef __ia64_ilp32__ +#if defined(__ia64__) && defined(_ILP32) +#define __ia64_ilp32__ 1 +#endif +#endif + +/* On x86_64 systems, the C compiler may be generating code in one of these ABIs: + - 64-bit instruction set, 64-bit pointers, 64-bit 'long': x86_64. + - 64-bit instruction set, 64-bit pointers, 32-bit 'long': x86_64 + with native Windows (mingw, MSVC). + - 64-bit instruction set, 32-bit pointers, 32-bit 'long': x86_64-x32. + - 32-bit instruction set, 32-bit pointers, 32-bit 'long': i386 (see above). */ +/* Note: When __x86_64_x32__ is defined, __x86_64__ may or may not be defined as + well. To test for the x86_64 64-bit ABI, use + #if defined(__x86_64__) && !defined(__x86_64_x32__) + */ +#ifndef __x86_64__ +#if (defined(__x86_64__) || defined(__amd64__)) /* GCC, clang, Sun C */ || (defined(_M_X64) || defined(_M_AMD64)) /* MSVC */ +#define __x86_64__ 1 +#endif +#endif +#ifndef __x86_64_x32__ +#if defined(__x86_64__) && (defined(__ILP32__) || defined(_ILP32)) +#define __x86_64_x32__ 1 +#endif +#endif + +/* Note: When __s390x__ is defined, __s390__ may or may not be defined as well. + To test for the S/390 31-bit ABI, use + #if defined(__s390__) && !defined(__s390x__) + */ +#ifndef __s390__ +#if defined(__s390__) /* GCC, clang */ +#define __s390__ 1 +#endif +#endif +#ifndef __s390x__ +#if defined(__s390x__) /* GCC, clang */ +#define __s390x__ 1 +#endif +#endif + +#ifndef __riscv32__ +#if defined(__riscv) && __riscv_xlen == 32 && !defined(__LP64__) /* GCC */ +#define __riscv32__ 1 +#endif +#endif + +#ifndef __riscv64__ +#if defined(__riscv) && __riscv_xlen == 64 && defined(__LP64__) /* GCC */ +#define __riscv64__ 1 +#endif +#endif diff --git a/ffcall-stdint.h b/ffcall-stdint.h new file mode 100644 index 0000000..125815c --- /dev/null +++ b/ffcall-stdint.h @@ -0,0 +1,40 @@ +/* + * Copyright 2017-2018 Bruno Haible + * + * 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, see . + */ + +/* Replacement for a subset of . + We cannot use gnulib's portable replacement, because when + cross-compiling the various avcall-$(CPU).c and vacall-$(CPU).c files, + gnulib-generated files are not available. And the cross-compilers of + GCC version < 4.5 don't provide . */ + +/* Define integer types that are as large as a pointer, */ + +#if defined(__x86_64__) && defined(_WIN32) && !defined(__CYGWIN__) +/* An LLP64 platform. */ +typedef long long ff_intptr_t; +typedef unsigned long long ff_uintptr_t; +#else +/* An ILP32 or LP64 platform. */ +typedef long ff_intptr_t; +typedef unsigned long ff_uintptr_t; +#endif +#define intptr_t ff_intptr_t +#define uintptr_t ff_uintptr_t + +/* Verify at compile time that sizeof([u]intptr_t) == sizeof(void*). */ +typedef int intptr_verify[2*(sizeof(intptr_t) == sizeof(void*))-1]; +typedef int uintptr_verify[2*(sizeof(uintptr_t) == sizeof(void*))-1]; diff --git a/ffcall-version.c b/ffcall-version.c new file mode 100644 index 0000000..97484be --- /dev/null +++ b/ffcall-version.c @@ -0,0 +1,26 @@ +/* + * Copyright 2017 Bruno Haible + * + * 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, see . + */ + +#include "config.h" + +/* Specification. */ +#include "ffcall-version.h" + +int ffcall_get_version (void) +{ + return LIBFFCALL_VERSION; +} diff --git a/ffcall-version.in.h b/ffcall-version.in.h new file mode 100644 index 0000000..494ec15 --- /dev/null +++ b/ffcall-version.in.h @@ -0,0 +1,34 @@ +/* + * Copyright 2009-2017 Bruno Haible + * + * 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, see . + */ + +#if !defined(FFCALL_VERSION_H) + +/* Version number of libffcall (include files): (major<<8) + minor. */ +#define LIBFFCALL_VERSION 0 + +#ifdef __cplusplus +extern "C" { +#endif + +/* Version number of libffcall (library): (major<<8) + minor. */ +extern int ffcall_get_version (void); + +#ifdef __cplusplus +} +#endif + +#endif /* FFCALL_VERSION_H */ diff --git a/gnulib-lib/Makefile.am b/gnulib-lib/Makefile.am new file mode 100644 index 0000000..2ecab06 --- /dev/null +++ b/gnulib-lib/Makefile.am @@ -0,0 +1,287 @@ +## DO NOT EDIT! GENERATED AUTOMATICALLY! +## Process this file with automake to produce Makefile.in. +# Copyright (C) 2002-2019 Free Software Foundation, Inc. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This file 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 file. If not, see . +# +# As a special exception to the GNU General Public License, +# this file may be distributed as part of a program that +# contains a configuration script generated by Autoconf, under +# the same distribution terms as the rest of that program. +# +# Generated by gnulib-tool. +# Reproduce by: +# gnulib-tool --import \ +# --lib=libgnu \ +# --source-base=gnulib-lib \ +# --m4-base=gnulib-m4 \ +# --doc-base=doc \ +# --tests-base=tests \ +# --aux-dir=build-aux \ +# --no-conditional-dependencies \ +# --libtool \ +# --macro-prefix=gl \ +# ansi-c++-opt \ +# host-cpu-c-abi \ +# lock \ +# longlong \ +# nocrash \ +# stdint \ +# stdnoreturn + +AUTOMAKE_OPTIONS = 1.11 gnits subdir-objects + +SUBDIRS = +noinst_HEADERS = +noinst_LIBRARIES = +noinst_LTLIBRARIES = +EXTRA_DIST = +BUILT_SOURCES = +SUFFIXES = +MOSTLYCLEANFILES = core *.stackdump +MOSTLYCLEANDIRS = +CLEANFILES = +DISTCLEANFILES = +MAINTAINERCLEANFILES = +# No GNU Make output. + +AM_CPPFLAGS = +AM_CFLAGS = + +noinst_LTLIBRARIES += libgnu.la + +libgnu_la_SOURCES = +libgnu_la_LIBADD = $(gl_LTLIBOBJS) +libgnu_la_DEPENDENCIES = $(gl_LTLIBOBJS) +EXTRA_libgnu_la_SOURCES = +libgnu_la_LDFLAGS = $(AM_LDFLAGS) +libgnu_la_LDFLAGS += -no-undefined +libgnu_la_LDFLAGS += $(LTLIBTHREAD) + +## begin gnulib module absolute-header + +# Use this preprocessor expression to decide whether #include_next works. +# Do not rely on a 'configure'-time test for this, since the expression +# might appear in an installed header, which is used by some other compiler. +HAVE_INCLUDE_NEXT = (__GNUC__ || 60000000 <= __DECC_VER) + +## end gnulib module absolute-header + +## begin gnulib module havelib + + +EXTRA_DIST += $(top_srcdir)/build-aux/config.rpath + +## end gnulib module havelib + +## begin gnulib module limits-h + +BUILT_SOURCES += $(LIMITS_H) + +# We need the following in order to create when the system +# doesn't have one that is compatible with GNU. +if GL_GENERATE_LIMITS_H +limits.h: limits.in.h $(top_builddir)/config.status + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ + sed -e 's|@''GUARD_PREFIX''@|GL|g' \ + -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ + -e 's|@''NEXT_LIMITS_H''@|$(NEXT_LIMITS_H)|g' \ + < $(srcdir)/limits.in.h; \ + } > $@-t && \ + mv $@-t $@ +else +limits.h: $(top_builddir)/config.status + rm -f $@ +endif +MOSTLYCLEANFILES += limits.h limits.h-t + +EXTRA_DIST += limits.in.h + +## end gnulib module limits-h + +## begin gnulib module lock + +libgnu_la_SOURCES += glthread/lock.h glthread/lock.c + +## end gnulib module lock + +## begin gnulib module snippet/_Noreturn + +# Because this Makefile snippet defines a variable used by other +# gnulib Makefile snippets, it must be present in all makefiles that +# need it. This is ensured by the applicability 'all' defined above. + +_NORETURN_H=$(srcdir)/_Noreturn.h + +EXTRA_DIST += _Noreturn.h + +## end gnulib module snippet/_Noreturn + +## begin gnulib module stdint + +BUILT_SOURCES += $(STDINT_H) + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +if GL_GENERATE_STDINT_H +stdint.h: stdint.in.h $(top_builddir)/config.status + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e 's|@''GUARD_PREFIX''@|GL|g' \ + -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \ + -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ + -e 's|@''NEXT_STDINT_H''@|$(NEXT_STDINT_H)|g' \ + -e 's/@''HAVE_C99_STDINT_H''@/$(HAVE_C99_STDINT_H)/g' \ + -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \ + -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \ + -e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \ + -e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \ + -e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \ + -e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \ + -e 's/@''HAVE_UNSIGNED_LONG_LONG_INT''@/$(HAVE_UNSIGNED_LONG_LONG_INT)/g' \ + -e 's/@''APPLE_UNIVERSAL_BUILD''@/$(APPLE_UNIVERSAL_BUILD)/g' \ + -e 's/@''BITSIZEOF_PTRDIFF_T''@/$(BITSIZEOF_PTRDIFF_T)/g' \ + -e 's/@''PTRDIFF_T_SUFFIX''@/$(PTRDIFF_T_SUFFIX)/g' \ + -e 's/@''BITSIZEOF_SIG_ATOMIC_T''@/$(BITSIZEOF_SIG_ATOMIC_T)/g' \ + -e 's/@''HAVE_SIGNED_SIG_ATOMIC_T''@/$(HAVE_SIGNED_SIG_ATOMIC_T)/g' \ + -e 's/@''SIG_ATOMIC_T_SUFFIX''@/$(SIG_ATOMIC_T_SUFFIX)/g' \ + -e 's/@''BITSIZEOF_SIZE_T''@/$(BITSIZEOF_SIZE_T)/g' \ + -e 's/@''SIZE_T_SUFFIX''@/$(SIZE_T_SUFFIX)/g' \ + -e 's/@''BITSIZEOF_WCHAR_T''@/$(BITSIZEOF_WCHAR_T)/g' \ + -e 's/@''HAVE_SIGNED_WCHAR_T''@/$(HAVE_SIGNED_WCHAR_T)/g' \ + -e 's/@''WCHAR_T_SUFFIX''@/$(WCHAR_T_SUFFIX)/g' \ + -e 's/@''BITSIZEOF_WINT_T''@/$(BITSIZEOF_WINT_T)/g' \ + -e 's/@''HAVE_SIGNED_WINT_T''@/$(HAVE_SIGNED_WINT_T)/g' \ + -e 's/@''WINT_T_SUFFIX''@/$(WINT_T_SUFFIX)/g' \ + -e 's/@''GNULIB_OVERRIDES_WINT_T''@/$(GNULIB_OVERRIDES_WINT_T)/g' \ + < $(srcdir)/stdint.in.h; \ + } > $@-t && \ + mv $@-t $@ +else +stdint.h: $(top_builddir)/config.status + rm -f $@ +endif +MOSTLYCLEANFILES += stdint.h stdint.h-t + +EXTRA_DIST += stdint.in.h + +## end gnulib module stdint + +## begin gnulib module stdnoreturn + +BUILT_SOURCES += $(STDNORETURN_H) + +# We need the following in order to create when the system +# doesn't have one that works. +if GL_GENERATE_STDNORETURN_H +stdnoreturn.h: stdnoreturn.in.h $(top_builddir)/config.status $(_NORETURN_H) + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ + sed -e '/definition of _Noreturn/r $(_NORETURN_H)' \ + < $(srcdir)/stdnoreturn.in.h; \ + } > $@-t && \ + mv $@-t $@ +else +stdnoreturn.h: $(top_builddir)/config.status + rm -f $@ +endif +MOSTLYCLEANFILES += stdnoreturn.h stdnoreturn.h-t + +EXTRA_DIST += stdnoreturn.in.h + +## end gnulib module stdnoreturn + +## begin gnulib module sys_types + +BUILT_SOURCES += sys/types.h + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +sys/types.h: sys_types.in.h $(top_builddir)/config.status + $(AM_V_at)$(MKDIR_P) sys + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e 's|@''GUARD_PREFIX''@|GL|g' \ + -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ + -e 's|@''NEXT_SYS_TYPES_H''@|$(NEXT_SYS_TYPES_H)|g' \ + -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \ + -e 's|@''WINDOWS_STAT_INODES''@|$(WINDOWS_STAT_INODES)|g' \ + < $(srcdir)/sys_types.in.h; \ + } > $@-t && \ + mv $@-t $@ +MOSTLYCLEANFILES += sys/types.h sys/types.h-t + +EXTRA_DIST += sys_types.in.h + +## end gnulib module sys_types + +## begin gnulib module threadlib + +libgnu_la_SOURCES += glthread/threadlib.c + +EXTRA_DIST += $(top_srcdir)/build-aux/config.rpath + +## end gnulib module threadlib + +## begin gnulib module windows-mutex + + +EXTRA_DIST += windows-initguard.h windows-mutex.c windows-mutex.h + +EXTRA_libgnu_la_SOURCES += windows-mutex.c + +## end gnulib module windows-mutex + +## begin gnulib module windows-once + + +EXTRA_DIST += windows-once.c windows-once.h + +EXTRA_libgnu_la_SOURCES += windows-once.c + +## end gnulib module windows-once + +## begin gnulib module windows-recmutex + + +EXTRA_DIST += windows-initguard.h windows-recmutex.c windows-recmutex.h + +EXTRA_libgnu_la_SOURCES += windows-recmutex.c + +## end gnulib module windows-recmutex + +## begin gnulib module windows-rwlock + + +EXTRA_DIST += windows-initguard.h windows-rwlock.c windows-rwlock.h + +EXTRA_libgnu_la_SOURCES += windows-rwlock.c + +## end gnulib module windows-rwlock + + +mostlyclean-local: mostlyclean-generic + @for dir in '' $(MOSTLYCLEANDIRS); do \ + if test -n "$$dir" && test -d $$dir; then \ + echo "rmdir $$dir"; rmdir $$dir; \ + fi; \ + done; \ + : diff --git a/gnulib-lib/Makefile.in b/gnulib-lib/Makefile.in new file mode 100644 index 0000000..6482e98 --- /dev/null +++ b/gnulib-lib/Makefile.in @@ -0,0 +1,1013 @@ +# Makefile.in generated by automake 1.15.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2017 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# Copyright (C) 2002-2019 Free Software Foundation, Inc. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This file 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 file. If not, see . +# +# As a special exception to the GNU General Public License, +# this file may be distributed as part of a program that +# contains a configuration script generated by Autoconf, under +# the same distribution terms as the rest of that program. +# +# Generated by gnulib-tool. +# Reproduce by: +# gnulib-tool --import \ +# --lib=libgnu \ +# --source-base=gnulib-lib \ +# --m4-base=gnulib-m4 \ +# --doc-base=doc \ +# --tests-base=tests \ +# --aux-dir=build-aux \ +# --no-conditional-dependencies \ +# --libtool \ +# --macro-prefix=gl \ +# ansi-c++-opt \ +# host-cpu-c-abi \ +# lock \ +# longlong \ +# nocrash \ +# stdint \ +# stdnoreturn + + + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = gnulib-lib +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/gnulib-m4/00gnulib.m4 \ + $(top_srcdir)/gnulib-m4/absolute-header.m4 \ + $(top_srcdir)/gnulib-m4/ansi-c++.m4 \ + $(top_srcdir)/gnulib-m4/asm-underscore.m4 \ + $(top_srcdir)/gnulib-m4/extensions.m4 \ + $(top_srcdir)/gnulib-m4/gnulib-common.m4 \ + $(top_srcdir)/gnulib-m4/gnulib-comp.m4 \ + $(top_srcdir)/gnulib-m4/host-cpu-c-abi.m4 \ + $(top_srcdir)/gnulib-m4/include_next.m4 \ + $(top_srcdir)/gnulib-m4/limits-h.m4 \ + $(top_srcdir)/gnulib-m4/lock.m4 \ + $(top_srcdir)/gnulib-m4/longlong.m4 \ + $(top_srcdir)/gnulib-m4/multiarch.m4 \ + $(top_srcdir)/gnulib-m4/nocrash.m4 \ + $(top_srcdir)/gnulib-m4/off_t.m4 \ + $(top_srcdir)/gnulib-m4/onceonly.m4 \ + $(top_srcdir)/gnulib-m4/pthread_rwlock_rdlock.m4 \ + $(top_srcdir)/gnulib-m4/ssize_t.m4 \ + $(top_srcdir)/gnulib-m4/stdint.m4 \ + $(top_srcdir)/gnulib-m4/stdnoreturn.m4 \ + $(top_srcdir)/gnulib-m4/sys_types_h.m4 \ + $(top_srcdir)/gnulib-m4/threadlib.m4 \ + $(top_srcdir)/gnulib-m4/wint_t.m4 \ + $(top_srcdir)/m4/as-underscore.m4 $(top_srcdir)/m4/cc-gcc.m4 \ + $(top_srcdir)/m4/codeexec.m4 $(top_srcdir)/m4/endianness.m4 \ + $(top_srcdir)/m4/general.m4 $(top_srcdir)/m4/getpagesize.m4 \ + $(top_srcdir)/m4/ireg.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ln.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/mach-vm.m4 \ + $(top_srcdir)/m4/mmap.m4 $(top_srcdir)/m4/mprotect.m4 \ + $(top_srcdir)/m4/proto.m4 $(top_srcdir)/m4/shm.m4 \ + $(top_srcdir)/m4/smallstruct.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \ + $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h \ + $(top_builddir)/ffcall-version.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +LIBRARIES = $(noinst_LIBRARIES) +LTLIBRARIES = $(noinst_LTLIBRARIES) +am__DEPENDENCIES_1 = +am__dirstamp = $(am__leading_dot)dirstamp +am_libgnu_la_OBJECTS = glthread/lock.lo glthread/threadlib.lo +libgnu_la_OBJECTS = $(am_libgnu_la_OBJECTS) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +libgnu_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libgnu_la_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(libgnu_la_SOURCES) $(EXTRA_libgnu_la_SOURCES) +DIST_SOURCES = $(libgnu_la_SOURCES) $(EXTRA_libgnu_la_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ + ctags-recursive dvi-recursive html-recursive info-recursive \ + install-data-recursive install-dvi-recursive \ + install-exec-recursive install-html-recursive \ + install-info-recursive install-pdf-recursive \ + install-ps-recursive install-recursive installcheck-recursive \ + installdirs-recursive pdf-recursive ps-recursive \ + tags-recursive uninstall-recursive +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +HEADERS = $(noinst_HEADERS) +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +am__recursive_targets = \ + $(RECURSIVE_TARGETS) \ + $(RECURSIVE_CLEAN_TARGETS) \ + $(am__extra_recursive_targets) +AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ + distdir +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +am__DIST_COMMON = $(srcdir)/Makefile.in \ + $(top_srcdir)/build-aux/depcomp +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +am__relativize = \ + dir0=`pwd`; \ + sed_first='s,^\([^/]*\)/.*$$,\1,'; \ + sed_rest='s,^[^/]*/*,,'; \ + sed_last='s,^.*/\([^/]*\)$$,\1,'; \ + sed_butlast='s,/*[^/]*$$,,'; \ + while test -n "$$dir1"; do \ + first=`echo "$$dir1" | sed -e "$$sed_first"`; \ + if test "$$first" != "."; then \ + if test "$$first" = ".."; then \ + dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ + dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ + else \ + first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ + if test "$$first2" = "$$first"; then \ + dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ + else \ + dir2="../$$dir2"; \ + fi; \ + dir0="$$dir0"/"$$first"; \ + fi; \ + fi; \ + dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ + done; \ + reldir="$$dir2" +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@ +AR = @AR@ +ARFLAGS = @ARFLAGS@ +AS = @AS@ +ASM_SYMBOL_PREFIX = @ASM_SYMBOL_PREFIX@ +AS_UNDERSCORE = @AS_UNDERSCORE@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BITSIZEOF_PTRDIFF_T = @BITSIZEOF_PTRDIFF_T@ +BITSIZEOF_SIG_ATOMIC_T = @BITSIZEOF_SIG_ATOMIC_T@ +BITSIZEOF_SIZE_T = @BITSIZEOF_SIZE_T@ +BITSIZEOF_WCHAR_T = @BITSIZEOF_WCHAR_T@ +BITSIZEOF_WINT_T = @BITSIZEOF_WINT_T@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CC_GCC = @CC_GCC@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CPU_OBJECTS = @CPU_OBJECTS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CXX_CHOICE = @CXX_CHOICE@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DISABLE_TYPE_BASED_ALIASING = @DISABLE_TYPE_BASED_ALIASING@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +ENDIANNESS = @ENDIANNESS@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GCC_X_NONE = @GCC_X_NONE@ +GNULIB_OVERRIDES_WINT_T = @GNULIB_OVERRIDES_WINT_T@ +GREP = @GREP@ +HAVE_C99_STDINT_H = @HAVE_C99_STDINT_H@ +HAVE_INTTYPES_H = @HAVE_INTTYPES_H@ +HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@ +HAVE_SIGNED_SIG_ATOMIC_T = @HAVE_SIGNED_SIG_ATOMIC_T@ +HAVE_SIGNED_WCHAR_T = @HAVE_SIGNED_WCHAR_T@ +HAVE_SIGNED_WINT_T = @HAVE_SIGNED_WINT_T@ +HAVE_STDINT_H = @HAVE_STDINT_H@ +HAVE_SYS_BITYPES_H = @HAVE_SYS_BITYPES_H@ +HAVE_SYS_INTTYPES_H = @HAVE_SYS_INTTYPES_H@ +HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@ +HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@ +HAVE_WCHAR_H = @HAVE_WCHAR_H@ +HOST_CPU = @HOST_CPU@ +HOST_CPU_C_ABI = @HOST_CPU_C_ABI@ +IFNOT_MSVC = @IFNOT_MSVC@ +IF_CXX = @IF_CXX@ +IF_MSVC = @IF_MSVC@ +INCLUDE_NEXT = @INCLUDE_NEXT@ +INCLUDE_NEXT_AS_FIRST_DIRECTIVE = @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBMULTITHREAD = @LIBMULTITHREAD@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTHREAD = @LIBTHREAD@ +LIBTOOL = @LIBTOOL@ +LIMITS_H = @LIMITS_H@ +LIPO = @LIPO@ +LN = @LN@ +LN_S = @LN_S@ +LTLIBMULTITHREAD = @LTLIBMULTITHREAD@ +LTLIBOBJS = @LTLIBOBJS@ +LTLIBTHREAD = @LTLIBTHREAD@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NEXT_AS_FIRST_DIRECTIVE_LIMITS_H = @NEXT_AS_FIRST_DIRECTIVE_LIMITS_H@ +NEXT_AS_FIRST_DIRECTIVE_STDINT_H = @NEXT_AS_FIRST_DIRECTIVE_STDINT_H@ +NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H@ +NEXT_LIMITS_H = @NEXT_LIMITS_H@ +NEXT_STDINT_H = @NEXT_STDINT_H@ +NEXT_SYS_TYPES_H = @NEXT_SYS_TYPES_H@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PRAGMA_COLUMNS = @PRAGMA_COLUMNS@ +PRAGMA_SYSTEM_HEADER = @PRAGMA_SYSTEM_HEADER@ +PTRDIFF_T_SUFFIX = @PTRDIFF_T_SUFFIX@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SIG_ATOMIC_T_SUFFIX = @SIG_ATOMIC_T_SUFFIX@ +SIZE_T_SUFFIX = @SIZE_T_SUFFIX@ +STDINT_H = @STDINT_H@ +STDNORETURN_H = @STDNORETURN_H@ +STRIP = @STRIP@ +VERSION = @VERSION@ +WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@ +WINDOWS_64_BIT_OFF_T = @WINDOWS_64_BIT_OFF_T@ +WINDOWS_STAT_INODES = @WINDOWS_STAT_INODES@ +WINT_T_SUFFIX = @WINT_T_SUFFIX@ +WORKAROUND_BUG_81653 = @WORKAROUND_BUG_81653@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +gl_LIBOBJS = @gl_LIBOBJS@ +gl_LTLIBOBJS = @gl_LTLIBOBJS@ +gltests_LIBOBJS = @gltests_LIBOBJS@ +gltests_LTLIBOBJS = @gltests_LTLIBOBJS@ +gltests_WITNESS = @gltests_WITNESS@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AUTOMAKE_OPTIONS = 1.11 gnits subdir-objects +SUBDIRS = +noinst_HEADERS = +noinst_LIBRARIES = +noinst_LTLIBRARIES = libgnu.la +EXTRA_DIST = $(top_srcdir)/build-aux/config.rpath limits.in.h \ + _Noreturn.h stdint.in.h stdnoreturn.in.h sys_types.in.h \ + $(top_srcdir)/build-aux/config.rpath windows-initguard.h \ + windows-mutex.c windows-mutex.h windows-once.c windows-once.h \ + windows-initguard.h windows-recmutex.c windows-recmutex.h \ + windows-initguard.h windows-rwlock.c windows-rwlock.h +BUILT_SOURCES = $(LIMITS_H) $(STDINT_H) $(STDNORETURN_H) sys/types.h +SUFFIXES = +MOSTLYCLEANFILES = core *.stackdump limits.h limits.h-t stdint.h \ + stdint.h-t stdnoreturn.h stdnoreturn.h-t sys/types.h \ + sys/types.h-t +MOSTLYCLEANDIRS = +CLEANFILES = +DISTCLEANFILES = +MAINTAINERCLEANFILES = +# No GNU Make output. +AM_CPPFLAGS = +AM_CFLAGS = +libgnu_la_SOURCES = glthread/lock.h glthread/lock.c \ + glthread/threadlib.c +libgnu_la_LIBADD = $(gl_LTLIBOBJS) +libgnu_la_DEPENDENCIES = $(gl_LTLIBOBJS) +EXTRA_libgnu_la_SOURCES = windows-mutex.c windows-once.c \ + windows-recmutex.c windows-rwlock.c +libgnu_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(LTLIBTHREAD) + +# Use this preprocessor expression to decide whether #include_next works. +# Do not rely on a 'configure'-time test for this, since the expression +# might appear in an installed header, which is used by some other compiler. +HAVE_INCLUDE_NEXT = (__GNUC__ || 60000000 <= __DECC_VER) + +# Because this Makefile snippet defines a variable used by other +# gnulib Makefile snippets, it must be present in all makefiles that +# need it. This is ensured by the applicability 'all' defined above. +_NORETURN_H = $(srcdir)/_Noreturn.h +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnits gnulib-lib/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnits gnulib-lib/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } +glthread/$(am__dirstamp): + @$(MKDIR_P) glthread + @: > glthread/$(am__dirstamp) +glthread/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) glthread/$(DEPDIR) + @: > glthread/$(DEPDIR)/$(am__dirstamp) +glthread/lock.lo: glthread/$(am__dirstamp) \ + glthread/$(DEPDIR)/$(am__dirstamp) +glthread/threadlib.lo: glthread/$(am__dirstamp) \ + glthread/$(DEPDIR)/$(am__dirstamp) + +libgnu.la: $(libgnu_la_OBJECTS) $(libgnu_la_DEPENDENCIES) $(EXTRA_libgnu_la_DEPENDENCIES) + $(AM_V_CCLD)$(libgnu_la_LINK) $(libgnu_la_OBJECTS) $(libgnu_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + -rm -f glthread/*.$(OBJEXT) + -rm -f glthread/*.lo + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/windows-mutex.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/windows-once.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/windows-recmutex.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/windows-rwlock.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@glthread/$(DEPDIR)/lock.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@glthread/$(DEPDIR)/threadlib.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + -rm -rf glthread/.libs glthread/_libs + +# This directory's subdirectories are mostly independent; you can cd +# into them and run 'make' without going through this Makefile. +# To change the values of 'make' variables: instead of editing Makefiles, +# (1) if the variable is set in 'config.status', edit 'config.status' +# (which will cause the Makefiles to be regenerated when you run 'make'); +# (2) otherwise, pass the desired values on the 'make' command line. +$(am__recursive_targets): + @fail=; \ + if $(am__make_keepgoing); then \ + failcom='fail=yes'; \ + else \ + failcom='exit 1'; \ + fi; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-recursive +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-recursive + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-recursive + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + $(am__make_dryrun) \ + || test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ + $(am__relativize); \ + new_distdir=$$reldir; \ + dir1=$$subdir; dir2="$(top_distdir)"; \ + $(am__relativize); \ + new_top_distdir=$$reldir; \ + echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ + echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ + ($(am__cd) $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$new_top_distdir" \ + distdir="$$new_distdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + am__skip_mode_fix=: \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-recursive +all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(HEADERS) +installdirs: installdirs-recursive +installdirs-am: +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -rm -f glthread/$(DEPDIR)/$(am__dirstamp) + -rm -f glthread/$(am__dirstamp) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-recursive + +clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ + clean-noinstLTLIBRARIES mostlyclean-am + +distclean: distclean-recursive + -rm -rf ./$(DEPDIR) glthread/$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +html-am: + +info: info-recursive + +info-am: + +install-data-am: + +install-dvi: install-dvi-recursive + +install-dvi-am: + +install-exec-am: + +install-html: install-html-recursive + +install-html-am: + +install-info: install-info-recursive + +install-info-am: + +install-man: + +install-pdf: install-pdf-recursive + +install-pdf-am: + +install-ps: install-ps-recursive + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -rf ./$(DEPDIR) glthread/$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool mostlyclean-local + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: + +.MAKE: $(am__recursive_targets) all check install install-am \ + install-strip + +.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ + check-am clean clean-generic clean-libtool \ + clean-noinstLIBRARIES clean-noinstLTLIBRARIES cscopelist-am \ + ctags ctags-am distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool mostlyclean-local pdf \ + pdf-am ps ps-am tags tags-am uninstall uninstall-am + +.PRECIOUS: Makefile + + +# We need the following in order to create when the system +# doesn't have one that is compatible with GNU. +@GL_GENERATE_LIMITS_H_TRUE@limits.h: limits.in.h $(top_builddir)/config.status +@GL_GENERATE_LIMITS_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \ +@GL_GENERATE_LIMITS_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ +@GL_GENERATE_LIMITS_H_TRUE@ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ +@GL_GENERATE_LIMITS_H_TRUE@ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ +@GL_GENERATE_LIMITS_H_TRUE@ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ +@GL_GENERATE_LIMITS_H_TRUE@ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ +@GL_GENERATE_LIMITS_H_TRUE@ -e 's|@''NEXT_LIMITS_H''@|$(NEXT_LIMITS_H)|g' \ +@GL_GENERATE_LIMITS_H_TRUE@ < $(srcdir)/limits.in.h; \ +@GL_GENERATE_LIMITS_H_TRUE@ } > $@-t && \ +@GL_GENERATE_LIMITS_H_TRUE@ mv $@-t $@ +@GL_GENERATE_LIMITS_H_FALSE@limits.h: $(top_builddir)/config.status +@GL_GENERATE_LIMITS_H_FALSE@ rm -f $@ + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +@GL_GENERATE_STDINT_H_TRUE@stdint.h: stdint.in.h $(top_builddir)/config.status +@GL_GENERATE_STDINT_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \ +@GL_GENERATE_STDINT_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ +@GL_GENERATE_STDINT_H_TRUE@ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ +@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \ +@GL_GENERATE_STDINT_H_TRUE@ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ +@GL_GENERATE_STDINT_H_TRUE@ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ +@GL_GENERATE_STDINT_H_TRUE@ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ +@GL_GENERATE_STDINT_H_TRUE@ -e 's|@''NEXT_STDINT_H''@|$(NEXT_STDINT_H)|g' \ +@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_C99_STDINT_H''@/$(HAVE_C99_STDINT_H)/g' \ +@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \ +@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \ +@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \ +@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \ +@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \ +@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \ +@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_UNSIGNED_LONG_LONG_INT''@/$(HAVE_UNSIGNED_LONG_LONG_INT)/g' \ +@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''APPLE_UNIVERSAL_BUILD''@/$(APPLE_UNIVERSAL_BUILD)/g' \ +@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''BITSIZEOF_PTRDIFF_T''@/$(BITSIZEOF_PTRDIFF_T)/g' \ +@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''PTRDIFF_T_SUFFIX''@/$(PTRDIFF_T_SUFFIX)/g' \ +@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''BITSIZEOF_SIG_ATOMIC_T''@/$(BITSIZEOF_SIG_ATOMIC_T)/g' \ +@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_SIGNED_SIG_ATOMIC_T''@/$(HAVE_SIGNED_SIG_ATOMIC_T)/g' \ +@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''SIG_ATOMIC_T_SUFFIX''@/$(SIG_ATOMIC_T_SUFFIX)/g' \ +@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''BITSIZEOF_SIZE_T''@/$(BITSIZEOF_SIZE_T)/g' \ +@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''SIZE_T_SUFFIX''@/$(SIZE_T_SUFFIX)/g' \ +@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''BITSIZEOF_WCHAR_T''@/$(BITSIZEOF_WCHAR_T)/g' \ +@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_SIGNED_WCHAR_T''@/$(HAVE_SIGNED_WCHAR_T)/g' \ +@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''WCHAR_T_SUFFIX''@/$(WCHAR_T_SUFFIX)/g' \ +@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''BITSIZEOF_WINT_T''@/$(BITSIZEOF_WINT_T)/g' \ +@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_SIGNED_WINT_T''@/$(HAVE_SIGNED_WINT_T)/g' \ +@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''WINT_T_SUFFIX''@/$(WINT_T_SUFFIX)/g' \ +@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''GNULIB_OVERRIDES_WINT_T''@/$(GNULIB_OVERRIDES_WINT_T)/g' \ +@GL_GENERATE_STDINT_H_TRUE@ < $(srcdir)/stdint.in.h; \ +@GL_GENERATE_STDINT_H_TRUE@ } > $@-t && \ +@GL_GENERATE_STDINT_H_TRUE@ mv $@-t $@ +@GL_GENERATE_STDINT_H_FALSE@stdint.h: $(top_builddir)/config.status +@GL_GENERATE_STDINT_H_FALSE@ rm -f $@ + +# We need the following in order to create when the system +# doesn't have one that works. +@GL_GENERATE_STDNORETURN_H_TRUE@stdnoreturn.h: stdnoreturn.in.h $(top_builddir)/config.status $(_NORETURN_H) +@GL_GENERATE_STDNORETURN_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \ +@GL_GENERATE_STDNORETURN_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ +@GL_GENERATE_STDNORETURN_H_TRUE@ sed -e '/definition of _Noreturn/r $(_NORETURN_H)' \ +@GL_GENERATE_STDNORETURN_H_TRUE@ < $(srcdir)/stdnoreturn.in.h; \ +@GL_GENERATE_STDNORETURN_H_TRUE@ } > $@-t && \ +@GL_GENERATE_STDNORETURN_H_TRUE@ mv $@-t $@ +@GL_GENERATE_STDNORETURN_H_FALSE@stdnoreturn.h: $(top_builddir)/config.status +@GL_GENERATE_STDNORETURN_H_FALSE@ rm -f $@ + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +sys/types.h: sys_types.in.h $(top_builddir)/config.status + $(AM_V_at)$(MKDIR_P) sys + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e 's|@''GUARD_PREFIX''@|GL|g' \ + -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ + -e 's|@''NEXT_SYS_TYPES_H''@|$(NEXT_SYS_TYPES_H)|g' \ + -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \ + -e 's|@''WINDOWS_STAT_INODES''@|$(WINDOWS_STAT_INODES)|g' \ + < $(srcdir)/sys_types.in.h; \ + } > $@-t && \ + mv $@-t $@ + +mostlyclean-local: mostlyclean-generic + @for dir in '' $(MOSTLYCLEANDIRS); do \ + if test -n "$$dir" && test -d $$dir; then \ + echo "rmdir $$dir"; rmdir $$dir; \ + fi; \ + done; \ + : + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/gnulib-lib/_Noreturn.h b/gnulib-lib/_Noreturn.h new file mode 100644 index 0000000..db9b455 --- /dev/null +++ b/gnulib-lib/_Noreturn.h @@ -0,0 +1,33 @@ +/* A C macro for declaring that a function does not return. + Copyright (C) 2011-2019 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3 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, see . */ + +#ifndef _Noreturn +# if (defined __cplusplus \ + && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \ + || (defined _MSC_VER && 1900 <= _MSC_VER))) +# define _Noreturn [[noreturn]] +# elif ((!defined __cplusplus || defined __clang__) \ + && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \ + || 4 < __GNUC__ + (7 <= __GNUC_MINOR__))) + /* _Noreturn works as-is. */ +# elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C +# define _Noreturn __attribute__ ((__noreturn__)) +# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0) +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn +# endif +#endif diff --git a/gnulib-lib/glthread/lock.c b/gnulib-lib/glthread/lock.c new file mode 100644 index 0000000..fefcd59 --- /dev/null +++ b/gnulib-lib/glthread/lock.c @@ -0,0 +1,506 @@ +/* Locking in multithreaded situations. + Copyright (C) 2005-2019 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, 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, see . */ + +/* Written by Bruno Haible , 2005. + Based on GCC's gthr-posix.h, gthr-posix95.h. */ + +#include + +#include "glthread/lock.h" + +/* ========================================================================= */ + +#if USE_POSIX_THREADS + +/* -------------------------- gl_lock_t datatype -------------------------- */ + +/* ------------------------- gl_rwlock_t datatype ------------------------- */ + +# if HAVE_PTHREAD_RWLOCK && (HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER || (defined PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP && (__GNU_LIBRARY__ > 1))) + +# ifdef PTHREAD_RWLOCK_INITIALIZER + +# if !HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER + /* glibc with bug https://sourceware.org/bugzilla/show_bug.cgi?id=13701 */ + +int +glthread_rwlock_init_for_glibc (pthread_rwlock_t *lock) +{ + pthread_rwlockattr_t attributes; + int err; + + err = pthread_rwlockattr_init (&attributes); + if (err != 0) + return err; + /* Note: PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP is the only value that + causes the writer to be preferred. PTHREAD_RWLOCK_PREFER_WRITER_NP does not + do this; see + http://man7.org/linux/man-pages/man3/pthread_rwlockattr_setkind_np.3.html */ + err = pthread_rwlockattr_setkind_np (&attributes, + PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP); + if (err == 0) + err = pthread_rwlock_init(lock, &attributes); + /* pthread_rwlockattr_destroy always returns 0. It cannot influence the + return value. */ + pthread_rwlockattr_destroy (&attributes); + return err; +} + +# endif +# else + +int +glthread_rwlock_init_multithreaded (gl_rwlock_t *lock) +{ + int err; + + err = pthread_rwlock_init (&lock->rwlock, NULL); + if (err != 0) + return err; + lock->initialized = 1; + return 0; +} + +int +glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock) +{ + if (!lock->initialized) + { + int err; + + err = pthread_mutex_lock (&lock->guard); + if (err != 0) + return err; + if (!lock->initialized) + { + err = glthread_rwlock_init_multithreaded (lock); + if (err != 0) + { + pthread_mutex_unlock (&lock->guard); + return err; + } + } + err = pthread_mutex_unlock (&lock->guard); + if (err != 0) + return err; + } + return pthread_rwlock_rdlock (&lock->rwlock); +} + +int +glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock) +{ + if (!lock->initialized) + { + int err; + + err = pthread_mutex_lock (&lock->guard); + if (err != 0) + return err; + if (!lock->initialized) + { + err = glthread_rwlock_init_multithreaded (lock); + if (err != 0) + { + pthread_mutex_unlock (&lock->guard); + return err; + } + } + err = pthread_mutex_unlock (&lock->guard); + if (err != 0) + return err; + } + return pthread_rwlock_wrlock (&lock->rwlock); +} + +int +glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock) +{ + if (!lock->initialized) + return EINVAL; + return pthread_rwlock_unlock (&lock->rwlock); +} + +int +glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock) +{ + int err; + + if (!lock->initialized) + return EINVAL; + err = pthread_rwlock_destroy (&lock->rwlock); + if (err != 0) + return err; + lock->initialized = 0; + return 0; +} + +# endif + +# else + +int +glthread_rwlock_init_multithreaded (gl_rwlock_t *lock) +{ + int err; + + err = pthread_mutex_init (&lock->lock, NULL); + if (err != 0) + return err; + err = pthread_cond_init (&lock->waiting_readers, NULL); + if (err != 0) + return err; + err = pthread_cond_init (&lock->waiting_writers, NULL); + if (err != 0) + return err; + lock->waiting_writers_count = 0; + lock->runcount = 0; + return 0; +} + +int +glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock) +{ + int err; + + err = pthread_mutex_lock (&lock->lock); + if (err != 0) + return err; + /* Test whether only readers are currently running, and whether the runcount + field will not overflow, and whether no writer is waiting. The latter + condition is because POSIX recommends that "write locks shall take + precedence over read locks", to avoid "writer starvation". */ + while (!(lock->runcount + 1 > 0 && lock->waiting_writers_count == 0)) + { + /* This thread has to wait for a while. Enqueue it among the + waiting_readers. */ + err = pthread_cond_wait (&lock->waiting_readers, &lock->lock); + if (err != 0) + { + pthread_mutex_unlock (&lock->lock); + return err; + } + } + lock->runcount++; + return pthread_mutex_unlock (&lock->lock); +} + +int +glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock) +{ + int err; + + err = pthread_mutex_lock (&lock->lock); + if (err != 0) + return err; + /* Test whether no readers or writers are currently running. */ + while (!(lock->runcount == 0)) + { + /* This thread has to wait for a while. Enqueue it among the + waiting_writers. */ + lock->waiting_writers_count++; + err = pthread_cond_wait (&lock->waiting_writers, &lock->lock); + if (err != 0) + { + lock->waiting_writers_count--; + pthread_mutex_unlock (&lock->lock); + return err; + } + lock->waiting_writers_count--; + } + lock->runcount--; /* runcount becomes -1 */ + return pthread_mutex_unlock (&lock->lock); +} + +int +glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock) +{ + int err; + + err = pthread_mutex_lock (&lock->lock); + if (err != 0) + return err; + if (lock->runcount < 0) + { + /* Drop a writer lock. */ + if (!(lock->runcount == -1)) + { + pthread_mutex_unlock (&lock->lock); + return EINVAL; + } + lock->runcount = 0; + } + else + { + /* Drop a reader lock. */ + if (!(lock->runcount > 0)) + { + pthread_mutex_unlock (&lock->lock); + return EINVAL; + } + lock->runcount--; + } + if (lock->runcount == 0) + { + /* POSIX recommends that "write locks shall take precedence over read + locks", to avoid "writer starvation". */ + if (lock->waiting_writers_count > 0) + { + /* Wake up one of the waiting writers. */ + err = pthread_cond_signal (&lock->waiting_writers); + if (err != 0) + { + pthread_mutex_unlock (&lock->lock); + return err; + } + } + else + { + /* Wake up all waiting readers. */ + err = pthread_cond_broadcast (&lock->waiting_readers); + if (err != 0) + { + pthread_mutex_unlock (&lock->lock); + return err; + } + } + } + return pthread_mutex_unlock (&lock->lock); +} + +int +glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock) +{ + int err; + + err = pthread_mutex_destroy (&lock->lock); + if (err != 0) + return err; + err = pthread_cond_destroy (&lock->waiting_readers); + if (err != 0) + return err; + err = pthread_cond_destroy (&lock->waiting_writers); + if (err != 0) + return err; + return 0; +} + +# endif + +/* --------------------- gl_recursive_lock_t datatype --------------------- */ + +# if HAVE_PTHREAD_MUTEX_RECURSIVE + +# if defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP + +int +glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock) +{ + pthread_mutexattr_t attributes; + int err; + + err = pthread_mutexattr_init (&attributes); + if (err != 0) + return err; + err = pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE); + if (err != 0) + { + pthread_mutexattr_destroy (&attributes); + return err; + } + err = pthread_mutex_init (lock, &attributes); + if (err != 0) + { + pthread_mutexattr_destroy (&attributes); + return err; + } + err = pthread_mutexattr_destroy (&attributes); + if (err != 0) + return err; + return 0; +} + +# else + +int +glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock) +{ + pthread_mutexattr_t attributes; + int err; + + err = pthread_mutexattr_init (&attributes); + if (err != 0) + return err; + err = pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE); + if (err != 0) + { + pthread_mutexattr_destroy (&attributes); + return err; + } + err = pthread_mutex_init (&lock->recmutex, &attributes); + if (err != 0) + { + pthread_mutexattr_destroy (&attributes); + return err; + } + err = pthread_mutexattr_destroy (&attributes); + if (err != 0) + return err; + lock->initialized = 1; + return 0; +} + +int +glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock) +{ + if (!lock->initialized) + { + int err; + + err = pthread_mutex_lock (&lock->guard); + if (err != 0) + return err; + if (!lock->initialized) + { + err = glthread_recursive_lock_init_multithreaded (lock); + if (err != 0) + { + pthread_mutex_unlock (&lock->guard); + return err; + } + } + err = pthread_mutex_unlock (&lock->guard); + if (err != 0) + return err; + } + return pthread_mutex_lock (&lock->recmutex); +} + +int +glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock) +{ + if (!lock->initialized) + return EINVAL; + return pthread_mutex_unlock (&lock->recmutex); +} + +int +glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock) +{ + int err; + + if (!lock->initialized) + return EINVAL; + err = pthread_mutex_destroy (&lock->recmutex); + if (err != 0) + return err; + lock->initialized = 0; + return 0; +} + +# endif + +# else + +int +glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock) +{ + int err; + + err = pthread_mutex_init (&lock->mutex, NULL); + if (err != 0) + return err; + lock->owner = (pthread_t) 0; + lock->depth = 0; + return 0; +} + +int +glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock) +{ + pthread_t self = pthread_self (); + if (lock->owner != self) + { + int err; + + err = pthread_mutex_lock (&lock->mutex); + if (err != 0) + return err; + lock->owner = self; + } + if (++(lock->depth) == 0) /* wraparound? */ + { + lock->depth--; + return EAGAIN; + } + return 0; +} + +int +glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock) +{ + if (lock->owner != pthread_self ()) + return EPERM; + if (lock->depth == 0) + return EINVAL; + if (--(lock->depth) == 0) + { + lock->owner = (pthread_t) 0; + return pthread_mutex_unlock (&lock->mutex); + } + else + return 0; +} + +int +glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock) +{ + if (lock->owner != (pthread_t) 0) + return EBUSY; + return pthread_mutex_destroy (&lock->mutex); +} + +# endif + +/* -------------------------- gl_once_t datatype -------------------------- */ + +static const pthread_once_t fresh_once = PTHREAD_ONCE_INIT; + +int +glthread_once_singlethreaded (pthread_once_t *once_control) +{ + /* We don't know whether pthread_once_t is an integer type, a floating-point + type, a pointer type, or a structure type. */ + char *firstbyte = (char *)once_control; + if (*firstbyte == *(const char *)&fresh_once) + { + /* First time use of once_control. Invert the first byte. */ + *firstbyte = ~ *(const char *)&fresh_once; + return 1; + } + else + return 0; +} + +#endif + +/* ========================================================================= */ + +#if USE_WINDOWS_THREADS + +#endif + +/* ========================================================================= */ diff --git a/gnulib-lib/glthread/lock.h b/gnulib-lib/glthread/lock.h new file mode 100644 index 0000000..a92c2a8 --- /dev/null +++ b/gnulib-lib/glthread/lock.h @@ -0,0 +1,666 @@ +/* Locking in multithreaded situations. + Copyright (C) 2005-2019 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, 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, see . */ + +/* Written by Bruno Haible , 2005. + Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-win32.h. */ + +/* This file contains locking primitives for use with a given thread library. + It does not contain primitives for creating threads or for other + synchronization primitives. + + Normal (non-recursive) locks: + Type: gl_lock_t + Declaration: gl_lock_define(extern, name) + Initializer: gl_lock_define_initialized(, name) + Initialization: gl_lock_init (name); + Taking the lock: gl_lock_lock (name); + Releasing the lock: gl_lock_unlock (name); + De-initialization: gl_lock_destroy (name); + Equivalent functions with control of error handling: + Initialization: err = glthread_lock_init (&name); + Taking the lock: err = glthread_lock_lock (&name); + Releasing the lock: err = glthread_lock_unlock (&name); + De-initialization: err = glthread_lock_destroy (&name); + + Read-Write (non-recursive) locks: + Type: gl_rwlock_t + Declaration: gl_rwlock_define(extern, name) + Initializer: gl_rwlock_define_initialized(, name) + Initialization: gl_rwlock_init (name); + Taking the lock: gl_rwlock_rdlock (name); + gl_rwlock_wrlock (name); + Releasing the lock: gl_rwlock_unlock (name); + De-initialization: gl_rwlock_destroy (name); + Equivalent functions with control of error handling: + Initialization: err = glthread_rwlock_init (&name); + Taking the lock: err = glthread_rwlock_rdlock (&name); + err = glthread_rwlock_wrlock (&name); + Releasing the lock: err = glthread_rwlock_unlock (&name); + De-initialization: err = glthread_rwlock_destroy (&name); + + Recursive locks: + Type: gl_recursive_lock_t + Declaration: gl_recursive_lock_define(extern, name) + Initializer: gl_recursive_lock_define_initialized(, name) + Initialization: gl_recursive_lock_init (name); + Taking the lock: gl_recursive_lock_lock (name); + Releasing the lock: gl_recursive_lock_unlock (name); + De-initialization: gl_recursive_lock_destroy (name); + Equivalent functions with control of error handling: + Initialization: err = glthread_recursive_lock_init (&name); + Taking the lock: err = glthread_recursive_lock_lock (&name); + Releasing the lock: err = glthread_recursive_lock_unlock (&name); + De-initialization: err = glthread_recursive_lock_destroy (&name); + + Once-only execution: + Type: gl_once_t + Initializer: gl_once_define(extern, name) + Execution: gl_once (name, initfunction); + Equivalent functions with control of error handling: + Execution: err = glthread_once (&name, initfunction); +*/ + + +#ifndef _LOCK_H +#define _LOCK_H + +#include +#include + +#if !defined c11_threads_in_use +# if HAVE_THREADS_H && USE_POSIX_THREADS_WEAK +# include +# pragma weak thrd_exit +# define c11_threads_in_use() (thrd_exit != NULL) +# else +# define c11_threads_in_use() 0 +# endif +#endif + +/* ========================================================================= */ + +#if USE_POSIX_THREADS + +/* Use the POSIX threads library. */ + +# include + +# ifdef __cplusplus +extern "C" { +# endif + +# if PTHREAD_IN_USE_DETECTION_HARD + +/* The pthread_in_use() detection needs to be done at runtime. */ +# define pthread_in_use() \ + glthread_in_use () +extern int glthread_in_use (void); + +# endif + +# if USE_POSIX_THREADS_WEAK + +/* Use weak references to the POSIX threads library. */ + +/* Weak references avoid dragging in external libraries if the other parts + of the program don't use them. Here we use them, because we don't want + every program that uses libintl to depend on libpthread. This assumes + that libpthread would not be loaded after libintl; i.e. if libintl is + loaded first, by an executable that does not depend on libpthread, and + then a module is dynamically loaded that depends on libpthread, libintl + will not be multithread-safe. */ + +/* The way to test at runtime whether libpthread is present is to test + whether a function pointer's value, such as &pthread_mutex_init, is + non-NULL. However, some versions of GCC have a bug through which, in + PIC mode, &foo != NULL always evaluates to true if there is a direct + call to foo(...) in the same function. To avoid this, we test the + address of a function in libpthread that we don't use. */ + +# pragma weak pthread_mutex_init +# pragma weak pthread_mutex_lock +# pragma weak pthread_mutex_unlock +# pragma weak pthread_mutex_destroy +# pragma weak pthread_rwlock_init +# pragma weak pthread_rwlock_rdlock +# pragma weak pthread_rwlock_wrlock +# pragma weak pthread_rwlock_unlock +# pragma weak pthread_rwlock_destroy +# pragma weak pthread_once +# pragma weak pthread_cond_init +# pragma weak pthread_cond_wait +# pragma weak pthread_cond_signal +# pragma weak pthread_cond_broadcast +# pragma weak pthread_cond_destroy +# pragma weak pthread_mutexattr_init +# pragma weak pthread_mutexattr_settype +# pragma weak pthread_mutexattr_destroy +# pragma weak pthread_rwlockattr_init +# if __GNU_LIBRARY__ > 1 +# pragma weak pthread_rwlockattr_setkind_np +# endif +# pragma weak pthread_rwlockattr_destroy +# ifndef pthread_self +# pragma weak pthread_self +# endif + +# if !PTHREAD_IN_USE_DETECTION_HARD + /* Considering all platforms with USE_POSIX_THREADS_WEAK, only few symbols + can be used to determine whether libpthread is in use. These are: + pthread_mutexattr_gettype + pthread_rwlockattr_destroy + pthread_rwlockattr_init + */ +# pragma weak pthread_mutexattr_gettype +# define pthread_in_use() \ + (pthread_mutexattr_gettype != NULL || c11_threads_in_use ()) +# endif + +# else + +# if !PTHREAD_IN_USE_DETECTION_HARD +# define pthread_in_use() 1 +# endif + +# endif + +/* -------------------------- gl_lock_t datatype -------------------------- */ + +typedef pthread_mutex_t gl_lock_t; +# define gl_lock_define(STORAGECLASS, NAME) \ + STORAGECLASS pthread_mutex_t NAME; +# define gl_lock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS pthread_mutex_t NAME = gl_lock_initializer; +# define gl_lock_initializer \ + PTHREAD_MUTEX_INITIALIZER +# define glthread_lock_init(LOCK) \ + (pthread_in_use () ? pthread_mutex_init (LOCK, NULL) : 0) +# define glthread_lock_lock(LOCK) \ + (pthread_in_use () ? pthread_mutex_lock (LOCK) : 0) +# define glthread_lock_unlock(LOCK) \ + (pthread_in_use () ? pthread_mutex_unlock (LOCK) : 0) +# define glthread_lock_destroy(LOCK) \ + (pthread_in_use () ? pthread_mutex_destroy (LOCK) : 0) + +/* ------------------------- gl_rwlock_t datatype ------------------------- */ + +# if HAVE_PTHREAD_RWLOCK && (HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER || (defined PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP && (__GNU_LIBRARY__ > 1))) + +# ifdef PTHREAD_RWLOCK_INITIALIZER + +typedef pthread_rwlock_t gl_rwlock_t; +# define gl_rwlock_define(STORAGECLASS, NAME) \ + STORAGECLASS pthread_rwlock_t NAME; +# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS pthread_rwlock_t NAME = gl_rwlock_initializer; +# if HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER +# define gl_rwlock_initializer \ + PTHREAD_RWLOCK_INITIALIZER +# define glthread_rwlock_init(LOCK) \ + (pthread_in_use () ? pthread_rwlock_init (LOCK, NULL) : 0) +# else /* glibc with bug https://sourceware.org/bugzilla/show_bug.cgi?id=13701 */ +# define gl_rwlock_initializer \ + PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP +# define glthread_rwlock_init(LOCK) \ + (pthread_in_use () ? glthread_rwlock_init_for_glibc (LOCK) : 0) +extern int glthread_rwlock_init_for_glibc (pthread_rwlock_t *lock); +# endif +# define glthread_rwlock_rdlock(LOCK) \ + (pthread_in_use () ? pthread_rwlock_rdlock (LOCK) : 0) +# define glthread_rwlock_wrlock(LOCK) \ + (pthread_in_use () ? pthread_rwlock_wrlock (LOCK) : 0) +# define glthread_rwlock_unlock(LOCK) \ + (pthread_in_use () ? pthread_rwlock_unlock (LOCK) : 0) +# define glthread_rwlock_destroy(LOCK) \ + (pthread_in_use () ? pthread_rwlock_destroy (LOCK) : 0) + +# else + +typedef struct + { + int initialized; + pthread_mutex_t guard; /* protects the initialization */ + pthread_rwlock_t rwlock; /* read-write lock */ + } + gl_rwlock_t; +# define gl_rwlock_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_rwlock_t NAME; +# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer; +# define gl_rwlock_initializer \ + { 0, PTHREAD_MUTEX_INITIALIZER } +# define glthread_rwlock_init(LOCK) \ + (pthread_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0) +# define glthread_rwlock_rdlock(LOCK) \ + (pthread_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0) +# define glthread_rwlock_wrlock(LOCK) \ + (pthread_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0) +# define glthread_rwlock_unlock(LOCK) \ + (pthread_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0) +# define glthread_rwlock_destroy(LOCK) \ + (pthread_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0) +extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock); +extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock); +extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock); +extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock); +extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock); + +# endif + +# else + +typedef struct + { + pthread_mutex_t lock; /* protects the remaining fields */ + pthread_cond_t waiting_readers; /* waiting readers */ + pthread_cond_t waiting_writers; /* waiting writers */ + unsigned int waiting_writers_count; /* number of waiting writers */ + int runcount; /* number of readers running, or -1 when a writer runs */ + } + gl_rwlock_t; +# define gl_rwlock_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_rwlock_t NAME; +# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer; +# define gl_rwlock_initializer \ + { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0 } +# define glthread_rwlock_init(LOCK) \ + (pthread_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0) +# define glthread_rwlock_rdlock(LOCK) \ + (pthread_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0) +# define glthread_rwlock_wrlock(LOCK) \ + (pthread_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0) +# define glthread_rwlock_unlock(LOCK) \ + (pthread_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0) +# define glthread_rwlock_destroy(LOCK) \ + (pthread_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0) +extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock); +extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock); +extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock); +extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock); +extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock); + +# endif + +/* --------------------- gl_recursive_lock_t datatype --------------------- */ + +# if HAVE_PTHREAD_MUTEX_RECURSIVE + +# if defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP + +typedef pthread_mutex_t gl_recursive_lock_t; +# define gl_recursive_lock_define(STORAGECLASS, NAME) \ + STORAGECLASS pthread_mutex_t NAME; +# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS pthread_mutex_t NAME = gl_recursive_lock_initializer; +# ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER +# define gl_recursive_lock_initializer \ + PTHREAD_RECURSIVE_MUTEX_INITIALIZER +# else +# define gl_recursive_lock_initializer \ + PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP +# endif +# define glthread_recursive_lock_init(LOCK) \ + (pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0) +# define glthread_recursive_lock_lock(LOCK) \ + (pthread_in_use () ? pthread_mutex_lock (LOCK) : 0) +# define glthread_recursive_lock_unlock(LOCK) \ + (pthread_in_use () ? pthread_mutex_unlock (LOCK) : 0) +# define glthread_recursive_lock_destroy(LOCK) \ + (pthread_in_use () ? pthread_mutex_destroy (LOCK) : 0) +extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock); + +# else + +typedef struct + { + pthread_mutex_t recmutex; /* recursive mutex */ + pthread_mutex_t guard; /* protects the initialization */ + int initialized; + } + gl_recursive_lock_t; +# define gl_recursive_lock_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_recursive_lock_t NAME; +# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; +# define gl_recursive_lock_initializer \ + { PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, 0 } +# define glthread_recursive_lock_init(LOCK) \ + (pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0) +# define glthread_recursive_lock_lock(LOCK) \ + (pthread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0) +# define glthread_recursive_lock_unlock(LOCK) \ + (pthread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0) +# define glthread_recursive_lock_destroy(LOCK) \ + (pthread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0) +extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock); +extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock); +extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock); +extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock); + +# endif + +# else + +/* Old versions of POSIX threads on Solaris did not have recursive locks. + We have to implement them ourselves. */ + +typedef struct + { + pthread_mutex_t mutex; + pthread_t owner; + unsigned long depth; + } + gl_recursive_lock_t; +# define gl_recursive_lock_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_recursive_lock_t NAME; +# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; +# define gl_recursive_lock_initializer \ + { PTHREAD_MUTEX_INITIALIZER, (pthread_t) 0, 0 } +# define glthread_recursive_lock_init(LOCK) \ + (pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0) +# define glthread_recursive_lock_lock(LOCK) \ + (pthread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0) +# define glthread_recursive_lock_unlock(LOCK) \ + (pthread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0) +# define glthread_recursive_lock_destroy(LOCK) \ + (pthread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0) +extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock); +extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock); +extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock); +extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock); + +# endif + +/* -------------------------- gl_once_t datatype -------------------------- */ + +typedef pthread_once_t gl_once_t; +# define gl_once_define(STORAGECLASS, NAME) \ + STORAGECLASS pthread_once_t NAME = PTHREAD_ONCE_INIT; +# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ + (pthread_in_use () \ + ? pthread_once (ONCE_CONTROL, INITFUNCTION) \ + : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0)) +extern int glthread_once_singlethreaded (pthread_once_t *once_control); + +# ifdef __cplusplus +} +# endif + +#endif + +/* ========================================================================= */ + +#if USE_WINDOWS_THREADS + +# define WIN32_LEAN_AND_MEAN /* avoid including junk */ +# include + +# include "windows-mutex.h" +# include "windows-rwlock.h" +# include "windows-recmutex.h" +# include "windows-once.h" + +# ifdef __cplusplus +extern "C" { +# endif + +/* We can use CRITICAL_SECTION directly, rather than the native Windows Event, + Mutex, Semaphore types, because + - we need only to synchronize inside a single process (address space), + not inter-process locking, + - we don't need to support trylock operations. (TryEnterCriticalSection + does not work on Windows 95/98/ME. Packages that need trylock usually + define their own mutex type.) */ + +/* There is no way to statically initialize a CRITICAL_SECTION. It needs + to be done lazily, once only. For this we need spinlocks. */ + +/* -------------------------- gl_lock_t datatype -------------------------- */ + +typedef glwthread_mutex_t gl_lock_t; +# define gl_lock_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_lock_t NAME; +# define gl_lock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS gl_lock_t NAME = gl_lock_initializer; +# define gl_lock_initializer \ + GLWTHREAD_MUTEX_INIT +# define glthread_lock_init(LOCK) \ + (glwthread_mutex_init (LOCK), 0) +# define glthread_lock_lock(LOCK) \ + glwthread_mutex_lock (LOCK) +# define glthread_lock_unlock(LOCK) \ + glwthread_mutex_unlock (LOCK) +# define glthread_lock_destroy(LOCK) \ + glwthread_mutex_destroy (LOCK) + +/* ------------------------- gl_rwlock_t datatype ------------------------- */ + +typedef glwthread_rwlock_t gl_rwlock_t; +# define gl_rwlock_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_rwlock_t NAME; +# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer; +# define gl_rwlock_initializer \ + GLWTHREAD_RWLOCK_INIT +# define glthread_rwlock_init(LOCK) \ + (glwthread_rwlock_init (LOCK), 0) +# define glthread_rwlock_rdlock(LOCK) \ + glwthread_rwlock_rdlock (LOCK) +# define glthread_rwlock_wrlock(LOCK) \ + glwthread_rwlock_wrlock (LOCK) +# define glthread_rwlock_unlock(LOCK) \ + glwthread_rwlock_unlock (LOCK) +# define glthread_rwlock_destroy(LOCK) \ + glwthread_rwlock_destroy (LOCK) + +/* --------------------- gl_recursive_lock_t datatype --------------------- */ + +typedef glwthread_recmutex_t gl_recursive_lock_t; +# define gl_recursive_lock_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_recursive_lock_t NAME; +# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; +# define gl_recursive_lock_initializer \ + GLWTHREAD_RECMUTEX_INIT +# define glthread_recursive_lock_init(LOCK) \ + (glwthread_recmutex_init (LOCK), 0) +# define glthread_recursive_lock_lock(LOCK) \ + glwthread_recmutex_lock (LOCK) +# define glthread_recursive_lock_unlock(LOCK) \ + glwthread_recmutex_unlock (LOCK) +# define glthread_recursive_lock_destroy(LOCK) \ + glwthread_recmutex_destroy (LOCK) + +/* -------------------------- gl_once_t datatype -------------------------- */ + +typedef glwthread_once_t gl_once_t; +# define gl_once_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_once_t NAME = GLWTHREAD_ONCE_INIT; +# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ + (glwthread_once (ONCE_CONTROL, INITFUNCTION), 0) + +# ifdef __cplusplus +} +# endif + +#endif + +/* ========================================================================= */ + +#if !(USE_POSIX_THREADS || USE_WINDOWS_THREADS) + +/* Provide dummy implementation if threads are not supported. */ + +/* -------------------------- gl_lock_t datatype -------------------------- */ + +typedef int gl_lock_t; +# define gl_lock_define(STORAGECLASS, NAME) +# define gl_lock_define_initialized(STORAGECLASS, NAME) +# define glthread_lock_init(NAME) 0 +# define glthread_lock_lock(NAME) 0 +# define glthread_lock_unlock(NAME) 0 +# define glthread_lock_destroy(NAME) 0 + +/* ------------------------- gl_rwlock_t datatype ------------------------- */ + +typedef int gl_rwlock_t; +# define gl_rwlock_define(STORAGECLASS, NAME) +# define gl_rwlock_define_initialized(STORAGECLASS, NAME) +# define glthread_rwlock_init(NAME) 0 +# define glthread_rwlock_rdlock(NAME) 0 +# define glthread_rwlock_wrlock(NAME) 0 +# define glthread_rwlock_unlock(NAME) 0 +# define glthread_rwlock_destroy(NAME) 0 + +/* --------------------- gl_recursive_lock_t datatype --------------------- */ + +typedef int gl_recursive_lock_t; +# define gl_recursive_lock_define(STORAGECLASS, NAME) +# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) +# define glthread_recursive_lock_init(NAME) 0 +# define glthread_recursive_lock_lock(NAME) 0 +# define glthread_recursive_lock_unlock(NAME) 0 +# define glthread_recursive_lock_destroy(NAME) 0 + +/* -------------------------- gl_once_t datatype -------------------------- */ + +typedef int gl_once_t; +# define gl_once_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_once_t NAME = 0; +# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ + (*(ONCE_CONTROL) == 0 ? (*(ONCE_CONTROL) = ~ 0, INITFUNCTION (), 0) : 0) + +#endif + +/* ========================================================================= */ + +/* Macros with built-in error handling. */ + +/* -------------------------- gl_lock_t datatype -------------------------- */ + +#define gl_lock_init(NAME) \ + do \ + { \ + if (glthread_lock_init (&NAME)) \ + abort (); \ + } \ + while (0) +#define gl_lock_lock(NAME) \ + do \ + { \ + if (glthread_lock_lock (&NAME)) \ + abort (); \ + } \ + while (0) +#define gl_lock_unlock(NAME) \ + do \ + { \ + if (glthread_lock_unlock (&NAME)) \ + abort (); \ + } \ + while (0) +#define gl_lock_destroy(NAME) \ + do \ + { \ + if (glthread_lock_destroy (&NAME)) \ + abort (); \ + } \ + while (0) + +/* ------------------------- gl_rwlock_t datatype ------------------------- */ + +#define gl_rwlock_init(NAME) \ + do \ + { \ + if (glthread_rwlock_init (&NAME)) \ + abort (); \ + } \ + while (0) +#define gl_rwlock_rdlock(NAME) \ + do \ + { \ + if (glthread_rwlock_rdlock (&NAME)) \ + abort (); \ + } \ + while (0) +#define gl_rwlock_wrlock(NAME) \ + do \ + { \ + if (glthread_rwlock_wrlock (&NAME)) \ + abort (); \ + } \ + while (0) +#define gl_rwlock_unlock(NAME) \ + do \ + { \ + if (glthread_rwlock_unlock (&NAME)) \ + abort (); \ + } \ + while (0) +#define gl_rwlock_destroy(NAME) \ + do \ + { \ + if (glthread_rwlock_destroy (&NAME)) \ + abort (); \ + } \ + while (0) + +/* --------------------- gl_recursive_lock_t datatype --------------------- */ + +#define gl_recursive_lock_init(NAME) \ + do \ + { \ + if (glthread_recursive_lock_init (&NAME)) \ + abort (); \ + } \ + while (0) +#define gl_recursive_lock_lock(NAME) \ + do \ + { \ + if (glthread_recursive_lock_lock (&NAME)) \ + abort (); \ + } \ + while (0) +#define gl_recursive_lock_unlock(NAME) \ + do \ + { \ + if (glthread_recursive_lock_unlock (&NAME)) \ + abort (); \ + } \ + while (0) +#define gl_recursive_lock_destroy(NAME) \ + do \ + { \ + if (glthread_recursive_lock_destroy (&NAME)) \ + abort (); \ + } \ + while (0) + +/* -------------------------- gl_once_t datatype -------------------------- */ + +#define gl_once(NAME, INITFUNCTION) \ + do \ + { \ + if (glthread_once (&NAME, INITFUNCTION)) \ + abort (); \ + } \ + while (0) + +/* ========================================================================= */ + +#endif /* _LOCK_H */ diff --git a/gnulib-lib/glthread/threadlib.c b/gnulib-lib/glthread/threadlib.c new file mode 100644 index 0000000..a5ebd9b --- /dev/null +++ b/gnulib-lib/glthread/threadlib.c @@ -0,0 +1,73 @@ +/* Multithreading primitives. + Copyright (C) 2005-2019 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, 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, see . */ + +/* Written by Bruno Haible , 2005. */ + +#include + +/* ========================================================================= */ + +#if USE_POSIX_THREADS + +/* Use the POSIX threads library. */ + +# include +# include + +# if PTHREAD_IN_USE_DETECTION_HARD + +/* The function to be executed by a dummy thread. */ +static void * +dummy_thread_func (void *arg) +{ + return arg; +} + +int +glthread_in_use (void) +{ + static int tested; + static int result; /* 1: linked with -lpthread, 0: only with libc */ + + if (!tested) + { + pthread_t thread; + + if (pthread_create (&thread, NULL, dummy_thread_func, NULL) != 0) + /* Thread creation failed. */ + result = 0; + else + { + /* Thread creation works. */ + void *retval; + if (pthread_join (thread, &retval) != 0) + abort (); + result = 1; + } + tested = 1; + } + return result; +} + +# endif + +#endif + +/* ========================================================================= */ + +/* This declaration is solely to ensure that after preprocessing + this file is never empty. */ +typedef int dummy; diff --git a/gnulib-lib/limits.in.h b/gnulib-lib/limits.in.h new file mode 100644 index 0000000..39750b3 --- /dev/null +++ b/gnulib-lib/limits.in.h @@ -0,0 +1,104 @@ +/* A GNU-like . + + Copyright 2016-2019 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 3, 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, see . */ + +#ifndef _@GUARD_PREFIX@_LIMITS_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +/* The include_next requires a split double-inclusion guard. */ +#@INCLUDE_NEXT@ @NEXT_LIMITS_H@ + +#ifndef _@GUARD_PREFIX@_LIMITS_H +#define _@GUARD_PREFIX@_LIMITS_H + +#ifndef LLONG_MIN +# if defined LONG_LONG_MIN /* HP-UX 11.31 */ +# define LLONG_MIN LONG_LONG_MIN +# elif defined LONGLONG_MIN /* IRIX 6.5 */ +# define LLONG_MIN LONGLONG_MIN +# elif defined __GNUC__ +# define LLONG_MIN (- __LONG_LONG_MAX__ - 1LL) +# endif +#endif +#ifndef LLONG_MAX +# if defined LONG_LONG_MAX /* HP-UX 11.31 */ +# define LLONG_MAX LONG_LONG_MAX +# elif defined LONGLONG_MAX /* IRIX 6.5 */ +# define LLONG_MAX LONGLONG_MAX +# elif defined __GNUC__ +# define LLONG_MAX __LONG_LONG_MAX__ +# endif +#endif +#ifndef ULLONG_MAX +# if defined ULONG_LONG_MAX /* HP-UX 11.31 */ +# define ULLONG_MAX ULONG_LONG_MAX +# elif defined ULONGLONG_MAX /* IRIX 6.5 */ +# define ULLONG_MAX ULONGLONG_MAX +# elif defined __GNUC__ +# define ULLONG_MAX (__LONG_LONG_MAX__ * 2ULL + 1ULL) +# endif +#endif + +/* The number of usable bits in an unsigned or signed integer type + with minimum value MIN and maximum value MAX, as an int expression + suitable in #if. Cover all known practical hosts. This + implementation exploits the fact that MAX is 1 less than a power of + 2, and merely counts the number of 1 bits in MAX; "COBn" means + "count the number of 1 bits in the low-order n bits"). */ +#define _GL_INTEGER_WIDTH(min, max) (((min) < 0) + _GL_COB128 (max)) +#define _GL_COB128(n) (_GL_COB64 ((n) >> 31 >> 31 >> 2) + _GL_COB64 (n)) +#define _GL_COB64(n) (_GL_COB32 ((n) >> 31 >> 1) + _GL_COB32 (n)) +#define _GL_COB32(n) (_GL_COB16 ((n) >> 16) + _GL_COB16 (n)) +#define _GL_COB16(n) (_GL_COB8 ((n) >> 8) + _GL_COB8 (n)) +#define _GL_COB8(n) (_GL_COB4 ((n) >> 4) + _GL_COB4 (n)) +#define _GL_COB4(n) (!!((n) & 8) + !!((n) & 4) + !!((n) & 2) + !!((n) & 1)) + +#ifndef WORD_BIT +/* Assume 'int' is 32 bits wide. */ +# define WORD_BIT 32 +#endif +#ifndef LONG_BIT +/* Assume 'long' is 32 or 64 bits wide. */ +# if LONG_MAX == INT_MAX +# define LONG_BIT 32 +# else +# define LONG_BIT 64 +# endif +#endif + +/* Macros specified by ISO/IEC TS 18661-1:2014. */ + +#if (! defined ULLONG_WIDTH \ + && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__)) +# define CHAR_WIDTH _GL_INTEGER_WIDTH (CHAR_MIN, CHAR_MAX) +# define SCHAR_WIDTH _GL_INTEGER_WIDTH (SCHAR_MIN, SCHAR_MAX) +# define UCHAR_WIDTH _GL_INTEGER_WIDTH (0, UCHAR_MAX) +# define SHRT_WIDTH _GL_INTEGER_WIDTH (SHRT_MIN, SHRT_MAX) +# define USHRT_WIDTH _GL_INTEGER_WIDTH (0, USHRT_MAX) +# define INT_WIDTH _GL_INTEGER_WIDTH (INT_MIN, INT_MAX) +# define UINT_WIDTH _GL_INTEGER_WIDTH (0, UINT_MAX) +# define LONG_WIDTH _GL_INTEGER_WIDTH (LONG_MIN, LONG_MAX) +# define ULONG_WIDTH _GL_INTEGER_WIDTH (0, ULONG_MAX) +# define LLONG_WIDTH _GL_INTEGER_WIDTH (LLONG_MIN, LLONG_MAX) +# define ULLONG_WIDTH _GL_INTEGER_WIDTH (0, ULLONG_MAX) +#endif /* !ULLONG_WIDTH && (_GNU_SOURCE || __STDC_WANT_IEC_60559_BFP_EXT__) */ + +#endif /* _@GUARD_PREFIX@_LIMITS_H */ +#endif /* _@GUARD_PREFIX@_LIMITS_H */ diff --git a/gnulib-lib/stdint.in.h b/gnulib-lib/stdint.in.h new file mode 100644 index 0000000..21dd8d2 --- /dev/null +++ b/gnulib-lib/stdint.in.h @@ -0,0 +1,726 @@ +/* Copyright (C) 2001-2002, 2004-2019 Free Software Foundation, Inc. + Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood. + This file is part of gnulib. + + 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 3, 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, see . */ + +/* + * ISO C 99 for platforms that lack it. + * + */ + +#ifndef _@GUARD_PREFIX@_STDINT_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +/* When including a system file that in turn includes , + use the system , not our substitute. This avoids + problems with (for example) VMS, whose includes + . */ +#define _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H + +/* On Android (Bionic libc), includes this file before + having defined 'time_t'. Therefore in this case avoid including + other system header files; just include the system's . + Ideally we should test __BIONIC__ here, but it is only defined after + has been included; hence test __ANDROID__ instead. */ +#if defined __ANDROID__ && defined _GL_INCLUDING_SYS_TYPES_H +# @INCLUDE_NEXT@ @NEXT_STDINT_H@ +#else + +/* Get those types that are already defined in other system include + files, so that we can "#define int8_t signed char" below without + worrying about a later system include file containing a "typedef + signed char int8_t;" that will get messed up by our macro. Our + macros should all be consistent with the system versions, except + for the "fast" types and macros, which we recommend against using + in public interfaces due to compiler differences. */ + +#if @HAVE_STDINT_H@ +# if defined __sgi && ! defined __c99 + /* Bypass IRIX's if in C89 mode, since it merely annoys users + with "This header file is to be used only for c99 mode compilations" + diagnostics. */ +# define __STDINT_H__ +# endif + + /* Some pre-C++11 implementations need this. */ +# ifdef __cplusplus +# ifndef __STDC_CONSTANT_MACROS +# define __STDC_CONSTANT_MACROS 1 +# endif +# ifndef __STDC_LIMIT_MACROS +# define __STDC_LIMIT_MACROS 1 +# endif +# endif + + /* Other systems may have an incomplete or buggy . + Include it before , since any "#include " + in would reinclude us, skipping our contents because + _@GUARD_PREFIX@_STDINT_H is defined. + The include_next requires a split double-inclusion guard. */ +# @INCLUDE_NEXT@ @NEXT_STDINT_H@ +#endif + +#if ! defined _@GUARD_PREFIX@_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H +#define _@GUARD_PREFIX@_STDINT_H + +/* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX, + LONG_MIN, LONG_MAX, ULONG_MAX, _GL_INTEGER_WIDTH. */ +#include + +/* Override WINT_MIN and WINT_MAX if gnulib's or overrides + wint_t. */ +#if @GNULIB_OVERRIDES_WINT_T@ +# undef WINT_MIN +# undef WINT_MAX +# define WINT_MIN 0x0U +# define WINT_MAX 0xffffffffU +#endif + +#if ! @HAVE_C99_STDINT_H@ + +/* defines some of the stdint.h types as well, on glibc, + IRIX 6.5, and OpenBSD 3.8 (via ). + AIX 5.2 isn't needed and causes troubles. + Mac OS X 10.4.6 includes (which is us), but + relies on the system definitions, so include + after @NEXT_STDINT_H@. */ +# if @HAVE_SYS_TYPES_H@ && ! defined _AIX +# include +# endif + +# if @HAVE_INTTYPES_H@ + /* In OpenBSD 3.8, includes , which defines + int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__. + also defines intptr_t and uintptr_t. */ +# include +# elif @HAVE_SYS_INTTYPES_H@ + /* Solaris 7 has the types except the *_fast*_t types, and + the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX. */ +# include +# endif + +# if @HAVE_SYS_BITYPES_H@ && ! defined __BIT_TYPES_DEFINED__ + /* Linux libc4 >= 4.6.7 and libc5 have a that defines + int{8,16,32,64}_t and __BIT_TYPES_DEFINED__. In libc5 >= 5.2.2 it is + included by . */ +# include +# endif + +# undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H + +/* Minimum and maximum values for an integer type under the usual assumption. + Return an unspecified value if BITS == 0, adding a check to pacify + picky compilers. */ + +/* These are separate macros, because if you try to merge these macros into + a single one, HP-UX cc rejects the resulting expression in constant + expressions. */ +# define _STDINT_UNSIGNED_MIN(bits, zero) \ + (zero) +# define _STDINT_SIGNED_MIN(bits, zero) \ + (~ _STDINT_MAX (1, bits, zero)) + +# define _STDINT_MAX(signed, bits, zero) \ + (((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1) + +#if !GNULIB_defined_stdint_types + +/* 7.18.1.1. Exact-width integer types */ + +/* Here we assume a standard architecture where the hardware integer + types have 8, 16, 32, optionally 64 bits. */ + +# undef int8_t +# undef uint8_t +typedef signed char gl_int8_t; +typedef unsigned char gl_uint8_t; +# define int8_t gl_int8_t +# define uint8_t gl_uint8_t + +# undef int16_t +# undef uint16_t +typedef short int gl_int16_t; +typedef unsigned short int gl_uint16_t; +# define int16_t gl_int16_t +# define uint16_t gl_uint16_t + +# undef int32_t +# undef uint32_t +typedef int gl_int32_t; +typedef unsigned int gl_uint32_t; +# define int32_t gl_int32_t +# define uint32_t gl_uint32_t + +/* If the system defines INT64_MAX, assume int64_t works. That way, + if the underlying platform defines int64_t to be a 64-bit long long + int, the code below won't mistakenly define it to be a 64-bit long + int, which would mess up C++ name mangling. We must use #ifdef + rather than #if, to avoid an error with HP-UX 10.20 cc. */ + +# ifdef INT64_MAX +# define GL_INT64_T +# else +/* Do not undefine int64_t if gnulib is not being used with 64-bit + types, since otherwise it breaks platforms like Tandem/NSK. */ +# if LONG_MAX >> 31 >> 31 == 1 +# undef int64_t +typedef long int gl_int64_t; +# define int64_t gl_int64_t +# define GL_INT64_T +# elif defined _MSC_VER +# undef int64_t +typedef __int64 gl_int64_t; +# define int64_t gl_int64_t +# define GL_INT64_T +# elif @HAVE_LONG_LONG_INT@ +# undef int64_t +typedef long long int gl_int64_t; +# define int64_t gl_int64_t +# define GL_INT64_T +# endif +# endif + +# ifdef UINT64_MAX +# define GL_UINT64_T +# else +# if ULONG_MAX >> 31 >> 31 >> 1 == 1 +# undef uint64_t +typedef unsigned long int gl_uint64_t; +# define uint64_t gl_uint64_t +# define GL_UINT64_T +# elif defined _MSC_VER +# undef uint64_t +typedef unsigned __int64 gl_uint64_t; +# define uint64_t gl_uint64_t +# define GL_UINT64_T +# elif @HAVE_UNSIGNED_LONG_LONG_INT@ +# undef uint64_t +typedef unsigned long long int gl_uint64_t; +# define uint64_t gl_uint64_t +# define GL_UINT64_T +# endif +# endif + +/* Avoid collision with Solaris 2.5.1 etc. */ +# define _UINT8_T +# define _UINT32_T +# define _UINT64_T + + +/* 7.18.1.2. Minimum-width integer types */ + +/* Here we assume a standard architecture where the hardware integer + types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types + are the same as the corresponding N_t types. */ + +# undef int_least8_t +# undef uint_least8_t +# undef int_least16_t +# undef uint_least16_t +# undef int_least32_t +# undef uint_least32_t +# undef int_least64_t +# undef uint_least64_t +# define int_least8_t int8_t +# define uint_least8_t uint8_t +# define int_least16_t int16_t +# define uint_least16_t uint16_t +# define int_least32_t int32_t +# define uint_least32_t uint32_t +# ifdef GL_INT64_T +# define int_least64_t int64_t +# endif +# ifdef GL_UINT64_T +# define uint_least64_t uint64_t +# endif + +/* 7.18.1.3. Fastest minimum-width integer types */ + +/* Note: Other substitutes may define these types differently. + It is not recommended to use these types in public header files. */ + +/* Here we assume a standard architecture where the hardware integer + types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types + are taken from the same list of types. The following code normally + uses types consistent with glibc, as that lessens the chance of + incompatibility with older GNU hosts. */ + +# undef int_fast8_t +# undef uint_fast8_t +# undef int_fast16_t +# undef uint_fast16_t +# undef int_fast32_t +# undef uint_fast32_t +# undef int_fast64_t +# undef uint_fast64_t +typedef signed char gl_int_fast8_t; +typedef unsigned char gl_uint_fast8_t; + +# ifdef __sun +/* Define types compatible with SunOS 5.10, so that code compiled under + earlier SunOS versions works with code compiled under SunOS 5.10. */ +typedef int gl_int_fast32_t; +typedef unsigned int gl_uint_fast32_t; +# else +typedef long int gl_int_fast32_t; +typedef unsigned long int gl_uint_fast32_t; +# endif +typedef gl_int_fast32_t gl_int_fast16_t; +typedef gl_uint_fast32_t gl_uint_fast16_t; + +# define int_fast8_t gl_int_fast8_t +# define uint_fast8_t gl_uint_fast8_t +# define int_fast16_t gl_int_fast16_t +# define uint_fast16_t gl_uint_fast16_t +# define int_fast32_t gl_int_fast32_t +# define uint_fast32_t gl_uint_fast32_t +# ifdef GL_INT64_T +# define int_fast64_t int64_t +# endif +# ifdef GL_UINT64_T +# define uint_fast64_t uint64_t +# endif + +/* 7.18.1.4. Integer types capable of holding object pointers */ + +/* kLIBC's stdint.h defines _INTPTR_T_DECLARED and needs its own + definitions of intptr_t and uintptr_t (which use int and unsigned) + to avoid clashes with declarations of system functions like sbrk. */ +# ifndef _INTPTR_T_DECLARED +# undef intptr_t +# undef uintptr_t +typedef long int gl_intptr_t; +typedef unsigned long int gl_uintptr_t; +# define intptr_t gl_intptr_t +# define uintptr_t gl_uintptr_t +# endif + +/* 7.18.1.5. Greatest-width integer types */ + +/* Note: These types are compiler dependent. It may be unwise to use them in + public header files. */ + +/* If the system defines INTMAX_MAX, assume that intmax_t works, and + similarly for UINTMAX_MAX and uintmax_t. This avoids problems with + assuming one type where another is used by the system. */ + +# ifndef INTMAX_MAX +# undef INTMAX_C +# undef intmax_t +# if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 +typedef long long int gl_intmax_t; +# define intmax_t gl_intmax_t +# elif defined GL_INT64_T +# define intmax_t int64_t +# else +typedef long int gl_intmax_t; +# define intmax_t gl_intmax_t +# endif +# endif + +# ifndef UINTMAX_MAX +# undef UINTMAX_C +# undef uintmax_t +# if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1 +typedef unsigned long long int gl_uintmax_t; +# define uintmax_t gl_uintmax_t +# elif defined GL_UINT64_T +# define uintmax_t uint64_t +# else +typedef unsigned long int gl_uintmax_t; +# define uintmax_t gl_uintmax_t +# endif +# endif + +/* Verify that intmax_t and uintmax_t have the same size. Too much code + breaks if this is not the case. If this check fails, the reason is likely + to be found in the autoconf macros. */ +typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t) + ? 1 : -1]; + +# define GNULIB_defined_stdint_types 1 +# endif /* !GNULIB_defined_stdint_types */ + +/* 7.18.2. Limits of specified-width integer types */ + +/* 7.18.2.1. Limits of exact-width integer types */ + +/* Here we assume a standard architecture where the hardware integer + types have 8, 16, 32, optionally 64 bits. */ + +# undef INT8_MIN +# undef INT8_MAX +# undef UINT8_MAX +# define INT8_MIN (~ INT8_MAX) +# define INT8_MAX 127 +# define UINT8_MAX 255 + +# undef INT16_MIN +# undef INT16_MAX +# undef UINT16_MAX +# define INT16_MIN (~ INT16_MAX) +# define INT16_MAX 32767 +# define UINT16_MAX 65535 + +# undef INT32_MIN +# undef INT32_MAX +# undef UINT32_MAX +# define INT32_MIN (~ INT32_MAX) +# define INT32_MAX 2147483647 +# define UINT32_MAX 4294967295U + +# if defined GL_INT64_T && ! defined INT64_MAX +/* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0 + evaluates the latter incorrectly in preprocessor expressions. */ +# define INT64_MIN (- INTMAX_C (1) << 63) +# define INT64_MAX INTMAX_C (9223372036854775807) +# endif + +# if defined GL_UINT64_T && ! defined UINT64_MAX +# define UINT64_MAX UINTMAX_C (18446744073709551615) +# endif + +/* 7.18.2.2. Limits of minimum-width integer types */ + +/* Here we assume a standard architecture where the hardware integer + types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types + are the same as the corresponding N_t types. */ + +# undef INT_LEAST8_MIN +# undef INT_LEAST8_MAX +# undef UINT_LEAST8_MAX +# define INT_LEAST8_MIN INT8_MIN +# define INT_LEAST8_MAX INT8_MAX +# define UINT_LEAST8_MAX UINT8_MAX + +# undef INT_LEAST16_MIN +# undef INT_LEAST16_MAX +# undef UINT_LEAST16_MAX +# define INT_LEAST16_MIN INT16_MIN +# define INT_LEAST16_MAX INT16_MAX +# define UINT_LEAST16_MAX UINT16_MAX + +# undef INT_LEAST32_MIN +# undef INT_LEAST32_MAX +# undef UINT_LEAST32_MAX +# define INT_LEAST32_MIN INT32_MIN +# define INT_LEAST32_MAX INT32_MAX +# define UINT_LEAST32_MAX UINT32_MAX + +# undef INT_LEAST64_MIN +# undef INT_LEAST64_MAX +# ifdef GL_INT64_T +# define INT_LEAST64_MIN INT64_MIN +# define INT_LEAST64_MAX INT64_MAX +# endif + +# undef UINT_LEAST64_MAX +# ifdef GL_UINT64_T +# define UINT_LEAST64_MAX UINT64_MAX +# endif + +/* 7.18.2.3. Limits of fastest minimum-width integer types */ + +/* Here we assume a standard architecture where the hardware integer + types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types + are taken from the same list of types. */ + +# undef INT_FAST8_MIN +# undef INT_FAST8_MAX +# undef UINT_FAST8_MAX +# define INT_FAST8_MIN SCHAR_MIN +# define INT_FAST8_MAX SCHAR_MAX +# define UINT_FAST8_MAX UCHAR_MAX + +# undef INT_FAST16_MIN +# undef INT_FAST16_MAX +# undef UINT_FAST16_MAX +# define INT_FAST16_MIN INT_FAST32_MIN +# define INT_FAST16_MAX INT_FAST32_MAX +# define UINT_FAST16_MAX UINT_FAST32_MAX + +# undef INT_FAST32_MIN +# undef INT_FAST32_MAX +# undef UINT_FAST32_MAX +# ifdef __sun +# define INT_FAST32_MIN INT_MIN +# define INT_FAST32_MAX INT_MAX +# define UINT_FAST32_MAX UINT_MAX +# else +# define INT_FAST32_MIN LONG_MIN +# define INT_FAST32_MAX LONG_MAX +# define UINT_FAST32_MAX ULONG_MAX +# endif + +# undef INT_FAST64_MIN +# undef INT_FAST64_MAX +# ifdef GL_INT64_T +# define INT_FAST64_MIN INT64_MIN +# define INT_FAST64_MAX INT64_MAX +# endif + +# undef UINT_FAST64_MAX +# ifdef GL_UINT64_T +# define UINT_FAST64_MAX UINT64_MAX +# endif + +/* 7.18.2.4. Limits of integer types capable of holding object pointers */ + +# undef INTPTR_MIN +# undef INTPTR_MAX +# undef UINTPTR_MAX +# define INTPTR_MIN LONG_MIN +# define INTPTR_MAX LONG_MAX +# define UINTPTR_MAX ULONG_MAX + +/* 7.18.2.5. Limits of greatest-width integer types */ + +# ifndef INTMAX_MAX +# undef INTMAX_MIN +# ifdef INT64_MAX +# define INTMAX_MIN INT64_MIN +# define INTMAX_MAX INT64_MAX +# else +# define INTMAX_MIN INT32_MIN +# define INTMAX_MAX INT32_MAX +# endif +# endif + +# ifndef UINTMAX_MAX +# ifdef UINT64_MAX +# define UINTMAX_MAX UINT64_MAX +# else +# define UINTMAX_MAX UINT32_MAX +# endif +# endif + +/* 7.18.3. Limits of other integer types */ + +/* ptrdiff_t limits */ +# undef PTRDIFF_MIN +# undef PTRDIFF_MAX +# if @APPLE_UNIVERSAL_BUILD@ +# ifdef _LP64 +# define PTRDIFF_MIN _STDINT_SIGNED_MIN (64, 0l) +# define PTRDIFF_MAX _STDINT_MAX (1, 64, 0l) +# else +# define PTRDIFF_MIN _STDINT_SIGNED_MIN (32, 0) +# define PTRDIFF_MAX _STDINT_MAX (1, 32, 0) +# endif +# else +# define PTRDIFF_MIN \ + _STDINT_SIGNED_MIN (@BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@) +# define PTRDIFF_MAX \ + _STDINT_MAX (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@) +# endif + +/* sig_atomic_t limits */ +# undef SIG_ATOMIC_MIN +# undef SIG_ATOMIC_MAX +# if @HAVE_SIGNED_SIG_ATOMIC_T@ +# define SIG_ATOMIC_MIN \ + _STDINT_SIGNED_MIN (@BITSIZEOF_SIG_ATOMIC_T@, 0@SIG_ATOMIC_T_SUFFIX@) +# else +# define SIG_ATOMIC_MIN \ + _STDINT_UNSIGNED_MIN (@BITSIZEOF_SIG_ATOMIC_T@, 0@SIG_ATOMIC_T_SUFFIX@) +# endif +# define SIG_ATOMIC_MAX \ + _STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \ + 0@SIG_ATOMIC_T_SUFFIX@) + + +/* size_t limit */ +# undef SIZE_MAX +# if @APPLE_UNIVERSAL_BUILD@ +# ifdef _LP64 +# define SIZE_MAX _STDINT_MAX (0, 64, 0ul) +# else +# define SIZE_MAX _STDINT_MAX (0, 32, 0ul) +# endif +# else +# define SIZE_MAX _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, 0@SIZE_T_SUFFIX@) +# endif + +/* wchar_t limits */ +/* Get WCHAR_MIN, WCHAR_MAX. + This include is not on the top, above, because on OSF/1 4.0 we have a + sequence of nested includes + -> -> -> , and the latter includes + and assumes its types are already defined. */ +# if @HAVE_WCHAR_H@ && ! (defined WCHAR_MIN && defined WCHAR_MAX) + /* BSD/OS 4.0.1 has a bug: , and must be + included before . */ +# include +# include +# include +# define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H +# include +# undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H +# endif +# undef WCHAR_MIN +# undef WCHAR_MAX +# if @HAVE_SIGNED_WCHAR_T@ +# define WCHAR_MIN \ + _STDINT_SIGNED_MIN (@BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@) +# else +# define WCHAR_MIN \ + _STDINT_UNSIGNED_MIN (@BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@) +# endif +# define WCHAR_MAX \ + _STDINT_MAX (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@) + +/* wint_t limits */ +# undef WINT_MIN +# undef WINT_MAX +# if @HAVE_SIGNED_WINT_T@ +# define WINT_MIN \ + _STDINT_SIGNED_MIN (@BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) +# else +# define WINT_MIN \ + _STDINT_UNSIGNED_MIN (@BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) +# endif +# define WINT_MAX \ + _STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) + +/* 7.18.4. Macros for integer constants */ + +/* 7.18.4.1. Macros for minimum-width integer constants */ +/* According to ISO C 99 Technical Corrigendum 1 */ + +/* Here we assume a standard architecture where the hardware integer + types have 8, 16, 32, optionally 64 bits, and int is 32 bits. */ + +# undef INT8_C +# undef UINT8_C +# define INT8_C(x) x +# define UINT8_C(x) x + +# undef INT16_C +# undef UINT16_C +# define INT16_C(x) x +# define UINT16_C(x) x + +# undef INT32_C +# undef UINT32_C +# define INT32_C(x) x +# define UINT32_C(x) x ## U + +# undef INT64_C +# undef UINT64_C +# if LONG_MAX >> 31 >> 31 == 1 +# define INT64_C(x) x##L +# elif defined _MSC_VER +# define INT64_C(x) x##i64 +# elif @HAVE_LONG_LONG_INT@ +# define INT64_C(x) x##LL +# endif +# if ULONG_MAX >> 31 >> 31 >> 1 == 1 +# define UINT64_C(x) x##UL +# elif defined _MSC_VER +# define UINT64_C(x) x##ui64 +# elif @HAVE_UNSIGNED_LONG_LONG_INT@ +# define UINT64_C(x) x##ULL +# endif + +/* 7.18.4.2. Macros for greatest-width integer constants */ + +# ifndef INTMAX_C +# if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 +# define INTMAX_C(x) x##LL +# elif defined GL_INT64_T +# define INTMAX_C(x) INT64_C(x) +# else +# define INTMAX_C(x) x##L +# endif +# endif + +# ifndef UINTMAX_C +# if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1 +# define UINTMAX_C(x) x##ULL +# elif defined GL_UINT64_T +# define UINTMAX_C(x) UINT64_C(x) +# else +# define UINTMAX_C(x) x##UL +# endif +# endif + +#endif /* !@HAVE_C99_STDINT_H@ */ + +/* Macros specified by ISO/IEC TS 18661-1:2014. */ + +#if (!defined UINTMAX_WIDTH \ + && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__)) +# ifdef INT8_MAX +# define INT8_WIDTH _GL_INTEGER_WIDTH (INT8_MIN, INT8_MAX) +# endif +# ifdef UINT8_MAX +# define UINT8_WIDTH _GL_INTEGER_WIDTH (0, UINT8_MAX) +# endif +# ifdef INT16_MAX +# define INT16_WIDTH _GL_INTEGER_WIDTH (INT16_MIN, INT16_MAX) +# endif +# ifdef UINT16_MAX +# define UINT16_WIDTH _GL_INTEGER_WIDTH (0, UINT16_MAX) +# endif +# ifdef INT32_MAX +# define INT32_WIDTH _GL_INTEGER_WIDTH (INT32_MIN, INT32_MAX) +# endif +# ifdef UINT32_MAX +# define UINT32_WIDTH _GL_INTEGER_WIDTH (0, UINT32_MAX) +# endif +# ifdef INT64_MAX +# define INT64_WIDTH _GL_INTEGER_WIDTH (INT64_MIN, INT64_MAX) +# endif +# ifdef UINT64_MAX +# define UINT64_WIDTH _GL_INTEGER_WIDTH (0, UINT64_MAX) +# endif +# define INT_LEAST8_WIDTH _GL_INTEGER_WIDTH (INT_LEAST8_MIN, INT_LEAST8_MAX) +# define UINT_LEAST8_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST8_MAX) +# define INT_LEAST16_WIDTH _GL_INTEGER_WIDTH (INT_LEAST16_MIN, INT_LEAST16_MAX) +# define UINT_LEAST16_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST16_MAX) +# define INT_LEAST32_WIDTH _GL_INTEGER_WIDTH (INT_LEAST32_MIN, INT_LEAST32_MAX) +# define UINT_LEAST32_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST32_MAX) +# define INT_LEAST64_WIDTH _GL_INTEGER_WIDTH (INT_LEAST64_MIN, INT_LEAST64_MAX) +# define UINT_LEAST64_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST64_MAX) +# define INT_FAST8_WIDTH _GL_INTEGER_WIDTH (INT_FAST8_MIN, INT_FAST8_MAX) +# define UINT_FAST8_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST8_MAX) +# define INT_FAST16_WIDTH _GL_INTEGER_WIDTH (INT_FAST16_MIN, INT_FAST16_MAX) +# define UINT_FAST16_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST16_MAX) +# define INT_FAST32_WIDTH _GL_INTEGER_WIDTH (INT_FAST32_MIN, INT_FAST32_MAX) +# define UINT_FAST32_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST32_MAX) +# define INT_FAST64_WIDTH _GL_INTEGER_WIDTH (INT_FAST64_MIN, INT_FAST64_MAX) +# define UINT_FAST64_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST64_MAX) +# define INTPTR_WIDTH _GL_INTEGER_WIDTH (INTPTR_MIN, INTPTR_MAX) +# define UINTPTR_WIDTH _GL_INTEGER_WIDTH (0, UINTPTR_MAX) +# define INTMAX_WIDTH _GL_INTEGER_WIDTH (INTMAX_MIN, INTMAX_MAX) +# define UINTMAX_WIDTH _GL_INTEGER_WIDTH (0, UINTMAX_MAX) +# define PTRDIFF_WIDTH _GL_INTEGER_WIDTH (PTRDIFF_MIN, PTRDIFF_MAX) +# define SIZE_WIDTH _GL_INTEGER_WIDTH (0, SIZE_MAX) +# define WCHAR_WIDTH _GL_INTEGER_WIDTH (WCHAR_MIN, WCHAR_MAX) +# ifdef WINT_MAX +# define WINT_WIDTH _GL_INTEGER_WIDTH (WINT_MIN, WINT_MAX) +# endif +# ifdef SIG_ATOMIC_MAX +# define SIG_ATOMIC_WIDTH _GL_INTEGER_WIDTH (SIG_ATOMIC_MIN, SIG_ATOMIC_MAX) +# endif +#endif /* !WINT_WIDTH && (_GNU_SOURCE || __STDC_WANT_IEC_60559_BFP_EXT__) */ + +#endif /* _@GUARD_PREFIX@_STDINT_H */ +#endif /* !(defined __ANDROID__ && ...) */ +#endif /* !defined _@GUARD_PREFIX@_STDINT_H && !defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H */ diff --git a/gnulib-lib/stdnoreturn.in.h b/gnulib-lib/stdnoreturn.in.h new file mode 100644 index 0000000..dc77e3e --- /dev/null +++ b/gnulib-lib/stdnoreturn.in.h @@ -0,0 +1,60 @@ +/* A substitute for ISO C11 . + + Copyright 2012-2019 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, 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, see . */ + +/* Written by Paul Eggert. */ + +#ifndef noreturn + +/* ISO C11 for platforms that lack it. + + References: + ISO C11 (latest free draft + ) + section 7.23 */ + +/* The definition of _Noreturn is copied here. */ + +#if 1200 <= _MSC_VER || defined __CYGWIN__ +/* On MSVC, standard include files contain declarations like + __declspec (noreturn) void abort (void); + "#define noreturn _Noreturn" would cause this declaration to be rewritten + to the invalid + __declspec (__declspec (noreturn)) void abort (void); + + Similarly, on Cygwin, standard include files contain declarations like + void __cdecl abort (void) __attribute__ ((noreturn)); + "#define noreturn _Noreturn" would cause this declaration to be rewritten + to the invalid + void __cdecl abort (void) __attribute__ ((__attribute__ ((__noreturn__)))); + + Instead, define noreturn to empty, so that such declarations are rewritten to + __declspec () void abort (void); + or + void __cdecl abort (void) __attribute__ (()); + respectively. This gives up on noreturn's advice to the compiler but at + least it is valid code. */ +# define noreturn /*empty*/ +#else +# define noreturn _Noreturn +#endif + +/* Did he ever return? + No he never returned + And his fate is still unlearn'd ... + -- Steiner J, Hawes BL. M.T.A. (1949) */ + +#endif /* noreturn */ diff --git a/gnulib-lib/sys_types.in.h b/gnulib-lib/sys_types.in.h new file mode 100644 index 0000000..237e206 --- /dev/null +++ b/gnulib-lib/sys_types.in.h @@ -0,0 +1,106 @@ +/* Provide a more complete sys/types.h. + + Copyright (C) 2011-2019 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, 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, see . */ + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +#if defined _WIN32 && !defined __CYGWIN__ \ + && (defined __need_off_t || defined __need___off64_t \ + || defined __need_ssize_t || defined __need_time_t) + +/* Special invocation convention inside mingw header files. */ + +#@INCLUDE_NEXT@ @NEXT_SYS_TYPES_H@ + +#else +/* Normal invocation convention. */ + +#ifndef _@GUARD_PREFIX@_SYS_TYPES_H + +/* The include_next requires a split double-inclusion guard. */ +# define _GL_INCLUDING_SYS_TYPES_H +#@INCLUDE_NEXT@ @NEXT_SYS_TYPES_H@ +# undef _GL_INCLUDING_SYS_TYPES_H + +#ifndef _@GUARD_PREFIX@_SYS_TYPES_H +#define _@GUARD_PREFIX@_SYS_TYPES_H + +/* Override off_t if Large File Support is requested on native Windows. */ +#if @WINDOWS_64_BIT_OFF_T@ +/* Same as int64_t in . */ +# if defined _MSC_VER +# define off_t __int64 +# else +# define off_t long long int +# endif +/* Indicator, for gnulib internal purposes. */ +# define _GL_WINDOWS_64_BIT_OFF_T 1 +#endif + +/* Override dev_t and ino_t if distinguishable inodes support is requested + on native Windows. */ +#if @WINDOWS_STAT_INODES@ + +# if @WINDOWS_STAT_INODES@ == 2 +/* Experimental, not useful in Windows 10. */ + +/* Define dev_t to a 64-bit type. */ +# if !defined GNULIB_defined_dev_t +typedef unsigned long long int rpl_dev_t; +# undef dev_t +# define dev_t rpl_dev_t +# define GNULIB_defined_dev_t 1 +# endif + +/* Define ino_t to a 128-bit type. */ +# if !defined GNULIB_defined_ino_t +/* MSVC does not have a 128-bit integer type. + GCC has a 128-bit integer type __int128, but only on 64-bit targets. */ +typedef struct { unsigned long long int _gl_ino[2]; } rpl_ino_t; +# undef ino_t +# define ino_t rpl_ino_t +# define GNULIB_defined_ino_t 1 +# endif + +# else /* @WINDOWS_STAT_INODES@ == 1 */ + +/* Define ino_t to a 64-bit type. */ +# if !defined GNULIB_defined_ino_t +typedef unsigned long long int rpl_ino_t; +# undef ino_t +# define ino_t rpl_ino_t +# define GNULIB_defined_ino_t 1 +# endif + +# endif + +/* Indicator, for gnulib internal purposes. */ +# define _GL_WINDOWS_STAT_INODES @WINDOWS_STAT_INODES@ + +#endif + +/* MSVC 9 defines size_t in , not in . */ +/* But avoid namespace pollution on glibc systems. */ +#if (defined _WIN32 && ! defined __CYGWIN__) && ! defined __GLIBC__ +# include +#endif + +#endif /* _@GUARD_PREFIX@_SYS_TYPES_H */ +#endif /* _@GUARD_PREFIX@_SYS_TYPES_H */ +#endif /* __need_XXX */ diff --git a/gnulib-lib/windows-initguard.h b/gnulib-lib/windows-initguard.h new file mode 100644 index 0000000..8aefd0b --- /dev/null +++ b/gnulib-lib/windows-initguard.h @@ -0,0 +1,35 @@ +/* Init guards, somewhat like spinlocks (native Windows implementation). + Copyright (C) 2005-2019 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, 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, see . */ + +/* Written by Bruno Haible , 2005. + Based on GCC's gthr-win32.h. */ + +#ifndef _WINDOWS_INITGUARD_H +#define _WINDOWS_INITGUARD_H + +#define WIN32_LEAN_AND_MEAN /* avoid including junk */ +#include + +typedef struct + { + volatile int done; + volatile LONG started; + } + glwthread_initguard_t; + +#define GLWTHREAD_INITGUARD_INIT { 0, -1 } + +#endif /* _WINDOWS_INITGUARD_H */ diff --git a/gnulib-lib/windows-mutex.c b/gnulib-lib/windows-mutex.c new file mode 100644 index 0000000..9433881 --- /dev/null +++ b/gnulib-lib/windows-mutex.c @@ -0,0 +1,95 @@ +/* Plain mutexes (native Windows implementation). + Copyright (C) 2005-2019 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, 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, see . */ + +/* Written by Bruno Haible , 2005. + Based on GCC's gthr-win32.h. */ + +#include + +/* Specification. */ +#include "windows-mutex.h" + +#include + +void +glwthread_mutex_init (glwthread_mutex_t *mutex) +{ + InitializeCriticalSection (&mutex->lock); + mutex->guard.done = 1; +} + +int +glwthread_mutex_lock (glwthread_mutex_t *mutex) +{ + if (!mutex->guard.done) + { + if (InterlockedIncrement (&mutex->guard.started) == 0) + /* This thread is the first one to need this mutex. Initialize it. */ + glwthread_mutex_init (mutex); + else + { + /* Don't let mutex->guard.started grow and wrap around. */ + InterlockedDecrement (&mutex->guard.started); + /* Yield the CPU while waiting for another thread to finish + initializing this mutex. */ + while (!mutex->guard.done) + Sleep (0); + } + } + EnterCriticalSection (&mutex->lock); + return 0; +} + +int +glwthread_mutex_trylock (glwthread_mutex_t *mutex) +{ + if (!mutex->guard.done) + { + if (InterlockedIncrement (&mutex->guard.started) == 0) + /* This thread is the first one to need this mutex. Initialize it. */ + glwthread_mutex_init (mutex); + else + { + /* Don't let mutex->guard.started grow and wrap around. */ + InterlockedDecrement (&mutex->guard.started); + /* Let another thread finish initializing this mutex, and let it also + lock this mutex. */ + return EBUSY; + } + } + if (!TryEnterCriticalSection (&mutex->lock)) + return EBUSY; + return 0; +} + +int +glwthread_mutex_unlock (glwthread_mutex_t *mutex) +{ + if (!mutex->guard.done) + return EINVAL; + LeaveCriticalSection (&mutex->lock); + return 0; +} + +int +glwthread_mutex_destroy (glwthread_mutex_t *mutex) +{ + if (!mutex->guard.done) + return EINVAL; + DeleteCriticalSection (&mutex->lock); + mutex->guard.done = 0; + return 0; +} diff --git a/gnulib-lib/windows-mutex.h b/gnulib-lib/windows-mutex.h new file mode 100644 index 0000000..5364f92 --- /dev/null +++ b/gnulib-lib/windows-mutex.h @@ -0,0 +1,51 @@ +/* Plain mutexes (native Windows implementation). + Copyright (C) 2005-2019 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, 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, see . */ + +/* Written by Bruno Haible , 2005. + Based on GCC's gthr-win32.h. */ + +#ifndef _WINDOWS_MUTEX_H +#define _WINDOWS_MUTEX_H + +#define WIN32_LEAN_AND_MEAN /* avoid including junk */ +#include + +#include "windows-initguard.h" + +typedef struct + { + glwthread_initguard_t guard; /* protects the initialization */ + CRITICAL_SECTION lock; + } + glwthread_mutex_t; + +#define GLWTHREAD_MUTEX_INIT { GLWTHREAD_INITGUARD_INIT } + +#ifdef __cplusplus +extern "C" { +#endif + +extern void glwthread_mutex_init (glwthread_mutex_t *mutex); +extern int glwthread_mutex_lock (glwthread_mutex_t *mutex); +extern int glwthread_mutex_trylock (glwthread_mutex_t *mutex); +extern int glwthread_mutex_unlock (glwthread_mutex_t *mutex); +extern int glwthread_mutex_destroy (glwthread_mutex_t *mutex); + +#ifdef __cplusplus +} +#endif + +#endif /* _WINDOWS_MUTEX_H */ diff --git a/gnulib-lib/windows-once.c b/gnulib-lib/windows-once.c new file mode 100644 index 0000000..455c50e --- /dev/null +++ b/gnulib-lib/windows-once.c @@ -0,0 +1,62 @@ +/* Once-only control (native Windows implementation). + Copyright (C) 2005-2019 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, 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, see . */ + +/* Written by Bruno Haible , 2005. + Based on GCC's gthr-win32.h. */ + +#include + +/* Specification. */ +#include "windows-once.h" + +#include + +void +glwthread_once (glwthread_once_t *once_control, void (*initfunction) (void)) +{ + if (once_control->inited <= 0) + { + if (InterlockedIncrement (&once_control->started) == 0) + { + /* This thread is the first one to come to this once_control. */ + InitializeCriticalSection (&once_control->lock); + EnterCriticalSection (&once_control->lock); + once_control->inited = 0; + initfunction (); + once_control->inited = 1; + LeaveCriticalSection (&once_control->lock); + } + else + { + /* Don't let once_control->started grow and wrap around. */ + InterlockedDecrement (&once_control->started); + /* Some other thread has already started the initialization. + Yield the CPU while waiting for the other thread to finish + initializing and taking the lock. */ + while (once_control->inited < 0) + Sleep (0); + if (once_control->inited <= 0) + { + /* Take the lock. This blocks until the other thread has + finished calling the initfunction. */ + EnterCriticalSection (&once_control->lock); + LeaveCriticalSection (&once_control->lock); + if (!(once_control->inited > 0)) + abort (); + } + } + } +} diff --git a/gnulib-lib/windows-once.h b/gnulib-lib/windows-once.h new file mode 100644 index 0000000..1599983 --- /dev/null +++ b/gnulib-lib/windows-once.h @@ -0,0 +1,47 @@ +/* Once-only control (native Windows implementation). + Copyright (C) 2005-2019 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, 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, see . */ + +/* Written by Bruno Haible , 2005. + Based on GCC's gthr-win32.h. */ + +#ifndef _WINDOWS_ONCE_H +#define _WINDOWS_ONCE_H + +#define WIN32_LEAN_AND_MEAN /* avoid including junk */ +#include + +typedef struct + { + volatile int inited; + volatile LONG started; + CRITICAL_SECTION lock; + } + glwthread_once_t; + +#define GLWTHREAD_ONCE_INIT { -1, -1 } + +#ifdef __cplusplus +extern "C" { +#endif + +extern void glwthread_once (glwthread_once_t *once_control, + void (*initfunction) (void)); + +#ifdef __cplusplus +} +#endif + +#endif /* _WINDOWS_ONCE_H */ diff --git a/gnulib-lib/windows-recmutex.c b/gnulib-lib/windows-recmutex.c new file mode 100644 index 0000000..7e6e446 --- /dev/null +++ b/gnulib-lib/windows-recmutex.c @@ -0,0 +1,127 @@ +/* Plain recursive mutexes (native Windows implementation). + Copyright (C) 2005-2019 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, 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, see . */ + +/* Written by Bruno Haible , 2005. + Based on GCC's gthr-win32.h. */ + +#include + +/* Specification. */ +#include "windows-recmutex.h" + +#include + +void +glwthread_recmutex_init (glwthread_recmutex_t *mutex) +{ + mutex->owner = 0; + mutex->depth = 0; + InitializeCriticalSection (&mutex->lock); + mutex->guard.done = 1; +} + +int +glwthread_recmutex_lock (glwthread_recmutex_t *mutex) +{ + if (!mutex->guard.done) + { + if (InterlockedIncrement (&mutex->guard.started) == 0) + /* This thread is the first one to need this mutex. Initialize it. */ + glwthread_recmutex_init (mutex); + else + { + /* Don't let mutex->guard.started grow and wrap around. */ + InterlockedDecrement (&mutex->guard.started); + /* Yield the CPU while waiting for another thread to finish + initializing this mutex. */ + while (!mutex->guard.done) + Sleep (0); + } + } + { + DWORD self = GetCurrentThreadId (); + if (mutex->owner != self) + { + EnterCriticalSection (&mutex->lock); + mutex->owner = self; + } + if (++(mutex->depth) == 0) /* wraparound? */ + { + mutex->depth--; + return EAGAIN; + } + } + return 0; +} + +int +glwthread_recmutex_trylock (glwthread_recmutex_t *mutex) +{ + if (!mutex->guard.done) + { + if (InterlockedIncrement (&mutex->guard.started) == 0) + /* This thread is the first one to need this mutex. Initialize it. */ + glwthread_recmutex_init (mutex); + else + { + /* Don't let mutex->guard.started grow and wrap around. */ + InterlockedDecrement (&mutex->guard.started); + /* Let another thread finish initializing this mutex, and let it also + lock this mutex. */ + return EBUSY; + } + } + { + DWORD self = GetCurrentThreadId (); + if (mutex->owner != self) + { + if (!TryEnterCriticalSection (&mutex->lock)) + return EBUSY; + mutex->owner = self; + } + if (++(mutex->depth) == 0) /* wraparound? */ + { + mutex->depth--; + return EAGAIN; + } + } + return 0; +} + +int +glwthread_recmutex_unlock (glwthread_recmutex_t *mutex) +{ + if (mutex->owner != GetCurrentThreadId ()) + return EPERM; + if (mutex->depth == 0) + return EINVAL; + if (--(mutex->depth) == 0) + { + mutex->owner = 0; + LeaveCriticalSection (&mutex->lock); + } + return 0; +} + +int +glwthread_recmutex_destroy (glwthread_recmutex_t *mutex) +{ + if (mutex->owner != 0) + return EBUSY; + DeleteCriticalSection (&mutex->lock); + mutex->guard.done = 0; + return 0; +} diff --git a/gnulib-lib/windows-recmutex.h b/gnulib-lib/windows-recmutex.h new file mode 100644 index 0000000..d143108 --- /dev/null +++ b/gnulib-lib/windows-recmutex.h @@ -0,0 +1,57 @@ +/* Plain recursive mutexes (native Windows implementation). + Copyright (C) 2005-2019 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, 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, see . */ + +/* Written by Bruno Haible , 2005. + Based on GCC's gthr-win32.h. */ + +#ifndef _WINDOWS_RECMUTEX_H +#define _WINDOWS_RECMUTEX_H + +#define WIN32_LEAN_AND_MEAN /* avoid including junk */ +#include + +#include "windows-initguard.h" + +/* The native Windows documentation says that CRITICAL_SECTION already + implements a recursive lock. But we need not rely on it: It's easy to + implement a recursive lock without this assumption. */ + +typedef struct + { + glwthread_initguard_t guard; /* protects the initialization */ + DWORD owner; + unsigned long depth; + CRITICAL_SECTION lock; + } + glwthread_recmutex_t; + +#define GLWTHREAD_RECMUTEX_INIT { GLWTHREAD_INITGUARD_INIT, 0, 0 } + +#ifdef __cplusplus +extern "C" { +#endif + +extern void glwthread_recmutex_init (glwthread_recmutex_t *mutex); +extern int glwthread_recmutex_lock (glwthread_recmutex_t *mutex); +extern int glwthread_recmutex_trylock (glwthread_recmutex_t *mutex); +extern int glwthread_recmutex_unlock (glwthread_recmutex_t *mutex); +extern int glwthread_recmutex_destroy (glwthread_recmutex_t *mutex); + +#ifdef __cplusplus +} +#endif + +#endif /* _WINDOWS_RECMUTEX_H */ diff --git a/gnulib-lib/windows-rwlock.c b/gnulib-lib/windows-rwlock.c new file mode 100644 index 0000000..9207d1b --- /dev/null +++ b/gnulib-lib/windows-rwlock.c @@ -0,0 +1,373 @@ +/* Read-write locks (native Windows implementation). + Copyright (C) 2005-2019 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, 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, see . */ + +/* Written by Bruno Haible , 2005. + Based on GCC's gthr-win32.h. */ + +#include + +/* Specification. */ +#include "windows-rwlock.h" + +#include +#include + +/* In this file, the waitqueues are implemented as circular arrays. */ +#define glwthread_waitqueue_t glwthread_carray_waitqueue_t + +static void +glwthread_waitqueue_init (glwthread_waitqueue_t *wq) +{ + wq->array = NULL; + wq->count = 0; + wq->alloc = 0; + wq->offset = 0; +} + +/* Enqueues the current thread, represented by an event, in a wait queue. + Returns INVALID_HANDLE_VALUE if an allocation failure occurs. */ +static HANDLE +glwthread_waitqueue_add (glwthread_waitqueue_t *wq) +{ + HANDLE event; + unsigned int index; + + if (wq->count == wq->alloc) + { + unsigned int new_alloc = 2 * wq->alloc + 1; + HANDLE *new_array = + (HANDLE *) realloc (wq->array, new_alloc * sizeof (HANDLE)); + if (new_array == NULL) + /* No more memory. */ + return INVALID_HANDLE_VALUE; + /* Now is a good opportunity to rotate the array so that its contents + starts at offset 0. */ + if (wq->offset > 0) + { + unsigned int old_count = wq->count; + unsigned int old_alloc = wq->alloc; + unsigned int old_offset = wq->offset; + unsigned int i; + if (old_offset + old_count > old_alloc) + { + unsigned int limit = old_offset + old_count - old_alloc; + for (i = 0; i < limit; i++) + new_array[old_alloc + i] = new_array[i]; + } + for (i = 0; i < old_count; i++) + new_array[i] = new_array[old_offset + i]; + wq->offset = 0; + } + wq->array = new_array; + wq->alloc = new_alloc; + } + /* Whether the created event is a manual-reset one or an auto-reset one, + does not matter, since we will wait on it only once. */ + event = CreateEvent (NULL, TRUE, FALSE, NULL); + if (event == INVALID_HANDLE_VALUE) + /* No way to allocate an event. */ + return INVALID_HANDLE_VALUE; + index = wq->offset + wq->count; + if (index >= wq->alloc) + index -= wq->alloc; + wq->array[index] = event; + wq->count++; + return event; +} + +/* Notifies the first thread from a wait queue and dequeues it. */ +static void +glwthread_waitqueue_notify_first (glwthread_waitqueue_t *wq) +{ + SetEvent (wq->array[wq->offset + 0]); + wq->offset++; + wq->count--; + if (wq->count == 0 || wq->offset == wq->alloc) + wq->offset = 0; +} + +/* Notifies all threads from a wait queue and dequeues them all. */ +static void +glwthread_waitqueue_notify_all (glwthread_waitqueue_t *wq) +{ + unsigned int i; + + for (i = 0; i < wq->count; i++) + { + unsigned int index = wq->offset + i; + if (index >= wq->alloc) + index -= wq->alloc; + SetEvent (wq->array[index]); + } + wq->count = 0; + wq->offset = 0; +} + +void +glwthread_rwlock_init (glwthread_rwlock_t *lock) +{ + InitializeCriticalSection (&lock->lock); + glwthread_waitqueue_init (&lock->waiting_readers); + glwthread_waitqueue_init (&lock->waiting_writers); + lock->runcount = 0; + lock->guard.done = 1; +} + +int +glwthread_rwlock_rdlock (glwthread_rwlock_t *lock) +{ + if (!lock->guard.done) + { + if (InterlockedIncrement (&lock->guard.started) == 0) + /* This thread is the first one to need this lock. Initialize it. */ + glwthread_rwlock_init (lock); + else + { + /* Don't let lock->guard.started grow and wrap around. */ + InterlockedDecrement (&lock->guard.started); + /* Yield the CPU while waiting for another thread to finish + initializing this lock. */ + while (!lock->guard.done) + Sleep (0); + } + } + EnterCriticalSection (&lock->lock); + /* Test whether only readers are currently running, and whether the runcount + field will not overflow, and whether no writer is waiting. The latter + condition is because POSIX recommends that "write locks shall take + precedence over read locks", to avoid "writer starvation". */ + if (!(lock->runcount + 1 > 0 && lock->waiting_writers.count == 0)) + { + /* This thread has to wait for a while. Enqueue it among the + waiting_readers. */ + HANDLE event = glwthread_waitqueue_add (&lock->waiting_readers); + if (event != INVALID_HANDLE_VALUE) + { + DWORD result; + LeaveCriticalSection (&lock->lock); + /* Wait until another thread signals this event. */ + result = WaitForSingleObject (event, INFINITE); + if (result == WAIT_FAILED || result == WAIT_TIMEOUT) + abort (); + CloseHandle (event); + /* The thread which signalled the event already did the bookkeeping: + removed us from the waiting_readers, incremented lock->runcount. */ + if (!(lock->runcount > 0)) + abort (); + return 0; + } + else + { + /* Allocation failure. Weird. */ + do + { + LeaveCriticalSection (&lock->lock); + Sleep (1); + EnterCriticalSection (&lock->lock); + } + while (!(lock->runcount + 1 > 0)); + } + } + lock->runcount++; + LeaveCriticalSection (&lock->lock); + return 0; +} + +int +glwthread_rwlock_wrlock (glwthread_rwlock_t *lock) +{ + if (!lock->guard.done) + { + if (InterlockedIncrement (&lock->guard.started) == 0) + /* This thread is the first one to need this lock. Initialize it. */ + glwthread_rwlock_init (lock); + else + { + /* Don't let lock->guard.started grow and wrap around. */ + InterlockedDecrement (&lock->guard.started); + /* Yield the CPU while waiting for another thread to finish + initializing this lock. */ + while (!lock->guard.done) + Sleep (0); + } + } + EnterCriticalSection (&lock->lock); + /* Test whether no readers or writers are currently running. */ + if (!(lock->runcount == 0)) + { + /* This thread has to wait for a while. Enqueue it among the + waiting_writers. */ + HANDLE event = glwthread_waitqueue_add (&lock->waiting_writers); + if (event != INVALID_HANDLE_VALUE) + { + DWORD result; + LeaveCriticalSection (&lock->lock); + /* Wait until another thread signals this event. */ + result = WaitForSingleObject (event, INFINITE); + if (result == WAIT_FAILED || result == WAIT_TIMEOUT) + abort (); + CloseHandle (event); + /* The thread which signalled the event already did the bookkeeping: + removed us from the waiting_writers, set lock->runcount = -1. */ + if (!(lock->runcount == -1)) + abort (); + return 0; + } + else + { + /* Allocation failure. Weird. */ + do + { + LeaveCriticalSection (&lock->lock); + Sleep (1); + EnterCriticalSection (&lock->lock); + } + while (!(lock->runcount == 0)); + } + } + lock->runcount--; /* runcount becomes -1 */ + LeaveCriticalSection (&lock->lock); + return 0; +} + +int +glwthread_rwlock_tryrdlock (glwthread_rwlock_t *lock) +{ + if (!lock->guard.done) + { + if (InterlockedIncrement (&lock->guard.started) == 0) + /* This thread is the first one to need this lock. Initialize it. */ + glwthread_rwlock_init (lock); + else + { + /* Don't let lock->guard.started grow and wrap around. */ + InterlockedDecrement (&lock->guard.started); + /* Yield the CPU while waiting for another thread to finish + initializing this lock. */ + while (!lock->guard.done) + Sleep (0); + } + } + /* It's OK to wait for this critical section, because it is never taken for a + long time. */ + EnterCriticalSection (&lock->lock); + /* Test whether only readers are currently running, and whether the runcount + field will not overflow, and whether no writer is waiting. The latter + condition is because POSIX recommends that "write locks shall take + precedence over read locks", to avoid "writer starvation". */ + if (!(lock->runcount + 1 > 0 && lock->waiting_writers.count == 0)) + { + /* This thread would have to wait for a while. Return instead. */ + LeaveCriticalSection (&lock->lock); + return EBUSY; + } + lock->runcount++; + LeaveCriticalSection (&lock->lock); + return 0; +} + +int +glwthread_rwlock_trywrlock (glwthread_rwlock_t *lock) +{ + if (!lock->guard.done) + { + if (InterlockedIncrement (&lock->guard.started) == 0) + /* This thread is the first one to need this lock. Initialize it. */ + glwthread_rwlock_init (lock); + else + { + /* Don't let lock->guard.started grow and wrap around. */ + InterlockedDecrement (&lock->guard.started); + /* Yield the CPU while waiting for another thread to finish + initializing this lock. */ + while (!lock->guard.done) + Sleep (0); + } + } + /* It's OK to wait for this critical section, because it is never taken for a + long time. */ + EnterCriticalSection (&lock->lock); + /* Test whether no readers or writers are currently running. */ + if (!(lock->runcount == 0)) + { + /* This thread would have to wait for a while. Return instead. */ + LeaveCriticalSection (&lock->lock); + return EBUSY; + } + lock->runcount--; /* runcount becomes -1 */ + LeaveCriticalSection (&lock->lock); + return 0; +} + +int +glwthread_rwlock_unlock (glwthread_rwlock_t *lock) +{ + if (!lock->guard.done) + return EINVAL; + EnterCriticalSection (&lock->lock); + if (lock->runcount < 0) + { + /* Drop a writer lock. */ + if (!(lock->runcount == -1)) + abort (); + lock->runcount = 0; + } + else + { + /* Drop a reader lock. */ + if (!(lock->runcount > 0)) + { + LeaveCriticalSection (&lock->lock); + return EPERM; + } + lock->runcount--; + } + if (lock->runcount == 0) + { + /* POSIX recommends that "write locks shall take precedence over read + locks", to avoid "writer starvation". */ + if (lock->waiting_writers.count > 0) + { + /* Wake up one of the waiting writers. */ + lock->runcount--; + glwthread_waitqueue_notify_first (&lock->waiting_writers); + } + else + { + /* Wake up all waiting readers. */ + lock->runcount += lock->waiting_readers.count; + glwthread_waitqueue_notify_all (&lock->waiting_readers); + } + } + LeaveCriticalSection (&lock->lock); + return 0; +} + +int +glwthread_rwlock_destroy (glwthread_rwlock_t *lock) +{ + if (!lock->guard.done) + return EINVAL; + if (lock->runcount != 0) + return EBUSY; + DeleteCriticalSection (&lock->lock); + if (lock->waiting_readers.array != NULL) + free (lock->waiting_readers.array); + if (lock->waiting_writers.array != NULL) + free (lock->waiting_writers.array); + lock->guard.done = 0; + return 0; +} diff --git a/gnulib-lib/windows-rwlock.h b/gnulib-lib/windows-rwlock.h new file mode 100644 index 0000000..9002040 --- /dev/null +++ b/gnulib-lib/windows-rwlock.h @@ -0,0 +1,68 @@ +/* Read-write locks (native Windows implementation). + Copyright (C) 2005-2019 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, 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, see . */ + +/* Written by Bruno Haible , 2005. + Based on GCC's gthr-win32.h. */ + +#ifndef _WINDOWS_RWLOCK_H +#define _WINDOWS_RWLOCK_H + +#define WIN32_LEAN_AND_MEAN /* avoid including junk */ +#include + +#include "windows-initguard.h" + +/* It is impossible to implement read-write locks using plain locks, without + introducing an extra thread dedicated to managing read-write locks. + Therefore here we need to use the low-level Event type. */ + +typedef struct + { + HANDLE *array; /* array of waiting threads, each represented by an event */ + unsigned int count; /* number of waiting threads */ + unsigned int alloc; /* length of allocated array */ + unsigned int offset; /* index of first waiting thread in array */ + } + glwthread_carray_waitqueue_t; +typedef struct + { + glwthread_initguard_t guard; /* protects the initialization */ + CRITICAL_SECTION lock; /* protects the remaining fields */ + glwthread_carray_waitqueue_t waiting_readers; /* waiting readers */ + glwthread_carray_waitqueue_t waiting_writers; /* waiting writers */ + int runcount; /* number of readers running, or -1 when a writer runs */ + } + glwthread_rwlock_t; + +#define GLWTHREAD_RWLOCK_INIT { GLWTHREAD_INITGUARD_INIT } + +#ifdef __cplusplus +extern "C" { +#endif + +extern void glwthread_rwlock_init (glwthread_rwlock_t *lock); +extern int glwthread_rwlock_rdlock (glwthread_rwlock_t *lock); +extern int glwthread_rwlock_wrlock (glwthread_rwlock_t *lock); +extern int glwthread_rwlock_tryrdlock (glwthread_rwlock_t *lock); +extern int glwthread_rwlock_trywrlock (glwthread_rwlock_t *lock); +extern int glwthread_rwlock_unlock (glwthread_rwlock_t *lock); +extern int glwthread_rwlock_destroy (glwthread_rwlock_t *lock); + +#ifdef __cplusplus +} +#endif + +#endif /* _WINDOWS_RWLOCK_H */ diff --git a/gnulib-m4/00gnulib.m4 b/gnulib-m4/00gnulib.m4 new file mode 100644 index 0000000..e3e0fb6 --- /dev/null +++ b/gnulib-m4/00gnulib.m4 @@ -0,0 +1,46 @@ +# 00gnulib.m4 serial 3 +dnl Copyright (C) 2009-2019 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl This file must be named something that sorts before all other +dnl gnulib-provided .m4 files. It is needed until such time as we can +dnl assume Autoconf 2.64, with its improved AC_DEFUN_ONCE and +dnl m4_divert semantics. + +# Until autoconf 2.63, handling of the diversion stack required m4_init +# to be called first; but this does not happen with aclocal. Wrapping +# the entire execution in another layer of the diversion stack fixes this. +# Worse, prior to autoconf 2.62, m4_wrap depended on the underlying m4 +# for whether it was FIFO or LIFO; in order to properly balance with +# m4_init, we need to undo our push just before anything wrapped within +# the m4_init body. The way to ensure this is to wrap both sides of +# m4_init with a one-shot macro that does the pop at the right time. +m4_ifndef([_m4_divert_diversion], +[m4_divert_push([KILL]) +m4_define([gl_divert_fixup], [m4_divert_pop()m4_define([$0])]) +m4_define([m4_init], + [gl_divert_fixup()]m4_defn([m4_init])[gl_divert_fixup()])]) + + +# AC_DEFUN_ONCE([NAME], VALUE) +# ---------------------------- +# Define NAME to expand to VALUE on the first use (whether by direct +# expansion, or by AC_REQUIRE), and to nothing on all subsequent uses. +# Avoid bugs in AC_REQUIRE in Autoconf 2.63 and earlier. This +# definition is slower than the version in Autoconf 2.64, because it +# can only use interfaces that existed since 2.59; but it achieves the +# same effect. Quoting is necessary to avoid confusing Automake. +m4_version_prereq([2.63.263], [], +[m4_define([AC][_DEFUN_ONCE], + [AC][_DEFUN([$1], + [AC_REQUIRE([_gl_DEFUN_ONCE([$1])], + [m4_indir([_gl_DEFUN_ONCE([$1])])])])]dnl +[AC][_DEFUN([_gl_DEFUN_ONCE([$1])], [$2])])]) + +# gl_00GNULIB +# ----------- +# Witness macro that this file has been included. Needed to force +# Automake to include this file prior to all other gnulib .m4 files. +AC_DEFUN([gl_00GNULIB]) diff --git a/gnulib-m4/absolute-header.m4 b/gnulib-m4/absolute-header.m4 new file mode 100644 index 0000000..a8f2cba --- /dev/null +++ b/gnulib-m4/absolute-header.m4 @@ -0,0 +1,102 @@ +# absolute-header.m4 serial 16 +dnl Copyright (C) 2006-2019 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Derek Price. + +# gl_ABSOLUTE_HEADER(HEADER1 HEADER2 ...) +# --------------------------------------- +# Find the absolute name of a header file, testing first if the header exists. +# If the header were sys/inttypes.h, this macro would define +# ABSOLUTE_SYS_INTTYPES_H to the '""' quoted absolute name of sys/inttypes.h +# in config.h +# (e.g. '#define ABSOLUTE_SYS_INTTYPES_H "///usr/include/sys/inttypes.h"'). +# The three "///" are to pacify Sun C 5.8, which otherwise would say +# "warning: #include of /usr/include/... may be non-portable". +# Use '""', not '<>', so that the /// cannot be confused with a C99 comment. +# Note: This macro assumes that the header file is not empty after +# preprocessing, i.e. it does not only define preprocessor macros but also +# provides some type/enum definitions or function/variable declarations. +AC_DEFUN([gl_ABSOLUTE_HEADER], +[AC_REQUIRE([AC_CANONICAL_HOST]) +AC_LANG_PREPROC_REQUIRE()dnl +dnl FIXME: gl_absolute_header and ac_header_exists must be used unquoted +dnl until we can assume autoconf 2.64 or newer. +m4_foreach_w([gl_HEADER_NAME], [$1], + [AS_VAR_PUSHDEF([gl_absolute_header], + [gl_cv_absolute_]m4_defn([gl_HEADER_NAME]))dnl + AC_CACHE_CHECK([absolute name of <]m4_defn([gl_HEADER_NAME])[>], + m4_defn([gl_absolute_header]), + [AS_VAR_PUSHDEF([ac_header_exists], + [ac_cv_header_]m4_defn([gl_HEADER_NAME]))dnl + AC_CHECK_HEADERS_ONCE(m4_defn([gl_HEADER_NAME]))dnl + if test AS_VAR_GET(ac_header_exists) = yes; then + gl_ABSOLUTE_HEADER_ONE(m4_defn([gl_HEADER_NAME])) + fi + AS_VAR_POPDEF([ac_header_exists])dnl + ])dnl + AC_DEFINE_UNQUOTED(AS_TR_CPP([ABSOLUTE_]m4_defn([gl_HEADER_NAME])), + ["AS_VAR_GET(gl_absolute_header)"], + [Define this to an absolute name of <]m4_defn([gl_HEADER_NAME])[>.]) + AS_VAR_POPDEF([gl_absolute_header])dnl +])dnl +])# gl_ABSOLUTE_HEADER + +# gl_ABSOLUTE_HEADER_ONE(HEADER) +# ------------------------------ +# Like gl_ABSOLUTE_HEADER, except that: +# - it assumes that the header exists, +# - it uses the current CPPFLAGS, +# - it does not cache the result, +# - it is silent. +AC_DEFUN([gl_ABSOLUTE_HEADER_ONE], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <]]m4_dquote([$1])[[>]])]) + dnl AIX "xlc -E" and "cc -E" omit #line directives for header files + dnl that contain only a #include of other header files and no + dnl non-comment tokens of their own. This leads to a failure to + dnl detect the absolute name of , , + dnl and others. The workaround is to force preservation of comments + dnl through option -C. This ensures all necessary #line directives + dnl are present. GCC supports option -C as well. + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac +changequote(,) + case "$host_os" in + mingw*) + dnl For the sake of native Windows compilers (excluding gcc), + dnl treat backslash as a directory separator, like /. + dnl Actually, these compilers use a double-backslash as + dnl directory separator, inside the + dnl # line "filename" + dnl directives. + gl_dirsep_regex='[/\\]' + ;; + *) + gl_dirsep_regex='\/' + ;; + esac + dnl A sed expression that turns a string into a basic regular + dnl expression, for use within "/.../". + gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' + gl_header_literal_regex=`echo '$1' \ + | sed -e "$gl_make_literal_regex_sed"` + gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ + s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ + s|^/[^/]|//&| + p + q + }' +changequote([,]) + dnl eval is necessary to expand gl_absname_cpp. + dnl Ultrix and Pyramid sh refuse to redirect output of eval, + dnl so use subshell. + AS_VAR_SET([gl_cv_absolute_]AS_TR_SH([[$1]]), +[`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD | + sed -n "$gl_absolute_header_sed"`]) +]) diff --git a/gnulib-m4/ansi-c++.m4 b/gnulib-m4/ansi-c++.m4 new file mode 100644 index 0000000..cc94dc6 --- /dev/null +++ b/gnulib-m4/ansi-c++.m4 @@ -0,0 +1,138 @@ +# ansi-c++.m4 serial 10 +dnl Copyright (C) 2002-2003, 2005, 2010-2019 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +# Sets CXX_CHOICE to 'yes' or 'no', depending on the preferred use of C++. +# The default is 'yes'. If the configure.ac contains a definition of the +# macro gl_CXX_CHOICE_DEFAULT_NO, then the default is 'no'. In both cases, +# the user can change the value by passing the option --disable-cxx or +# --enable-cxx, respectively. + +AC_DEFUN([gl_CXX_CHOICE], +[ + AC_MSG_CHECKING([whether to use C++]) + dnl Plus signs are supported in AC_ARG_ENABLE starting with autoconf-2.66. + m4_version_prereq([2.66], + [m4_ifdef([gl_CXX_CHOICE_DEFAULT_NO], + [AC_ARG_ENABLE([c++], + [ --enable-c++ also build C++ sources], + [CXX_CHOICE="$enableval"], + [CXX_CHOICE=no])], + [AC_ARG_ENABLE([c++], + [ --disable-c++ do not build C++ sources], + [CXX_CHOICE="$enableval"], + [CXX_CHOICE=yes])])], + [m4_ifdef([gl_CXX_CHOICE_DEFAULT_NO], + [AC_ARG_ENABLE([cxx], + [ --enable-cxx also build C++ sources], + [CXX_CHOICE="$enableval"], + [CXX_CHOICE=no])], + [AC_ARG_ENABLE([cxx], + [ --disable-cxx do not build C++ sources], + [CXX_CHOICE="$enableval"], + [CXX_CHOICE=yes])])]) + AC_MSG_RESULT([$CXX_CHOICE]) + AC_SUBST([CXX_CHOICE]) +]) + +# gl_PROG_ANSI_CXX([ANSICXX_VARIABLE], [ANSICXX_CONDITIONAL]) +# Sets ANSICXX_VARIABLE to the name of a sufficiently ANSI C++ compliant +# compiler, or to "no" if none is found. +# Defines the Automake condition ANSICXX_CONDITIONAL to true if such a compiler +# was found, or to false if not. + +AC_DEFUN([gl_PROG_ANSI_CXX], +[ + AC_REQUIRE([gl_CXX_CHOICE]) + m4_if([$1], [CXX], [], + [gl_save_CXX="$CXX"]) + if test "$CXX_CHOICE" = no; then + CXX=no + fi + if test -z "$CXX"; then + if test -n "$CCC"; then + CXX="$CCC" + else + AC_CHECK_TOOLS([CXX], + [g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC], + [:]) + fi + fi + if test "$CXX" != no; then + dnl Use a modified version of AC_PROG_CXX_WORKS that does not exit + dnl upon failure. + AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works]) + AC_LANG_PUSH([C++]) + AC_ARG_VAR([CXX], [C++ compiler command]) + AC_ARG_VAR([CXXFLAGS], [C++ compiler flags]) + echo 'int main () { return 0; }' > conftest.$ac_ext + if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then + gl_cv_prog_ansicxx_works=yes + if (./conftest; exit) 2>/dev/null; then + gl_cv_prog_ansicxx_cross=no + else + gl_cv_prog_ansicxx_cross=yes + fi + else + gl_cv_prog_ansicxx_works=no + fi + rm -fr conftest* + AC_LANG_POP([C++]) + AC_MSG_RESULT([$gl_cv_prog_ansicxx_works]) + if test $gl_cv_prog_ansicxx_works = no; then + CXX=no + else + dnl Test for namespaces. + dnl We don't bother supporting pre-ANSI-C++ compilers. + AC_MSG_CHECKING([whether the C++ compiler supports namespaces]) + AC_LANG_PUSH([C++]) + cat < conftest.$ac_ext +#include +namespace test { using namespace std; } +std::ostream* ptr; +int main () { return 0; } +EOF + if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then + gl_cv_prog_ansicxx_namespaces=yes + else + gl_cv_prog_ansicxx_namespaces=no + fi + rm -fr conftest* + AC_LANG_POP([C++]) + AC_MSG_RESULT([$gl_cv_prog_ansicxx_namespaces]) + if test $gl_cv_prog_ansicxx_namespaces = no; then + CXX=no + fi + fi + fi + m4_if([$1], [CXX], [], + [$1="$CXX" + CXX="$gl_save_CXX"]) + AC_SUBST([$1]) + + AM_CONDITIONAL([$2], [test "$$1" != no]) + + if test "$$1" != no; then + dnl This macro invocation resolves an automake error: + dnl /usr/local/share/automake-1.11/am/depend2.am: am__fastdepCXX does not appear in AM_CONDITIONAL + dnl /usr/local/share/automake-1.11/am/depend2.am: The usual way to define 'am__fastdepCXX' is to add 'AC_PROG_CXX' + dnl /usr/local/share/automake-1.11/am/depend2.am: to 'configure.ac' and run 'aclocal' and 'autoconf' again. + _AM_DEPENDENCIES([CXX]) + else + AM_CONDITIONAL([am__fastdepCXX], [false]) + fi +]) + +# gl_ANSI_CXX +# Sets CXX to the name of a sufficiently ANSI C++ compliant compiler, or to +# "no" if none is found. +# Defines the Automake condition ANSICXX to true if such a compiler was found, +# or to false if not. +AC_DEFUN([gl_ANSI_CXX], +[ + gl_PROG_ANSI_CXX([CXX], [ANSICXX]) +]) diff --git a/gnulib-m4/asm-underscore.m4 b/gnulib-m4/asm-underscore.m4 new file mode 100644 index 0000000..0f6bee4 --- /dev/null +++ b/gnulib-m4/asm-underscore.m4 @@ -0,0 +1,72 @@ +# asm-underscore.m4 serial 4 +dnl Copyright (C) 2010-2019 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. Based on as-underscore.m4 in GNU clisp. + +# gl_ASM_SYMBOL_PREFIX +# Tests for the prefix of C symbols at the assembly language level and the +# linker level. This prefix is either an underscore or empty. Defines the +# C macro USER_LABEL_PREFIX to this prefix, and sets ASM_SYMBOL_PREFIX to +# a stringified variant of this prefix. + +AC_DEFUN([gl_ASM_SYMBOL_PREFIX], +[ + AC_REQUIRE([AC_PROG_EGREP]) + dnl We don't use GCC's __USER_LABEL_PREFIX__ here, because + dnl 1. It works only for GCC. + dnl 2. It is incorrectly defined on some platforms, in some GCC versions. + AC_REQUIRE([gl_C_ASM]) + AC_CACHE_CHECK( + [whether C symbols are prefixed with underscore at the linker level], + [gl_cv_prog_as_underscore], + [cat > conftest.c </dev/null 2>&1 + if LC_ALL=C $EGREP '(^|[[^a-zA-Z0-9_]])_foo([[^a-zA-Z0-9_]]|$)' conftest.$gl_asmext >/dev/null; then + gl_cv_prog_as_underscore=yes + else + gl_cv_prog_as_underscore=no + fi + rm -f conftest* + ]) + if test $gl_cv_prog_as_underscore = yes; then + USER_LABEL_PREFIX=_ + else + USER_LABEL_PREFIX= + fi + AC_DEFINE_UNQUOTED([USER_LABEL_PREFIX], [$USER_LABEL_PREFIX], + [Define to the prefix of C symbols at the assembler and linker level, + either an underscore or empty.]) + ASM_SYMBOL_PREFIX='"'${USER_LABEL_PREFIX}'"' + AC_SUBST([ASM_SYMBOL_PREFIX]) +]) + +# gl_C_ASM +# Determines how to produce an assembly language file from C source code. +# Sets the variables: +# gl_asmext - the extension of assembly language output, +# gl_c_asm_opt - the C compiler option that produces assembly language output. + +AC_DEFUN([gl_C_ASM], +[ + AC_EGREP_CPP([MicrosoftCompiler], + [ +#ifdef _MSC_VER +MicrosoftCompiler +#endif + ], + [gl_asmext='asm' + gl_c_asm_opt='-c -Fa' + ], + [gl_asmext='s' + gl_c_asm_opt='-S' + ]) +]) diff --git a/gnulib-m4/extensions.m4 b/gnulib-m4/extensions.m4 new file mode 100644 index 0000000..fd1ce81 --- /dev/null +++ b/gnulib-m4/extensions.m4 @@ -0,0 +1,189 @@ +# serial 18 -*- Autoconf -*- +# Enable extensions on systems that normally disable them. + +# Copyright (C) 2003, 2006-2019 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from git +# Autoconf. Perhaps we can remove this once we can assume Autoconf +# 2.70 or later everywhere, but since Autoconf mutates rapidly +# enough in this area it's likely we'll need to redefine +# AC_USE_SYSTEM_EXTENSIONS for quite some time. + +# If autoconf reports a warning +# warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS +# or warning: AC_RUN_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS +# the fix is +# 1) to ensure that AC_USE_SYSTEM_EXTENSIONS is never directly invoked +# but always AC_REQUIREd, +# 2) to ensure that for each occurrence of +# AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) +# or +# AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) +# the corresponding gnulib module description has 'extensions' among +# its dependencies. This will ensure that the gl_USE_SYSTEM_EXTENSIONS +# invocation occurs in gl_EARLY, not in gl_INIT. + +# AC_USE_SYSTEM_EXTENSIONS +# ------------------------ +# Enable extensions on systems that normally disable them, +# typically due to standards-conformance issues. +# +# Remember that #undef in AH_VERBATIM gets replaced with #define by +# AC_DEFINE. The goal here is to define all known feature-enabling +# macros, then, if reports of conflicts are made, disable macros that +# cause problems on some platforms (such as __EXTENSIONS__). +AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS], +[AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl +AC_BEFORE([$0], [AC_RUN_IFELSE])dnl + + AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=]) + if test "$MINIX" = yes; then + AC_DEFINE([_POSIX_SOURCE], [1], + [Define to 1 if you need to in order for 'stat' and other + things to work.]) + AC_DEFINE([_POSIX_1_SOURCE], [2], + [Define to 2 if the system does not provide POSIX.1 features + except with this defined.]) + AC_DEFINE([_MINIX], [1], + [Define to 1 if on MINIX.]) + AC_DEFINE([_NETBSD_SOURCE], [1], + [Define to 1 to make NetBSD features available. MINIX 3 needs this.]) + fi + +dnl Use a different key than __EXTENSIONS__, as that name broke existing +dnl configure.ac when using autoheader 2.62. + AH_VERBATIM([USE_SYSTEM_EXTENSIONS], +[/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# undef _ALL_SOURCE +#endif +/* Enable general extensions on macOS. */ +#ifndef _DARWIN_C_SOURCE +# undef _DARWIN_C_SOURCE +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# undef _GNU_SOURCE +#endif +/* Enable NetBSD extensions on NetBSD. */ +#ifndef _NETBSD_SOURCE +# undef _NETBSD_SOURCE +#endif +/* Enable OpenBSD extensions on NetBSD. */ +#ifndef _OPENBSD_SOURCE +# undef _OPENBSD_SOURCE +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# undef _POSIX_PTHREAD_SEMANTICS +#endif +/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */ +#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__ +# undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__ +#endif +/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */ +#ifndef __STDC_WANT_IEC_60559_BFP_EXT__ +# undef __STDC_WANT_IEC_60559_BFP_EXT__ +#endif +/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */ +#ifndef __STDC_WANT_IEC_60559_DFP_EXT__ +# undef __STDC_WANT_IEC_60559_DFP_EXT__ +#endif +/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */ +#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__ +# undef __STDC_WANT_IEC_60559_FUNCS_EXT__ +#endif +/* Enable extensions specified by ISO/IEC TS 18661-3:2015. */ +#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__ +# undef __STDC_WANT_IEC_60559_TYPES_EXT__ +#endif +/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */ +#ifndef __STDC_WANT_LIB_EXT2__ +# undef __STDC_WANT_LIB_EXT2__ +#endif +/* Enable extensions specified by ISO/IEC 24747:2009. */ +#ifndef __STDC_WANT_MATH_SPEC_FUNCS__ +# undef __STDC_WANT_MATH_SPEC_FUNCS__ +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# undef _TANDEM_SOURCE +#endif +/* Enable X/Open extensions if necessary. HP-UX 11.11 defines + mbstate_t only if _XOPEN_SOURCE is defined to 500, regardless of + whether compiling with -Ae or -D_HPUX_SOURCE=1. */ +#ifndef _XOPEN_SOURCE +# undef _XOPEN_SOURCE +#endif +/* Enable X/Open compliant socket functions that do not require linking + with -lxnet on HP-UX 11.11. */ +#ifndef _HPUX_ALT_XOPEN_SOCKET_API +# undef _HPUX_ALT_XOPEN_SOCKET_API +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# undef __EXTENSIONS__ +#endif +]) + AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__], + [ac_cv_safe_to_define___extensions__], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ +# define __EXTENSIONS__ 1 + ]AC_INCLUDES_DEFAULT])], + [ac_cv_safe_to_define___extensions__=yes], + [ac_cv_safe_to_define___extensions__=no])]) + test $ac_cv_safe_to_define___extensions__ = yes && + AC_DEFINE([__EXTENSIONS__]) + AC_DEFINE([_ALL_SOURCE]) + AC_DEFINE([_DARWIN_C_SOURCE]) + AC_DEFINE([_GNU_SOURCE]) + AC_DEFINE([_NETBSD_SOURCE]) + AC_DEFINE([_OPENBSD_SOURCE]) + AC_DEFINE([_POSIX_PTHREAD_SEMANTICS]) + AC_DEFINE([__STDC_WANT_IEC_60559_ATTRIBS_EXT__]) + AC_DEFINE([__STDC_WANT_IEC_60559_BFP_EXT__]) + AC_DEFINE([__STDC_WANT_IEC_60559_DFP_EXT__]) + AC_DEFINE([__STDC_WANT_IEC_60559_FUNCS_EXT__]) + AC_DEFINE([__STDC_WANT_IEC_60559_TYPES_EXT__]) + AC_DEFINE([__STDC_WANT_LIB_EXT2__]) + AC_DEFINE([__STDC_WANT_MATH_SPEC_FUNCS__]) + AC_DEFINE([_TANDEM_SOURCE]) + AC_CACHE_CHECK([whether _XOPEN_SOURCE should be defined], + [ac_cv_should_define__xopen_source], + [ac_cv_should_define__xopen_source=no + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + #include + mbstate_t x;]])], + [], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + #define _XOPEN_SOURCE 500 + #include + mbstate_t x;]])], + [ac_cv_should_define__xopen_source=yes])])]) + test $ac_cv_should_define__xopen_source = yes && + AC_DEFINE([_XOPEN_SOURCE], [500]) + AC_DEFINE([_HPUX_ALT_XOPEN_SOCKET_API]) +])# AC_USE_SYSTEM_EXTENSIONS + +# gl_USE_SYSTEM_EXTENSIONS +# ------------------------ +# Enable extensions on systems that normally disable them, +# typically due to standards-conformance issues. +AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS], +[ + dnl Require this macro before AC_USE_SYSTEM_EXTENSIONS. + dnl gnulib does not need it. But if it gets required by third-party macros + dnl after AC_USE_SYSTEM_EXTENSIONS is required, autoconf 2.62..2.63 emit a + dnl warning: "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS". + dnl Note: We can do this only for one of the macros AC_AIX, AC_GNU_SOURCE, + dnl AC_MINIX. If people still use AC_AIX or AC_MINIX, they are out of luck. + AC_REQUIRE([AC_GNU_SOURCE]) + + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) +]) diff --git a/gnulib-m4/gnulib-cache.m4 b/gnulib-m4/gnulib-cache.m4 new file mode 100644 index 0000000..aab31ca --- /dev/null +++ b/gnulib-m4/gnulib-cache.m4 @@ -0,0 +1,70 @@ +# Copyright (C) 2002-2019 Free Software Foundation, Inc. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This file 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 file. If not, see . +# +# As a special exception to the GNU General Public License, +# this file may be distributed as part of a program that +# contains a configuration script generated by Autoconf, under +# the same distribution terms as the rest of that program. +# +# Generated by gnulib-tool. +# +# This file represents the specification of how gnulib-tool is used. +# It acts as a cache: It is written and read by gnulib-tool. +# In projects that use version control, this file is meant to be put under +# version control, like the configure.ac and various Makefile.am files. + + +# Specification in the form of a command-line invocation: +# gnulib-tool --import \ +# --lib=libgnu \ +# --source-base=gnulib-lib \ +# --m4-base=gnulib-m4 \ +# --doc-base=doc \ +# --tests-base=tests \ +# --aux-dir=build-aux \ +# --no-conditional-dependencies \ +# --libtool \ +# --macro-prefix=gl \ +# ansi-c++-opt \ +# host-cpu-c-abi \ +# lock \ +# longlong \ +# nocrash \ +# stdint \ +# stdnoreturn + +# Specification in the form of a few gnulib-tool.m4 macro invocations: +gl_LOCAL_DIR([]) +gl_MODULES([ + ansi-c++-opt + host-cpu-c-abi + lock + longlong + nocrash + stdint + stdnoreturn +]) +gl_AVOID([]) +gl_SOURCE_BASE([gnulib-lib]) +gl_M4_BASE([gnulib-m4]) +gl_PO_BASE([]) +gl_DOC_BASE([doc]) +gl_TESTS_BASE([tests]) +gl_LIB([libgnu]) +gl_MAKEFILE_NAME([]) +gl_LIBTOOL +gl_MACRO_PREFIX([gl]) +gl_PO_DOMAIN([]) +gl_WITNESS_C_MACRO([]) diff --git a/gnulib-m4/gnulib-common.m4 b/gnulib-m4/gnulib-common.m4 new file mode 100644 index 0000000..57b94ed --- /dev/null +++ b/gnulib-m4/gnulib-common.m4 @@ -0,0 +1,424 @@ +# gnulib-common.m4 serial 44 +dnl Copyright (C) 2007-2019 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_PREREQ([2.62]) + +# gl_COMMON +# is expanded unconditionally through gnulib-tool magic. +AC_DEFUN([gl_COMMON], [ + dnl Use AC_REQUIRE here, so that the code is expanded once only. + AC_REQUIRE([gl_00GNULIB]) + AC_REQUIRE([gl_COMMON_BODY]) +]) +AC_DEFUN([gl_COMMON_BODY], [ + AH_VERBATIM([_Noreturn], +[/* The _Noreturn keyword of C11. */ +#ifndef _Noreturn +# if (defined __cplusplus \ + && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \ + || (defined _MSC_VER && 1900 <= _MSC_VER))) +# define _Noreturn [[noreturn]] +# elif ((!defined __cplusplus || defined __clang__) \ + && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \ + || 4 < __GNUC__ + (7 <= __GNUC_MINOR__))) + /* _Noreturn works as-is. */ +# elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C +# define _Noreturn __attribute__ ((__noreturn__)) +# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0) +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn +# endif +#endif +]) + AH_VERBATIM([isoc99_inline], +[/* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports + the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of + earlier versions), but does not display it by setting __GNUC_STDC_INLINE__. + __APPLE__ && __MACH__ test for Mac OS X. + __APPLE_CC__ tests for the Apple compiler and its version. + __STDC_VERSION__ tests for the C99 mode. */ +#if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__ +# define __GNUC_STDC_INLINE__ 1 +#endif]) + AH_VERBATIM([unused_parameter], +[/* Define as a marker that can be attached to declarations that might not + be used. This helps to reduce warnings, such as from + GCC -Wunused-parameter. */ +#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) +# define _GL_UNUSED __attribute__ ((__unused__)) +#else +# define _GL_UNUSED +#endif +/* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name + is a misnomer outside of parameter lists. */ +#define _UNUSED_PARAMETER_ _GL_UNUSED + +/* gcc supports the "unused" attribute on possibly unused labels, and + g++ has since version 4.5. Note to support C++ as well as C, + _GL_UNUSED_LABEL should be used with a trailing ; */ +#if !defined __cplusplus || __GNUC__ > 4 \ + || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) +# define _GL_UNUSED_LABEL _GL_UNUSED +#else +# define _GL_UNUSED_LABEL +#endif + +/* The __pure__ attribute was added in gcc 2.96. */ +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) +# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) +#else +# define _GL_ATTRIBUTE_PURE /* empty */ +#endif + +/* The __const__ attribute was added in gcc 2.95. */ +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) +# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__)) +#else +# define _GL_ATTRIBUTE_CONST /* empty */ +#endif + +/* The __malloc__ attribute was added in gcc 3. */ +#if 3 <= __GNUC__ +# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) +#else +# define _GL_ATTRIBUTE_MALLOC /* empty */ +#endif +]) + AH_VERBATIM([async_safe], +[/* The _GL_ASYNC_SAFE marker should be attached to functions that are + signal handlers (for signals other than SIGABRT, SIGPIPE) or can be + invoked from such signal handlers. Such functions have some restrictions: + * All functions that it calls should be marked _GL_ASYNC_SAFE as well, + or should be listed as async-signal-safe in POSIX + + section 2.4.3. Note that malloc(), sprintf(), and fwrite(), in + particular, are NOT async-signal-safe. + * All memory locations (variables and struct fields) that these functions + access must be marked 'volatile'. This holds for both read and write + accesses. Otherwise the compiler might optimize away stores to and + reads from such locations that occur in the program, depending on its + data flow analysis. For example, when the program contains a loop + that is intended to inspect a variable set from within a signal handler + while (!signal_occurred) + ; + the compiler is allowed to transform this into an endless loop if the + variable 'signal_occurred' is not declared 'volatile'. + Additionally, recall that: + * A signal handler should not modify errno (except if it is a handler + for a fatal signal and ends by raising the same signal again, thus + provoking the termination of the process). If it invokes a function + that may clobber errno, it needs to save and restore the value of + errno. */ +#define _GL_ASYNC_SAFE +]) + dnl Preparation for running test programs: + dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not + dnl to /dev/tty, so they can be redirected to log files. Such diagnostics + dnl arise e.g., in the macros gl_PRINTF_DIRECTIVE_N, gl_SNPRINTF_DIRECTIVE_N. + LIBC_FATAL_STDERR_=1 + export LIBC_FATAL_STDERR_ +]) + +# gl_MODULE_INDICATOR_CONDITION +# expands to a C preprocessor expression that evaluates to 1 or 0, depending +# whether a gnulib module that has been requested shall be considered present +# or not. +m4_define([gl_MODULE_INDICATOR_CONDITION], [1]) + +# gl_MODULE_INDICATOR_SET_VARIABLE([modulename]) +# sets the shell variable that indicates the presence of the given module to +# a C preprocessor expression that will evaluate to 1. +AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE], +[ + gl_MODULE_INDICATOR_SET_VARIABLE_AUX( + [GNULIB_[]m4_translit([[$1]], + [abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])], + [gl_MODULE_INDICATOR_CONDITION]) +]) + +# gl_MODULE_INDICATOR_SET_VARIABLE_AUX([variable]) +# modifies the shell variable to include the gl_MODULE_INDICATOR_CONDITION. +# The shell variable's value is a C preprocessor expression that evaluates +# to 0 or 1. +AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE_AUX], +[ + m4_if(m4_defn([gl_MODULE_INDICATOR_CONDITION]), [1], + [ + dnl Simplify the expression VALUE || 1 to 1. + $1=1 + ], + [gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR([$1], + [gl_MODULE_INDICATOR_CONDITION])]) +]) + +# gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR([variable], [condition]) +# modifies the shell variable to include the given condition. The shell +# variable's value is a C preprocessor expression that evaluates to 0 or 1. +AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR], +[ + dnl Simplify the expression 1 || CONDITION to 1. + if test "$[]$1" != 1; then + dnl Simplify the expression 0 || CONDITION to CONDITION. + if test "$[]$1" = 0; then + $1=$2 + else + $1="($[]$1 || $2)" + fi + fi +]) + +# gl_MODULE_INDICATOR([modulename]) +# defines a C macro indicating the presence of the given module +# in a location where it can be used. +# | Value | Value | +# | in lib/ | in tests/ | +# --------------------------------------------+---------+-----------+ +# Module present among main modules: | 1 | 1 | +# --------------------------------------------+---------+-----------+ +# Module present among tests-related modules: | 0 | 1 | +# --------------------------------------------+---------+-----------+ +# Module not present at all: | 0 | 0 | +# --------------------------------------------+---------+-----------+ +AC_DEFUN([gl_MODULE_INDICATOR], +[ + AC_DEFINE_UNQUOTED([GNULIB_]m4_translit([[$1]], + [abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), + [gl_MODULE_INDICATOR_CONDITION], + [Define to a C preprocessor expression that evaluates to 1 or 0, + depending whether the gnulib module $1 shall be considered present.]) +]) + +# gl_MODULE_INDICATOR_FOR_TESTS([modulename]) +# defines a C macro indicating the presence of the given module +# in lib or tests. This is useful to determine whether the module +# should be tested. +# | Value | Value | +# | in lib/ | in tests/ | +# --------------------------------------------+---------+-----------+ +# Module present among main modules: | 1 | 1 | +# --------------------------------------------+---------+-----------+ +# Module present among tests-related modules: | 1 | 1 | +# --------------------------------------------+---------+-----------+ +# Module not present at all: | 0 | 0 | +# --------------------------------------------+---------+-----------+ +AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS], +[ + AC_DEFINE([GNULIB_TEST_]m4_translit([[$1]], + [abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), [1], + [Define to 1 when the gnulib module $1 should be tested.]) +]) + +# gl_ASSERT_NO_GNULIB_POSIXCHECK +# asserts that there will never be a need to #define GNULIB_POSIXCHECK. +# and thereby enables an optimization of configure and config.h. +# Used by Emacs. +AC_DEFUN([gl_ASSERT_NO_GNULIB_POSIXCHECK], +[ + dnl Override gl_WARN_ON_USE_PREPARE. + dnl But hide this definition from 'aclocal'. + AC_DEFUN([gl_W][ARN_ON_USE_PREPARE], []) +]) + +# gl_ASSERT_NO_GNULIB_TESTS +# asserts that there will be no gnulib tests in the scope of the configure.ac +# and thereby enables an optimization of config.h. +# Used by Emacs. +AC_DEFUN([gl_ASSERT_NO_GNULIB_TESTS], +[ + dnl Override gl_MODULE_INDICATOR_FOR_TESTS. + AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS], []) +]) + +# Test whether exists. +# Set HAVE_FEATURES_H. +AC_DEFUN([gl_FEATURES_H], +[ + AC_CHECK_HEADERS_ONCE([features.h]) + if test $ac_cv_header_features_h = yes; then + HAVE_FEATURES_H=1 + else + HAVE_FEATURES_H=0 + fi + AC_SUBST([HAVE_FEATURES_H]) +]) + +# AS_VAR_IF(VAR, VALUE, [IF-MATCH], [IF-NOT-MATCH]) +# ---------------------------------------------------- +# Backport of autoconf-2.63b's macro. +# Remove this macro when we can assume autoconf >= 2.64. +m4_ifndef([AS_VAR_IF], +[m4_define([AS_VAR_IF], +[AS_IF([test x"AS_VAR_GET([$1])" = x""$2], [$3], [$4])])]) + +# gl_PROG_CC_C99 +# Modifies the value of the shell variable CC in an attempt to make $CC +# understand ISO C99 source code. +# This is like AC_PROG_CC_C99, except that +# - AC_PROG_CC_C99 does not mix well with AC_PROG_CC_STDC +# , +# but many more packages use AC_PROG_CC_STDC than AC_PROG_CC_C99 +# . +# Remaining problems: +# - When AC_PROG_CC_STDC is invoked twice, it adds the C99 enabling options +# to CC twice +# . +# - AC_PROG_CC_STDC is likely to change now that C11 is an ISO standard. +AC_DEFUN([gl_PROG_CC_C99], +[ + dnl Change that version number to the minimum Autoconf version that supports + dnl mixing AC_PROG_CC_C99 calls with AC_PROG_CC_STDC calls. + m4_version_prereq([9.0], + [AC_REQUIRE([AC_PROG_CC_C99])], + [AC_REQUIRE([AC_PROG_CC_STDC])]) +]) + +# gl_PROG_AR_RANLIB +# Determines the values for AR, ARFLAGS, RANLIB that fit with the compiler. +# The user can set the variables AR, ARFLAGS, RANLIB if he wants to override +# the values. +AC_DEFUN([gl_PROG_AR_RANLIB], +[ + dnl Minix 3 comes with two toolchains: The Amsterdam Compiler Kit compiler + dnl as "cc", and GCC as "gcc". They have different object file formats and + dnl library formats. In particular, the GNU binutils programs ar and ranlib + dnl produce libraries that work only with gcc, not with cc. + AC_REQUIRE([AC_PROG_CC]) + dnl The '][' hides this use from 'aclocal'. + AC_BEFORE([$0], [A][M_PROG_AR]) + AC_CACHE_CHECK([for Minix Amsterdam compiler], [gl_cv_c_amsterdam_compiler], + [ + AC_EGREP_CPP([Amsterdam], + [ +#ifdef __ACK__ +Amsterdam +#endif + ], + [gl_cv_c_amsterdam_compiler=yes], + [gl_cv_c_amsterdam_compiler=no]) + ]) + + dnl Don't compete with AM_PROG_AR's decision about AR/ARFLAGS if we are not + dnl building with __ACK__. + if test $gl_cv_c_amsterdam_compiler = yes; then + if test -z "$AR"; then + AR='cc -c.a' + fi + if test -z "$ARFLAGS"; then + ARFLAGS='-o' + fi + else + dnl AM_PROG_AR was added in automake v1.11.2. AM_PROG_AR does not AC_SUBST + dnl ARFLAGS variable (it is filed into Makefile.in directly by automake + dnl script on-demand, if not specified by ./configure of course). + dnl Don't AC_REQUIRE the AM_PROG_AR otherwise the code for __ACK__ above + dnl will be ignored. Also, pay attention to call AM_PROG_AR in else block + dnl because AM_PROG_AR is written so it could re-set AR variable even for + dnl __ACK__. It may seem like its easier to avoid calling the macro here, + dnl but we need to AC_SUBST both AR/ARFLAGS (thus those must have some good + dnl default value and automake should usually know them). + dnl + dnl The '][' hides this use from 'aclocal'. + m4_ifdef([A][M_PROG_AR], [A][M_PROG_AR], [:]) + fi + + dnl In case the code above has not helped with setting AR/ARFLAGS, use + dnl Automake-documented default values for AR and ARFLAGS, but prefer + dnl ${host}-ar over ar (useful for cross-compiling). + AC_CHECK_TOOL([AR], [ar], [ar]) + if test -z "$ARFLAGS"; then + ARFLAGS='cr' + fi + + AC_SUBST([AR]) + AC_SUBST([ARFLAGS]) + if test -z "$RANLIB"; then + if test $gl_cv_c_amsterdam_compiler = yes; then + RANLIB=':' + else + dnl Use the ranlib program if it is available. + AC_PROG_RANLIB + fi + fi + AC_SUBST([RANLIB]) +]) + +# AC_C_RESTRICT +# This definition is copied from post-2.69 Autoconf and overrides the +# AC_C_RESTRICT macro from autoconf 2.60..2.69. It can be removed +# once autoconf >= 2.70 can be assumed. It's painful to check version +# numbers, and in practice this macro is more up-to-date than Autoconf +# is, so override Autoconf unconditionally. +AC_DEFUN([AC_C_RESTRICT], +[AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict], + [ac_cv_c_restrict=no + # The order here caters to the fact that C++ does not require restrict. + for ac_kw in __restrict __restrict__ _Restrict restrict; do + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[typedef int *int_ptr; + int foo (int_ptr $ac_kw ip) { return ip[0]; } + int bar (int [$ac_kw]); /* Catch GCC bug 14050. */ + int bar (int ip[$ac_kw]) { return ip[0]; } + ]], + [[int s[1]; + int *$ac_kw t = s; + t[0] = 0; + return foo (t) + bar (t); + ]])], + [ac_cv_c_restrict=$ac_kw]) + test "$ac_cv_c_restrict" != no && break + done + ]) + AH_VERBATIM([restrict], +[/* Define to the equivalent of the C99 'restrict' keyword, or to + nothing if this is not supported. Do not define if restrict is + supported directly. */ +#undef restrict +/* Work around a bug in Sun C++: it does not support _Restrict or + __restrict__, even though the corresponding Sun C compiler ends up with + "#define restrict _Restrict" or "#define restrict __restrict__" in the + previous line. Perhaps some future version of Sun C++ will work with + restrict; if so, hopefully it defines __RESTRICT like Sun C does. */ +#if defined __SUNPRO_CC && !defined __RESTRICT +# define _Restrict +# define __restrict__ +#endif]) + case $ac_cv_c_restrict in + restrict) ;; + no) AC_DEFINE([restrict], []) ;; + *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;; + esac +])# AC_C_RESTRICT + +# gl_BIGENDIAN +# is like AC_C_BIGENDIAN, except that it can be AC_REQUIREd. +# Note that AC_REQUIRE([AC_C_BIGENDIAN]) does not work reliably because some +# macros invoke AC_C_BIGENDIAN with arguments. +AC_DEFUN([gl_BIGENDIAN], +[ + AC_C_BIGENDIAN +]) + +# gl_CACHE_VAL_SILENT(cache-id, command-to-set-it) +# is like AC_CACHE_VAL(cache-id, command-to-set-it), except that it does not +# output a spurious "(cached)" mark in the midst of other configure output. +# This macro should be used instead of AC_CACHE_VAL when it is not surrounded +# by an AC_MSG_CHECKING/AC_MSG_RESULT pair. +AC_DEFUN([gl_CACHE_VAL_SILENT], +[ + saved_as_echo_n="$as_echo_n" + as_echo_n=':' + AC_CACHE_VAL([$1], [$2]) + as_echo_n="$saved_as_echo_n" +]) + +# AS_VAR_COPY was added in autoconf 2.63b +m4_define_default([AS_VAR_COPY], +[AS_LITERAL_IF([$1[]$2], [$1=$$2], [eval $1=\$$2])]) diff --git a/gnulib-m4/gnulib-comp.m4 b/gnulib-m4/gnulib-comp.m4 new file mode 100644 index 0000000..bbcb959 --- /dev/null +++ b/gnulib-m4/gnulib-comp.m4 @@ -0,0 +1,300 @@ +# DO NOT EDIT! GENERATED AUTOMATICALLY! +# Copyright (C) 2002-2019 Free Software Foundation, Inc. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This file 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 file. If not, see . +# +# As a special exception to the GNU General Public License, +# this file may be distributed as part of a program that +# contains a configuration script generated by Autoconf, under +# the same distribution terms as the rest of that program. +# +# Generated by gnulib-tool. +# +# This file represents the compiled summary of the specification in +# gnulib-cache.m4. It lists the computed macro invocations that need +# to be invoked from configure.ac. +# In projects that use version control, this file can be treated like +# other built files. + + +# This macro should be invoked from ./configure.ac, in the section +# "Checks for programs", right after AC_PROG_CC, and certainly before +# any checks for libraries, header files, types and library functions. +AC_DEFUN([gl_EARLY], +[ + m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace + m4_pattern_allow([^gl_ES$])dnl a valid locale name + m4_pattern_allow([^gl_LIBOBJS$])dnl a variable + m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable + + # Pre-early section. + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_REQUIRE([gl_PROG_AR_RANLIB]) + + AC_REQUIRE([AM_PROG_CC_C_O]) + # Code from module absolute-header: + # Code from module ansi-c++-opt: + # Code from module extensions: + # Code from module havelib: + # Code from module host-cpu-c-abi: + # Code from module include_next: + # Code from module limits-h: + # Code from module lock: + # Code from module longlong: + # Code from module multiarch: + # Code from module nocrash: + # Code from module snippet/_Noreturn: + # Code from module ssize_t: + # Code from module stdint: + # Code from module stdnoreturn: + # Code from module sys_types: + # Code from module threadlib: + gl_THREADLIB_EARLY + # Code from module windows-mutex: + # Code from module windows-once: + # Code from module windows-recmutex: + # Code from module windows-rwlock: +]) + +# This macro should be invoked from ./configure.ac, in the section +# "Check for header files, types and library functions". +AC_DEFUN([gl_INIT], +[ + AM_CONDITIONAL([GL_COND_LIBTOOL], [true]) + gl_cond_libtool=true + gl_m4_base='gnulib-m4' + m4_pushdef([AC_LIBOBJ], m4_defn([gl_LIBOBJ])) + m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gl_REPLACE_FUNCS])) + m4_pushdef([AC_LIBSOURCES], m4_defn([gl_LIBSOURCES])) + m4_pushdef([gl_LIBSOURCES_LIST], []) + m4_pushdef([gl_LIBSOURCES_DIR], []) + gl_COMMON + gl_source_base='gnulib-lib' + AC_REQUIRE([gl_ANSI_CXX]) + AC_REQUIRE([gl_HOST_CPU_C_ABI]) + gl_LIMITS_H + gl_LOCK + gl_MODULE_INDICATOR([lock]) + AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) + AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT]) + gl_MULTIARCH + gt_TYPE_SSIZE_T + gl_STDINT_H + gl_STDNORETURN_H + gl_SYS_TYPES_H + AC_PROG_MKDIR_P + AC_REQUIRE([gl_THREADLIB]) + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_os" in + mingw*) + AC_LIBOBJ([windows-mutex]) + ;; + esac + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_os" in + mingw*) + AC_LIBOBJ([windows-once]) + ;; + esac + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_os" in + mingw*) + AC_LIBOBJ([windows-recmutex]) + ;; + esac + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_os" in + mingw*) + AC_LIBOBJ([windows-rwlock]) + ;; + esac + # End of code from modules + m4_ifval(gl_LIBSOURCES_LIST, [ + m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ || + for gl_file in ]gl_LIBSOURCES_LIST[ ; do + if test ! -r ]m4_defn([gl_LIBSOURCES_DIR])[/$gl_file ; then + echo "missing file ]m4_defn([gl_LIBSOURCES_DIR])[/$gl_file" >&2 + exit 1 + fi + done])dnl + m4_if(m4_sysval, [0], [], + [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])]) + ]) + m4_popdef([gl_LIBSOURCES_DIR]) + m4_popdef([gl_LIBSOURCES_LIST]) + m4_popdef([AC_LIBSOURCES]) + m4_popdef([AC_REPLACE_FUNCS]) + m4_popdef([AC_LIBOBJ]) + AC_CONFIG_COMMANDS_PRE([ + gl_libobjs= + gl_ltlibobjs= + if test -n "$gl_LIBOBJS"; then + # Remove the extension. + sed_drop_objext='s/\.o$//;s/\.obj$//' + for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do + gl_libobjs="$gl_libobjs $i.$ac_objext" + gl_ltlibobjs="$gl_ltlibobjs $i.lo" + done + fi + AC_SUBST([gl_LIBOBJS], [$gl_libobjs]) + AC_SUBST([gl_LTLIBOBJS], [$gl_ltlibobjs]) + ]) + gltests_libdeps= + gltests_ltlibdeps= + m4_pushdef([AC_LIBOBJ], m4_defn([gltests_LIBOBJ])) + m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gltests_REPLACE_FUNCS])) + m4_pushdef([AC_LIBSOURCES], m4_defn([gltests_LIBSOURCES])) + m4_pushdef([gltests_LIBSOURCES_LIST], []) + m4_pushdef([gltests_LIBSOURCES_DIR], []) + gl_COMMON + gl_source_base='tests' +changequote(,)dnl + gltests_WITNESS=IN_`echo "${PACKAGE-$PACKAGE_TARNAME}" | LC_ALL=C tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'`_GNULIB_TESTS +changequote([, ])dnl + AC_SUBST([gltests_WITNESS]) + gl_module_indicator_condition=$gltests_WITNESS + m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$gl_module_indicator_condition]) + m4_popdef([gl_MODULE_INDICATOR_CONDITION]) + m4_ifval(gltests_LIBSOURCES_LIST, [ + m4_syscmd([test ! -d ]m4_defn([gltests_LIBSOURCES_DIR])[ || + for gl_file in ]gltests_LIBSOURCES_LIST[ ; do + if test ! -r ]m4_defn([gltests_LIBSOURCES_DIR])[/$gl_file ; then + echo "missing file ]m4_defn([gltests_LIBSOURCES_DIR])[/$gl_file" >&2 + exit 1 + fi + done])dnl + m4_if(m4_sysval, [0], [], + [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])]) + ]) + m4_popdef([gltests_LIBSOURCES_DIR]) + m4_popdef([gltests_LIBSOURCES_LIST]) + m4_popdef([AC_LIBSOURCES]) + m4_popdef([AC_REPLACE_FUNCS]) + m4_popdef([AC_LIBOBJ]) + AC_CONFIG_COMMANDS_PRE([ + gltests_libobjs= + gltests_ltlibobjs= + if test -n "$gltests_LIBOBJS"; then + # Remove the extension. + sed_drop_objext='s/\.o$//;s/\.obj$//' + for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do + gltests_libobjs="$gltests_libobjs $i.$ac_objext" + gltests_ltlibobjs="$gltests_ltlibobjs $i.lo" + done + fi + AC_SUBST([gltests_LIBOBJS], [$gltests_libobjs]) + AC_SUBST([gltests_LTLIBOBJS], [$gltests_ltlibobjs]) + ]) +]) + +# Like AC_LIBOBJ, except that the module name goes +# into gl_LIBOBJS instead of into LIBOBJS. +AC_DEFUN([gl_LIBOBJ], [ + AS_LITERAL_IF([$1], [gl_LIBSOURCES([$1.c])])dnl + gl_LIBOBJS="$gl_LIBOBJS $1.$ac_objext" +]) + +# Like AC_REPLACE_FUNCS, except that the module name goes +# into gl_LIBOBJS instead of into LIBOBJS. +AC_DEFUN([gl_REPLACE_FUNCS], [ + m4_foreach_w([gl_NAME], [$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl + AC_CHECK_FUNCS([$1], , [gl_LIBOBJ($ac_func)]) +]) + +# Like AC_LIBSOURCES, except the directory where the source file is +# expected is derived from the gnulib-tool parameterization, +# and alloca is special cased (for the alloca-opt module). +# We could also entirely rely on EXTRA_lib..._SOURCES. +AC_DEFUN([gl_LIBSOURCES], [ + m4_foreach([_gl_NAME], [$1], [ + m4_if(_gl_NAME, [alloca.c], [], [ + m4_define([gl_LIBSOURCES_DIR], [gnulib-lib]) + m4_append([gl_LIBSOURCES_LIST], _gl_NAME, [ ]) + ]) + ]) +]) + +# Like AC_LIBOBJ, except that the module name goes +# into gltests_LIBOBJS instead of into LIBOBJS. +AC_DEFUN([gltests_LIBOBJ], [ + AS_LITERAL_IF([$1], [gltests_LIBSOURCES([$1.c])])dnl + gltests_LIBOBJS="$gltests_LIBOBJS $1.$ac_objext" +]) + +# Like AC_REPLACE_FUNCS, except that the module name goes +# into gltests_LIBOBJS instead of into LIBOBJS. +AC_DEFUN([gltests_REPLACE_FUNCS], [ + m4_foreach_w([gl_NAME], [$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl + AC_CHECK_FUNCS([$1], , [gltests_LIBOBJ($ac_func)]) +]) + +# Like AC_LIBSOURCES, except the directory where the source file is +# expected is derived from the gnulib-tool parameterization, +# and alloca is special cased (for the alloca-opt module). +# We could also entirely rely on EXTRA_lib..._SOURCES. +AC_DEFUN([gltests_LIBSOURCES], [ + m4_foreach([_gl_NAME], [$1], [ + m4_if(_gl_NAME, [alloca.c], [], [ + m4_define([gltests_LIBSOURCES_DIR], [tests]) + m4_append([gltests_LIBSOURCES_LIST], _gl_NAME, [ ]) + ]) + ]) +]) + +# This macro records the list of files which have been installed by +# gnulib-tool and may be removed by future gnulib-tool invocations. +AC_DEFUN([gl_FILE_LIST], [ + build-aux/config.rpath + lib/_Noreturn.h + lib/glthread/lock.c + lib/glthread/lock.h + lib/glthread/threadlib.c + lib/limits.in.h + lib/stdint.in.h + lib/stdnoreturn.in.h + lib/sys_types.in.h + lib/windows-initguard.h + lib/windows-mutex.c + lib/windows-mutex.h + lib/windows-once.c + lib/windows-once.h + lib/windows-recmutex.c + lib/windows-recmutex.h + lib/windows-rwlock.c + lib/windows-rwlock.h + m4/00gnulib.m4 + m4/absolute-header.m4 + m4/ansi-c++.m4 + m4/asm-underscore.m4 + m4/extensions.m4 + m4/gnulib-common.m4 + m4/host-cpu-c-abi.m4 + m4/include_next.m4 + m4/lib-ld.m4 + m4/lib-link.m4 + m4/lib-prefix.m4 + m4/limits-h.m4 + m4/lock.m4 + m4/longlong.m4 + m4/multiarch.m4 + m4/nocrash.m4 + m4/off_t.m4 + m4/pthread_rwlock_rdlock.m4 + m4/ssize_t.m4 + m4/stdint.m4 + m4/stdnoreturn.m4 + m4/sys_types_h.m4 + m4/threadlib.m4 + m4/wint_t.m4 +]) diff --git a/gnulib-m4/gnulib-tool.m4 b/gnulib-m4/gnulib-tool.m4 new file mode 100644 index 0000000..98e6ade --- /dev/null +++ b/gnulib-m4/gnulib-tool.m4 @@ -0,0 +1,57 @@ +# gnulib-tool.m4 serial 2 +dnl Copyright (C) 2004-2005, 2009-2019 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl The following macros need not be invoked explicitly. +dnl Invoking them does nothing except to declare default arguments +dnl for "gnulib-tool --import". + +dnl Usage: gl_LOCAL_DIR([DIR]) +AC_DEFUN([gl_LOCAL_DIR], []) + +dnl Usage: gl_MODULES([module1 module2 ...]) +AC_DEFUN([gl_MODULES], []) + +dnl Usage: gl_AVOID([module1 module2 ...]) +AC_DEFUN([gl_AVOID], []) + +dnl Usage: gl_SOURCE_BASE([DIR]) +AC_DEFUN([gl_SOURCE_BASE], []) + +dnl Usage: gl_M4_BASE([DIR]) +AC_DEFUN([gl_M4_BASE], []) + +dnl Usage: gl_PO_BASE([DIR]) +AC_DEFUN([gl_PO_BASE], []) + +dnl Usage: gl_DOC_BASE([DIR]) +AC_DEFUN([gl_DOC_BASE], []) + +dnl Usage: gl_TESTS_BASE([DIR]) +AC_DEFUN([gl_TESTS_BASE], []) + +dnl Usage: gl_WITH_TESTS +AC_DEFUN([gl_WITH_TESTS], []) + +dnl Usage: gl_LIB([LIBNAME]) +AC_DEFUN([gl_LIB], []) + +dnl Usage: gl_LGPL or gl_LGPL([VERSION]) +AC_DEFUN([gl_LGPL], []) + +dnl Usage: gl_MAKEFILE_NAME([FILENAME]) +AC_DEFUN([gl_MAKEFILE_NAME], []) + +dnl Usage: gl_LIBTOOL +AC_DEFUN([gl_LIBTOOL], []) + +dnl Usage: gl_MACRO_PREFIX([PREFIX]) +AC_DEFUN([gl_MACRO_PREFIX], []) + +dnl Usage: gl_PO_DOMAIN([DOMAIN]) +AC_DEFUN([gl_PO_DOMAIN], []) + +dnl Usage: gl_VC_FILES([BOOLEAN]) +AC_DEFUN([gl_VC_FILES], []) diff --git a/gnulib-m4/host-cpu-c-abi.m4 b/gnulib-m4/host-cpu-c-abi.m4 new file mode 100644 index 0000000..4407296 --- /dev/null +++ b/gnulib-m4/host-cpu-c-abi.m4 @@ -0,0 +1,644 @@ +# host-cpu-c-abi.m4 serial 11 +dnl Copyright (C) 2002-2019 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible and Sam Steingold. + +dnl Sets the HOST_CPU variable to the canonical name of the CPU. +dnl Sets the HOST_CPU_C_ABI variable to the canonical name of the CPU with its +dnl C language ABI (application binary interface). +dnl Also defines __${HOST_CPU}__ and __${HOST_CPU_C_ABI}__ as C macros in +dnl config.h. +dnl +dnl This canonical name can be used to select a particular assembly language +dnl source file that will interoperate with C code on the given host. +dnl +dnl For example: +dnl * 'i386' and 'sparc' are different canonical names, because code for i386 +dnl will not run on SPARC CPUs and vice versa. They have different +dnl instruction sets. +dnl * 'sparc' and 'sparc64' are different canonical names, because code for +dnl 'sparc' and code for 'sparc64' cannot be linked together: 'sparc' code +dnl contains 32-bit instructions, whereas 'sparc64' code contains 64-bit +dnl instructions. A process on a SPARC CPU can be in 32-bit mode or in 64-bit +dnl mode, but not both. +dnl * 'mips' and 'mipsn32' are different canonical names, because they use +dnl different argument passing and return conventions for C functions, and +dnl although the instruction set of 'mips' is a large subset of the +dnl instruction set of 'mipsn32'. +dnl * 'mipsn32' and 'mips64' are different canonical names, because they use +dnl different sizes for the C types like 'int' and 'void *', and although +dnl the instruction sets of 'mipsn32' and 'mips64' are the same. +dnl * The same canonical name is used for different endiannesses. You can +dnl determine the endianness through preprocessor symbols: +dnl - 'arm': test __ARMEL__. +dnl - 'mips', 'mipsn32', 'mips64': test _MIPSEB vs. _MIPSEL. +dnl - 'powerpc64': test _BIG_ENDIAN vs. _LITTLE_ENDIAN. +dnl * The same name 'i386' is used for CPUs of type i386, i486, i586 +dnl (Pentium), AMD K7, Pentium II, Pentium IV, etc., because +dnl - Instructions that do not exist on all of these CPUs (cmpxchg, +dnl MMX, SSE, SSE2, 3DNow! etc.) are not frequently used. If your +dnl assembly language source files use such instructions, you will +dnl need to make the distinction. +dnl - Speed of execution of the common instruction set is reasonable across +dnl the entire family of CPUs. If you have assembly language source files +dnl that are optimized for particular CPU types (like GNU gmp has), you +dnl will need to make the distinction. +dnl See . +AC_DEFUN([gl_HOST_CPU_C_ABI], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([gl_C_ASM]) + AC_CACHE_CHECK([host CPU and C ABI], [gl_cv_host_cpu_c_abi], + [case "$host_cpu" in + +changequote(,)dnl + i[4567]86 ) +changequote([,])dnl + gl_cv_host_cpu_c_abi=i386 + ;; + + x86_64 ) + # On x86_64 systems, the C compiler may be generating code in one of + # these ABIs: + # - 64-bit instruction set, 64-bit pointers, 64-bit 'long': x86_64. + # - 64-bit instruction set, 64-bit pointers, 32-bit 'long': x86_64 + # with native Windows (mingw, MSVC). + # - 64-bit instruction set, 32-bit pointers, 32-bit 'long': x86_64-x32. + # - 32-bit instruction set, 32-bit pointers, 32-bit 'long': i386. + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if (defined __x86_64__ || defined __amd64__ \ + || defined _M_X64 || defined _M_AMD64) + int ok; + #else + error fail + #endif + ]])], + [AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if defined __ILP32__ || defined _ILP32 + int ok; + #else + error fail + #endif + ]])], + [gl_cv_host_cpu_c_abi=x86_64-x32], + [gl_cv_host_cpu_c_abi=x86_64])], + [gl_cv_host_cpu_c_abi=i386]) + ;; + +changequote(,)dnl + alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] ) +changequote([,])dnl + gl_cv_host_cpu_c_abi=alpha + ;; + + arm* | aarch64 ) + # Assume arm with EABI. + # On arm64 systems, the C compiler may be generating code in one of + # these ABIs: + # - aarch64 instruction set, 64-bit pointers, 64-bit 'long': arm64. + # - aarch64 instruction set, 32-bit pointers, 32-bit 'long': arm64-ilp32. + # - 32-bit instruction set, 32-bit pointers, 32-bit 'long': arm or armhf. + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#ifdef __aarch64__ + int ok; + #else + error fail + #endif + ]])], + [AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if defined __ILP32__ || defined _ILP32 + int ok; + #else + error fail + #endif + ]])], + [gl_cv_host_cpu_c_abi=arm64-ilp32], + [gl_cv_host_cpu_c_abi=arm64])], + [# Don't distinguish little-endian and big-endian arm, since they + # don't require different machine code for simple operations and + # since the user can distinguish them through the preprocessor + # defines __ARMEL__ vs. __ARMEB__. + # But distinguish arm which passes floating-point arguments and + # return values in integer registers (r0, r1, ...) - this is + # gcc -mfloat-abi=soft or gcc -mfloat-abi=softfp - from arm which + # passes them in float registers (s0, s1, ...) and double registers + # (d0, d1, ...) - this is gcc -mfloat-abi=hard. GCC 4.6 or newer + # sets the preprocessor defines __ARM_PCS (for the first case) and + # __ARM_PCS_VFP (for the second case), but older GCC does not. + echo 'double ddd; void func (double dd) { ddd = dd; }' > conftest.c + # Look for a reference to the register d0 in the .s file. + AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS $gl_c_asm_opt conftest.c) >/dev/null 2>&1 + if LC_ALL=C grep 'd0,' conftest.$gl_asmext >/dev/null; then + gl_cv_host_cpu_c_abi=armhf + else + gl_cv_host_cpu_c_abi=arm + fi + rm -f conftest* + ]) + ;; + + hppa1.0 | hppa1.1 | hppa2.0* | hppa64 ) + # On hppa, the C compiler may be generating 32-bit code or 64-bit + # code. In the latter case, it defines _LP64 and __LP64__. + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#ifdef __LP64__ + int ok; + #else + error fail + #endif + ]])], + [gl_cv_host_cpu_c_abi=hppa64], + [gl_cv_host_cpu_c_abi=hppa]) + ;; + + ia64* ) + # On ia64 on HP-UX, the C compiler may be generating 64-bit code or + # 32-bit code. In the latter case, it defines _ILP32. + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#ifdef _ILP32 + int ok; + #else + error fail + #endif + ]])], + [gl_cv_host_cpu_c_abi=ia64-ilp32], + [gl_cv_host_cpu_c_abi=ia64]) + ;; + + mips* ) + # We should also check for (_MIPS_SZPTR == 64), but gcc keeps this + # at 32. + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if defined _MIPS_SZLONG && (_MIPS_SZLONG == 64) + int ok; + #else + error fail + #endif + ]])], + [gl_cv_host_cpu_c_abi=mips64], + [# In the n32 ABI, _ABIN32 is defined, _ABIO32 is not defined (but + # may later get defined by ), and _MIPS_SIM == _ABIN32. + # In the 32 ABI, _ABIO32 is defined, _ABIN32 is not defined (but + # may later get defined by ), and _MIPS_SIM == _ABIO32. + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if (_MIPS_SIM == _ABIN32) + int ok; + #else + error fail + #endif + ]])], + [gl_cv_host_cpu_c_abi=mipsn32], + [gl_cv_host_cpu_c_abi=mips])]) + ;; + + powerpc* ) + # Different ABIs are in use on AIX vs. Mac OS X vs. Linux,*BSD. + # No need to distinguish them here; the caller may distinguish + # them based on the OS. + # On powerpc64 systems, the C compiler may still be generating + # 32-bit code. And on powerpc-ibm-aix systems, the C compiler may + # be generating 64-bit code. + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if defined __powerpc64__ || defined _ARCH_PPC64 + int ok; + #else + error fail + #endif + ]])], + [# On powerpc64, there are two ABIs on Linux: The AIX compatible + # one and the ELFv2 one. The latter defines _CALL_ELF=2. + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if defined _CALL_ELF && _CALL_ELF == 2 + int ok; + #else + error fail + #endif + ]])], + [gl_cv_host_cpu_c_abi=powerpc64-elfv2], + [gl_cv_host_cpu_c_abi=powerpc64]) + ], + [gl_cv_host_cpu_c_abi=powerpc]) + ;; + + rs6000 ) + gl_cv_host_cpu_c_abi=powerpc + ;; + + riscv32 | riscv64 ) + # There are 2 architectures (with variants): rv32* and rv64*. + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if __riscv_xlen == 64 + int ok; + #else + error fail + #endif + ]])], + [cpu=riscv64], + [cpu=riscv32]) + # There are 6 ABIs: ilp32, ilp32f, ilp32d, lp64, lp64f, lp64d. + # Size of 'long' and 'void *': + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if defined __LP64__ + int ok; + #else + error fail + #endif + ]])], + [main_abi=lp64], + [main_abi=ilp32]) + # Float ABIs: + # __riscv_float_abi_double: + # 'float' and 'double' are passed in floating-point registers. + # __riscv_float_abi_single: + # 'float' are passed in floating-point registers. + # __riscv_float_abi_soft: + # No values are passed in floating-point registers. + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if defined __riscv_float_abi_double + int ok; + #else + error fail + #endif + ]])], + [float_abi=d], + [AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if defined __riscv_float_abi_single + int ok; + #else + error fail + #endif + ]])], + [float_abi=f], + [float_abi='']) + ]) + gl_cv_host_cpu_c_abi="${cpu}-${main_abi}${float_abi}" + ;; + + s390* ) + # On s390x, the C compiler may be generating 64-bit (= s390x) code + # or 31-bit (= s390) code. + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if defined __LP64__ || defined __s390x__ + int ok; + #else + error fail + #endif + ]])], + [gl_cv_host_cpu_c_abi=s390x], + [gl_cv_host_cpu_c_abi=s390]) + ;; + + sparc | sparc64 ) + # UltraSPARCs running Linux have `uname -m` = "sparc64", but the + # C compiler still generates 32-bit code. + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if defined __sparcv9 || defined __arch64__ + int ok; + #else + error fail + #endif + ]])], + [gl_cv_host_cpu_c_abi=sparc64], + [gl_cv_host_cpu_c_abi=sparc]) + ;; + + *) + gl_cv_host_cpu_c_abi="$host_cpu" + ;; + esac + ]) + + dnl In most cases, $HOST_CPU and $HOST_CPU_C_ABI are the same. + HOST_CPU=`echo "$gl_cv_host_cpu_c_abi" | sed -e 's/-.*//'` + HOST_CPU_C_ABI="$gl_cv_host_cpu_c_abi" + AC_SUBST([HOST_CPU]) + AC_SUBST([HOST_CPU_C_ABI]) + + # This was + # AC_DEFINE_UNQUOTED([__${HOST_CPU}__]) + # AC_DEFINE_UNQUOTED([__${HOST_CPU_C_ABI}__]) + # earlier, but KAI C++ 3.2d doesn't like this. + sed -e 's/-/_/g' >> confdefs.h <. + dnl Additionally, with this same compiler, include_next is a no-op when + dnl used in a header file that was included by specifying its absolute + dnl file name. Despite these two bugs, include_next is used in the + dnl compiler's . By virtue of the second bug, we need to use + dnl include_next as well in this case. + cat < conftestd1a/conftest.h +#define DEFINED_IN_CONFTESTD1 +#include_next +#ifdef DEFINED_IN_CONFTESTD2 +int foo; +#else +#error "include_next doesn't work" +#endif +EOF + cat < conftestd1b/conftest.h +#define DEFINED_IN_CONFTESTD1 +#include +#include_next +#ifdef DEFINED_IN_CONFTESTD2 +int foo; +#else +#error "include_next doesn't work" +#endif +EOF + cat < conftestd2/conftest.h +#ifndef DEFINED_IN_CONFTESTD1 +#error "include_next test doesn't work" +#endif +#define DEFINED_IN_CONFTESTD2 +EOF + gl_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2" +dnl We intentionally avoid using AC_LANG_SOURCE here. + AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include ]], + [gl_cv_have_include_next=yes], + [CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2" + AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include ]], + [gl_cv_have_include_next=buggy], + [gl_cv_have_include_next=no]) + ]) + CPPFLAGS="$gl_save_CPPFLAGS" + rm -rf conftestd1a conftestd1b conftestd2 + ]) + PRAGMA_SYSTEM_HEADER= + if test $gl_cv_have_include_next = yes; then + INCLUDE_NEXT=include_next + INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next + if test -n "$GCC"; then + PRAGMA_SYSTEM_HEADER='#pragma GCC system_header' + fi + else + if test $gl_cv_have_include_next = buggy; then + INCLUDE_NEXT=include + INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next + else + INCLUDE_NEXT=include + INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include + fi + fi + AC_SUBST([INCLUDE_NEXT]) + AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE]) + AC_SUBST([PRAGMA_SYSTEM_HEADER]) + AC_CACHE_CHECK([whether system header files limit the line length], + [gl_cv_pragma_columns], + [dnl HP NonStop systems, which define __TANDEM, have this misfeature. + AC_EGREP_CPP([choke me], + [ +#ifdef __TANDEM +choke me +#endif + ], + [gl_cv_pragma_columns=yes], + [gl_cv_pragma_columns=no]) + ]) + if test $gl_cv_pragma_columns = yes; then + PRAGMA_COLUMNS="#pragma COLUMNS 10000" + else + PRAGMA_COLUMNS= + fi + AC_SUBST([PRAGMA_COLUMNS]) +]) + +# gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...) +# ------------------------------------------ +# For each arg foo.h, if #include_next works, define NEXT_FOO_H to be +# ''; otherwise define it to be +# '"///usr/include/foo.h"', or whatever other absolute file name is suitable. +# Also, if #include_next works as first preprocessing directive in a file, +# define NEXT_AS_FIRST_DIRECTIVE_FOO_H to be ''; otherwise define it to +# be +# '"///usr/include/foo.h"', or whatever other absolute file name is suitable. +# That way, a header file with the following line: +# #@INCLUDE_NEXT@ @NEXT_FOO_H@ +# or +# #@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_FOO_H@ +# behaves (after sed substitution) as if it contained +# #include_next +# even if the compiler does not support include_next. +# The three "///" are to pacify Sun C 5.8, which otherwise would say +# "warning: #include of /usr/include/... may be non-portable". +# Use '""', not '<>', so that the /// cannot be confused with a C99 comment. +# Note: This macro assumes that the header file is not empty after +# preprocessing, i.e. it does not only define preprocessor macros but also +# provides some type/enum definitions or function/variable declarations. +# +# This macro also checks whether each header exists, by invoking +# AC_CHECK_HEADERS_ONCE or AC_CHECK_HEADERS on each argument. +AC_DEFUN([gl_CHECK_NEXT_HEADERS], +[ + gl_NEXT_HEADERS_INTERNAL([$1], [check]) +]) + +# gl_NEXT_HEADERS(HEADER1 HEADER2 ...) +# ------------------------------------ +# Like gl_CHECK_NEXT_HEADERS, except do not check whether the headers exist. +# This is suitable for headers like that are standardized by C89 +# and therefore can be assumed to exist. +AC_DEFUN([gl_NEXT_HEADERS], +[ + gl_NEXT_HEADERS_INTERNAL([$1], [assume]) +]) + +# The guts of gl_CHECK_NEXT_HEADERS and gl_NEXT_HEADERS. +AC_DEFUN([gl_NEXT_HEADERS_INTERNAL], +[ + AC_REQUIRE([gl_INCLUDE_NEXT]) + AC_REQUIRE([AC_CANONICAL_HOST]) + + m4_if([$2], [check], + [AC_CHECK_HEADERS_ONCE([$1]) + ]) + +dnl FIXME: gl_next_header and gl_header_exists must be used unquoted +dnl until we can assume autoconf 2.64 or newer. + m4_foreach_w([gl_HEADER_NAME], [$1], + [AS_VAR_PUSHDEF([gl_next_header], + [gl_cv_next_]m4_defn([gl_HEADER_NAME])) + if test $gl_cv_have_include_next = yes; then + AS_VAR_SET(gl_next_header, ['<'gl_HEADER_NAME'>']) + else + AC_CACHE_CHECK( + [absolute name of <]m4_defn([gl_HEADER_NAME])[>], + m4_defn([gl_next_header]), + [m4_if([$2], [check], + [AS_VAR_PUSHDEF([gl_header_exists], + [ac_cv_header_]m4_defn([gl_HEADER_NAME])) + if test AS_VAR_GET(gl_header_exists) = yes; then + AS_VAR_POPDEF([gl_header_exists]) + ]) + gl_ABSOLUTE_HEADER_ONE(gl_HEADER_NAME) + AS_VAR_COPY([gl_header], [gl_cv_absolute_]AS_TR_SH(gl_HEADER_NAME)) + AS_VAR_SET(gl_next_header, ['"'$gl_header'"']) + m4_if([$2], [check], + [else + AS_VAR_SET(gl_next_header, ['<'gl_HEADER_NAME'>']) + fi + ]) + ]) + fi + AC_SUBST( + AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])), + [AS_VAR_GET(gl_next_header)]) + if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then + # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' + gl_next_as_first_directive='<'gl_HEADER_NAME'>' + else + # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' + gl_next_as_first_directive=AS_VAR_GET(gl_next_header) + fi + AC_SUBST( + AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])), + [$gl_next_as_first_directive]) + AS_VAR_POPDEF([gl_next_header])]) +]) + +# Autoconf 2.68 added warnings for our use of AC_COMPILE_IFELSE; +# this fallback is safe for all earlier autoconf versions. +m4_define_default([AC_LANG_DEFINES_PROVIDED]) diff --git a/gnulib-m4/lib-ld.m4 b/gnulib-m4/lib-ld.m4 new file mode 100644 index 0000000..a187196 --- /dev/null +++ b/gnulib-m4/lib-ld.m4 @@ -0,0 +1,168 @@ +# lib-ld.m4 serial 9 +dnl Copyright (C) 1996-2003, 2009-2019 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Subroutines of libtool.m4, +dnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid +dnl collision with libtool.m4. + +dnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no. +AC_DEFUN([AC_LIB_PROG_LD_GNU], +[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld], +[# I'd rather use --version here, but apparently some GNU lds only accept -v. +case `$LD -v 2>&1 /dev/null 2>&1 \ + && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ + || PATH_SEPARATOR=';' + } +fi + +if test -n "$LD"; then + AC_MSG_CHECKING([for ld]) +elif test "$GCC" = yes; then + AC_MSG_CHECKING([for ld used by $CC]) +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +if test -n "$LD"; then + # Let the user override the test with a path. + : +else + AC_CACHE_VAL([acl_cv_path_LD], + [ + acl_cv_path_LD= # Final result of this test + ac_prog=ld # Program to search in $PATH + if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + acl_output=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + acl_output=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $acl_output in + # Accept absolute paths. + [[\\/]]* | ?:[[\\/]]*) + re_direlt='/[[^/]][[^/]]*/\.\./' + # Canonicalize the pathname of ld + acl_output=`echo "$acl_output" | sed 's%\\\\%/%g'` + while echo "$acl_output" | grep "$re_direlt" > /dev/null 2>&1; do + acl_output=`echo $acl_output | sed "s%$re_direlt%/%"` + done + # Got the pathname. No search in PATH is needed. + acl_cv_path_LD="$acl_output" + ac_prog= + ;; + "") + # If it fails, then pretend we aren't using GCC. + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac + fi + if test -n "$ac_prog"; then + # Search for $ac_prog in $PATH. + acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$acl_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + acl_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$acl_cv_path_LD" -v 2>&1 conftest.sh + . ./conftest.sh + rm -f ./conftest.sh + acl_cv_rpath=done + ]) + wl="$acl_cv_wl" + acl_libext="$acl_cv_libext" + acl_shlibext="$acl_cv_shlibext" + acl_libname_spec="$acl_cv_libname_spec" + acl_library_names_spec="$acl_cv_library_names_spec" + acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" + acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" + acl_hardcode_direct="$acl_cv_hardcode_direct" + acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" + dnl Determine whether the user wants rpath handling at all. + AC_ARG_ENABLE([rpath], + [ --disable-rpath do not hardcode runtime library paths], + :, enable_rpath=yes) +]) + +dnl AC_LIB_FROMPACKAGE(name, package) +dnl declares that libname comes from the given package. The configure file +dnl will then not have a --with-libname-prefix option but a +dnl --with-package-prefix option. Several libraries can come from the same +dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar +dnl macro call that searches for libname. +AC_DEFUN([AC_LIB_FROMPACKAGE], +[ + pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) + define([acl_frompackage_]NAME, [$2]) + popdef([NAME]) + pushdef([PACK],[$2]) + pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) + define([acl_libsinpackage_]PACKUP, + m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1]) + popdef([PACKUP]) + popdef([PACK]) +]) + +dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and +dnl the libraries corresponding to explicit and implicit dependencies. +dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. +dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found +dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem. +AC_DEFUN([AC_LIB_LINKFLAGS_BODY], +[ + AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) + pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) + pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])]) + pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) + pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])]) + dnl By default, look in $includedir and $libdir. + use_additional=yes + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + AC_ARG_WITH(PACK[-prefix], +[[ --with-]]PACK[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib + --without-]]PACK[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]], +[ + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + else + additional_includedir="$withval/include" + additional_libdir="$withval/$acl_libdirstem" + if test "$acl_libdirstem2" != "$acl_libdirstem" \ + && test ! -d "$withval/$acl_libdirstem"; then + additional_libdir="$withval/$acl_libdirstem2" + fi + fi + fi +]) + dnl Search the library and its dependencies in $additional_libdir and + dnl $LDFLAGS. Using breadth-first-seach. + LIB[]NAME= + LTLIB[]NAME= + INC[]NAME= + LIB[]NAME[]_PREFIX= + dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been + dnl computed. So it has to be reset here. + HAVE_LIB[]NAME= + rpathdirs= + ltrpathdirs= + names_already_handled= + names_next_round='$1 $2' + while test -n "$names_next_round"; do + names_this_round="$names_next_round" + names_next_round= + for name in $names_this_round; do + already_handled= + for n in $names_already_handled; do + if test "$n" = "$name"; then + already_handled=yes + break + fi + done + if test -z "$already_handled"; then + names_already_handled="$names_already_handled $name" + dnl See if it was already located by an earlier AC_LIB_LINKFLAGS + dnl or AC_LIB_HAVE_LINKFLAGS call. + uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'` + eval value=\"\$HAVE_LIB$uppername\" + if test -n "$value"; then + if test "$value" = yes; then + eval value=\"\$LIB$uppername\" + test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value" + eval value=\"\$LTLIB$uppername\" + test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value" + else + dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined + dnl that this library doesn't exist. So just drop it. + : + fi + else + dnl Search the library lib$name in $additional_libdir and $LDFLAGS + dnl and the already constructed $LIBNAME/$LTLIBNAME. + found_dir= + found_la= + found_so= + found_a= + eval libname=\"$acl_libname_spec\" # typically: libname=lib$name + if test -n "$acl_shlibext"; then + shrext=".$acl_shlibext" # typically: shrext=.so + else + shrext= + fi + if test $use_additional = yes; then + dir="$additional_libdir" + dnl The same code as in the loop below: + dnl First look for a shared library. + if test -n "$acl_shlibext"; then + if test -f "$dir/$libname$shrext"; then + found_dir="$dir" + found_so="$dir/$libname$shrext" + else + if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then + ver=`(cd "$dir" && \ + for f in "$libname$shrext".*; do echo "$f"; done \ + | sed -e "s,^$libname$shrext\\\\.,," \ + | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ + | sed 1q ) 2>/dev/null` + if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then + found_dir="$dir" + found_so="$dir/$libname$shrext.$ver" + fi + else + eval library_names=\"$acl_library_names_spec\" + for f in $library_names; do + if test -f "$dir/$f"; then + found_dir="$dir" + found_so="$dir/$f" + break + fi + done + fi + fi + fi + dnl Then look for a static library. + if test "X$found_dir" = "X"; then + if test -f "$dir/$libname.$acl_libext"; then + found_dir="$dir" + found_a="$dir/$libname.$acl_libext" + fi + fi + if test "X$found_dir" != "X"; then + if test -f "$dir/$libname.la"; then + found_la="$dir/$libname.la" + fi + fi + fi + if test "X$found_dir" = "X"; then + for x in $LDFLAGS $LTLIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + case "$x" in + -L*) + dir=`echo "X$x" | sed -e 's/^X-L//'` + dnl First look for a shared library. + if test -n "$acl_shlibext"; then + if test -f "$dir/$libname$shrext"; then + found_dir="$dir" + found_so="$dir/$libname$shrext" + else + if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then + ver=`(cd "$dir" && \ + for f in "$libname$shrext".*; do echo "$f"; done \ + | sed -e "s,^$libname$shrext\\\\.,," \ + | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ + | sed 1q ) 2>/dev/null` + if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then + found_dir="$dir" + found_so="$dir/$libname$shrext.$ver" + fi + else + eval library_names=\"$acl_library_names_spec\" + for f in $library_names; do + if test -f "$dir/$f"; then + found_dir="$dir" + found_so="$dir/$f" + break + fi + done + fi + fi + fi + dnl Then look for a static library. + if test "X$found_dir" = "X"; then + if test -f "$dir/$libname.$acl_libext"; then + found_dir="$dir" + found_a="$dir/$libname.$acl_libext" + fi + fi + if test "X$found_dir" != "X"; then + if test -f "$dir/$libname.la"; then + found_la="$dir/$libname.la" + fi + fi + ;; + esac + if test "X$found_dir" != "X"; then + break + fi + done + fi + if test "X$found_dir" != "X"; then + dnl Found the library. + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name" + if test "X$found_so" != "X"; then + dnl Linking with a shared library. We attempt to hardcode its + dnl directory into the executable's runpath, unless it's the + dnl standard /usr/lib. + if test "$enable_rpath" = no \ + || test "X$found_dir" = "X/usr/$acl_libdirstem" \ + || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then + dnl No hardcoding is needed. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + dnl Use an explicit option to hardcode DIR into the resulting + dnl binary. + dnl Potentially add DIR to ltrpathdirs. + dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $found_dir" + fi + dnl The hardcoding into $LIBNAME is system dependent. + if test "$acl_hardcode_direct" = yes; then + dnl Using DIR/libNAME.so during linking hardcodes DIR into the + dnl resulting binary. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then + dnl Use an explicit option to hardcode DIR into the resulting + dnl binary. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + dnl Potentially add DIR to rpathdirs. + dnl The rpathdirs will be appended to $LIBNAME at the end. + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $found_dir" + fi + else + dnl Rely on "-L$found_dir". + dnl But don't add it if it's already contained in the LDFLAGS + dnl or the already constructed $LIBNAME + haveit= + for x in $LDFLAGS $LIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" + fi + if test "$acl_hardcode_minus_L" != no; then + dnl FIXME: Not sure whether we should use + dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" + dnl here. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH + dnl here, because this doesn't fit in flags passed to the + dnl compiler. So give up. No hardcoding. This affects only + dnl very old systems. + dnl FIXME: Not sure whether we should use + dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" + dnl here. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" + fi + fi + fi + fi + else + if test "X$found_a" != "X"; then + dnl Linking with a static library. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a" + else + dnl We shouldn't come here, but anyway it's good to have a + dnl fallback. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name" + fi + fi + dnl Assume the include files are nearby. + additional_includedir= + case "$found_dir" in + */$acl_libdirstem | */$acl_libdirstem/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` + if test "$name" = '$1'; then + LIB[]NAME[]_PREFIX="$basedir" + fi + additional_includedir="$basedir/include" + ;; + */$acl_libdirstem2 | */$acl_libdirstem2/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` + if test "$name" = '$1'; then + LIB[]NAME[]_PREFIX="$basedir" + fi + additional_includedir="$basedir/include" + ;; + esac + if test "X$additional_includedir" != "X"; then + dnl Potentially add $additional_includedir to $INCNAME. + dnl But don't add it + dnl 1. if it's the standard /usr/include, + dnl 2. if it's /usr/local/include and we are using GCC on Linux, + dnl 3. if it's already present in $CPPFLAGS or the already + dnl constructed $INCNAME, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + for x in $CPPFLAGS $INC[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + dnl Really add $additional_includedir to $INCNAME. + INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir" + fi + fi + fi + fi + fi + dnl Look for dependencies. + if test -n "$found_la"; then + dnl Read the .la file. It defines the variables + dnl dlname, library_names, old_library, dependency_libs, current, + dnl age, revision, installed, dlopen, dlpreopen, libdir. + save_libdir="$libdir" + case "$found_la" in + */* | *\\*) . "$found_la" ;; + *) . "./$found_la" ;; + esac + libdir="$save_libdir" + dnl We use only dependency_libs. + for dep in $dependency_libs; do + case "$dep" in + -L*) + additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` + dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME. + dnl But don't add it + dnl 1. if it's the standard /usr/lib, + dnl 2. if it's /usr/local/lib and we are using GCC on Linux, + dnl 3. if it's already present in $LDFLAGS or the already + dnl constructed $LIBNAME, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ + && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then + haveit= + if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ + || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + haveit= + for x in $LDFLAGS $LIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LIBNAME. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir" + fi + fi + haveit= + for x in $LDFLAGS $LTLIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LTLIBNAME. + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir" + fi + fi + fi + fi + ;; + -R*) + dir=`echo "X$dep" | sed -e 's/^X-R//'` + if test "$enable_rpath" != no; then + dnl Potentially add DIR to rpathdirs. + dnl The rpathdirs will be appended to $LIBNAME at the end. + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $dir" + fi + dnl Potentially add DIR to ltrpathdirs. + dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $dir" + fi + fi + ;; + -l*) + dnl Handle this in the next round. + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` + ;; + *.la) + dnl Handle this in the next round. Throw away the .la's + dnl directory; it is already contained in a preceding -L + dnl option. + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` + ;; + *) + dnl Most likely an immediate library name. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep" + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep" + ;; + esac + done + fi + else + dnl Didn't find the library; assume it is in the system directories + dnl known to the linker and runtime loader. (All the system + dnl directories known to the linker should also be known to the + dnl runtime loader, otherwise the system is severely misconfigured.) + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" + fi + fi + fi + done + done + if test "X$rpathdirs" != "X"; then + if test -n "$acl_hardcode_libdir_separator"; then + dnl Weird platform: only the last -rpath option counts, the user must + dnl pass all path elements in one option. We can arrange that for a + dnl single library, but not when more than one $LIBNAMEs are used. + alldirs= + for found_dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" + done + dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl. + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" + else + dnl The -rpath options are cumulative. + for found_dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$found_dir" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" + done + fi + fi + if test "X$ltrpathdirs" != "X"; then + dnl When using libtool, the option that works for both libraries and + dnl executables is -R. The -R options are cumulative. + for found_dir in $ltrpathdirs; do + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" + done + fi + popdef([PACKLIBS]) + popdef([PACKUP]) + popdef([PACK]) + popdef([NAME]) +]) + +dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, +dnl unless already present in VAR. +dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes +dnl contains two or three consecutive elements that belong together. +AC_DEFUN([AC_LIB_APPENDTOVAR], +[ + for element in [$2]; do + haveit= + for x in $[$1]; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X$element"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + [$1]="${[$1]}${[$1]:+ }$element" + fi + done +]) + +dnl For those cases where a variable contains several -L and -l options +dnl referring to unknown libraries and directories, this macro determines the +dnl necessary additional linker options for the runtime path. +dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL]) +dnl sets LDADDVAR to linker options needed together with LIBSVALUE. +dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed, +dnl otherwise linking without libtool is assumed. +AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], +[ + AC_REQUIRE([AC_LIB_RPATH]) + AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) + $1= + if test "$enable_rpath" != no; then + if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then + dnl Use an explicit option to hardcode directories into the resulting + dnl binary. + rpathdirs= + next= + for opt in $2; do + if test -n "$next"; then + dir="$next" + dnl No need to hardcode the standard /usr/lib. + if test "X$dir" != "X/usr/$acl_libdirstem" \ + && test "X$dir" != "X/usr/$acl_libdirstem2"; then + rpathdirs="$rpathdirs $dir" + fi + next= + else + case $opt in + -L) next=yes ;; + -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'` + dnl No need to hardcode the standard /usr/lib. + if test "X$dir" != "X/usr/$acl_libdirstem" \ + && test "X$dir" != "X/usr/$acl_libdirstem2"; then + rpathdirs="$rpathdirs $dir" + fi + next= ;; + *) next= ;; + esac + fi + done + if test "X$rpathdirs" != "X"; then + if test -n ""$3""; then + dnl libtool is used for linking. Use -R options. + for dir in $rpathdirs; do + $1="${$1}${$1:+ }-R$dir" + done + else + dnl The linker is used for linking directly. + if test -n "$acl_hardcode_libdir_separator"; then + dnl Weird platform: only the last -rpath option counts, the user + dnl must pass all path elements in one option. + alldirs= + for dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir" + done + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + $1="$flag" + else + dnl The -rpath options are cumulative. + for dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$dir" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + $1="${$1}${$1:+ }$flag" + done + fi + fi + fi + fi + fi + AC_SUBST([$1]) +]) diff --git a/gnulib-m4/lib-prefix.m4 b/gnulib-m4/lib-prefix.m4 new file mode 100644 index 0000000..8adb17b --- /dev/null +++ b/gnulib-m4/lib-prefix.m4 @@ -0,0 +1,249 @@ +# lib-prefix.m4 serial 14 +dnl Copyright (C) 2001-2005, 2008-2019 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed +dnl to access previously installed libraries. The basic assumption is that +dnl a user will want packages to use other packages he previously installed +dnl with the same --prefix option. +dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate +dnl libraries, but is otherwise very convenient. +AC_DEFUN([AC_LIB_PREFIX], +[ + AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + dnl By default, look in $includedir and $libdir. + use_additional=yes + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + AC_ARG_WITH([lib-prefix], +[[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib + --without-lib-prefix don't search for libraries in includedir and libdir]], +[ + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + else + additional_includedir="$withval/include" + additional_libdir="$withval/$acl_libdirstem" + fi + fi +]) + if test $use_additional = yes; then + dnl Potentially add $additional_includedir to $CPPFLAGS. + dnl But don't add it + dnl 1. if it's the standard /usr/include, + dnl 2. if it's already present in $CPPFLAGS, + dnl 3. if it's /usr/local/include and we are using GCC on Linux, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + for x in $CPPFLAGS; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + dnl Really add $additional_includedir to $CPPFLAGS. + CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" + fi + fi + fi + fi + dnl Potentially add $additional_libdir to $LDFLAGS. + dnl But don't add it + dnl 1. if it's the standard /usr/lib, + dnl 2. if it's already present in $LDFLAGS, + dnl 3. if it's /usr/local/lib and we are using GCC on Linux, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then + haveit= + for x in $LDFLAGS; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LDFLAGS. + LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" + fi + fi + fi + fi + fi +]) + +dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, +dnl acl_final_exec_prefix, containing the values to which $prefix and +dnl $exec_prefix will expand at the end of the configure script. +AC_DEFUN([AC_LIB_PREPARE_PREFIX], +[ + dnl Unfortunately, prefix and exec_prefix get only finally determined + dnl at the end of configure. + if test "X$prefix" = "XNONE"; then + acl_final_prefix="$ac_default_prefix" + else + acl_final_prefix="$prefix" + fi + if test "X$exec_prefix" = "XNONE"; then + acl_final_exec_prefix='${prefix}' + else + acl_final_exec_prefix="$exec_prefix" + fi + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" + prefix="$acl_save_prefix" +]) + +dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the +dnl variables prefix and exec_prefix bound to the values they will have +dnl at the end of the configure script. +AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], +[ + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + $1 + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" +]) + +dnl AC_LIB_PREPARE_MULTILIB creates +dnl - a variable acl_libdirstem, containing the basename of the libdir, either +dnl "lib" or "lib64" or "lib/64", +dnl - a variable acl_libdirstem2, as a secondary possible value for +dnl acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or +dnl "lib/amd64". +AC_DEFUN([AC_LIB_PREPARE_MULTILIB], +[ + dnl There is no formal standard regarding lib and lib64. + dnl On glibc systems, the current practice is that on a system supporting + dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under + dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine + dnl the compiler's default mode by looking at the compiler's library search + dnl path. If at least one of its elements ends in /lib64 or points to a + dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI. + dnl Otherwise we use the default, namely "lib". + dnl On Solaris systems, the current practice is that on a system supporting + dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under + dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or + dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib. + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([gl_HOST_CPU_C_ABI_32BIT]) + + case "$host_os" in + solaris*) + AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit], + [AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#ifdef _LP64 + int ok; + #else + error fail + #endif + ]])], + [gl_cv_solaris_64bit=yes], + [gl_cv_solaris_64bit=no]) + ]);; + esac + + dnl Allow the user to override the result by setting acl_cv_libdirstems. + AC_CACHE_CHECK([for the common suffixes of directories in the library search path], + [acl_cv_libdirstems], + [acl_libdirstem=lib + acl_libdirstem2= + case "$host_os" in + solaris*) + dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment + dnl . + dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link." + dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the + dnl symlink is missing, so we set acl_libdirstem2 too. + if test $gl_cv_solaris_64bit = yes; then + acl_libdirstem=lib/64 + case "$host_cpu" in + sparc*) acl_libdirstem2=lib/sparcv9 ;; + i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; + esac + fi + ;; + *) + dnl If $CC generates code for a 32-bit ABI, the libraries are + dnl surely under $prefix/lib, not $prefix/lib64. + if test "$HOST_CPU_C_ABI_32BIT" != yes; then + dnl The result is a property of the system. However, non-system + dnl compilers sometimes have odd library search paths. Therefore + dnl prefer asking /usr/bin/gcc, if available, rather than $CC. + searchpath=`(if test -f /usr/bin/gcc \ + && LC_ALL=C /usr/bin/gcc -print-search-dirs >/dev/null 2>/dev/null; then \ + LC_ALL=C /usr/bin/gcc -print-search-dirs; \ + else \ + LC_ALL=C $CC -print-search-dirs; \ + fi) 2>/dev/null \ + | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` + if test -n "$searchpath"; then + acl_save_IFS="${IFS= }"; IFS=":" + for searchdir in $searchpath; do + if test -d "$searchdir"; then + case "$searchdir" in + */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; + */../ | */.. ) + # Better ignore directories of this form. They are misleading. + ;; + *) searchdir=`cd "$searchdir" && pwd` + case "$searchdir" in + */lib64 ) acl_libdirstem=lib64 ;; + esac ;; + esac + fi + done + IFS="$acl_save_IFS" + fi + fi + ;; + esac + test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" + acl_cv_libdirstems="$acl_libdirstem,$acl_libdirstem2" + ]) + # Decompose acl_cv_libdirstems into acl_libdirstem and acl_libdirstem2. + acl_libdirstem=`echo "$acl_cv_libdirstems" | sed -e 's/,.*//'` + acl_libdirstem2=`echo "$acl_cv_libdirstems" | sed -e '/,/s/.*,//'` +]) diff --git a/gnulib-m4/limits-h.m4 b/gnulib-m4/limits-h.m4 new file mode 100644 index 0000000..68f724c --- /dev/null +++ b/gnulib-m4/limits-h.m4 @@ -0,0 +1,43 @@ +dnl Check whether limits.h has needed features. + +dnl Copyright 2016-2019 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Paul Eggert. + +AC_DEFUN_ONCE([gl_LIMITS_H], +[ + gl_CHECK_NEXT_HEADERS([limits.h]) + + AC_CACHE_CHECK([whether limits.h has LLONG_MAX, WORD_BIT, ULLONG_WIDTH etc.], + [gl_cv_header_limits_width], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#ifndef __STDC_WANT_IEC_60559_BFP_EXT__ + #define __STDC_WANT_IEC_60559_BFP_EXT__ 1 + #endif + #include + long long llm = LLONG_MAX; + int wb = WORD_BIT; + int ullw = ULLONG_WIDTH; + ]])], + [gl_cv_header_limits_width=yes], + [gl_cv_header_limits_width=no])]) + if test "$gl_cv_header_limits_width" = yes; then + LIMITS_H= + else + LIMITS_H=limits.h + fi + AC_SUBST([LIMITS_H]) + AM_CONDITIONAL([GL_GENERATE_LIMITS_H], [test -n "$LIMITS_H"]) +]) + +dnl Unconditionally enables the replacement of . +AC_DEFUN([gl_REPLACE_LIMITS_H], +[ + AC_REQUIRE([gl_LIMITS_H]) + LIMITS_H='limits.h' + AM_CONDITIONAL([GL_GENERATE_LIMITS_H], [test -n "$LIMITS_H"]) +]) diff --git a/gnulib-m4/lock.m4 b/gnulib-m4/lock.m4 new file mode 100644 index 0000000..93b76fa --- /dev/null +++ b/gnulib-m4/lock.m4 @@ -0,0 +1,47 @@ +# lock.m4 serial 14 +dnl Copyright (C) 2005-2019 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_DEFUN([gl_LOCK], +[ + AC_REQUIRE([gl_THREADLIB]) + if test "$gl_threads_api" = posix; then + # OSF/1 4.0 and Mac OS X 10.1 lack the pthread_rwlock_t type and the + # pthread_rwlock_* functions. + has_rwlock=false + AC_CHECK_TYPE([pthread_rwlock_t], + [has_rwlock=true + AC_DEFINE([HAVE_PTHREAD_RWLOCK], [1], + [Define if the POSIX multithreading library has read/write locks.])], + [], + [#include ]) + if $has_rwlock; then + gl_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER + fi + # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro. + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM( + [[#include ]], + [[ +#if __FreeBSD__ == 4 +error "No, in FreeBSD 4.0 recursive mutexes actually don't work." +#elif (defined __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ \ + && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070) +error "No, in Mac OS X < 10.7 recursive mutexes actually don't work." +#else +int x = (int)PTHREAD_MUTEX_RECURSIVE; +return !x; +#endif + ]])], + [AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE], [1], + [Define if the defines PTHREAD_MUTEX_RECURSIVE.])]) + fi + gl_PREREQ_LOCK +]) + +# Prerequisites of lib/glthread/lock.c. +AC_DEFUN([gl_PREREQ_LOCK], [:]) diff --git a/gnulib-m4/longlong.m4 b/gnulib-m4/longlong.m4 new file mode 100644 index 0000000..08d0e36 --- /dev/null +++ b/gnulib-m4/longlong.m4 @@ -0,0 +1,113 @@ +# longlong.m4 serial 18 +dnl Copyright (C) 1999-2007, 2009-2019 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Paul Eggert. + +AC_PREREQ([2.62]) + +# Define HAVE_LONG_LONG_INT if 'long long int' works. +# This can be faster than what's in Autoconf 2.62 through 2.68. + +# Note: If the type 'long long int' exists but is only 32 bits large +# (as on some very old compilers), HAVE_LONG_LONG_INT will not be +# defined. In this case you can treat 'long long int' like 'long int'. + +AC_DEFUN([AC_TYPE_LONG_LONG_INT], +[ + AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT]) + AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int], + [ac_cv_type_long_long_int=yes + if test "x${ac_cv_prog_cc_c99-no}" = xno; then + ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int + if test $ac_cv_type_long_long_int = yes; then + dnl Catch a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004. + dnl If cross compiling, assume the bug is not important, since + dnl nobody cross compiles for this platform as far as we know. + AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[@%:@include + @%:@ifndef LLONG_MAX + @%:@ define HALF \ + (1LL << (sizeof (long long int) * CHAR_BIT - 2)) + @%:@ define LLONG_MAX (HALF - 1 + HALF) + @%:@endif]], + [[long long int n = 1; + int i; + for (i = 0; ; i++) + { + long long int m = n << i; + if (m >> i != n) + return 1; + if (LLONG_MAX / 2 < m) + break; + } + return 0;]])], + [], + [ac_cv_type_long_long_int=no], + [:]) + fi + fi]) + if test $ac_cv_type_long_long_int = yes; then + AC_DEFINE([HAVE_LONG_LONG_INT], [1], + [Define to 1 if the system has the type 'long long int'.]) + fi +]) + +# Define HAVE_UNSIGNED_LONG_LONG_INT if 'unsigned long long int' works. +# This can be faster than what's in Autoconf 2.62 through 2.68. + +# Note: If the type 'unsigned long long int' exists but is only 32 bits +# large (as on some very old compilers), AC_TYPE_UNSIGNED_LONG_LONG_INT +# will not be defined. In this case you can treat 'unsigned long long int' +# like 'unsigned long int'. + +AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT], +[ + AC_CACHE_CHECK([for unsigned long long int], + [ac_cv_type_unsigned_long_long_int], + [ac_cv_type_unsigned_long_long_int=yes + if test "x${ac_cv_prog_cc_c99-no}" = xno; then + AC_LINK_IFELSE( + [_AC_TYPE_LONG_LONG_SNIPPET], + [], + [ac_cv_type_unsigned_long_long_int=no]) + fi]) + if test $ac_cv_type_unsigned_long_long_int = yes; then + AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1], + [Define to 1 if the system has the type 'unsigned long long int'.]) + fi +]) + +# Expands to a C program that can be used to test for simultaneous support +# of 'long long' and 'unsigned long long'. We don't want to say that +# 'long long' is available if 'unsigned long long' is not, or vice versa, +# because too many programs rely on the symmetry between signed and unsigned +# integer types (excluding 'bool'). +AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET], +[ + AC_LANG_PROGRAM( + [[/* For now, do not test the preprocessor; as of 2007 there are too many + implementations with broken preprocessors. Perhaps this can + be revisited in 2012. In the meantime, code should not expect + #if to work with literals wider than 32 bits. */ + /* Test literals. */ + long long int ll = 9223372036854775807ll; + long long int nll = -9223372036854775807LL; + unsigned long long int ull = 18446744073709551615ULL; + /* Test constant expressions. */ + typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll) + ? 1 : -1)]; + typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1 + ? 1 : -1)]; + int i = 63;]], + [[/* Test availability of runtime routines for shift and division. */ + long long int llmax = 9223372036854775807ll; + unsigned long long int ullmax = 18446744073709551615ull; + return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i) + | (llmax / ll) | (llmax % ll) + | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i) + | (ullmax / ull) | (ullmax % ull));]]) +]) diff --git a/gnulib-m4/multiarch.m4 b/gnulib-m4/multiarch.m4 new file mode 100644 index 0000000..d48316e --- /dev/null +++ b/gnulib-m4/multiarch.m4 @@ -0,0 +1,62 @@ +# multiarch.m4 serial 7 +dnl Copyright (C) 2008-2019 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Determine whether the compiler is or may be producing universal binaries. +# +# On Mac OS X 10.5 and later systems, the user can create libraries and +# executables that work on multiple system types--known as "fat" or +# "universal" binaries--by specifying multiple '-arch' options to the +# compiler but only a single '-arch' option to the preprocessor. Like +# this: +# +# ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ +# CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ +# CPP="gcc -E" CXXCPP="g++ -E" +# +# Detect this situation and set APPLE_UNIVERSAL_BUILD accordingly. + +AC_DEFUN_ONCE([gl_MULTIARCH], +[ + dnl Code similar to autoconf-2.63 AC_C_BIGENDIAN. + gl_cv_c_multiarch=no + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#ifndef __APPLE_CC__ + not a universal capable compiler + #endif + typedef int dummy; + ]])], + [ + dnl Check for potential -arch flags. It is not universal unless + dnl there are at least two -arch flags with different values. + arch= + prev= + for word in ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do + if test -n "$prev"; then + case $word in + i?86 | x86_64 | ppc | ppc64) + if test -z "$arch" || test "$arch" = "$word"; then + arch="$word" + else + gl_cv_c_multiarch=yes + fi + ;; + esac + prev= + else + if test "x$word" = "x-arch"; then + prev=arch + fi + fi + done + ]) + if test $gl_cv_c_multiarch = yes; then + APPLE_UNIVERSAL_BUILD=1 + else + APPLE_UNIVERSAL_BUILD=0 + fi + AC_SUBST([APPLE_UNIVERSAL_BUILD]) +]) diff --git a/gnulib-m4/nocrash.m4 b/gnulib-m4/nocrash.m4 new file mode 100644 index 0000000..4d9f022 --- /dev/null +++ b/gnulib-m4/nocrash.m4 @@ -0,0 +1,131 @@ +# nocrash.m4 serial 5 +dnl Copyright (C) 2005, 2009-2019 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Based on libsigsegv, from Bruno Haible and Paolo Bonzini. + +AC_PREREQ([2.13]) + +dnl Expands to some code for use in .c programs that will cause the configure +dnl test to exit instead of crashing. This is useful to avoid triggering +dnl action from a background debugger and to avoid core dumps. +dnl Usage: ... +dnl ]GL_NOCRASH[ +dnl ... +dnl int main() { nocrash_init(); ... } +AC_DEFUN([GL_NOCRASH],[[ +#include +#if defined __MACH__ && defined __APPLE__ +/* Avoid a crash on Mac OS X. */ +#include +#include +#include +#include +#include +#include +/* The exception port on which our thread listens. */ +static mach_port_t our_exception_port; +/* The main function of the thread listening for exceptions of type + EXC_BAD_ACCESS. */ +static void * +mach_exception_thread (void *arg) +{ + /* Buffer for a message to be received. */ + struct { + mach_msg_header_t head; + mach_msg_body_t msgh_body; + char data[1024]; + } msg; + mach_msg_return_t retval; + /* Wait for a message on the exception port. */ + retval = mach_msg (&msg.head, MACH_RCV_MSG | MACH_RCV_LARGE, 0, sizeof (msg), + our_exception_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (retval != MACH_MSG_SUCCESS) + abort (); + exit (1); +} +static void +nocrash_init (void) +{ + mach_port_t self = mach_task_self (); + /* Allocate a port on which the thread shall listen for exceptions. */ + if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port) + == KERN_SUCCESS) { + /* See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/mach_port_insert_right.html. */ + if (mach_port_insert_right (self, our_exception_port, our_exception_port, + MACH_MSG_TYPE_MAKE_SEND) + == KERN_SUCCESS) { + /* The exceptions we want to catch. Only EXC_BAD_ACCESS is interesting + for us. */ + exception_mask_t mask = EXC_MASK_BAD_ACCESS; + /* Create the thread listening on the exception port. */ + pthread_attr_t attr; + pthread_t thread; + if (pthread_attr_init (&attr) == 0 + && pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) == 0 + && pthread_create (&thread, &attr, mach_exception_thread, NULL) == 0) { + pthread_attr_destroy (&attr); + /* Replace the exception port info for these exceptions with our own. + Note that we replace the exception port for the entire task, not only + for a particular thread. This has the effect that when our exception + port gets the message, the thread specific exception port has already + been asked, and we don't need to bother about it. + See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/task_set_exception_ports.html. */ + task_set_exception_ports (self, mask, our_exception_port, + EXCEPTION_DEFAULT, MACHINE_THREAD_STATE); + } + } + } +} +#elif defined _WIN32 && ! defined __CYGWIN__ +/* Avoid a crash on native Windows. */ +#define WIN32_LEAN_AND_MEAN +#include +#include +static LONG WINAPI +exception_filter (EXCEPTION_POINTERS *ExceptionInfo) +{ + switch (ExceptionInfo->ExceptionRecord->ExceptionCode) + { + case EXCEPTION_ACCESS_VIOLATION: + case EXCEPTION_IN_PAGE_ERROR: + case EXCEPTION_STACK_OVERFLOW: + case EXCEPTION_GUARD_PAGE: + case EXCEPTION_PRIV_INSTRUCTION: + case EXCEPTION_ILLEGAL_INSTRUCTION: + case EXCEPTION_DATATYPE_MISALIGNMENT: + case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: + case EXCEPTION_NONCONTINUABLE_EXCEPTION: + exit (1); + } + return EXCEPTION_CONTINUE_SEARCH; +} +static void +nocrash_init (void) +{ + SetUnhandledExceptionFilter ((LPTOP_LEVEL_EXCEPTION_FILTER) exception_filter); +} +#else +/* Avoid a crash on POSIX systems. */ +#include +#include +/* A POSIX signal handler. */ +static void +exception_handler (int sig) +{ + _exit (1); +} +static void +nocrash_init (void) +{ +#ifdef SIGSEGV + signal (SIGSEGV, exception_handler); +#endif +#ifdef SIGBUS + signal (SIGBUS, exception_handler); +#endif +} +#endif +]]) diff --git a/gnulib-m4/off_t.m4 b/gnulib-m4/off_t.m4 new file mode 100644 index 0000000..711a2d4 --- /dev/null +++ b/gnulib-m4/off_t.m4 @@ -0,0 +1,18 @@ +# off_t.m4 serial 1 +dnl Copyright (C) 2012-2019 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Check whether to override the 'off_t' type. +dnl Set WINDOWS_64_BIT_OFF_T. + +AC_DEFUN([gl_TYPE_OFF_T], +[ + m4_ifdef([gl_LARGEFILE], [ + AC_REQUIRE([gl_LARGEFILE]) + ], [ + WINDOWS_64_BIT_OFF_T=0 + ]) + AC_SUBST([WINDOWS_64_BIT_OFF_T]) +]) diff --git a/gnulib-m4/onceonly.m4 b/gnulib-m4/onceonly.m4 new file mode 100644 index 0000000..5ab3dd7 --- /dev/null +++ b/gnulib-m4/onceonly.m4 @@ -0,0 +1,104 @@ +# onceonly.m4 serial 9 +dnl Copyright (C) 2002-2003, 2005-2006, 2008-2018 Free Software Foundation, +dnl Inc. +dnl +dnl This file is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This file is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this file. If not, see . +dnl +dnl As a special exception to the GNU General Public License, +dnl this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl This file defines some "once only" variants of standard autoconf macros. +dnl AC_CHECK_HEADERS_ONCE like AC_CHECK_HEADERS +dnl AC_CHECK_FUNCS_ONCE like AC_CHECK_FUNCS +dnl AC_CHECK_DECLS_ONCE like AC_CHECK_DECLS +dnl AC_REQUIRE([AC_FUNC_STRCOLL]) like AC_FUNC_STRCOLL +dnl The advantage is that the check for each of the headers/functions/decls +dnl will be put only once into the 'configure' file. It keeps the size of +dnl the 'configure' file down, and avoids redundant output when 'configure' +dnl is run. +dnl The drawback is that the checks cannot be conditionalized. If you write +dnl if some_condition; then gl_CHECK_HEADERS(stdlib.h); fi +dnl inside an AC_DEFUNed function, the gl_CHECK_HEADERS macro call expands to +dnl empty, and the check will be inserted before the body of the AC_DEFUNed +dnl function. + +dnl The original code implemented AC_CHECK_HEADERS_ONCE and AC_CHECK_FUNCS_ONCE +dnl in terms of AC_DEFUN and AC_REQUIRE. This implementation uses diversions to +dnl named sections DEFAULTS and INIT_PREPARE in order to check all requested +dnl headers at once, thus reducing the size of 'configure'. It is known to work +dnl with autoconf 2.57..2.62 at least . The size reduction is ca. 9%. + +dnl Autoconf version 2.59 plus gnulib is required; this file is not needed +dnl with Autoconf 2.60 or greater. But note that autoconf's implementation of +dnl AC_CHECK_DECLS_ONCE expects a comma-separated list of symbols as first +dnl argument! +AC_PREREQ([2.59]) + +# AC_CHECK_HEADERS_ONCE(HEADER1 HEADER2 ...) is a once-only variant of +# AC_CHECK_HEADERS(HEADER1 HEADER2 ...). +AC_DEFUN([AC_CHECK_HEADERS_ONCE], [ + : + m4_foreach_w([gl_HEADER_NAME], [$1], [ + AC_DEFUN([gl_CHECK_HEADER_]m4_quote(m4_translit(gl_HEADER_NAME, + [./-], [___])), [ + m4_divert_text([INIT_PREPARE], + [gl_header_list="$gl_header_list gl_HEADER_NAME"]) + gl_HEADERS_EXPANSION + AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_HEADER_NAME])), + [Define to 1 if you have the <]m4_defn([gl_HEADER_NAME])[> header file.]) + ]) + AC_REQUIRE([gl_CHECK_HEADER_]m4_quote(m4_translit(gl_HEADER_NAME, + [./-], [___]))) + ]) +]) +m4_define([gl_HEADERS_EXPANSION], [ + m4_divert_text([DEFAULTS], [gl_header_list=]) + AC_CHECK_HEADERS([$gl_header_list]) + m4_define([gl_HEADERS_EXPANSION], []) +]) + +# AC_CHECK_FUNCS_ONCE(FUNC1 FUNC2 ...) is a once-only variant of +# AC_CHECK_FUNCS(FUNC1 FUNC2 ...). +AC_DEFUN([AC_CHECK_FUNCS_ONCE], [ + : + m4_foreach_w([gl_FUNC_NAME], [$1], [ + AC_DEFUN([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]), [ + m4_divert_text([INIT_PREPARE], + [gl_func_list="$gl_func_list gl_FUNC_NAME"]) + gl_FUNCS_EXPANSION + AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_FUNC_NAME])), + [Define to 1 if you have the ']m4_defn([gl_FUNC_NAME])[' function.]) + ]) + AC_REQUIRE([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME])) + ]) +]) +m4_define([gl_FUNCS_EXPANSION], [ + m4_divert_text([DEFAULTS], [gl_func_list=]) + AC_CHECK_FUNCS([$gl_func_list]) + m4_define([gl_FUNCS_EXPANSION], []) +]) + +# AC_CHECK_DECLS_ONCE(DECL1 DECL2 ...) is a once-only variant of +# AC_CHECK_DECLS(DECL1, DECL2, ...). +AC_DEFUN([AC_CHECK_DECLS_ONCE], [ + : + m4_foreach_w([gl_DECL_NAME], [$1], [ + AC_DEFUN([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]), [ + AC_CHECK_DECLS(m4_defn([gl_DECL_NAME])) + ]) + AC_REQUIRE([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME])) + ]) +]) diff --git a/gnulib-m4/pthread_rwlock_rdlock.m4 b/gnulib-m4/pthread_rwlock_rdlock.m4 new file mode 100644 index 0000000..3c1d645 --- /dev/null +++ b/gnulib-m4/pthread_rwlock_rdlock.m4 @@ -0,0 +1,165 @@ +# pthread_rwlock_rdlock.m4 serial 2 +dnl Copyright (C) 2017-2019 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. +dnl Inspired by +dnl https://github.com/linux-test-project/ltp/blob/master/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-2.c +dnl by Intel Corporation. + +dnl Test whether in a situation where +dnl - an rwlock is taken by a reader and has a writer waiting, +dnl - an additional reader requests the lock, +dnl - the waiting writer and the requesting reader threads have the same +dnl priority, +dnl the requesting reader thread gets blocked, so that at some point the +dnl waiting writer can acquire the lock. +dnl Without such a guarantee, when there a N readers and each of the readers +dnl spends more than 1/Nth of the time with the lock held, there is a high +dnl probability that the waiting writer will not get the lock in a given finite +dnl time, a phenomenon called "writer starvation". +dnl Without such a guarantee, applications have a hard time avoiding writer +dnl starvation. +dnl +dnl POSIX:2017 makes this requirement only for implementations that support TPS +dnl (Thread Priority Scheduling) and only for the scheduling policies SCHED_FIFO +dnl and SCHED_RR, see +dnl http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_rwlock_rdlock.html +dnl but this test verifies the guarantee regardless of TPS and regardless of +dnl scheduling policy. +dnl Glibc currently does not provide this guarantee, see +dnl https://sourceware.org/bugzilla/show_bug.cgi?id=13701 +AC_DEFUN([gl_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER], +[ + AC_REQUIRE([gl_THREADLIB_EARLY]) + AC_CACHE_CHECK([whether pthread_rwlock_rdlock prefers a writer to a reader], + [gl_cv_pthread_rwlock_rdlock_prefer_writer], + [save_LIBS="$LIBS" + LIBS="$LIBS $LIBMULTITHREAD" + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +#include + +#define SUCCEED() exit (0) +#define FAILURE() exit (1) +#define UNEXPECTED(n) (exit (10 + (n))) + +/* The main thread creates the waiting writer and the requesting reader threads + in the default way; this guarantees that they have the same priority. + We can reuse the main thread as first reader thread. */ + +static pthread_rwlock_t lock; +static pthread_t reader1; +static pthread_t writer; +static pthread_t reader2; +static pthread_t timer; +/* Used to pass control from writer to reader2 and from reader2 to timer, + as in a relay race. + Passing control from one running thread to another running thread + is most likely faster than to create the second thread. */ +static pthread_mutex_t baton; + +static void * +timer_func (void *ignored) +{ + /* Step 13 (can be before or after step 12): + The timer thread takes the baton, then waits a moment to make sure + it can tell whether the second reader thread is blocked at step 12. */ + if (pthread_mutex_lock (&baton)) + UNEXPECTED (13); + usleep (100000); + /* By the time we get here, it's clear that the second reader thread is + blocked at step 12. This is the desired behaviour. */ + SUCCEED (); +} + +static void * +reader2_func (void *ignored) +{ + int err; + + /* Step 8 (can be before or after step 7): + The second reader thread takes the baton, then waits a moment to make sure + the writer thread has reached step 7. */ + if (pthread_mutex_lock (&baton)) + UNEXPECTED (8); + usleep (100000); + /* Step 9: The second reader thread requests the lock. */ + err = pthread_rwlock_tryrdlock (&lock); + if (err == 0) + FAILURE (); + else if (err != EBUSY) + UNEXPECTED (9); + /* Step 10: Launch a timer, to test whether the next call blocks. */ + if (pthread_create (&timer, NULL, timer_func, NULL)) + UNEXPECTED (10); + /* Step 11: Release the baton. */ + if (pthread_mutex_unlock (&baton)) + UNEXPECTED (11); + /* Step 12: The second reader thread requests the lock. */ + err = pthread_rwlock_rdlock (&lock); + if (err == 0) + FAILURE (); + else + UNEXPECTED (12); +} + +static void * +writer_func (void *ignored) +{ + /* Step 4: Take the baton, so that the second reader thread does not go ahead + too early. */ + if (pthread_mutex_lock (&baton)) + UNEXPECTED (4); + /* Step 5: Create the second reader thread. */ + if (pthread_create (&reader2, NULL, reader2_func, NULL)) + UNEXPECTED (5); + /* Step 6: Release the baton. */ + if (pthread_mutex_unlock (&baton)) + UNEXPECTED (6); + /* Step 7: The writer thread requests the lock. */ + if (pthread_rwlock_wrlock (&lock)) + UNEXPECTED (7); + return NULL; +} + +int +main () +{ + reader1 = pthread_self (); + + /* Step 1: The main thread initializes the lock and the baton. */ + if (pthread_rwlock_init (&lock, NULL)) + UNEXPECTED (1); + if (pthread_mutex_init (&baton, NULL)) + UNEXPECTED (1); + /* Step 2: The main thread acquires the lock as a reader. */ + if (pthread_rwlock_rdlock (&lock)) + UNEXPECTED (2); + /* Step 3: Create the writer thread. */ + if (pthread_create (&writer, NULL, writer_func, NULL)) + UNEXPECTED (3); + /* Job done. Go to sleep. */ + for (;;) + { + sleep (1); + } +} +]])], + [gl_cv_pthread_rwlock_rdlock_prefer_writer=yes], + [gl_cv_pthread_rwlock_rdlock_prefer_writer=no], + [gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing yes"]) + LIBS="$save_LIBS" + ]) + case "$gl_cv_pthread_rwlock_rdlock_prefer_writer" in + *yes) + AC_DEFINE([HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER], [1], + [Define if the 'pthread_rwlock_rdlock' function prefers a writer to a reader.]) + ;; + esac +]) diff --git a/gnulib-m4/ssize_t.m4 b/gnulib-m4/ssize_t.m4 new file mode 100644 index 0000000..38bcee1 --- /dev/null +++ b/gnulib-m4/ssize_t.m4 @@ -0,0 +1,23 @@ +# ssize_t.m4 serial 5 (gettext-0.18.2) +dnl Copyright (C) 2001-2003, 2006, 2010-2019 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. +dnl Test whether ssize_t is defined. + +AC_DEFUN([gt_TYPE_SSIZE_T], +[ + AC_CACHE_CHECK([for ssize_t], [gt_cv_ssize_t], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[int x = sizeof (ssize_t *) + sizeof (ssize_t); + return !x;]])], + [gt_cv_ssize_t=yes], [gt_cv_ssize_t=no])]) + if test $gt_cv_ssize_t = no; then + AC_DEFINE([ssize_t], [int], + [Define as a signed type of the same size as size_t.]) + fi +]) diff --git a/gnulib-m4/stdint.m4 b/gnulib-m4/stdint.m4 new file mode 100644 index 0000000..11d8e8e --- /dev/null +++ b/gnulib-m4/stdint.m4 @@ -0,0 +1,544 @@ +# stdint.m4 serial 53 +dnl Copyright (C) 2001-2019 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Paul Eggert and Bruno Haible. +dnl Test whether is supported or must be substituted. + +AC_PREREQ([2.61]) + +AC_DEFUN_ONCE([gl_STDINT_H], +[ + AC_PREREQ([2.59])dnl + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + AC_REQUIRE([gl_LIMITS_H]) + AC_REQUIRE([gt_TYPE_WINT_T]) + + dnl Check for long long int and unsigned long long int. + AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) + if test $ac_cv_type_long_long_int = yes; then + HAVE_LONG_LONG_INT=1 + else + HAVE_LONG_LONG_INT=0 + fi + AC_SUBST([HAVE_LONG_LONG_INT]) + AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT]) + if test $ac_cv_type_unsigned_long_long_int = yes; then + HAVE_UNSIGNED_LONG_LONG_INT=1 + else + HAVE_UNSIGNED_LONG_LONG_INT=0 + fi + AC_SUBST([HAVE_UNSIGNED_LONG_LONG_INT]) + + dnl Check for , in the same way as gl_WCHAR_H does. + AC_CHECK_HEADERS_ONCE([wchar.h]) + if test $ac_cv_header_wchar_h = yes; then + HAVE_WCHAR_H=1 + else + HAVE_WCHAR_H=0 + fi + AC_SUBST([HAVE_WCHAR_H]) + + dnl Check for . + dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_inttypes_h. + if test $ac_cv_header_inttypes_h = yes; then + HAVE_INTTYPES_H=1 + else + HAVE_INTTYPES_H=0 + fi + AC_SUBST([HAVE_INTTYPES_H]) + + dnl Check for . + dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_sys_types_h. + if test $ac_cv_header_sys_types_h = yes; then + HAVE_SYS_TYPES_H=1 + else + HAVE_SYS_TYPES_H=0 + fi + AC_SUBST([HAVE_SYS_TYPES_H]) + + gl_CHECK_NEXT_HEADERS([stdint.h]) + if test $ac_cv_header_stdint_h = yes; then + HAVE_STDINT_H=1 + else + HAVE_STDINT_H=0 + fi + AC_SUBST([HAVE_STDINT_H]) + + dnl Now see whether we need a substitute . + if test $ac_cv_header_stdint_h = yes; then + AC_CACHE_CHECK([whether stdint.h conforms to C99], + [gl_cv_header_working_stdint_h], + [gl_cv_header_working_stdint_h=no + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ +#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */ +#define __STDC_CONSTANT_MACROS 1 +#define __STDC_LIMIT_MACROS 1 +#include +/* Dragonfly defines WCHAR_MIN, WCHAR_MAX only in . */ +#if !(defined WCHAR_MIN && defined WCHAR_MAX) +#error "WCHAR_MIN, WCHAR_MAX not defined in " +#endif +] +gl_STDINT_INCLUDES +[ +#ifdef INT8_MAX +int8_t a1 = INT8_MAX; +int8_t a1min = INT8_MIN; +#endif +#ifdef INT16_MAX +int16_t a2 = INT16_MAX; +int16_t a2min = INT16_MIN; +#endif +#ifdef INT32_MAX +int32_t a3 = INT32_MAX; +int32_t a3min = INT32_MIN; +#endif +#ifdef INT64_MAX +int64_t a4 = INT64_MAX; +int64_t a4min = INT64_MIN; +#endif +#ifdef UINT8_MAX +uint8_t b1 = UINT8_MAX; +#else +typedef int b1[(unsigned char) -1 != 255 ? 1 : -1]; +#endif +#ifdef UINT16_MAX +uint16_t b2 = UINT16_MAX; +#endif +#ifdef UINT32_MAX +uint32_t b3 = UINT32_MAX; +#endif +#ifdef UINT64_MAX +uint64_t b4 = UINT64_MAX; +#endif +int_least8_t c1 = INT8_C (0x7f); +int_least8_t c1max = INT_LEAST8_MAX; +int_least8_t c1min = INT_LEAST8_MIN; +int_least16_t c2 = INT16_C (0x7fff); +int_least16_t c2max = INT_LEAST16_MAX; +int_least16_t c2min = INT_LEAST16_MIN; +int_least32_t c3 = INT32_C (0x7fffffff); +int_least32_t c3max = INT_LEAST32_MAX; +int_least32_t c3min = INT_LEAST32_MIN; +int_least64_t c4 = INT64_C (0x7fffffffffffffff); +int_least64_t c4max = INT_LEAST64_MAX; +int_least64_t c4min = INT_LEAST64_MIN; +uint_least8_t d1 = UINT8_C (0xff); +uint_least8_t d1max = UINT_LEAST8_MAX; +uint_least16_t d2 = UINT16_C (0xffff); +uint_least16_t d2max = UINT_LEAST16_MAX; +uint_least32_t d3 = UINT32_C (0xffffffff); +uint_least32_t d3max = UINT_LEAST32_MAX; +uint_least64_t d4 = UINT64_C (0xffffffffffffffff); +uint_least64_t d4max = UINT_LEAST64_MAX; +int_fast8_t e1 = INT_FAST8_MAX; +int_fast8_t e1min = INT_FAST8_MIN; +int_fast16_t e2 = INT_FAST16_MAX; +int_fast16_t e2min = INT_FAST16_MIN; +int_fast32_t e3 = INT_FAST32_MAX; +int_fast32_t e3min = INT_FAST32_MIN; +int_fast64_t e4 = INT_FAST64_MAX; +int_fast64_t e4min = INT_FAST64_MIN; +uint_fast8_t f1 = UINT_FAST8_MAX; +uint_fast16_t f2 = UINT_FAST16_MAX; +uint_fast32_t f3 = UINT_FAST32_MAX; +uint_fast64_t f4 = UINT_FAST64_MAX; +#ifdef INTPTR_MAX +intptr_t g = INTPTR_MAX; +intptr_t gmin = INTPTR_MIN; +#endif +#ifdef UINTPTR_MAX +uintptr_t h = UINTPTR_MAX; +#endif +intmax_t i = INTMAX_MAX; +uintmax_t j = UINTMAX_MAX; + +/* Check that SIZE_MAX has the correct type, if possible. */ +#if 201112 <= __STDC_VERSION__ +int k = _Generic (SIZE_MAX, size_t: 0); +#elif (2 <= __GNUC__ || defined __IBM__TYPEOF__ \ + || (0x5110 <= __SUNPRO_C && !__STDC__)) +extern size_t k; +extern __typeof__ (SIZE_MAX) k; +#endif + +#include /* for CHAR_BIT */ +#define TYPE_MINIMUM(t) \ + ((t) ((t) 0 < (t) -1 ? (t) 0 : ~ TYPE_MAXIMUM (t))) +#define TYPE_MAXIMUM(t) \ + ((t) ((t) 0 < (t) -1 \ + ? (t) -1 \ + : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1))) +struct s { + int check_PTRDIFF: + PTRDIFF_MIN == TYPE_MINIMUM (ptrdiff_t) + && PTRDIFF_MAX == TYPE_MAXIMUM (ptrdiff_t) + ? 1 : -1; + /* Detect bug in FreeBSD 6.0 / ia64. */ + int check_SIG_ATOMIC: + SIG_ATOMIC_MIN == TYPE_MINIMUM (sig_atomic_t) + && SIG_ATOMIC_MAX == TYPE_MAXIMUM (sig_atomic_t) + ? 1 : -1; + int check_SIZE: SIZE_MAX == TYPE_MAXIMUM (size_t) ? 1 : -1; + int check_WCHAR: + WCHAR_MIN == TYPE_MINIMUM (wchar_t) + && WCHAR_MAX == TYPE_MAXIMUM (wchar_t) + ? 1 : -1; + /* Detect bug in mingw. */ + int check_WINT: + WINT_MIN == TYPE_MINIMUM (wint_t) + && WINT_MAX == TYPE_MAXIMUM (wint_t) + ? 1 : -1; + + /* Detect bugs in glibc 2.4 and Solaris 10 stdint.h, among others. */ + int check_UINT8_C: + (-1 < UINT8_C (0)) == (-1 < (uint_least8_t) 0) ? 1 : -1; + int check_UINT16_C: + (-1 < UINT16_C (0)) == (-1 < (uint_least16_t) 0) ? 1 : -1; + + /* Detect bugs in OpenBSD 3.9 stdint.h. */ +#ifdef UINT8_MAX + int check_uint8: (uint8_t) -1 == UINT8_MAX ? 1 : -1; +#endif +#ifdef UINT16_MAX + int check_uint16: (uint16_t) -1 == UINT16_MAX ? 1 : -1; +#endif +#ifdef UINT32_MAX + int check_uint32: (uint32_t) -1 == UINT32_MAX ? 1 : -1; +#endif +#ifdef UINT64_MAX + int check_uint64: (uint64_t) -1 == UINT64_MAX ? 1 : -1; +#endif + int check_uint_least8: (uint_least8_t) -1 == UINT_LEAST8_MAX ? 1 : -1; + int check_uint_least16: (uint_least16_t) -1 == UINT_LEAST16_MAX ? 1 : -1; + int check_uint_least32: (uint_least32_t) -1 == UINT_LEAST32_MAX ? 1 : -1; + int check_uint_least64: (uint_least64_t) -1 == UINT_LEAST64_MAX ? 1 : -1; + int check_uint_fast8: (uint_fast8_t) -1 == UINT_FAST8_MAX ? 1 : -1; + int check_uint_fast16: (uint_fast16_t) -1 == UINT_FAST16_MAX ? 1 : -1; + int check_uint_fast32: (uint_fast32_t) -1 == UINT_FAST32_MAX ? 1 : -1; + int check_uint_fast64: (uint_fast64_t) -1 == UINT_FAST64_MAX ? 1 : -1; + int check_uintptr: (uintptr_t) -1 == UINTPTR_MAX ? 1 : -1; + int check_uintmax: (uintmax_t) -1 == UINTMAX_MAX ? 1 : -1; + int check_size: (size_t) -1 == SIZE_MAX ? 1 : -1; +}; + ]])], + [dnl Determine whether the various *_MIN, *_MAX macros are usable + dnl in preprocessor expression. We could do it by compiling a test + dnl program for each of these macros. It is faster to run a program + dnl that inspects the macro expansion. + dnl This detects a bug on HP-UX 11.23/ia64. + AC_RUN_IFELSE([ + AC_LANG_PROGRAM([[ +#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */ +#define __STDC_CONSTANT_MACROS 1 +#define __STDC_LIMIT_MACROS 1 +#include +] +gl_STDINT_INCLUDES +[ +#include +#include +#define MVAL(macro) MVAL1(macro) +#define MVAL1(expression) #expression +static const char *macro_values[] = + { +#ifdef INT8_MAX + MVAL (INT8_MAX), +#endif +#ifdef INT16_MAX + MVAL (INT16_MAX), +#endif +#ifdef INT32_MAX + MVAL (INT32_MAX), +#endif +#ifdef INT64_MAX + MVAL (INT64_MAX), +#endif +#ifdef UINT8_MAX + MVAL (UINT8_MAX), +#endif +#ifdef UINT16_MAX + MVAL (UINT16_MAX), +#endif +#ifdef UINT32_MAX + MVAL (UINT32_MAX), +#endif +#ifdef UINT64_MAX + MVAL (UINT64_MAX), +#endif + NULL + }; +]], [[ + const char **mv; + for (mv = macro_values; *mv != NULL; mv++) + { + const char *value = *mv; + /* Test whether it looks like a cast expression. */ + if (strncmp (value, "((unsigned int)"/*)*/, 15) == 0 + || strncmp (value, "((unsigned short)"/*)*/, 17) == 0 + || strncmp (value, "((unsigned char)"/*)*/, 16) == 0 + || strncmp (value, "((int)"/*)*/, 6) == 0 + || strncmp (value, "((signed short)"/*)*/, 15) == 0 + || strncmp (value, "((signed char)"/*)*/, 14) == 0) + return mv - macro_values + 1; + } + return 0; +]])], + [gl_cv_header_working_stdint_h=yes], + [], + [case "$host_os" in + # Guess yes on native Windows. + mingw*) gl_cv_header_working_stdint_h="guessing yes" ;; + # In general, assume it works. + *) gl_cv_header_working_stdint_h="guessing yes" ;; + esac + ]) + ]) + ]) + fi + + HAVE_C99_STDINT_H=0 + HAVE_SYS_BITYPES_H=0 + HAVE_SYS_INTTYPES_H=0 + STDINT_H=stdint.h + case "$gl_cv_header_working_stdint_h" in + *yes) + HAVE_C99_STDINT_H=1 + dnl Now see whether the system works without + dnl __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS defined. + AC_CACHE_CHECK([whether stdint.h predates C++11], + [gl_cv_header_stdint_predates_cxx11_h], + [gl_cv_header_stdint_predates_cxx11_h=yes + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ +#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */ +#include +] +gl_STDINT_INCLUDES +[ +intmax_t im = INTMAX_MAX; +int32_t i32 = INT32_C (0x7fffffff); + ]])], + [gl_cv_header_stdint_predates_cxx11_h=no])]) + + if test "$gl_cv_header_stdint_predates_cxx11_h" = yes; then + AC_DEFINE([__STDC_CONSTANT_MACROS], [1], + [Define to 1 if the system predates C++11.]) + AC_DEFINE([__STDC_LIMIT_MACROS], [1], + [Define to 1 if the system predates C++11.]) + fi + AC_CACHE_CHECK([whether stdint.h has UINTMAX_WIDTH etc.], + [gl_cv_header_stdint_width], + [gl_cv_header_stdint_width=no + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + /* Work if build is not clean. */ + #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 + #ifndef __STDC_WANT_IEC_60559_BFP_EXT__ + #define __STDC_WANT_IEC_60559_BFP_EXT__ 1 + #endif + #include + ]gl_STDINT_INCLUDES[ + int iw = UINTMAX_WIDTH; + ]])], + [gl_cv_header_stdint_width=yes])]) + if test "$gl_cv_header_stdint_width" = yes; then + STDINT_H= + fi + ;; + *) + dnl Check for , and for + dnl (used in Linux libc4 >= 4.6.7 and libc5). + AC_CHECK_HEADERS([sys/inttypes.h sys/bitypes.h]) + if test $ac_cv_header_sys_inttypes_h = yes; then + HAVE_SYS_INTTYPES_H=1 + fi + if test $ac_cv_header_sys_bitypes_h = yes; then + HAVE_SYS_BITYPES_H=1 + fi + gl_STDINT_TYPE_PROPERTIES + ;; + esac + + dnl The substitute stdint.h needs the substitute limit.h's _GL_INTEGER_WIDTH. + gl_REPLACE_LIMITS_H + + AC_SUBST([HAVE_C99_STDINT_H]) + AC_SUBST([HAVE_SYS_BITYPES_H]) + AC_SUBST([HAVE_SYS_INTTYPES_H]) + AC_SUBST([STDINT_H]) + AM_CONDITIONAL([GL_GENERATE_STDINT_H], [test -n "$STDINT_H"]) +]) + +dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES) +dnl Determine the size of each of the given types in bits. +AC_DEFUN([gl_STDINT_BITSIZEOF], +[ + dnl Use a shell loop, to avoid bloating configure, and + dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into + dnl config.h.in, + dnl - extra AC_SUBST calls, so that the right substitutions are made. + m4_foreach_w([gltype], [$1], + [AH_TEMPLATE([BITSIZEOF_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]), + [Define to the number of bits in type ']gltype['.])]) + for gltype in $1 ; do + AC_CACHE_CHECK([for bit size of $gltype], [gl_cv_bitsizeof_${gltype}], + [AC_COMPUTE_INT([result], [sizeof ($gltype) * CHAR_BIT], + [$2 +#include ], [result=unknown]) + eval gl_cv_bitsizeof_${gltype}=\$result + ]) + eval result=\$gl_cv_bitsizeof_${gltype} + if test $result = unknown; then + dnl Use a nonempty default, because some compilers, such as IRIX 5 cc, + dnl do a syntax check even on unused #if conditions and give an error + dnl on valid C code like this: + dnl #if 0 + dnl # if > 32 + dnl # endif + dnl #endif + result=0 + fi + GLTYPE=`echo "$gltype" | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'` + AC_DEFINE_UNQUOTED([BITSIZEOF_${GLTYPE}], [$result]) + eval BITSIZEOF_${GLTYPE}=\$result + done + m4_foreach_w([gltype], [$1], + [AC_SUBST([BITSIZEOF_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))]) +]) + +dnl gl_CHECK_TYPES_SIGNED(TYPES, INCLUDES) +dnl Determine the signedness of each of the given types. +dnl Define HAVE_SIGNED_TYPE if type is signed. +AC_DEFUN([gl_CHECK_TYPES_SIGNED], +[ + dnl Use a shell loop, to avoid bloating configure, and + dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into + dnl config.h.in, + dnl - extra AC_SUBST calls, so that the right substitutions are made. + m4_foreach_w([gltype], [$1], + [AH_TEMPLATE([HAVE_SIGNED_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]), + [Define to 1 if ']gltype[' is a signed integer type.])]) + for gltype in $1 ; do + AC_CACHE_CHECK([whether $gltype is signed], [gl_cv_type_${gltype}_signed], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([$2[ + int verify[2 * (($gltype) -1 < ($gltype) 0) - 1];]])], + result=yes, result=no) + eval gl_cv_type_${gltype}_signed=\$result + ]) + eval result=\$gl_cv_type_${gltype}_signed + GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'` + if test "$result" = yes; then + AC_DEFINE_UNQUOTED([HAVE_SIGNED_${GLTYPE}], [1]) + eval HAVE_SIGNED_${GLTYPE}=1 + else + eval HAVE_SIGNED_${GLTYPE}=0 + fi + done + m4_foreach_w([gltype], [$1], + [AC_SUBST([HAVE_SIGNED_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))]) +]) + +dnl gl_INTEGER_TYPE_SUFFIX(TYPES, INCLUDES) +dnl Determine the suffix to use for integer constants of the given types. +dnl Define t_SUFFIX for each such type. +AC_DEFUN([gl_INTEGER_TYPE_SUFFIX], +[ + dnl Use a shell loop, to avoid bloating configure, and + dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into + dnl config.h.in, + dnl - extra AC_SUBST calls, so that the right substitutions are made. + m4_foreach_w([gltype], [$1], + [AH_TEMPLATE(m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX], + [Define to l, ll, u, ul, ull, etc., as suitable for + constants of type ']gltype['.])]) + for gltype in $1 ; do + AC_CACHE_CHECK([for $gltype integer literal suffix], + [gl_cv_type_${gltype}_suffix], + [eval gl_cv_type_${gltype}_suffix=no + eval result=\$gl_cv_type_${gltype}_signed + if test "$result" = yes; then + glsufu= + else + glsufu=u + fi + for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do + case $glsuf in + '') gltype1='int';; + l) gltype1='long int';; + ll) gltype1='long long int';; + i64) gltype1='__int64';; + u) gltype1='unsigned int';; + ul) gltype1='unsigned long int';; + ull) gltype1='unsigned long long int';; + ui64)gltype1='unsigned __int64';; + esac + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([$2[ + extern $gltype foo; + extern $gltype1 foo;]])], + [eval gl_cv_type_${gltype}_suffix=\$glsuf]) + eval result=\$gl_cv_type_${gltype}_suffix + test "$result" != no && break + done]) + GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'` + eval result=\$gl_cv_type_${gltype}_suffix + test "$result" = no && result= + eval ${GLTYPE}_SUFFIX=\$result + AC_DEFINE_UNQUOTED([${GLTYPE}_SUFFIX], [$result]) + done + m4_foreach_w([gltype], [$1], + [AC_SUBST(m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX])]) +]) + +dnl gl_STDINT_INCLUDES +AC_DEFUN([gl_STDINT_INCLUDES], +[[ + /* BSD/OS 4.0.1 has a bug: , and must be + included before . */ + #include + #include + #if HAVE_WCHAR_H + # include + # include + # include + #endif +]]) + +dnl gl_STDINT_TYPE_PROPERTIES +dnl Compute HAVE_SIGNED_t, BITSIZEOF_t and t_SUFFIX, for all the types t +dnl of interest to stdint.in.h. +AC_DEFUN([gl_STDINT_TYPE_PROPERTIES], +[ + AC_REQUIRE([gl_MULTIARCH]) + if test $APPLE_UNIVERSAL_BUILD = 0; then + gl_STDINT_BITSIZEOF([ptrdiff_t size_t], + [gl_STDINT_INCLUDES]) + fi + gl_STDINT_BITSIZEOF([sig_atomic_t wchar_t wint_t], + [gl_STDINT_INCLUDES]) + gl_CHECK_TYPES_SIGNED([sig_atomic_t wchar_t wint_t], + [gl_STDINT_INCLUDES]) + gl_cv_type_ptrdiff_t_signed=yes + gl_cv_type_size_t_signed=no + if test $APPLE_UNIVERSAL_BUILD = 0; then + gl_INTEGER_TYPE_SUFFIX([ptrdiff_t size_t], + [gl_STDINT_INCLUDES]) + fi + gl_INTEGER_TYPE_SUFFIX([sig_atomic_t wchar_t wint_t], + [gl_STDINT_INCLUDES]) + + dnl If wint_t is smaller than 'int', it cannot satisfy the ISO C 99 + dnl requirement that wint_t is "unchanged by default argument promotions". + dnl In this case gnulib's and override wint_t. + dnl Set the variable BITSIZEOF_WINT_T accordingly. + if test $GNULIB_OVERRIDES_WINT_T = 1; then + BITSIZEOF_WINT_T=32 + fi +]) diff --git a/gnulib-m4/stdnoreturn.m4 b/gnulib-m4/stdnoreturn.m4 new file mode 100644 index 0000000..9dfd48d --- /dev/null +++ b/gnulib-m4/stdnoreturn.m4 @@ -0,0 +1,51 @@ +# Check for stdnoreturn.h that conforms to C11. + +dnl Copyright 2012-2019 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Prepare for substituting if it is not supported. + +AC_DEFUN([gl_STDNORETURN_H], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_os" in + cygwin*) + dnl Regardless whether a working exists or not, + dnl we need our own , because of the definition + dnl of _Noreturn done by gnulib-common.m4. + STDNORETURN_H='stdnoreturn.h' + ;; + *) + AC_CACHE_CHECK([for working stdnoreturn.h], + [gl_cv_header_working_stdnoreturn_h], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + /* Do not check for 'noreturn' after the return type. + C11 allows it, but it's rarely done that way + and circa-2012 bleeding-edge GCC rejects it when given + -Werror=old-style-declaration. */ + noreturn void foo1 (void) { exit (0); } + _Noreturn void foo2 (void) { exit (0); } + int testit (int argc, char **argv) + { + if (argc & 1) + return 0; + (argv[0][0] ? foo1 : foo2) (); + } + ]])], + [gl_cv_header_working_stdnoreturn_h=yes], + [gl_cv_header_working_stdnoreturn_h=no])]) + if test $gl_cv_header_working_stdnoreturn_h = yes; then + STDNORETURN_H='' + else + STDNORETURN_H='stdnoreturn.h' + fi + ;; + esac + AC_SUBST([STDNORETURN_H]) + AM_CONDITIONAL([GL_GENERATE_STDNORETURN_H], [test -n "$STDNORETURN_H"]) +]) diff --git a/gnulib-m4/sys_types_h.m4 b/gnulib-m4/sys_types_h.m4 new file mode 100644 index 0000000..be06559 --- /dev/null +++ b/gnulib-m4/sys_types_h.m4 @@ -0,0 +1,60 @@ +# sys_types_h.m4 serial 9 +dnl Copyright (C) 2011-2019 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN_ONCE([gl_SYS_TYPES_H], +[ + dnl Use sane struct stat types in OpenVMS 8.2 and later. + AC_DEFINE([_USE_STD_STAT], 1, [For standard stat data types on VMS.]) + + AC_REQUIRE([gl_SYS_TYPES_H_DEFAULTS]) + gl_NEXT_HEADERS([sys/types.h]) + + dnl Ensure the type pid_t gets defined. + AC_REQUIRE([AC_TYPE_PID_T]) + + dnl Ensure the type mode_t gets defined. + AC_REQUIRE([AC_TYPE_MODE_T]) + + dnl Whether to override the 'off_t' type. + AC_REQUIRE([gl_TYPE_OFF_T]) + + dnl Whether to override the 'dev_t' and 'ino_t' types. + m4_ifdef([gl_WINDOWS_STAT_INODES], [ + AC_REQUIRE([gl_WINDOWS_STAT_INODES]) + ], [ + WINDOWS_STAT_INODES=0 + ]) + AC_SUBST([WINDOWS_STAT_INODES]) +]) + +AC_DEFUN([gl_SYS_TYPES_H_DEFAULTS], +[ +]) + +# This works around a buggy version in autoconf <= 2.69. +# See + +m4_version_prereq([2.70], [], [ + +# This is taken from the following Autoconf patch: +# https://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=e17a30e987d7ee695fb4294a82d987ec3dc9b974 + +m4_undefine([AC_HEADER_MAJOR]) +AC_DEFUN([AC_HEADER_MAJOR], +[AC_CHECK_HEADERS_ONCE([sys/types.h]) +AC_CHECK_HEADER([sys/mkdev.h], + [AC_DEFINE([MAJOR_IN_MKDEV], [1], + [Define to 1 if `major', `minor', and `makedev' are declared in + .])]) +if test $ac_cv_header_sys_mkdev_h = no; then + AC_CHECK_HEADER([sys/sysmacros.h], + [AC_DEFINE([MAJOR_IN_SYSMACROS], [1], + [Define to 1 if `major', `minor', and `makedev' are declared in + .])]) +fi +]) + +]) diff --git a/gnulib-m4/threadlib.m4 b/gnulib-m4/threadlib.m4 new file mode 100644 index 0000000..045d9da --- /dev/null +++ b/gnulib-m4/threadlib.m4 @@ -0,0 +1,359 @@ +# threadlib.m4 serial 20 +dnl Copyright (C) 2005-2019 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_PREREQ([2.60]) + +dnl gl_THREADLIB +dnl ------------ +dnl Tests for a multithreading library to be used. +dnl If the configure.ac contains a definition of the gl_THREADLIB_DEFAULT_NO +dnl (it must be placed before the invocation of gl_THREADLIB_EARLY!), then the +dnl default is 'no', otherwise it is system dependent. In both cases, the user +dnl can change the choice through the options --enable-threads=choice or +dnl --disable-threads. +dnl Defines at most one of the macros USE_POSIX_THREADS, USE_WINDOWS_THREADS. +dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use +dnl in a Makefile (LIBTHREAD for use without libtool, LTLIBTHREAD for use with +dnl libtool). +dnl Sets the variables LIBMULTITHREAD and LTLIBMULTITHREAD similarly, for +dnl programs that really need multithread functionality. The difference +dnl between LIBTHREAD and LIBMULTITHREAD is that on platforms supporting weak +dnl symbols, typically LIBTHREAD is empty whereas LIBMULTITHREAD is not. +dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for +dnl multithread-safe programs. +dnl Since support for GNU pth was removed, $LTLIBTHREAD and $LIBTHREAD have the +dnl same value, and similarly $LTLIBMULTITHREAD and $LIBMULTITHREAD have the +dnl same value. Only system libraries are needed. + +AC_DEFUN([gl_THREADLIB_EARLY], +[ + AC_REQUIRE([gl_THREADLIB_EARLY_BODY]) +]) + +dnl The guts of gl_THREADLIB_EARLY. Needs to be expanded only once. + +AC_DEFUN([gl_THREADLIB_EARLY_BODY], +[ + dnl Ordering constraints: This macro modifies CPPFLAGS in a way that + dnl influences the result of the autoconf tests that test for *_unlocked + dnl declarations, on AIX 5 at least. Therefore it must come early. + AC_BEFORE([$0], [gl_FUNC_GLIBC_UNLOCKED_IO])dnl + AC_BEFORE([$0], [gl_ARGP])dnl + + AC_REQUIRE([AC_CANONICAL_HOST]) + dnl _GNU_SOURCE is needed for pthread_rwlock_t on glibc systems. + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + dnl Check for multithreading. + m4_ifdef([gl_THREADLIB_DEFAULT_NO], + [m4_divert_text([DEFAULTS], [gl_use_threads_default=no])], + [m4_divert_text([DEFAULTS], [gl_use_threads_default=])]) + m4_divert_text([DEFAULTS], [gl_use_winpthreads_default=]) + AC_ARG_ENABLE([threads], +AC_HELP_STRING([--enable-threads={posix|windows}], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [ +AC_HELP_STRING([--disable-threads], [build without multithread safety])]), + [gl_use_threads=$enableval], + [if test -n "$gl_use_threads_default"; then + gl_use_threads="$gl_use_threads_default" + else +changequote(,)dnl + case "$host_os" in + dnl Disable multithreading by default on OSF/1, because it interferes + dnl with fork()/exec(): When msgexec is linked with -lpthread, its + dnl child process gets an endless segmentation fault inside execvp(). + osf*) gl_use_threads=no ;; + dnl Disable multithreading by default on Cygwin 1.5.x, because it has + dnl bugs that lead to endless loops or crashes. See + dnl . + cygwin*) + case `uname -r` in + 1.[0-5].*) gl_use_threads=no ;; + *) gl_use_threads=yes ;; + esac + ;; + dnl Obey gl_AVOID_WINPTHREAD on mingw. + mingw*) + case "$gl_use_winpthreads_default" in + yes) gl_use_threads=posix ;; + no) gl_use_threads=windows ;; + *) gl_use_threads=yes ;; + esac + ;; + *) gl_use_threads=yes ;; + esac +changequote([,])dnl + fi + ]) + if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then + # For using : + case "$host_os" in + osf*) + # On OSF/1, the compiler needs the flag -D_REENTRANT so that it + # groks . cc also understands the flag -pthread, but + # we don't use it because 1. gcc-2.95 doesn't understand -pthread, + # 2. putting a flag into CPPFLAGS that has an effect on the linker + # causes the AC_LINK_IFELSE test below to succeed unexpectedly, + # leading to wrong values of LIBTHREAD and LTLIBTHREAD. + CPPFLAGS="$CPPFLAGS -D_REENTRANT" + ;; + esac + # Some systems optimize for single-threaded programs by default, and + # need special flags to disable these optimizations. For example, the + # definition of 'errno' in . + case "$host_os" in + aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;; + solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;; + esac + fi +]) + +dnl The guts of gl_THREADLIB. Needs to be expanded only once. + +AC_DEFUN([gl_THREADLIB_BODY], +[ + AC_REQUIRE([gl_THREADLIB_EARLY_BODY]) + gl_threads_api=none + LIBTHREAD= + LTLIBTHREAD= + LIBMULTITHREAD= + LTLIBMULTITHREAD= + if test "$gl_use_threads" != no; then + dnl Check whether the compiler and linker support weak declarations. + AC_CACHE_CHECK([whether imported symbols can be declared weak], + [gl_cv_have_weak], + [gl_cv_have_weak=no + dnl First, test whether the compiler accepts it syntactically. + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[extern void xyzzy (); +#pragma weak xyzzy]], + [[xyzzy();]])], + [gl_cv_have_weak=maybe]) + if test $gl_cv_have_weak = maybe; then + dnl Second, test whether it actually works. On Cygwin 1.7.2, with + dnl gcc 4.3, symbols declared weak always evaluate to the address 0. + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#pragma weak fputs +int main () +{ + return (fputs == NULL); +}]])], + [gl_cv_have_weak=yes], + [gl_cv_have_weak=no], + [dnl When cross-compiling, assume that only ELF platforms support + dnl weak symbols. + AC_EGREP_CPP([Extensible Linking Format], + [#ifdef __ELF__ + Extensible Linking Format + #endif + ], + [gl_cv_have_weak="guessing yes"], + [gl_cv_have_weak="guessing no"]) + ]) + fi + dnl But when linking statically, weak symbols don't work. + case " $LDFLAGS " in + *" -static "*) gl_cv_have_weak=no ;; + esac + ]) + if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then + dnl If we use weak symbols to implement pthread_in_use / pth_in_use / + dnl thread_in_use, we also need to test whether the ISO C 11 thrd_create + dnl facility is in use. + AC_CHECK_HEADERS_ONCE([threads.h]) + : + fi + if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then + # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that + # it groks . It's added above, in gl_THREADLIB_EARLY_BODY. + AC_CHECK_HEADER([pthread.h], + [gl_have_pthread_h=yes], [gl_have_pthread_h=no]) + if test "$gl_have_pthread_h" = yes; then + # Other possible tests: + # -lpthreads (FSU threads, PCthreads) + # -lgthreads + gl_have_pthread= + # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist + # in libc. IRIX 6.5 has the first one in both libc and libpthread, but + # the second one only in libpthread, and lock.c needs it. + # + # If -pthread works, prefer it to -lpthread, since Ubuntu 14.04 + # needs -pthread for some reason. See: + # https://lists.gnu.org/r/bug-gnulib/2014-09/msg00023.html + save_LIBS=$LIBS + for gl_pthread in '' '-pthread'; do + LIBS="$LIBS $gl_pthread" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include + pthread_mutex_t m; + pthread_mutexattr_t ma; + ]], + [[pthread_mutex_lock (&m); + pthread_mutexattr_init (&ma);]])], + [gl_have_pthread=yes + LIBTHREAD=$gl_pthread LTLIBTHREAD=$gl_pthread + LIBMULTITHREAD=$gl_pthread LTLIBMULTITHREAD=$gl_pthread]) + LIBS=$save_LIBS + test -n "$gl_have_pthread" && break + done + + # Test for libpthread by looking for pthread_kill. (Not pthread_self, + # since it is defined as a macro on OSF/1.) + if test -n "$gl_have_pthread" && test -z "$LIBTHREAD"; then + # The program links fine without libpthread. But it may actually + # need to link with libpthread in order to create multiple threads. + AC_CHECK_LIB([pthread], [pthread_kill], + [LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread + # On Solaris and HP-UX, most pthread functions exist also in libc. + # Therefore pthread_in_use() needs to actually try to create a + # thread: pthread_create from libc will fail, whereas + # pthread_create will actually create a thread. + # On Solaris 10 or newer, this test is no longer needed, because + # libc contains the fully functional pthread functions. + case "$host_os" in + solaris | solaris2.[1-9] | solaris2.[1-9].* | hpux*) + AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1], + [Define if the pthread_in_use() detection is hard.]) + esac + ]) + elif test -z "$gl_have_pthread"; then + # Some library is needed. Try libpthread and libc_r. + AC_CHECK_LIB([pthread], [pthread_kill], + [gl_have_pthread=yes + LIBTHREAD=-lpthread LTLIBTHREAD=-lpthread + LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread]) + if test -z "$gl_have_pthread"; then + # For FreeBSD 4. + AC_CHECK_LIB([c_r], [pthread_kill], + [gl_have_pthread=yes + LIBTHREAD=-lc_r LTLIBTHREAD=-lc_r + LIBMULTITHREAD=-lc_r LTLIBMULTITHREAD=-lc_r]) + fi + fi + if test -n "$gl_have_pthread"; then + gl_threads_api=posix + AC_DEFINE([USE_POSIX_THREADS], [1], + [Define if the POSIX multithreading library can be used.]) + if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then + if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then + AC_DEFINE([USE_POSIX_THREADS_WEAK], [1], + [Define if references to the POSIX multithreading library should be made weak.]) + LIBTHREAD= + LTLIBTHREAD= + fi + fi + fi + fi + fi + if test -z "$gl_have_pthread"; then + case "$gl_use_threads" in + yes | windows | win32) # The 'win32' is for backward compatibility. + if { case "$host_os" in + mingw*) true;; + *) false;; + esac + }; then + gl_threads_api=windows + AC_DEFINE([USE_WINDOWS_THREADS], [1], + [Define if the native Windows multithreading API can be used.]) + fi + ;; + esac + fi + fi + AC_MSG_CHECKING([for multithread API to use]) + AC_MSG_RESULT([$gl_threads_api]) + AC_SUBST([LIBTHREAD]) + AC_SUBST([LTLIBTHREAD]) + AC_SUBST([LIBMULTITHREAD]) + AC_SUBST([LTLIBMULTITHREAD]) +]) + +AC_DEFUN([gl_THREADLIB], +[ + AC_REQUIRE([gl_THREADLIB_EARLY]) + AC_REQUIRE([gl_THREADLIB_BODY]) +]) + + +dnl gl_DISABLE_THREADS +dnl ------------------ +dnl Sets the gl_THREADLIB default so that threads are not used by default. +dnl The user can still override it at installation time, by using the +dnl configure option '--enable-threads'. + +AC_DEFUN([gl_DISABLE_THREADS], [ + m4_divert_text([INIT_PREPARE], [gl_use_threads_default=no]) +]) + + +dnl gl_AVOID_WINPTHREAD +dnl ------------------- +dnl Sets the gl_THREADLIB default so that on mingw, a dependency to the +dnl libwinpthread DLL (mingw-w64 winpthreads library) is avoided. +dnl The user can still override it at installation time, by using the +dnl configure option '--enable-threads'. + +AC_DEFUN([gl_AVOID_WINPTHREAD], [ + m4_divert_text([INIT_PREPARE], [gl_use_winpthreads_default=no]) +]) + + +dnl Survey of platforms: +dnl +dnl Platform Available Compiler Supports test-lock +dnl flavours option weak result +dnl --------------- --------- --------- -------- --------- +dnl Linux 2.4/glibc posix -lpthread Y OK +dnl +dnl GNU Hurd/glibc posix +dnl +dnl Ubuntu 14.04 posix -pthread Y OK +dnl +dnl FreeBSD 5.3 posix -lc_r Y +dnl posix -lkse ? Y +dnl posix -lpthread ? Y +dnl posix -lthr Y +dnl +dnl FreeBSD 5.2 posix -lc_r Y +dnl posix -lkse Y +dnl posix -lthr Y +dnl +dnl FreeBSD 4.0,4.10 posix -lc_r Y OK +dnl +dnl NetBSD 1.6 -- +dnl +dnl OpenBSD 3.4 posix -lpthread Y OK +dnl +dnl Mac OS X 10.[123] posix -lpthread Y OK +dnl +dnl Solaris 7,8,9 posix -lpthread Y Sol 7,8: 0.0; Sol 9: OK +dnl +dnl HP-UX 11 posix -lpthread N (cc) OK +dnl Y (gcc) +dnl +dnl IRIX 6.5 posix -lpthread Y 0.5 +dnl +dnl AIX 4.3,5.1 posix -lpthread N AIX 4: 0.5; AIX 5: OK +dnl +dnl OSF/1 4.0,5.1 posix -pthread (cc) N OK +dnl -lpthread (gcc) Y +dnl +dnl Cygwin posix -lpthread Y OK +dnl +dnl Mingw windows N OK +dnl +dnl BeOS 5 -- +dnl +dnl The test-lock result shows what happens if in test-lock.c EXPLICIT_YIELD is +dnl turned off: +dnl OK if all three tests terminate OK, +dnl 0.5 if the first test terminates OK but the second one loops endlessly, +dnl 0.0 if the first test already loops endlessly. diff --git a/gnulib-m4/wint_t.m4 b/gnulib-m4/wint_t.m4 new file mode 100644 index 0000000..61e8a23 --- /dev/null +++ b/gnulib-m4/wint_t.m4 @@ -0,0 +1,74 @@ +# wint_t.m4 serial 7 +dnl Copyright (C) 2003, 2007-2019 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. +dnl Test whether has the 'wint_t' type and whether gnulib's +dnl or would, if present, override 'wint_t'. +dnl Prerequisite: AC_PROG_CC + +AC_DEFUN([gt_TYPE_WINT_T], +[ + AC_CACHE_CHECK([for wint_t], [gt_cv_c_wint_t], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ +/* Tru64 with Desktop Toolkit C has a bug: must be included before + . + BSD/OS 4.0.1 has a bug: , and must be included + before . */ +#include +#include +#include +#include + wint_t foo = (wchar_t)'\0';]], + [[]])], + [gt_cv_c_wint_t=yes], + [gt_cv_c_wint_t=no])]) + if test $gt_cv_c_wint_t = yes; then + AC_DEFINE([HAVE_WINT_T], [1], [Define if you have the 'wint_t' type.]) + + dnl Determine whether gnulib's or would, if present, + dnl override 'wint_t'. + AC_CACHE_CHECK([whether wint_t is too small], + [gl_cv_type_wint_t_too_small], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ +/* Tru64 with Desktop Toolkit C has a bug: must be included before + . + BSD/OS 4.0.1 has a bug: , and must be + included before . */ +#if !(defined __GLIBC__ && !defined __UCLIBC__) +# include +# include +# include +#endif +#include + int verify[sizeof (wint_t) < sizeof (int) ? -1 : 1]; + ]])], + [gl_cv_type_wint_t_too_small=no], + [gl_cv_type_wint_t_too_small=yes])]) + if test $gl_cv_type_wint_t_too_small = yes; then + GNULIB_OVERRIDES_WINT_T=1 + else + GNULIB_OVERRIDES_WINT_T=0 + fi + else + GNULIB_OVERRIDES_WINT_T=0 + fi + AC_SUBST([GNULIB_OVERRIDES_WINT_T]) +]) + +dnl Prerequisites of the 'wint_t' override. +AC_DEFUN([gl_TYPE_WINT_T_PREREQ], +[ + AC_CHECK_HEADERS_ONCE([crtdefs.h]) + if test $ac_cv_header_crtdefs_h = yes; then + HAVE_CRTDEFS_H=1 + else + HAVE_CRTDEFS_H=0 + fi + AC_SUBST([HAVE_CRTDEFS_H]) +]) diff --git a/m4/as-underscore.m4 b/m4/as-underscore.m4 new file mode 100644 index 0000000..92dc7f9 --- /dev/null +++ b/m4/as-underscore.m4 @@ -0,0 +1,24 @@ +dnl -*- Autoconf -*- +dnl Copyright (C) 1993-2017 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License as published by the Free Software Foundation; +dnl either version 2 of the License, or (at your option) any later version. +dnl As a special exception to the GNU General Public License, this file +dnl may be distributed as part of a program that contains a configuration +dnl script generated by Autoconf, under the same distribution terms as +dnl the rest of that program. + +dnl From Bruno Haible, Marcus Daniels, Sam Steingold. + +AC_PREREQ([2.57]) + +AC_DEFUN([CL_AS_UNDERSCORE], +[ + AC_REQUIRE([gl_ASM_SYMBOL_PREFIX]) + if test "$USER_LABEL_PREFIX" = '_'; then + AS_UNDERSCORE=true + else + AS_UNDERSCORE=false + fi + AC_SUBST([AS_UNDERSCORE]) +]) diff --git a/m4/cc-gcc.m4 b/m4/cc-gcc.m4 new file mode 100644 index 0000000..1e12d8e --- /dev/null +++ b/m4/cc-gcc.m4 @@ -0,0 +1,36 @@ +dnl -*- Autoconf -*- +dnl Copyright (C) 1993-2017 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License as published by the Free Software Foundation; +dnl either version 2 of the License, or (at your option) any later version. +dnl As a special exception to the GNU General Public License, this file +dnl may be distributed as part of a program that contains a configuration +dnl script generated by Autoconf, under the same distribution terms as +dnl the rest of that program. + +dnl From Bruno Haible, Marcus Daniels. + +AC_PREREQ([2.13]) + +AC_DEFUN([CL_CC_GCC], +[ + AC_REQUIRE([AC_PROG_CPP]) + AC_CACHE_CHECK([whether using GNU C], [cl_cv_prog_cc_gcc], + [AC_EGREP_CPP([yes], + [#ifdef __GNUC__ + yes + #endif + ], + [cl_cv_prog_cc_gcc=yes], + [cl_cv_prog_cc_gcc=no]) + ]) + if test $cl_cv_prog_cc_gcc = yes; then + CC_GCC=true + GCC_X_NONE='-x none' + else + CC_GCC=false + GCC_X_NONE='' + fi + AC_SUBST([CC_GCC]) + AC_SUBST([GCC_X_NONE]) +]) diff --git a/m4/codeexec.m4 b/m4/codeexec.m4 new file mode 100644 index 0000000..2d9eab3 --- /dev/null +++ b/m4/codeexec.m4 @@ -0,0 +1,362 @@ +dnl -*- Autoconf -*- +dnl Copyright (C) 1993-2017 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License as published by the Free Software Foundation; +dnl either version 2 of the License, or (at your option) any later version. +dnl As a special exception to the GNU General Public License, this file +dnl may be distributed as part of a program that contains a configuration +dnl script generated by Autoconf, under the same distribution terms as +dnl the rest of that program. + +dnl From Bruno Haible, Marcus Daniels, Sam Steingold. + +AC_PREREQ([2.13]) + +AC_DEFUN([CE_DOC],[whether code in malloc()ed memory is executable]) +AC_DEFUN([FFCALL_CODEEXEC], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([gl_HOST_CPU_C_ABI]) + AC_CACHE_CHECK([CE_DOC], [ffcall_cv_codeexec], + [dnl The test below does not work on platforms with the following ABIs: + dnl - hppa, because function pointers are actually pointers into(!) + dnl a two-pointer struct. + dnl - hppa64, because function pointers are actually pointers to a + dnl four-pointer struct. + dnl - powerpc on AIX, powerpc64, because function pointers are actually + dnl pointers to a three-pointer struct. + dnl - ia64, because function pointers are actually pointers to a + dnl two-pointer struct. + case "$HOST_CPU_C_ABI--$host_os" in + hppa--* | hppa64--* | powerpc--aix* | powerpc64--* | ia64--*) + dnl On these platforms, it's irrelevant whether malloc'ed memory is + dnl executable, because the trampolines are built without executable + dnl code. + ffcall_cv_codeexec="irrelevant" + ;; + arm64--freebsd*) + dnl On this platform, malloc()ed memory is not executable, and the + dnl test program loops endlessly. + ffcall_cv_codeexec=no + ;; + *) + AC_TRY_RUN(GL_NOCRASH + [#include + /* declare malloc() */ + #include + int fun () { return 31415926; } + int main () + { nocrash_init(); + {long size = (char*)&main - (char*)&fun; + char* funcopy = (char*) malloc(size); + int i; + for (i = 0; i < size; i++) { funcopy[i] = ((char*)&fun)[i]; } + return !((*(int(*)())funcopy)() == 31415926); + }} + ], + [ffcall_cv_codeexec=yes], + [ffcall_cv_codeexec=no], + [dnl When cross-compiling, assume the known behaviour. + dnl If we don't know, assume the worst. + case "$host_os" in + cygwin*) + case "$HOST_CPU_C_ABI" in + i386) + ffcall_cv_codeexec="guessing yes" ;; + x86_64) + ffcall_cv_codeexec="guessing no" ;; + *) + ffcall_cv_codeexec="guessing no" ;; + esac + ;; + darwin*) + case "$HOST_CPU_C_ABI" in + i386 | powerpc) + ffcall_cv_codeexec="guessing yes" ;; + x86_64) + ffcall_cv_codeexec="guessing no" ;; + *) + ffcall_cv_codeexec="guessing no" ;; + esac + ;; + irix*) + ffcall_cv_codeexec="guessing no" ;; + linux*) + case "$HOST_CPU_C_ABI" in + alpha | ia64) + ffcall_cv_codeexec="guessing yes" ;; + arm | armhf | arm64 | i386 | mips* | s390 | s390x | sparc | sparc64 | x86_64*) + ffcall_cv_codeexec="guessing no" ;; + *) + ffcall_cv_codeexec="guessing no" ;; + esac + ;; + solaris*) + case "$HOST_CPU_C_ABI" in + i386 | sparc | sparc64) + ffcall_cv_codeexec="guessing yes" ;; + x86_64) + ffcall_cv_codeexec="guessing no" ;; + *) + ffcall_cv_codeexec="guessing no" ;; + esac + ;; + *) + ffcall_cv_codeexec="guessing no" ;; + esac + ]) + ;; + esac + ]) + case "$ffcall_cv_codeexec" in + *yes | irrelevant) AC_DEFINE([CODE_EXECUTABLE], [], CE_DOC) ;; + *no) ;; + esac +]) + +dnl Test how to use the mprotect function to make memory executable. +dnl Test against the mprotect limitations found in PaX enabled Linux kernels +dnl and HardenedBSD. +AC_DEFUN([FFCALL_CODEEXEC_PAX], +[ + AC_REQUIRE([FFCALL_MMAP]) + AC_REQUIRE([FFCALL_MPROTECT]) + AC_REQUIRE([FFCALL_CODEEXEC]) + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$ffcall_cv_codeexec" in + *yes | irrelevant) ;; + *) + case "$ac_cv_func_mprotect--$cl_cv_func_mprotect_works" in + yes--*yes) + AC_CACHE_CHECK([whether mprotect can make malloc()ed memory executable], + [ffcall_cv_malloc_mprotect_can_exec], + [dnl On RHEL 6 / CentOS 6 with SELinux enabled, the result of + dnl this test depends on SELinux flags that can be changed at + dnl runtime: By default, the result is 'no'. However, when the flag + dnl allow_execheap is turned on, the result is 'yes'. But the flag + dnl can be turned off again at any moment. + if test "$cross_compiling" != yes -a -d /etc/selinux; then + ffcall_cv_malloc_mprotect_can_exec='determined by SELinux at runtime' + else + AC_TRY_RUN( + [#include + #include + #ifdef HAVE_UNISTD_H + #include + #endif + #include + /* declare getpagesize() and mprotect() */ + #include + #ifndef HAVE_GETPAGESIZE + #include + #define getpagesize() PAGESIZE + #else + ]AC_LANG_EXTERN[ + RETGETPAGESIZETYPE getpagesize (void); + #endif + int + main () + { + unsigned int pagesize = getpagesize (); + char *p = (char *) malloc (50); + int ret; + if (p == (char*) -1) + /* malloc is not working as expected. */ + return 1; + p[5] = 0x77; + ret = mprotect (p - ((unsigned int) p & (pagesize - 1)), pagesize, PROT_READ | PROT_WRITE | PROT_EXEC); + if (ret < 0 + && (errno == EACCES || errno == ENOMEM + #ifdef ENOTSUP + || errno == ENOTSUP + #endif + ) ) + /* mprotect is forbidden to make malloc()ed pages executable that were writable earlier. */ + return 2; + return 0; + } + ], + [ffcall_cv_malloc_mprotect_can_exec=yes], + [dnl When cross-compiling, assume SELinux on Linux. + dnl If we don't know, assume the worst. + case "$host_os" in + linux*) + ffcall_cv_malloc_mprotect_can_exec='determined by SELinux at runtime' ;; + aix* | cygwin* | darwin* | irix* | solaris*) + ffcall_cv_malloc_mprotect_can_exec="guessing yes" ;; + *) + ffcall_cv_malloc_mprotect_can_exec="guessing no" ;; + esac + ]) + fi + ]) + case "$ffcall_cv_malloc_mprotect_can_exec" in + *yes) MPROTECT_AFTER_MALLOC_CAN_EXEC=1 ;; + *no) MPROTECT_AFTER_MALLOC_CAN_EXEC=0 ;; + *runtime*) MPROTECT_AFTER_MALLOC_CAN_EXEC='-1' ;; + esac + AC_DEFINE_UNQUOTED([HAVE_MPROTECT_AFTER_MALLOC_CAN_EXEC], [$MPROTECT_AFTER_MALLOC_CAN_EXEC], + [have an mprotect() function that can make malloc()ed memory pages executable]) + case "$ffcall_cv_malloc_mprotect_can_exec" in + *yes) ;; + *) + AC_CACHE_CHECK([whether mprotect can make mmap()ed memory executable], + [ffcall_cv_mmap_mprotect_can_exec], + [dnl On RHEL 6 / CentOS 6 with SELinux enabled, the result of + dnl this test depends on SELinux flags that can be changed at + dnl runtime: By default, the result is 'yes'. However, when the flags + dnl allow_execmem and allow_execstack are turned off, the result is + dnl 'no'. + if test "$cross_compiling" != yes -a -d /etc/selinux; then + ffcall_cv_mmap_mprotect_can_exec='determined by SELinux at runtime' + else + AC_TRY_RUN( + [#include + #include + #ifdef HAVE_UNISTD_H + #include + #endif + #include + /* declare getpagesize() and mprotect() */ + #include + #ifndef HAVE_GETPAGESIZE + #include + #define getpagesize() PAGESIZE + #else + ]AC_LANG_EXTERN[ + RETGETPAGESIZETYPE getpagesize (void); + #endif + #ifndef MAP_FILE + #define MAP_FILE 0 + #endif + #ifndef MAP_VARIABLE + #define MAP_VARIABLE 0 + #endif + int + main () + { + unsigned int pagesize = getpagesize (); + char *p; + int ret; + #if defined HAVE_MMAP_ANON + p = (char *) mmap (NULL, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | MAP_VARIABLE, -1, 0); + #elif defined HAVE_MMAP_ANONYMOUS + p = (char *) mmap (NULL, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_VARIABLE, -1, 0); + #elif defined HAVE_MMAP_DEVZERO + int zero_fd = open("/dev/zero", O_RDONLY, 0666); + if (zero_fd < 0) + return 1; + p = (char *) mmap (NULL, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FILE | MAP_VARIABLE, zero_fd, 0); + #else + ?? + #endif + if (p == (char*) -1) + /* mmap is not working as expected. */ + return 1; + p[5] = 0x77; + ret = mprotect (p, pagesize, PROT_READ | PROT_WRITE | PROT_EXEC); + if (ret < 0 + && (errno == EACCES || errno == ENOMEM + #ifdef ENOTSUP + || errno == ENOTSUP + #endif + ) ) + /* mprotect is forbidden to make mmap()ed pages executable that were writable earlier. */ + return 2; + return 0; + } + ], + [ffcall_cv_mmap_mprotect_can_exec=yes], + [dnl When cross-compiling, assume SELinux on Linux. + dnl If we don't know, assume the worst. + case "$host_os" in + linux*) ffcall_cv_mmap_mprotect_can_exec='determined by SELinux at runtime' ;; + *) ffcall_cv_mmap_mprotect_can_exec="guessing no" ;; + esac + ]) + fi + ]) + case "$ffcall_cv_mmap_mprotect_can_exec" in + *yes) MPROTECT_AFTER_MMAP_CAN_EXEC=1 ;; + *no) MPROTECT_AFTER_MMAP_CAN_EXEC=0 ;; + *runtime*) MPROTECT_AFTER_MMAP_CAN_EXEC='-1' ;; + esac + AC_DEFINE_UNQUOTED([HAVE_MPROTECT_AFTER_MMAP_CAN_EXEC], [$MPROTECT_AFTER_MMAP_CAN_EXEC], + [have an mprotect() function that can make mmap()ed memory pages executable]) + case "$ffcall_cv_mmap_mprotect_can_exec" in + *yes) ;; + *) + AC_CACHE_CHECK([whether a shared mmap can make memory pages executable], + [ffcall_cv_mmap_shared_can_exec], + [filename="/tmp/trampdata$$.data" + AC_TRY_RUN( + [#include + #include + #ifdef HAVE_UNISTD_H + #include + #endif + /* declare getpagesize() and mmap() */ + #include + #ifndef HAVE_GETPAGESIZE + #include + #define getpagesize() PAGESIZE + #else + ]AC_LANG_EXTERN[ + RETGETPAGESIZETYPE getpagesize (void); + #endif + #ifndef MAP_FILE + #define MAP_FILE 0 + #endif + #ifndef MAP_VARIABLE + #define MAP_VARIABLE 0 + #endif + int + main () + { + unsigned int pagesize = getpagesize (); + int fd; + char *pw; + char *px; + fd = open ("$filename", O_CREAT | O_RDWR | O_TRUNC, 0700); + if (fd < 0) + return 1; + if (ftruncate (fd, pagesize) < 0) + return 2; + pw = (char *) mmap (NULL, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FILE | MAP_VARIABLE, fd, 0); + if (pw == (char*) -1) + return 3; + pw[5] = 0xc3; + px = (char *) mmap (NULL, pagesize, PROT_READ | PROT_EXEC, MAP_SHARED | MAP_FILE | MAP_VARIABLE, fd, 0); + if (px == (char*) -1) + return 4; + if ((char)px[5] != (char)0xc3) + return 5; + /* On i386 and x86_64 this is a 'ret' instruction that we can invoke. */ + #if (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_) || (defined __x86_64__ || defined __amd64__) + ((void (*) (void)) (px + 5)) (); + #endif + return 0; + } + ], + [ffcall_cv_mmap_shared_can_exec=yes], + [dnl When cross-compiling, assume yes, since this is the result + dnl on all the platforms where we have tested it. + ffcall_cv_mmap_shared_can_exec="guessing yes" + ]) + rm -f "$filename" + ]) + case "$ffcall_cv_mmap_shared_can_exec" in + *yes) + AC_DEFINE([HAVE_MMAP_SHARED_CAN_EXEC], [], + [have an mmap() function that, with MAP_SHARED, can make memory pages executable]) + ;; + esac + ;; + esac + ;; + esac + ;; + esac + ;; + esac +]) diff --git a/m4/endianness.m4 b/m4/endianness.m4 new file mode 100644 index 0000000..51f1a3d --- /dev/null +++ b/m4/endianness.m4 @@ -0,0 +1,70 @@ +# endianness.m4 serial 1 +dnl Copyright (C) 2017 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +dnl For specific bi-endian CPUs, sets the ENDIANNESS variable to either +dnl 'eb' (means big endian) or 'el' (means little endian). +dnl +dnl This variable can be used to select a particular assembly language +dnl source file that will interoperate with C code on the given host. +AC_DEFUN([FFCALL_ENDIANNESS], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_cpu" in + arm* ) + AC_CACHE_CHECK([endianness], [ffcall_cv_endianness], + [AC_EGREP_CPP([yes], + [#if defined __ARMEL__ + yes + #endif], + [ffcall_cv_endianness=little], + [ffcall_cv_endianness=big])]) + ;; + mips* ) + AC_CACHE_CHECK([endianness], [ffcall_cv_endianness], + [# Compilers on IRIX define only _MIPSEB as indicator. + # Compilers on Linux define _MIPSEB, __MIPSEB__, __MIPSEB or - in + # the opposite case - _MIPSEL, __MIPSEL__, __MIPSEL. + AC_EGREP_CPP([yes], + [#if defined _MIPSEB + yes + #endif], + [ffcall_cv_endianness=big], + [AC_EGREP_CPP([yes], + [#if defined _MIPSEL + yes + #endif], + [ffcall_cv_endianness=little], + [ffcall_cv_endianness=unknown])]) + ]) + ;; + powerpc*) + AC_CACHE_CHECK([endianness], [ffcall_cv_endianness], + [# Compilers on AIX and Linux define _BIG_ENDIAN, __BIG_ENDIAN__ or + # - in the opposite case - _LITTLE_ENDIAN, __LITTLE_ENDIAN__. + AC_EGREP_CPP([yes], + [#if defined _BIG_ENDIAN + yes + #endif], + [ffcall_cv_endianness=big], + [AC_EGREP_CPP([yes], + [#if defined _LITTLE_ENDIAN + yes + #endif], + [ffcall_cv_endianness=little], + [ffcall_cv_endianness=unknown])]) + ]) + ;; + *) ffcall_cv_endianness=known ;; + esac + case "$ffcall_cv_endianness" in + big) ENDIANNESS='eb' ;; + little) ENDIANNESS='el' ;; + *) ENDIANNESS='' ;; + esac + AC_SUBST([ENDIANNESS]) +]) diff --git a/m4/general.m4 b/m4/general.m4 new file mode 100644 index 0000000..329d5b1 --- /dev/null +++ b/m4/general.m4 @@ -0,0 +1,34 @@ +dnl -*- Autoconf -*- +dnl Copyright (C) 1993-2017 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License as published by the Free Software Foundation; +dnl either version 2 of the License, or (at your option) any later version. +dnl As a special exception to the GNU General Public License, this file +dnl may be distributed as part of a program that contains a configuration +dnl script generated by Autoconf, under the same distribution terms as +dnl the rest of that program. + +dnl From Bruno Haible, Marcus Daniels, Sam Steingold. + +AC_PREREQ([2.61]) + +AC_DEFUN([CL_CHECK], +[ + AC_CACHE_CHECK([for $2],[$3], + [$1([AC_LANG_PROGRAM([$4],[$5])],[$3=yes],[$3=no])]) + AS_IF([test $$3 = yes], [$6], [$7]) +]) + +AC_DEFUN([CL_LINK_CHECK], +[ + CL_CHECK([AC_LINK_IFELSE],$@) +]) + +dnl Expands to the "extern ..." prefix used for system declarations. +dnl AC_LANG_EXTERN +AC_DEFUN([AC_LANG_EXTERN], +[extern +#ifdef __cplusplus +"C" +#endif +]) diff --git a/m4/getpagesize.m4 b/m4/getpagesize.m4 new file mode 100644 index 0000000..291af73 --- /dev/null +++ b/m4/getpagesize.m4 @@ -0,0 +1,47 @@ +dnl -*- Autoconf -*- +dnl Copyright (C) 1993-2017 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License as published by the Free Software Foundation; +dnl either version 2 of the License, or (at your option) any later version. +dnl As a special exception to the GNU General Public License, this file +dnl may be distributed as part of a program that contains a configuration +dnl script generated by Autoconf, under the same distribution terms as +dnl the rest of that program. + +dnl From Bruno Haible, Marcus Daniels, Sam Steingold. + +AC_PREREQ([2.57]) + +AC_DEFUN([CL_GETPAGESIZE], +[ + CL_LINK_CHECK([getpagesize], [cl_cv_func_getpagesize], + [#ifdef HAVE_UNISTD_H + #include + #include + #endif + ], + [getpagesize();], + [ + AC_DEFINE([HAVE_GETPAGESIZE], [], [have getpagesize()]) + have_getpagesize=1 + ]) + if test -n "$have_getpagesize"; then + CL_PROTO([getpagesize], + [CL_PROTO_RET( + [#include + #ifdef HAVE_UNISTD_H + #include + #endif + ], + [int getpagesize();], + [cl_cv_proto_getpagesize_ret], [int], [size_t]) + ], + [extern $cl_cv_proto_getpagesize_ret getpagesize (void);]) + AC_DEFINE_UNQUOTED([RETGETPAGESIZETYPE], [$cl_cv_proto_getpagesize_ret], + [return type of getpagesize()]) + else + dnl Otherwise we use PAGESIZE defined in . + dnl But mingw32 doesn't have . + AC_CHECK_HEADERS([sys/param.h]) + fi +]) diff --git a/m4/ireg.m4 b/m4/ireg.m4 new file mode 100644 index 0000000..bd83d31 --- /dev/null +++ b/m4/ireg.m4 @@ -0,0 +1,40 @@ +dnl -*- Autoconf -*- +dnl Copyright (C) 1993-2017 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License as published by the Free Software Foundation; +dnl either version 2 of the License, or (at your option) any later version. +dnl As a special exception to the GNU General Public License, this file +dnl may be distributed as part of a program that contains a configuration +dnl script generated by Autoconf, under the same distribution terms as +dnl the rest of that program. + +dnl From Bruno Haible, Marcus Daniels, Sam Steingold. + +AC_PREREQ([2.13]) + +AC_DEFUN([IREG_DOC],[whether floats are returned in integer registers]) +AC_DEFUN([FFCALL_IREG_FLOAT_RETURN], +[ + AC_CACHE_CHECK([IREG_DOC], [ffcall_cv_c_float_return_ireg], + [AC_TRY_RUN(GL_NOCRASH + [float x = (float)1.2; + float y = (float)1.3; + float fun () { return x*y; } + int main() + { nocrash_init(); + {int val = (* (int (*) ()) fun) (); + return !(val == 0x3FC7AE15 || val == 0x15AEC73F); + }} + ], + [ffcall_cv_c_float_return_ireg=yes], + [ffcall_cv_c_float_return_ireg=no], + [dnl When cross-compiling, assume no, because that's how it comes out on + dnl most platforms with floating-point unit, including m68k-linux. + ffcall_cv_c_float_return_ireg="guessing no" + ]) + ]) + case "$ffcall_cv_c_float_return_ireg" in + *yes) AC_DEFINE([__IREG_FLOAT_RETURN__], [], IREG_DOC) ;; + *no) ;; + esac +]) diff --git a/m4/libtool.m4 b/m4/libtool.m4 new file mode 100644 index 0000000..2851b20 --- /dev/null +++ b/m4/libtool.m4 @@ -0,0 +1,8369 @@ +# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- +# +# Copyright (C) 1996-2001, 2003-2015 Free Software Foundation, Inc. +# Written by Gordon Matzigkeit, 1996 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +m4_define([_LT_COPYING], [dnl +# Copyright (C) 2014 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# GNU Libtool 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 of the License, or +# (at your option) any later version. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program or library that is built +# using GNU Libtool, you may include this file under the same +# distribution terms that you use for the rest of that program. +# +# GNU Libtool 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, see . +]) + +# serial 58 LT_INIT + + +# LT_PREREQ(VERSION) +# ------------------ +# Complain and exit if this libtool version is less that VERSION. +m4_defun([LT_PREREQ], +[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, + [m4_default([$3], + [m4_fatal([Libtool version $1 or higher is required], + 63)])], + [$2])]) + + +# _LT_CHECK_BUILDDIR +# ------------------ +# Complain if the absolute build directory name contains unusual characters +m4_defun([_LT_CHECK_BUILDDIR], +[case `pwd` in + *\ * | *\ *) + AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; +esac +]) + + +# LT_INIT([OPTIONS]) +# ------------------ +AC_DEFUN([LT_INIT], +[AC_PREREQ([2.62])dnl We use AC_PATH_PROGS_FEATURE_CHECK +AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl +AC_BEFORE([$0], [LT_LANG])dnl +AC_BEFORE([$0], [LT_OUTPUT])dnl +AC_BEFORE([$0], [LTDL_INIT])dnl +m4_require([_LT_CHECK_BUILDDIR])dnl + +dnl Autoconf doesn't catch unexpanded LT_ macros by default: +m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl +m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl +dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 +dnl unless we require an AC_DEFUNed macro: +AC_REQUIRE([LTOPTIONS_VERSION])dnl +AC_REQUIRE([LTSUGAR_VERSION])dnl +AC_REQUIRE([LTVERSION_VERSION])dnl +AC_REQUIRE([LTOBSOLETE_VERSION])dnl +m4_require([_LT_PROG_LTMAIN])dnl + +_LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) + +dnl Parse OPTIONS +_LT_SET_OPTIONS([$0], [$1]) + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS=$ltmain + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +_LT_SETUP + +# Only expand once: +m4_define([LT_INIT]) +])# LT_INIT + +# Old names: +AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) +AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_PROG_LIBTOOL], []) +dnl AC_DEFUN([AM_PROG_LIBTOOL], []) + + +# _LT_PREPARE_CC_BASENAME +# ----------------------- +m4_defun([_LT_PREPARE_CC_BASENAME], [ +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +func_cc_basename () +{ + for cc_temp in @S|@*""; do + case $cc_temp in + compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; + distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; + \-*) ;; + *) break;; + esac + done + func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` +} +])# _LT_PREPARE_CC_BASENAME + + +# _LT_CC_BASENAME(CC) +# ------------------- +# It would be clearer to call AC_REQUIREs from _LT_PREPARE_CC_BASENAME, +# but that macro is also expanded into generated libtool script, which +# arranges for $SED and $ECHO to be set by different means. +m4_defun([_LT_CC_BASENAME], +[m4_require([_LT_PREPARE_CC_BASENAME])dnl +AC_REQUIRE([_LT_DECL_SED])dnl +AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl +func_cc_basename $1 +cc_basename=$func_cc_basename_result +]) + + +# _LT_FILEUTILS_DEFAULTS +# ---------------------- +# It is okay to use these file commands and assume they have been set +# sensibly after 'm4_require([_LT_FILEUTILS_DEFAULTS])'. +m4_defun([_LT_FILEUTILS_DEFAULTS], +[: ${CP="cp -f"} +: ${MV="mv -f"} +: ${RM="rm -f"} +])# _LT_FILEUTILS_DEFAULTS + + +# _LT_SETUP +# --------- +m4_defun([_LT_SETUP], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl +AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl + +_LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl +dnl +_LT_DECL([], [host_alias], [0], [The host system])dnl +_LT_DECL([], [host], [0])dnl +_LT_DECL([], [host_os], [0])dnl +dnl +_LT_DECL([], [build_alias], [0], [The build system])dnl +_LT_DECL([], [build], [0])dnl +_LT_DECL([], [build_os], [0])dnl +dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([LT_PATH_LD])dnl +AC_REQUIRE([LT_PATH_NM])dnl +dnl +AC_REQUIRE([AC_PROG_LN_S])dnl +test -z "$LN_S" && LN_S="ln -s" +_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl +dnl +AC_REQUIRE([LT_CMD_MAX_LEN])dnl +_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl +_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl +dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_CHECK_SHELL_FEATURES])dnl +m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl +m4_require([_LT_CMD_RELOAD])dnl +m4_require([_LT_CHECK_MAGIC_METHOD])dnl +m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl +m4_require([_LT_CMD_OLD_ARCHIVE])dnl +m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl +m4_require([_LT_WITH_SYSROOT])dnl +m4_require([_LT_CMD_TRUNCATE])dnl + +_LT_CONFIG_LIBTOOL_INIT([ +# See if we are running on zsh, and set the options that allow our +# commands through without removal of \ escapes INIT. +if test -n "\${ZSH_VERSION+set}"; then + setopt NO_GLOB_SUBST +fi +]) +if test -n "${ZSH_VERSION+set}"; then + setopt NO_GLOB_SUBST +fi + +_LT_CHECK_OBJDIR + +m4_require([_LT_TAG_COMPILER])dnl + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test set != "${COLLECT_NAMES+set}"; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Global variables: +ofile=libtool +can_build_shared=yes + +# All known linkers require a '.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a + +with_gnu_ld=$lt_cv_prog_gnu_ld + +old_CC=$CC +old_CFLAGS=$CFLAGS + +# Set sane defaults for various variables +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS +test -z "$LD" && LD=ld +test -z "$ac_objext" && ac_objext=o + +_LT_CC_BASENAME([$compiler]) + +# Only perform the check for file, if the check method requires it +test -z "$MAGIC_CMD" && MAGIC_CMD=file +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + _LT_PATH_MAGIC + fi + ;; +esac + +# Use C for the default configuration in the libtool script +LT_SUPPORTED_TAG([CC]) +_LT_LANG_C_CONFIG +_LT_LANG_DEFAULT_CONFIG +_LT_CONFIG_COMMANDS +])# _LT_SETUP + + +# _LT_PREPARE_SED_QUOTE_VARS +# -------------------------- +# Define a few sed substitution that help us do robust quoting. +m4_defun([_LT_PREPARE_SED_QUOTE_VARS], +[# Backslashify metacharacters that are still active within +# double-quoted strings. +sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\([["`\\]]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to delay expansion of an escaped single quote. +delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' +]) + +# _LT_PROG_LTMAIN +# --------------- +# Note that this code is called both from 'configure', and 'config.status' +# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, +# 'config.status' has no value for ac_aux_dir unless we are using Automake, +# so we pass a copy along to make sure it has a sensible value anyway. +m4_defun([_LT_PROG_LTMAIN], +[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl +_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) +ltmain=$ac_aux_dir/ltmain.sh +])# _LT_PROG_LTMAIN + + +## ------------------------------------- ## +## Accumulate code for creating libtool. ## +## ------------------------------------- ## + +# So that we can recreate a full libtool script including additional +# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS +# in macros and then make a single call at the end using the 'libtool' +# label. + + +# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) +# ---------------------------------------- +# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. +m4_define([_LT_CONFIG_LIBTOOL_INIT], +[m4_ifval([$1], + [m4_append([_LT_OUTPUT_LIBTOOL_INIT], + [$1 +])])]) + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_INIT]) + + +# _LT_CONFIG_LIBTOOL([COMMANDS]) +# ------------------------------ +# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. +m4_define([_LT_CONFIG_LIBTOOL], +[m4_ifval([$1], + [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], + [$1 +])])]) + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) + + +# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) +# ----------------------------------------------------- +m4_defun([_LT_CONFIG_SAVE_COMMANDS], +[_LT_CONFIG_LIBTOOL([$1]) +_LT_CONFIG_LIBTOOL_INIT([$2]) +]) + + +# _LT_FORMAT_COMMENT([COMMENT]) +# ----------------------------- +# Add leading comment marks to the start of each line, and a trailing +# full-stop to the whole comment if one is not present already. +m4_define([_LT_FORMAT_COMMENT], +[m4_ifval([$1], [ +m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], + [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) +)]) + + + +## ------------------------ ## +## FIXME: Eliminate VARNAME ## +## ------------------------ ## + + +# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) +# ------------------------------------------------------------------- +# CONFIGNAME is the name given to the value in the libtool script. +# VARNAME is the (base) name used in the configure script. +# VALUE may be 0, 1 or 2 for a computed quote escaped value based on +# VARNAME. Any other value will be used directly. +m4_define([_LT_DECL], +[lt_if_append_uniq([lt_decl_varnames], [$2], [, ], + [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], + [m4_ifval([$1], [$1], [$2])]) + lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) + m4_ifval([$4], + [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) + lt_dict_add_subkey([lt_decl_dict], [$2], + [tagged?], [m4_ifval([$5], [yes], [no])])]) +]) + + +# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) +# -------------------------------------------------------- +m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) + + +# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) +# ------------------------------------------------ +m4_define([lt_decl_tag_varnames], +[_lt_decl_filter([tagged?], [yes], $@)]) + + +# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) +# --------------------------------------------------------- +m4_define([_lt_decl_filter], +[m4_case([$#], + [0], [m4_fatal([$0: too few arguments: $#])], + [1], [m4_fatal([$0: too few arguments: $#: $1])], + [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], + [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], + [lt_dict_filter([lt_decl_dict], $@)])[]dnl +]) + + +# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) +# -------------------------------------------------- +m4_define([lt_decl_quote_varnames], +[_lt_decl_filter([value], [1], $@)]) + + +# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) +# --------------------------------------------------- +m4_define([lt_decl_dquote_varnames], +[_lt_decl_filter([value], [2], $@)]) + + +# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) +# --------------------------------------------------- +m4_define([lt_decl_varnames_tagged], +[m4_assert([$# <= 2])dnl +_$0(m4_quote(m4_default([$1], [[, ]])), + m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), + m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) +m4_define([_lt_decl_varnames_tagged], +[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) + + +# lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) +# ------------------------------------------------ +m4_define([lt_decl_all_varnames], +[_$0(m4_quote(m4_default([$1], [[, ]])), + m4_if([$2], [], + m4_quote(lt_decl_varnames), + m4_quote(m4_shift($@))))[]dnl +]) +m4_define([_lt_decl_all_varnames], +[lt_join($@, lt_decl_varnames_tagged([$1], + lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl +]) + + +# _LT_CONFIG_STATUS_DECLARE([VARNAME]) +# ------------------------------------ +# Quote a variable value, and forward it to 'config.status' so that its +# declaration there will have the same value as in 'configure'. VARNAME +# must have a single quote delimited value for this to work. +m4_define([_LT_CONFIG_STATUS_DECLARE], +[$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`']) + + +# _LT_CONFIG_STATUS_DECLARATIONS +# ------------------------------ +# We delimit libtool config variables with single quotes, so when +# we write them to config.status, we have to be sure to quote all +# embedded single quotes properly. In configure, this macro expands +# each variable declared with _LT_DECL (and _LT_TAGDECL) into: +# +# ='`$ECHO "$" | $SED "$delay_single_quote_subst"`' +m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], +[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), + [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) + + +# _LT_LIBTOOL_TAGS +# ---------------- +# Output comment and list of tags supported by the script +m4_defun([_LT_LIBTOOL_TAGS], +[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl +available_tags='_LT_TAGS'dnl +]) + + +# _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) +# ----------------------------------- +# Extract the dictionary values for VARNAME (optionally with TAG) and +# expand to a commented shell variable setting: +# +# # Some comment about what VAR is for. +# visible_name=$lt_internal_name +m4_define([_LT_LIBTOOL_DECLARE], +[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], + [description])))[]dnl +m4_pushdef([_libtool_name], + m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl +m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), + [0], [_libtool_name=[$]$1], + [1], [_libtool_name=$lt_[]$1], + [2], [_libtool_name=$lt_[]$1], + [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl +m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl +]) + + +# _LT_LIBTOOL_CONFIG_VARS +# ----------------------- +# Produce commented declarations of non-tagged libtool config variables +# suitable for insertion in the LIBTOOL CONFIG section of the 'libtool' +# script. Tagged libtool config variables (even for the LIBTOOL CONFIG +# section) are produced by _LT_LIBTOOL_TAG_VARS. +m4_defun([_LT_LIBTOOL_CONFIG_VARS], +[m4_foreach([_lt_var], + m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), + [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) + + +# _LT_LIBTOOL_TAG_VARS(TAG) +# ------------------------- +m4_define([_LT_LIBTOOL_TAG_VARS], +[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), + [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) + + +# _LT_TAGVAR(VARNAME, [TAGNAME]) +# ------------------------------ +m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) + + +# _LT_CONFIG_COMMANDS +# ------------------- +# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of +# variables for single and double quote escaping we saved from calls +# to _LT_DECL, we can put quote escaped variables declarations +# into 'config.status', and then the shell code to quote escape them in +# for loops in 'config.status'. Finally, any additional code accumulated +# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. +m4_defun([_LT_CONFIG_COMMANDS], +[AC_PROVIDE_IFELSE([LT_OUTPUT], + dnl If the libtool generation code has been placed in $CONFIG_LT, + dnl instead of duplicating it all over again into config.status, + dnl then we will have config.status run $CONFIG_LT later, so it + dnl needs to know what name is stored there: + [AC_CONFIG_COMMANDS([libtool], + [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], + dnl If the libtool generation code is destined for config.status, + dnl expand the accumulated commands and init code now: + [AC_CONFIG_COMMANDS([libtool], + [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) +])#_LT_CONFIG_COMMANDS + + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], +[ + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +sed_quote_subst='$sed_quote_subst' +double_quote_subst='$double_quote_subst' +delay_variable_subst='$delay_variable_subst' +_LT_CONFIG_STATUS_DECLARATIONS +LTCC='$LTCC' +LTCFLAGS='$LTCFLAGS' +compiler='$compiler_DEFAULT' + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +\$[]1 +_LTECHO_EOF' +} + +# Quote evaled strings. +for var in lt_decl_all_varnames([[ \ +]], lt_decl_quote_varnames); do + case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in + *[[\\\\\\\`\\"\\\$]]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +# Double-quote double-evaled strings. +for var in lt_decl_all_varnames([[ \ +]], lt_decl_dquote_varnames); do + case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in + *[[\\\\\\\`\\"\\\$]]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +_LT_OUTPUT_LIBTOOL_INIT +]) + +# _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) +# ------------------------------------ +# Generate a child script FILE with all initialization necessary to +# reuse the environment learned by the parent script, and make the +# file executable. If COMMENT is supplied, it is inserted after the +# '#!' sequence but before initialization text begins. After this +# macro, additional text can be appended to FILE to form the body of +# the child script. The macro ends with non-zero status if the +# file could not be fully written (such as if the disk is full). +m4_ifdef([AS_INIT_GENERATED], +[m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], +[m4_defun([_LT_GENERATED_FILE_INIT], +[m4_require([AS_PREPARE])]dnl +[m4_pushdef([AS_MESSAGE_LOG_FD])]dnl +[lt_write_fail=0 +cat >$1 <<_ASEOF || lt_write_fail=1 +#! $SHELL +# Generated by $as_me. +$2 +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$1 <<\_ASEOF || lt_write_fail=1 +AS_SHELL_SANITIZE +_AS_PREPARE +exec AS_MESSAGE_FD>&1 +_ASEOF +test 0 = "$lt_write_fail" && chmod +x $1[]dnl +m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT + +# LT_OUTPUT +# --------- +# This macro allows early generation of the libtool script (before +# AC_OUTPUT is called), incase it is used in configure for compilation +# tests. +AC_DEFUN([LT_OUTPUT], +[: ${CONFIG_LT=./config.lt} +AC_MSG_NOTICE([creating $CONFIG_LT]) +_LT_GENERATED_FILE_INIT(["$CONFIG_LT"], +[# Run this file to recreate a libtool stub with the current configuration.]) + +cat >>"$CONFIG_LT" <<\_LTEOF +lt_cl_silent=false +exec AS_MESSAGE_LOG_FD>>config.log +{ + echo + AS_BOX([Running $as_me.]) +} >&AS_MESSAGE_LOG_FD + +lt_cl_help="\ +'$as_me' creates a local libtool stub from the current configuration, +for use in further configure time tests before the real libtool is +generated. + +Usage: $[0] [[OPTIONS]] + + -h, --help print this help, then exit + -V, --version print version number, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + +Report bugs to ." + +lt_cl_version="\ +m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl +m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) +configured by $[0], generated by m4_PACKAGE_STRING. + +Copyright (C) 2011 Free Software Foundation, Inc. +This config.lt script is free software; the Free Software Foundation +gives unlimited permision to copy, distribute and modify it." + +while test 0 != $[#] +do + case $[1] in + --version | --v* | -V ) + echo "$lt_cl_version"; exit 0 ;; + --help | --h* | -h ) + echo "$lt_cl_help"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --quiet | --q* | --silent | --s* | -q ) + lt_cl_silent=: ;; + + -*) AC_MSG_ERROR([unrecognized option: $[1] +Try '$[0] --help' for more information.]) ;; + + *) AC_MSG_ERROR([unrecognized argument: $[1] +Try '$[0] --help' for more information.]) ;; + esac + shift +done + +if $lt_cl_silent; then + exec AS_MESSAGE_FD>/dev/null +fi +_LTEOF + +cat >>"$CONFIG_LT" <<_LTEOF +_LT_OUTPUT_LIBTOOL_COMMANDS_INIT +_LTEOF + +cat >>"$CONFIG_LT" <<\_LTEOF +AC_MSG_NOTICE([creating $ofile]) +_LT_OUTPUT_LIBTOOL_COMMANDS +AS_EXIT(0) +_LTEOF +chmod +x "$CONFIG_LT" + +# configure is writing to config.log, but config.lt does its own redirection, +# appending to config.log, which fails on DOS, as config.log is still kept +# open by configure. Here we exec the FD to /dev/null, effectively closing +# config.log, so it can be properly (re)opened and appended to by config.lt. +lt_cl_success=: +test yes = "$silent" && + lt_config_lt_args="$lt_config_lt_args --quiet" +exec AS_MESSAGE_LOG_FD>/dev/null +$SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false +exec AS_MESSAGE_LOG_FD>>config.log +$lt_cl_success || AS_EXIT(1) +])# LT_OUTPUT + + +# _LT_CONFIG(TAG) +# --------------- +# If TAG is the built-in tag, create an initial libtool script with a +# default configuration from the untagged config vars. Otherwise add code +# to config.status for appending the configuration named by TAG from the +# matching tagged config vars. +m4_defun([_LT_CONFIG], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +_LT_CONFIG_SAVE_COMMANDS([ + m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl + m4_if(_LT_TAG, [C], [ + # See if we are running on zsh, and set the options that allow our + # commands through without removal of \ escapes. + if test -n "${ZSH_VERSION+set}"; then + setopt NO_GLOB_SUBST + fi + + cfgfile=${ofile}T + trap "$RM \"$cfgfile\"; exit 1" 1 2 15 + $RM "$cfgfile" + + cat <<_LT_EOF >> "$cfgfile" +#! $SHELL +# Generated automatically by $as_me ($PACKAGE) $VERSION +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# NOTE: Changes made to this file will be lost: look at ltmain.sh. + +# Provide generalized library-building support services. +# Written by Gordon Matzigkeit, 1996 + +_LT_COPYING +_LT_LIBTOOL_TAGS + +# Configured defaults for sys_lib_dlsearch_path munging. +: \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"} + +# ### BEGIN LIBTOOL CONFIG +_LT_LIBTOOL_CONFIG_VARS +_LT_LIBTOOL_TAG_VARS +# ### END LIBTOOL CONFIG + +_LT_EOF + + cat <<'_LT_EOF' >> "$cfgfile" + +# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE + +_LT_PREPARE_MUNGE_PATH_LIST +_LT_PREPARE_CC_BASENAME + +# ### END FUNCTIONS SHARED WITH CONFIGURE + +_LT_EOF + + case $host_os in + aix3*) + cat <<\_LT_EOF >> "$cfgfile" +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test set != "${COLLECT_NAMES+set}"; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +_LT_EOF + ;; + esac + + _LT_PROG_LTMAIN + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '$q' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" +], +[cat <<_LT_EOF >> "$ofile" + +dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded +dnl in a comment (ie after a #). +# ### BEGIN LIBTOOL TAG CONFIG: $1 +_LT_LIBTOOL_TAG_VARS(_LT_TAG) +# ### END LIBTOOL TAG CONFIG: $1 +_LT_EOF +])dnl /m4_if +], +[m4_if([$1], [], [ + PACKAGE='$PACKAGE' + VERSION='$VERSION' + RM='$RM' + ofile='$ofile'], []) +])dnl /_LT_CONFIG_SAVE_COMMANDS +])# _LT_CONFIG + + +# LT_SUPPORTED_TAG(TAG) +# --------------------- +# Trace this macro to discover what tags are supported by the libtool +# --tag option, using: +# autoconf --trace 'LT_SUPPORTED_TAG:$1' +AC_DEFUN([LT_SUPPORTED_TAG], []) + + +# C support is built-in for now +m4_define([_LT_LANG_C_enabled], []) +m4_define([_LT_TAGS], []) + + +# LT_LANG(LANG) +# ------------- +# Enable libtool support for the given language if not already enabled. +AC_DEFUN([LT_LANG], +[AC_BEFORE([$0], [LT_OUTPUT])dnl +m4_case([$1], + [C], [_LT_LANG(C)], + [C++], [_LT_LANG(CXX)], + [Go], [_LT_LANG(GO)], + [Java], [_LT_LANG(GCJ)], + [Fortran 77], [_LT_LANG(F77)], + [Fortran], [_LT_LANG(FC)], + [Windows Resource], [_LT_LANG(RC)], + [m4_ifdef([_LT_LANG_]$1[_CONFIG], + [_LT_LANG($1)], + [m4_fatal([$0: unsupported language: "$1"])])])dnl +])# LT_LANG + + +# _LT_LANG(LANGNAME) +# ------------------ +m4_defun([_LT_LANG], +[m4_ifdef([_LT_LANG_]$1[_enabled], [], + [LT_SUPPORTED_TAG([$1])dnl + m4_append([_LT_TAGS], [$1 ])dnl + m4_define([_LT_LANG_]$1[_enabled], [])dnl + _LT_LANG_$1_CONFIG($1)])dnl +])# _LT_LANG + + +m4_ifndef([AC_PROG_GO], [ +############################################################ +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_GO. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # +############################################################ +m4_defun([AC_PROG_GO], +[AC_LANG_PUSH(Go)dnl +AC_ARG_VAR([GOC], [Go compiler command])dnl +AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl +_AC_ARG_VAR_LDFLAGS()dnl +AC_CHECK_TOOL(GOC, gccgo) +if test -z "$GOC"; then + if test -n "$ac_tool_prefix"; then + AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) + fi +fi +if test -z "$GOC"; then + AC_CHECK_PROG(GOC, gccgo, gccgo, false) +fi +])#m4_defun +])#m4_ifndef + + +# _LT_LANG_DEFAULT_CONFIG +# ----------------------- +m4_defun([_LT_LANG_DEFAULT_CONFIG], +[AC_PROVIDE_IFELSE([AC_PROG_CXX], + [LT_LANG(CXX)], + [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) + +AC_PROVIDE_IFELSE([AC_PROG_F77], + [LT_LANG(F77)], + [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) + +AC_PROVIDE_IFELSE([AC_PROG_FC], + [LT_LANG(FC)], + [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) + +dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal +dnl pulling things in needlessly. +AC_PROVIDE_IFELSE([AC_PROG_GCJ], + [LT_LANG(GCJ)], + [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], + [LT_LANG(GCJ)], + [AC_PROVIDE_IFELSE([LT_PROG_GCJ], + [LT_LANG(GCJ)], + [m4_ifdef([AC_PROG_GCJ], + [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) + m4_ifdef([A][M_PROG_GCJ], + [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) + m4_ifdef([LT_PROG_GCJ], + [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) + +AC_PROVIDE_IFELSE([AC_PROG_GO], + [LT_LANG(GO)], + [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) + +AC_PROVIDE_IFELSE([LT_PROG_RC], + [LT_LANG(RC)], + [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) +])# _LT_LANG_DEFAULT_CONFIG + +# Obsolete macros: +AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) +AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) +AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) +AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) +AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_CXX], []) +dnl AC_DEFUN([AC_LIBTOOL_F77], []) +dnl AC_DEFUN([AC_LIBTOOL_FC], []) +dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) +dnl AC_DEFUN([AC_LIBTOOL_RC], []) + + +# _LT_TAG_COMPILER +# ---------------- +m4_defun([_LT_TAG_COMPILER], +[AC_REQUIRE([AC_PROG_CC])dnl + +_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl +_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl +_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl +_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC +])# _LT_TAG_COMPILER + + +# _LT_COMPILER_BOILERPLATE +# ------------------------ +# Check for compiler boilerplate output or warnings with +# the simple compiler test code. +m4_defun([_LT_COMPILER_BOILERPLATE], +[m4_require([_LT_DECL_SED])dnl +ac_outfile=conftest.$ac_objext +echo "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$RM conftest* +])# _LT_COMPILER_BOILERPLATE + + +# _LT_LINKER_BOILERPLATE +# ---------------------- +# Check for linker boilerplate output or warnings with +# the simple link test code. +m4_defun([_LT_LINKER_BOILERPLATE], +[m4_require([_LT_DECL_SED])dnl +ac_outfile=conftest.$ac_objext +echo "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$RM -r conftest* +])# _LT_LINKER_BOILERPLATE + +# _LT_REQUIRED_DARWIN_CHECKS +# ------------------------- +m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ + case $host_os in + rhapsody* | darwin*) + AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) + AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) + AC_CHECK_TOOL([LIPO], [lipo], [:]) + AC_CHECK_TOOL([OTOOL], [otool], [:]) + AC_CHECK_TOOL([OTOOL64], [otool64], [:]) + _LT_DECL([], [DSYMUTIL], [1], + [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) + _LT_DECL([], [NMEDIT], [1], + [Tool to change global to local symbols on Mac OS X]) + _LT_DECL([], [LIPO], [1], + [Tool to manipulate fat objects and archives on Mac OS X]) + _LT_DECL([], [OTOOL], [1], + [ldd/readelf like tool for Mach-O binaries on Mac OS X]) + _LT_DECL([], [OTOOL64], [1], + [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) + + AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], + [lt_cv_apple_cc_single_mod=no + if test -z "$LT_MULTI_MODULE"; then + # By default we will add the -single_module flag. You can override + # by either setting the environment variable LT_MULTI_MODULE + # non-empty at configure time, or by adding -multi_module to the + # link flags. + rm -rf libconftest.dylib* + echo "int foo(void){return 1;}" > conftest.c + echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ +-dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD + $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ + -dynamiclib -Wl,-single_module conftest.c 2>conftest.err + _lt_result=$? + # If there is a non-empty error log, and "single_module" + # appears in it, assume the flag caused a linker warning + if test -s conftest.err && $GREP single_module conftest.err; then + cat conftest.err >&AS_MESSAGE_LOG_FD + # Otherwise, if the output was created with a 0 exit code from + # the compiler, it worked. + elif test -f libconftest.dylib && test 0 = "$_lt_result"; then + lt_cv_apple_cc_single_mod=yes + else + cat conftest.err >&AS_MESSAGE_LOG_FD + fi + rm -rf libconftest.dylib* + rm -f conftest.* + fi]) + + AC_CACHE_CHECK([for -exported_symbols_list linker flag], + [lt_cv_ld_exported_symbols_list], + [lt_cv_ld_exported_symbols_list=no + save_LDFLAGS=$LDFLAGS + echo "_main" > conftest.sym + LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [lt_cv_ld_exported_symbols_list=yes], + [lt_cv_ld_exported_symbols_list=no]) + LDFLAGS=$save_LDFLAGS + ]) + + AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], + [lt_cv_ld_force_load=no + cat > conftest.c << _LT_EOF +int forced_loaded() { return 2;} +_LT_EOF + echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD + $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD + echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD + $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD + echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD + $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD + cat > conftest.c << _LT_EOF +int main() { return 0;} +_LT_EOF + echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD + $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err + _lt_result=$? + if test -s conftest.err && $GREP force_load conftest.err; then + cat conftest.err >&AS_MESSAGE_LOG_FD + elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then + lt_cv_ld_force_load=yes + else + cat conftest.err >&AS_MESSAGE_LOG_FD + fi + rm -f conftest.err libconftest.a conftest conftest.c + rm -rf conftest.dSYM + ]) + case $host_os in + rhapsody* | darwin1.[[012]]) + _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; + darwin1.*) + _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; + darwin*) # darwin 5.x on + # if running on 10.5 or later, the deployment target defaults + # to the OS version, if on x86, and 10.4, the deployment + # target defaults to 10.4. Don't you love it? + case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in + 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) + _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; + 10.[[012]][[,.]]*) + _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; + 10.*) + _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; + esac + ;; + esac + if test yes = "$lt_cv_apple_cc_single_mod"; then + _lt_dar_single_mod='$single_module' + fi + if test yes = "$lt_cv_ld_exported_symbols_list"; then + _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym' + else + _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib' + fi + if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then + _lt_dsymutil='~$DSYMUTIL $lib || :' + else + _lt_dsymutil= + fi + ;; + esac +]) + + +# _LT_DARWIN_LINKER_FEATURES([TAG]) +# --------------------------------- +# Checks for linker and compiler features on darwin +m4_defun([_LT_DARWIN_LINKER_FEATURES], +[ + m4_require([_LT_REQUIRED_DARWIN_CHECKS]) + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_automatic, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + if test yes = "$lt_cv_ld_force_load"; then + _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' + m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], + [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) + else + _LT_TAGVAR(whole_archive_flag_spec, $1)='' + fi + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)=$_lt_dar_allow_undefined + case $cc_basename in + ifort*|nagfor*) _lt_dar_can_shared=yes ;; + *) _lt_dar_can_shared=$GCC ;; + esac + if test yes = "$_lt_dar_can_shared"; then + output_verbose_link_cmd=func_echo_all + _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" + _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" + _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" + _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" + m4_if([$1], [CXX], +[ if test yes != "$lt_cv_apple_cc_single_mod"; then + _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil" + _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil" + fi +],[]) + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi +]) + +# _LT_SYS_MODULE_PATH_AIX([TAGNAME]) +# ---------------------------------- +# Links a minimal program and checks the executable +# for the system default hardcoded library path. In most cases, +# this is /usr/lib:/lib, but when the MPI compilers are used +# the location of the communication and MPI libs are included too. +# If we don't find anything, use the default library path according +# to the aix ld manual. +# Store the results from the different compilers for each TAGNAME. +# Allow to override them for all tags through lt_cv_aix_libpath. +m4_defun([_LT_SYS_MODULE_PATH_AIX], +[m4_require([_LT_DECL_SED])dnl +if test set = "${lt_cv_aix_libpath+set}"; then + aix_libpath=$lt_cv_aix_libpath +else + AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], + [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ + lt_aix_libpath_sed='[ + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\([^ ]*\) *$/\1/ + p + } + }]' + _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + # Check for a 64-bit object if we didn't find anything. + if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then + _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + fi],[]) + if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then + _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=/usr/lib:/lib + fi + ]) + aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) +fi +])# _LT_SYS_MODULE_PATH_AIX + + +# _LT_SHELL_INIT(ARG) +# ------------------- +m4_define([_LT_SHELL_INIT], +[m4_divert_text([M4SH-INIT], [$1 +])])# _LT_SHELL_INIT + + + +# _LT_PROG_ECHO_BACKSLASH +# ----------------------- +# Find how we can fake an echo command that does not interpret backslash. +# In particular, with Autoconf 2.60 or later we add some code to the start +# of the generated configure script that will find a shell with a builtin +# printf (that we can use as an echo command). +m4_defun([_LT_PROG_ECHO_BACKSLASH], +[ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO + +AC_MSG_CHECKING([how to print strings]) +# Test print first, because it will be a builtin if present. +if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ + test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then + ECHO='print -r --' +elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then + ECHO='printf %s\n' +else + # Use this function as a fallback that always works. + func_fallback_echo () + { + eval 'cat <<_LTECHO_EOF +$[]1 +_LTECHO_EOF' + } + ECHO='func_fallback_echo' +fi + +# func_echo_all arg... +# Invoke $ECHO with all args, space-separated. +func_echo_all () +{ + $ECHO "$*" +} + +case $ECHO in + printf*) AC_MSG_RESULT([printf]) ;; + print*) AC_MSG_RESULT([print -r]) ;; + *) AC_MSG_RESULT([cat]) ;; +esac + +m4_ifdef([_AS_DETECT_SUGGESTED], +[_AS_DETECT_SUGGESTED([ + test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || ( + ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' + ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO + ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO + PATH=/empty FPATH=/empty; export PATH FPATH + test "X`printf %s $ECHO`" = "X$ECHO" \ + || test "X`print -r -- $ECHO`" = "X$ECHO" )])]) + +_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) +_LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) +])# _LT_PROG_ECHO_BACKSLASH + + +# _LT_WITH_SYSROOT +# ---------------- +AC_DEFUN([_LT_WITH_SYSROOT], +[AC_MSG_CHECKING([for sysroot]) +AC_ARG_WITH([sysroot], +[AS_HELP_STRING([--with-sysroot@<:@=DIR@:>@], + [Search for dependent libraries within DIR (or the compiler's sysroot + if not specified).])], +[], [with_sysroot=no]) + +dnl lt_sysroot will always be passed unquoted. We quote it here +dnl in case the user passed a directory name. +lt_sysroot= +case $with_sysroot in #( + yes) + if test yes = "$GCC"; then + lt_sysroot=`$CC --print-sysroot 2>/dev/null` + fi + ;; #( + /*) + lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` + ;; #( + no|'') + ;; #( + *) + AC_MSG_RESULT([$with_sysroot]) + AC_MSG_ERROR([The sysroot must be an absolute path.]) + ;; +esac + + AC_MSG_RESULT([${lt_sysroot:-no}]) +_LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl +[dependent libraries, and where our libraries should be installed.])]) + +# _LT_ENABLE_LOCK +# --------------- +m4_defun([_LT_ENABLE_LOCK], +[AC_ARG_ENABLE([libtool-lock], + [AS_HELP_STRING([--disable-libtool-lock], + [avoid locking (might break parallel builds)])]) +test no = "$enable_libtool_lock" || enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out what ABI is being produced by ac_compile, and set mode + # options accordingly. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE=32 + ;; + *ELF-64*) + HPUX_IA64_MODE=64 + ;; + esac + fi + rm -rf conftest* + ;; +*-*-irix6*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. + echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + if test yes = "$lt_cv_prog_gnu_ld"; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + fi + rm -rf conftest* + ;; + +mips64*-*linux*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. + echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + emul=elf + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + emul="${emul}32" + ;; + *64-bit*) + emul="${emul}64" + ;; + esac + case `/usr/bin/file conftest.$ac_objext` in + *MSB*) + emul="${emul}btsmip" + ;; + *LSB*) + emul="${emul}ltsmip" + ;; + esac + case `/usr/bin/file conftest.$ac_objext` in + *N32*) + emul="${emul}n32" + ;; + esac + LD="${LD-ld} -m $emul" + fi + rm -rf conftest* + ;; + +x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ +s390*-*linux*|s390*-*tpf*|sparc*-*linux*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. Note that the listed cases only cover the + # situations where additional linker options are needed (such as when + # doing 32-bit compilation for a host where ld defaults to 64-bit, or + # vice versa); the common cases where no linker options are needed do + # not appear in the list. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.o` in + *32-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_i386_fbsd" + ;; + x86_64-*linux*) + case `/usr/bin/file conftest.o` in + *x86-64*) + LD="${LD-ld} -m elf32_x86_64" + ;; + *) + LD="${LD-ld} -m elf_i386" + ;; + esac + ;; + powerpc64le-*linux*) + LD="${LD-ld} -m elf32lppclinux" + ;; + powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_x86_64_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + powerpcle-*linux*) + LD="${LD-ld} -m elf64lppc" + ;; + powerpc-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*|s390*-*tpf*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS -belf" + AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, + [AC_LANG_PUSH(C) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) + AC_LANG_POP]) + if test yes != "$lt_cv_cc_needs_belf"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS=$SAVE_CFLAGS + fi + ;; +*-*solaris*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.o` in + *64-bit*) + case $lt_cv_prog_gnu_ld in + yes*) + case $host in + i?86-*-solaris*|x86_64-*-solaris*) + LD="${LD-ld} -m elf_x86_64" + ;; + sparc*-*-solaris*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + # GNU ld 2.21 introduced _sol2 emulations. Use them if available. + if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then + LD=${LD-ld}_sol2 + fi + ;; + *) + if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then + LD="${LD-ld} -64" + fi + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; +esac + +need_locks=$enable_libtool_lock +])# _LT_ENABLE_LOCK + + +# _LT_PROG_AR +# ----------- +m4_defun([_LT_PROG_AR], +[AC_CHECK_TOOLS(AR, [ar], false) +: ${AR=ar} +: ${AR_FLAGS=cru} +_LT_DECL([], [AR], [1], [The archiver]) +_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) + +AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], + [lt_cv_ar_at_file=no + AC_COMPILE_IFELSE([AC_LANG_PROGRAM], + [echo conftest.$ac_objext > conftest.lst + lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' + AC_TRY_EVAL([lt_ar_try]) + if test 0 -eq "$ac_status"; then + # Ensure the archiver fails upon bogus file names. + rm -f conftest.$ac_objext libconftest.a + AC_TRY_EVAL([lt_ar_try]) + if test 0 -ne "$ac_status"; then + lt_cv_ar_at_file=@ + fi + fi + rm -f conftest.* libconftest.a + ]) + ]) + +if test no = "$lt_cv_ar_at_file"; then + archiver_list_spec= +else + archiver_list_spec=$lt_cv_ar_at_file +fi +_LT_DECL([], [archiver_list_spec], [1], + [How to feed a file listing to the archiver]) +])# _LT_PROG_AR + + +# _LT_CMD_OLD_ARCHIVE +# ------------------- +m4_defun([_LT_CMD_OLD_ARCHIVE], +[_LT_PROG_AR + +AC_CHECK_TOOL(STRIP, strip, :) +test -z "$STRIP" && STRIP=: +_LT_DECL([], [STRIP], [1], [A symbol stripping program]) + +AC_CHECK_TOOL(RANLIB, ranlib, :) +test -z "$RANLIB" && RANLIB=: +_LT_DECL([], [RANLIB], [1], + [Commands used to install an old-style archive]) + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + bitrig* | openbsd*) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" + ;; + *) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" +fi + +case $host_os in + darwin*) + lock_old_archive_extraction=yes ;; + *) + lock_old_archive_extraction=no ;; +esac +_LT_DECL([], [old_postinstall_cmds], [2]) +_LT_DECL([], [old_postuninstall_cmds], [2]) +_LT_TAGDECL([], [old_archive_cmds], [2], + [Commands used to build an old-style archive]) +_LT_DECL([], [lock_old_archive_extraction], [0], + [Whether to use a lock for old archive extraction]) +])# _LT_CMD_OLD_ARCHIVE + + +# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) +# ---------------------------------------------------------------- +# Check whether the given compiler option works +AC_DEFUN([_LT_COMPILER_OPTION], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_SED])dnl +AC_CACHE_CHECK([$1], [$2], + [$2=no + m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$3" ## exclude from sc_useless_quotes_in_assignment + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + $2=yes + fi + fi + $RM conftest* +]) + +if test yes = "[$]$2"; then + m4_if([$5], , :, [$5]) +else + m4_if([$6], , :, [$6]) +fi +])# _LT_COMPILER_OPTION + +# Old name: +AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) + + +# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [ACTION-SUCCESS], [ACTION-FAILURE]) +# ---------------------------------------------------- +# Check whether the given linker option works +AC_DEFUN([_LT_LINKER_OPTION], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_SED])dnl +AC_CACHE_CHECK([$1], [$2], + [$2=no + save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS $3" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&AS_MESSAGE_LOG_FD + $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + $2=yes + fi + else + $2=yes + fi + fi + $RM -r conftest* + LDFLAGS=$save_LDFLAGS +]) + +if test yes = "[$]$2"; then + m4_if([$4], , :, [$4]) +else + m4_if([$5], , :, [$5]) +fi +])# _LT_LINKER_OPTION + +# Old name: +AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) + + +# LT_CMD_MAX_LEN +#--------------- +AC_DEFUN([LT_CMD_MAX_LEN], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +# find the maximum length of command line arguments +AC_MSG_CHECKING([the maximum length of command line arguments]) +AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl + i=0 + teststring=ABCD + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + + cygwin* | mingw* | cegcc*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + + mint*) + # On MiNT this can take a long time and run out of memory. + lt_cv_sys_max_cmd_len=8192; + ;; + + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*) + # This has been around since 386BSD, at least. Likely further. + if test -x /sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` + elif test -x /usr/sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` + else + lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs + fi + # And add a safety zone + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + ;; + + interix*) + # We know the value 262144 and hardcode it with a safety zone (like BSD) + lt_cv_sys_max_cmd_len=196608 + ;; + + os2*) + # The test takes a long time on OS/2. + lt_cv_sys_max_cmd_len=8192 + ;; + + osf*) + # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure + # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not + # nice to cause kernel panics so lets avoid the loop below. + # First set a reasonable default. + lt_cv_sys_max_cmd_len=16384 + # + if test -x /sbin/sysconfig; then + case `/sbin/sysconfig -q proc exec_disable_arg_limit` in + *1*) lt_cv_sys_max_cmd_len=-1 ;; + esac + fi + ;; + sco3.2v5*) + lt_cv_sys_max_cmd_len=102400 + ;; + sysv5* | sco5v6* | sysv4.2uw2*) + kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` + if test -n "$kargmax"; then + lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` + else + lt_cv_sys_max_cmd_len=32768 + fi + ;; + *) + lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` + if test -n "$lt_cv_sys_max_cmd_len" && \ + test undefined != "$lt_cv_sys_max_cmd_len"; then + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + else + # Make teststring a little bigger before we do anything with it. + # a 1K string should be a reasonable start. + for i in 1 2 3 4 5 6 7 8; do + teststring=$teststring$teststring + done + SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} + # If test is not a shell built-in, we'll probably end up computing a + # maximum length that is only half of the actual maximum length, but + # we can't tell. + while { test X`env echo "$teststring$teststring" 2>/dev/null` \ + = "X$teststring$teststring"; } >/dev/null 2>&1 && + test 17 != "$i" # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + # Only check the string length outside the loop. + lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` + teststring= + # Add a significant safety factor because C++ compilers can tack on + # massive amounts of additional arguments before passing them to the + # linker. It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + fi + ;; + esac +]) +if test -n "$lt_cv_sys_max_cmd_len"; then + AC_MSG_RESULT($lt_cv_sys_max_cmd_len) +else + AC_MSG_RESULT(none) +fi +max_cmd_len=$lt_cv_sys_max_cmd_len +_LT_DECL([], [max_cmd_len], [0], + [What is the maximum length of a command?]) +])# LT_CMD_MAX_LEN + +# Old name: +AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) + + +# _LT_HEADER_DLFCN +# ---------------- +m4_defun([_LT_HEADER_DLFCN], +[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl +])# _LT_HEADER_DLFCN + + +# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, +# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) +# ---------------------------------------------------------------- +m4_defun([_LT_TRY_DLOPEN_SELF], +[m4_require([_LT_HEADER_DLFCN])dnl +if test yes = "$cross_compiling"; then : + [$4] +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +[#line $LINENO "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +/* When -fvisibility=hidden is used, assume the code has been annotated + correspondingly for the symbols needed. */ +#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) +int fnord () __attribute__((visibility("default"))); +#endif + +int fnord () { return 42; } +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else + { + if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + else puts (dlerror ()); + } + /* dlclose (self); */ + } + else + puts (dlerror ()); + + return status; +}] +_LT_EOF + if AC_TRY_EVAL(ac_link) && test -s "conftest$ac_exeext" 2>/dev/null; then + (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) $1 ;; + x$lt_dlneed_uscore) $2 ;; + x$lt_dlunknown|x*) $3 ;; + esac + else : + # compilation failed + $3 + fi +fi +rm -fr conftest* +])# _LT_TRY_DLOPEN_SELF + + +# LT_SYS_DLOPEN_SELF +# ------------------ +AC_DEFUN([LT_SYS_DLOPEN_SELF], +[m4_require([_LT_HEADER_DLFCN])dnl +if test yes != "$enable_dlopen"; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen=load_add_on + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32* | cegcc*) + lt_cv_dlopen=LoadLibrary + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen=dlopen + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl],[ + lt_cv_dlopen=dyld + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ]) + ;; + + tpf*) + # Don't try to run any link tests for TPF. We know it's impossible + # because TPF is a cross-compiler, and we know how we open DSOs. + lt_cv_dlopen=dlopen + lt_cv_dlopen_libs= + lt_cv_dlopen_self=no + ;; + + *) + AC_CHECK_FUNC([shl_load], + [lt_cv_dlopen=shl_load], + [AC_CHECK_LIB([dld], [shl_load], + [lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld], + [AC_CHECK_FUNC([dlopen], + [lt_cv_dlopen=dlopen], + [AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl], + [AC_CHECK_LIB([svld], [dlopen], + [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld], + [AC_CHECK_LIB([dld], [dld_link], + [lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld]) + ]) + ]) + ]) + ]) + ]) + ;; + esac + + if test no = "$lt_cv_dlopen"; then + enable_dlopen=no + else + enable_dlopen=yes + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS=$CPPFLAGS + test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS=$LDFLAGS + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS=$LIBS + LIBS="$lt_cv_dlopen_libs $LIBS" + + AC_CACHE_CHECK([whether a program can dlopen itself], + lt_cv_dlopen_self, [dnl + _LT_TRY_DLOPEN_SELF( + lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, + lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) + ]) + + if test yes = "$lt_cv_dlopen_self"; then + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" + AC_CACHE_CHECK([whether a statically linked program can dlopen itself], + lt_cv_dlopen_self_static, [dnl + _LT_TRY_DLOPEN_SELF( + lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, + lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) + ]) + fi + + CPPFLAGS=$save_CPPFLAGS + LDFLAGS=$save_LDFLAGS + LIBS=$save_LIBS + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi +_LT_DECL([dlopen_support], [enable_dlopen], [0], + [Whether dlopen is supported]) +_LT_DECL([dlopen_self], [enable_dlopen_self], [0], + [Whether dlopen of programs is supported]) +_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], + [Whether dlopen of statically linked programs is supported]) +])# LT_SYS_DLOPEN_SELF + +# Old name: +AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) + + +# _LT_COMPILER_C_O([TAGNAME]) +# --------------------------- +# Check to see if options -c and -o are simultaneously supported by compiler. +# This macro does not hard code the compiler like AC_PROG_CC_C_O. +m4_defun([_LT_COMPILER_C_O], +[m4_require([_LT_DECL_SED])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_TAG_COMPILER])dnl +AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], + [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], + [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + fi + fi + chmod u+w . 2>&AS_MESSAGE_LOG_FD + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* +]) +_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], + [Does compiler simultaneously support -c and -o options?]) +])# _LT_COMPILER_C_O + + +# _LT_COMPILER_FILE_LOCKS([TAGNAME]) +# ---------------------------------- +# Check to see if we can do hard links to lock some files if needed +m4_defun([_LT_COMPILER_FILE_LOCKS], +[m4_require([_LT_ENABLE_LOCK])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +_LT_COMPILER_C_O([$1]) + +hard_links=nottested +if test no = "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" && test no != "$need_locks"; then + # do not overwrite the value of need_locks provided by the user + AC_MSG_CHECKING([if we can lock with hard links]) + hard_links=yes + $RM conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + AC_MSG_RESULT([$hard_links]) + if test no = "$hard_links"; then + AC_MSG_WARN(['$CC' does not support '-c -o', so 'make -j' may be unsafe]) + need_locks=warn + fi +else + need_locks=no +fi +_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) +])# _LT_COMPILER_FILE_LOCKS + + +# _LT_CHECK_OBJDIR +# ---------------- +m4_defun([_LT_CHECK_OBJDIR], +[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], +[rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null]) +objdir=$lt_cv_objdir +_LT_DECL([], [objdir], [0], + [The name of the directory that contains temporary libtool files])dnl +m4_pattern_allow([LT_OBJDIR])dnl +AC_DEFINE_UNQUOTED([LT_OBJDIR], "$lt_cv_objdir/", + [Define to the sub-directory where libtool stores uninstalled libraries.]) +])# _LT_CHECK_OBJDIR + + +# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) +# -------------------------------------- +# Check hardcoding attributes. +m4_defun([_LT_LINKER_HARDCODE_LIBPATH], +[AC_MSG_CHECKING([how to hardcode library paths into programs]) +_LT_TAGVAR(hardcode_action, $1)= +if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || + test -n "$_LT_TAGVAR(runpath_var, $1)" || + test yes = "$_LT_TAGVAR(hardcode_automatic, $1)"; then + + # We can hardcode non-existent directories. + if test no != "$_LT_TAGVAR(hardcode_direct, $1)" && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" && + test no != "$_LT_TAGVAR(hardcode_minus_L, $1)"; then + # Linking always hardcodes the temporary library directory. + _LT_TAGVAR(hardcode_action, $1)=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + _LT_TAGVAR(hardcode_action, $1)=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + _LT_TAGVAR(hardcode_action, $1)=unsupported +fi +AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) + +if test relink = "$_LT_TAGVAR(hardcode_action, $1)" || + test yes = "$_LT_TAGVAR(inherit_rpath, $1)"; then + # Fast installation is not supported + enable_fast_install=no +elif test yes = "$shlibpath_overrides_runpath" || + test no = "$enable_shared"; then + # Fast installation is not necessary + enable_fast_install=needless +fi +_LT_TAGDECL([], [hardcode_action], [0], + [How to hardcode a shared library path into an executable]) +])# _LT_LINKER_HARDCODE_LIBPATH + + +# _LT_CMD_STRIPLIB +# ---------------- +m4_defun([_LT_CMD_STRIPLIB], +[m4_require([_LT_DECL_EGREP]) +striplib= +old_striplib= +AC_MSG_CHECKING([whether stripping libraries is possible]) +if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + AC_MSG_RESULT([yes]) +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP"; then + striplib="$STRIP -x" + old_striplib="$STRIP -S" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + ;; + *) + AC_MSG_RESULT([no]) + ;; + esac +fi +_LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) +_LT_DECL([], [striplib], [1]) +])# _LT_CMD_STRIPLIB + + +# _LT_PREPARE_MUNGE_PATH_LIST +# --------------------------- +# Make sure func_munge_path_list() is defined correctly. +m4_defun([_LT_PREPARE_MUNGE_PATH_LIST], +[[# func_munge_path_list VARIABLE PATH +# ----------------------------------- +# VARIABLE is name of variable containing _space_ separated list of +# directories to be munged by the contents of PATH, which is string +# having a format: +# "DIR[:DIR]:" +# string "DIR[ DIR]" will be prepended to VARIABLE +# ":DIR[:DIR]" +# string "DIR[ DIR]" will be appended to VARIABLE +# "DIRP[:DIRP]::[DIRA:]DIRA" +# string "DIRP[ DIRP]" will be prepended to VARIABLE and string +# "DIRA[ DIRA]" will be appended to VARIABLE +# "DIR[:DIR]" +# VARIABLE will be replaced by "DIR[ DIR]" +func_munge_path_list () +{ + case x@S|@2 in + x) + ;; + *:) + eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'` \@S|@@S|@1\" + ;; + x:*) + eval @S|@1=\"\@S|@@S|@1 `$ECHO @S|@2 | $SED 's/:/ /g'`\" + ;; + *::*) + eval @S|@1=\"\@S|@@S|@1\ `$ECHO @S|@2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" + eval @S|@1=\"`$ECHO @S|@2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \@S|@@S|@1\" + ;; + *) + eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'`\" + ;; + esac +} +]])# _LT_PREPARE_PATH_LIST + + +# _LT_SYS_DYNAMIC_LINKER([TAG]) +# ----------------------------- +# PORTME Fill in your ld.so characteristics +m4_defun([_LT_SYS_DYNAMIC_LINKER], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_OBJDUMP])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_CHECK_SHELL_FEATURES])dnl +m4_require([_LT_PREPARE_MUNGE_PATH_LIST])dnl +AC_MSG_CHECKING([dynamic linker characteristics]) +m4_if([$1], + [], [ +if test yes = "$GCC"; then + case $host_os in + darwin*) lt_awk_arg='/^libraries:/,/LR/' ;; + *) lt_awk_arg='/^libraries:/' ;; + esac + case $host_os in + mingw* | cegcc*) lt_sed_strip_eq='s|=\([[A-Za-z]]:\)|\1|g' ;; + *) lt_sed_strip_eq='s|=/|/|g' ;; + esac + lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` + case $lt_search_path_spec in + *\;*) + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` + ;; + *) + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` + ;; + esac + # Ok, now we have the path, separated by spaces, we can step through it + # and add multilib dir if necessary... + lt_tmp_lt_search_path_spec= + lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` + # ...but if some path component already ends with the multilib dir we assume + # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer). + case "$lt_multi_os_dir; $lt_search_path_spec " in + "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*) + lt_multi_os_dir= + ;; + esac + for lt_sys_path in $lt_search_path_spec; do + if test -d "$lt_sys_path$lt_multi_os_dir"; then + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir" + elif test -n "$lt_multi_os_dir"; then + test -d "$lt_sys_path" && \ + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" + fi + done + lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' +BEGIN {RS = " "; FS = "/|\n";} { + lt_foo = ""; + lt_count = 0; + for (lt_i = NF; lt_i > 0; lt_i--) { + if ($lt_i != "" && $lt_i != ".") { + if ($lt_i == "..") { + lt_count++; + } else { + if (lt_count == 0) { + lt_foo = "/" $lt_i lt_foo; + } else { + lt_count--; + } + } + } + } + if (lt_foo != "") { lt_freq[[lt_foo]]++; } + if (lt_freq[[lt_foo]] == 1) { print lt_foo; } +}'` + # AWK program above erroneously prepends '/' to C:/dos/paths + # for these hosts. + case $host_os in + mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ + $SED 's|/\([[A-Za-z]]:\)|\1|g'` ;; + esac + sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi]) +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=.so +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +AC_ARG_VAR([LT_SYS_LIBRARY_PATH], +[User-defined run-time library search path.]) + +case $host_os in +aix3*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='$libname$release$shared_ext$major' + ;; + +aix[[4-9]]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test ia64 = "$host_cpu"; then + # AIX 5 supports IA64 + library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line '#! .'. This would cause the generated library to + # depend on '.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[[01]] | aix4.[[01]].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # Using Import Files as archive members, it is possible to support + # filename-based versioning of shared library archives on AIX. While + # this would work for both with and without runtime linking, it will + # prevent static linking of such archives. So we do filename-based + # shared library versioning with .so extension only, which is used + # when both runtime linking and shared linking is enabled. + # Unfortunately, runtime linking may impact performance, so we do + # not want this to be the default eventually. Also, we use the + # versioned .so libs for executables only if there is the -brtl + # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only. + # To allow for filename-based versioning support, we need to create + # libNAME.so.V as an archive file, containing: + # *) an Import File, referring to the versioned filename of the + # archive as well as the shared archive member, telling the + # bitwidth (32 or 64) of that shared object, and providing the + # list of exported symbols of that shared object, eventually + # decorated with the 'weak' keyword + # *) the shared object with the F_LOADONLY flag set, to really avoid + # it being seen by the linker. + # At run time we better use the real file rather than another symlink, + # but for link time we create the symlink libNAME.so -> libNAME.so.V + + case $with_aix_soname,$aix_use_runtimelinking in + # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + aix,yes) # traditional libtool + dynamic_linker='AIX unversionable lib.so' + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + ;; + aix,no) # traditional AIX only + dynamic_linker='AIX lib.a[(]lib.so.V[)]' + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='$libname$release.a $libname.a' + soname_spec='$libname$release$shared_ext$major' + ;; + svr4,*) # full svr4 only + dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)]" + library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' + # We do not specify a path in Import Files, so LIBPATH fires. + shlibpath_overrides_runpath=yes + ;; + *,yes) # both, prefer svr4 + dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)], lib.a[(]lib.so.V[)]" + library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' + # unpreferred sharedlib libNAME.a needs extra handling + postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"' + postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"' + # We do not specify a path in Import Files, so LIBPATH fires. + shlibpath_overrides_runpath=yes + ;; + *,no) # both, prefer aix + dynamic_linker="AIX lib.a[(]lib.so.V[)], lib.so.V[(]$shared_archive_member_spec.o[)]" + library_names_spec='$libname$release.a $libname.a' + soname_spec='$libname$release$shared_ext$major' + # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling + postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)' + postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"' + ;; + esac + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + case $host_cpu in + powerpc) + # Since July 2007 AmigaOS4 officially supports .so libraries. + # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + ;; + m68k) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + esac + ;; + +beos*) + library_names_spec='$libname$shared_ext' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[[45]]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32* | cegcc*) + version_type=windows + shrext_cmds=.dll + need_version=no + need_lib_prefix=no + + case $GCC,$cc_basename in + yes,*) + # gcc + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' +m4_if([$1], [],[ + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) + ;; + mingw* | cegcc*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' + ;; + esac + dynamic_linker='Win32 ld.exe' + ;; + + *,cl*) + # Native MSVC + libname_spec='$name' + soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' + library_names_spec='$libname.dll.lib' + + case $build_os in + mingw*) + sys_lib_search_path_spec= + lt_save_ifs=$IFS + IFS=';' + for lt_path in $LIB + do + IFS=$lt_save_ifs + # Let DOS variable expansion print the short 8.3 style file name. + lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` + sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" + done + IFS=$lt_save_ifs + # Convert to MSYS style. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` + ;; + cygwin*) + # Convert to unix form, then to dos form, then back to unix form + # but this time dos style (no spaces!) so that the unix form looks + # like /cygdrive/c/PROGRA~1:/cygdr... + sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` + sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` + sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + ;; + *) + sys_lib_search_path_spec=$LIB + if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then + # It is most probably a Windows format PATH. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + # FIXME: find the short name or the path components, as spaces are + # common. (e.g. "Program Files" -> "PROGRA~1") + ;; + esac + + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + dynamic_linker='Win32 link.exe' + ;; + + *) + # Assume MSVC wrapper + library_names_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext $libname.lib' + dynamic_linker='Win32 ld.exe' + ;; + esac + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' + soname_spec='$libname$release$major$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' +m4_if([$1], [],[ + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[[23]].*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2.*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[[01]]* | freebsdelf3.[[01]]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ + freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + *) # from 4.6 on, and DragonFly + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +haiku*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + dynamic_linker="$host_os runtime_loader" + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LIBRARY_PATH + shlibpath_overrides_runpath=no + sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + if test 32 = "$HPUX_IA64_MODE"; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + sys_lib_dlsearch_path_spec=/usr/lib/hpux32 + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + sys_lib_dlsearch_path_spec=/usr/lib/hpux64 + fi + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555, ... + postinstall_cmds='chmod 555 $lib' + # or fails outright, so override atomically: + install_override_mode=555 + ;; + +interix[[3-9]]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test yes = "$lt_cv_prog_gnu_ld"; then + version_type=linux # correct to gnu/linux during the next big refactor + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='$libname$release$shared_ext$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff" + sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +linux*android*) + version_type=none # Android doesn't support versioned libraries. + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext' + soname_spec='$libname$release$shared_ext' + finish_cmds= + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + dynamic_linker='Android linker' + # Don't embed -rpath directories since the linker doesn't support them. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + ;; + +# This must be glibc/ELF. +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + + # Some binutils ld are patched to set DT_RUNPATH + AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], + [lt_cv_shlibpath_overrides_runpath=no + save_LDFLAGS=$LDFLAGS + save_libdir=$libdir + eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ + LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], + [lt_cv_shlibpath_overrides_runpath=yes])]) + LDFLAGS=$save_LDFLAGS + libdir=$save_libdir + ]) + shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Ideally, we could use ldconfig to report *all* directores which are + # searched for libraries, however this is still not possible. Aside from not + # being certain /sbin/ldconfig is available, command + # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64, + # even though it is searched at run-time. Try to do the best guess by + # appending ld.so.conf contents (and includes) to the search path. + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +*nto* | *qnx*) + version_type=qnx + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='ldqnx.so' + ;; + +openbsd* | bitrig*) + version_type=sunos + sys_lib_dlsearch_path_spec=/usr/lib + need_lib_prefix=no + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + need_version=no + else + need_version=yes + fi + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +os2*) + libname_spec='$name' + version_type=windows + shrext_cmds=.dll + need_version=no + need_lib_prefix=no + # OS/2 can only load a DLL with a base name of 8 characters or less. + soname_spec='`test -n "$os2dllname" && libname="$os2dllname"; + v=$($ECHO $release$versuffix | tr -d .-); + n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _); + $ECHO $n$v`$shared_ext' + library_names_spec='${libname}_dll.$libext' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=BEGINLIBPATH + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='$libname$release$shared_ext$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + +rdos*) + dynamic_linker=no + ;; + +solaris*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test yes = "$with_gnu_ld"; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec; then + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext' + soname_spec='$libname$shared_ext.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=sco + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + if test yes = "$with_gnu_ld"; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +tpf*) + # TPF is a cross-target only. Preferred cross-host = GNU/Linux. + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +uts4*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +AC_MSG_RESULT([$dynamic_linker]) +test no = "$dynamic_linker" && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test yes = "$GCC"; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then + sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec +fi + +if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then + sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec +fi + +# remember unaugmented sys_lib_dlsearch_path content for libtool script decls... +configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec + +# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code +func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH" + +# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool +configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH + +_LT_DECL([], [variables_saved_for_relink], [1], + [Variables whose values should be saved in libtool wrapper scripts and + restored at link time]) +_LT_DECL([], [need_lib_prefix], [0], + [Do we need the "lib" prefix for modules?]) +_LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) +_LT_DECL([], [version_type], [0], [Library versioning type]) +_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) +_LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) +_LT_DECL([], [shlibpath_overrides_runpath], [0], + [Is shlibpath searched before the hard-coded library search path?]) +_LT_DECL([], [libname_spec], [1], [Format of library name prefix]) +_LT_DECL([], [library_names_spec], [1], + [[List of archive names. First name is the real one, the rest are links. + The last name is the one that the linker finds with -lNAME]]) +_LT_DECL([], [soname_spec], [1], + [[The coded name of the library, if different from the real name]]) +_LT_DECL([], [install_override_mode], [1], + [Permission mode override for installation of shared libraries]) +_LT_DECL([], [postinstall_cmds], [2], + [Command to use after installation of a shared archive]) +_LT_DECL([], [postuninstall_cmds], [2], + [Command to use after uninstallation of a shared archive]) +_LT_DECL([], [finish_cmds], [2], + [Commands used to finish a libtool library installation in a directory]) +_LT_DECL([], [finish_eval], [1], + [[As "finish_cmds", except a single script fragment to be evaled but + not shown]]) +_LT_DECL([], [hardcode_into_libs], [0], + [Whether we should hardcode library paths into libraries]) +_LT_DECL([], [sys_lib_search_path_spec], [2], + [Compile-time system search path for libraries]) +_LT_DECL([sys_lib_dlsearch_path_spec], [configure_time_dlsearch_path], [2], + [Detected run-time system search path for libraries]) +_LT_DECL([], [configure_time_lt_sys_library_path], [2], + [Explicit LT_SYS_LIBRARY_PATH set during ./configure time]) +])# _LT_SYS_DYNAMIC_LINKER + + +# _LT_PATH_TOOL_PREFIX(TOOL) +# -------------------------- +# find a file program that can recognize shared library +AC_DEFUN([_LT_PATH_TOOL_PREFIX], +[m4_require([_LT_DECL_EGREP])dnl +AC_MSG_CHECKING([for $1]) +AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, +[case $MAGIC_CMD in +[[\\/*] | ?:[\\/]*]) + lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD=$MAGIC_CMD + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR +dnl $ac_dummy forces splitting on constant user-supplied paths. +dnl POSIX.2 word splitting is done only on the output of word expansions, +dnl not every word. This closes a longstanding sh security hole. + ac_dummy="m4_if([$2], , $PATH, [$2])" + for ac_dir in $ac_dummy; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$1"; then + lt_cv_path_MAGIC_CMD=$ac_dir/"$1" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD=$lt_cv_path_MAGIC_CMD + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<_LT_EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +_LT_EOF + fi ;; + esac + fi + break + fi + done + IFS=$lt_save_ifs + MAGIC_CMD=$lt_save_MAGIC_CMD + ;; +esac]) +MAGIC_CMD=$lt_cv_path_MAGIC_CMD +if test -n "$MAGIC_CMD"; then + AC_MSG_RESULT($MAGIC_CMD) +else + AC_MSG_RESULT(no) +fi +_LT_DECL([], [MAGIC_CMD], [0], + [Used to examine libraries when file_magic_cmd begins with "file"])dnl +])# _LT_PATH_TOOL_PREFIX + +# Old name: +AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) + + +# _LT_PATH_MAGIC +# -------------- +# find a file program that can recognize a shared library +m4_defun([_LT_PATH_MAGIC], +[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) + else + MAGIC_CMD=: + fi +fi +])# _LT_PATH_MAGIC + + +# LT_PATH_LD +# ---------- +# find the pathname to the GNU or non-GNU linker +AC_DEFUN([LT_PATH_LD], +[AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_PROG_ECHO_BACKSLASH])dnl + +AC_ARG_WITH([gnu-ld], + [AS_HELP_STRING([--with-gnu-ld], + [assume the C compiler uses GNU ld @<:@default=no@:>@])], + [test no = "$withval" || with_gnu_ld=yes], + [with_gnu_ld=no])dnl + +ac_prog=ld +if test yes = "$GCC"; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by $CC]) + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return, which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [[\\/]]* | ?:[[\\/]]*) + re_direlt='/[[^/]][[^/]]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` + while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do + ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD=$ac_prog + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test yes = "$with_gnu_ld"; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(lt_cv_path_LD, +[if test -z "$LD"; then + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD=$ac_dir/$ac_prog + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &1 conftest.i +cat conftest.i conftest.i >conftest2.i +: ${lt_DD:=$DD} +AC_PATH_PROGS_FEATURE_CHECK([lt_DD], [dd], +[if "$ac_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then + cmp -s conftest.i conftest.out \ + && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=: +fi]) +rm -f conftest.i conftest2.i conftest.out]) +])# _LT_PATH_DD + + +# _LT_CMD_TRUNCATE +# ---------------- +# find command to truncate a binary pipe +m4_defun([_LT_CMD_TRUNCATE], +[m4_require([_LT_PATH_DD]) +AC_CACHE_CHECK([how to truncate binary pipes], [lt_cv_truncate_bin], +[printf 0123456789abcdef0123456789abcdef >conftest.i +cat conftest.i conftest.i >conftest2.i +lt_cv_truncate_bin= +if "$ac_cv_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then + cmp -s conftest.i conftest.out \ + && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1" +fi +rm -f conftest.i conftest2.i conftest.out +test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q"]) +_LT_DECL([lt_truncate_bin], [lt_cv_truncate_bin], [1], + [Command to truncate a binary pipe]) +])# _LT_CMD_TRUNCATE + + +# _LT_CHECK_MAGIC_METHOD +# ---------------------- +# how to check for library dependencies +# -- PORTME fill in with the dynamic library characteristics +m4_defun([_LT_CHECK_MAGIC_METHOD], +[m4_require([_LT_DECL_EGREP]) +m4_require([_LT_DECL_OBJDUMP]) +AC_CACHE_CHECK([how to recognize dependent libraries], +lt_cv_deplibs_check_method, +[lt_cv_file_magic_cmd='$MAGIC_CMD' +lt_cv_file_magic_test_file= +lt_cv_deplibs_check_method='unknown' +# Need to set the preceding variable on all platforms that support +# interlibrary dependencies. +# 'none' -- dependencies not supported. +# 'unknown' -- same as none, but documents that we really don't know. +# 'pass_all' -- all dependencies passed with no checks. +# 'test_compile' -- check by making test program. +# 'file_magic [[regex]]' -- check by looking for files in library path +# that responds to the $file_magic_cmd with a given extended regex. +# If you have 'file' or equivalent on your system and you're not sure +# whether 'pass_all' will *always* work, you probably want this one. + +case $host_os in +aix[[4-9]]*) + lt_cv_deplibs_check_method=pass_all + ;; + +beos*) + lt_cv_deplibs_check_method=pass_all + ;; + +bsdi[[45]]*) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)' + lt_cv_file_magic_cmd='/usr/bin/file -L' + lt_cv_file_magic_test_file=/shlib/libc.so + ;; + +cygwin*) + # func_win32_libid is a shell function defined in ltmain.sh + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + ;; + +mingw* | pw32*) + # Base MSYS/MinGW do not provide the 'file' command needed by + # func_win32_libid shell function, so use a weaker test based on 'objdump', + # unless we find 'file', for example because we are cross-compiling. + if ( file / ) >/dev/null 2>&1; then + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + else + # Keep this pattern in sync with the one in func_win32_libid. + lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' + lt_cv_file_magic_cmd='$OBJDUMP -f' + fi + ;; + +cegcc*) + # use the weaker test based on 'objdump'. See mingw*. + lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + ;; + +darwin* | rhapsody*) + lt_cv_deplibs_check_method=pass_all + ;; + +freebsd* | dragonfly*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +haiku*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20* | hpux11*) + lt_cv_file_magic_cmd=/usr/bin/file + case $host_cpu in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'] + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl + ;; + *) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +interix[[3-9]]*) + # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be glibc/ELF. +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +*nto* | *qnx*) + lt_cv_deplibs_check_method=pass_all + ;; + +openbsd* | bitrig*) + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + fi + ;; + +osf3* | osf4* | osf5*) + lt_cv_deplibs_check_method=pass_all + ;; + +rdos*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.3*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + pc) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; + +tpf*) + lt_cv_deplibs_check_method=pass_all + ;; +os2*) + lt_cv_deplibs_check_method=pass_all + ;; +esac +]) + +file_magic_glob= +want_nocaseglob=no +if test "$build" = "$host"; then + case $host_os in + mingw* | pw32*) + if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then + want_nocaseglob=yes + else + file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` + fi + ;; + esac +fi + +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown + +_LT_DECL([], [deplibs_check_method], [1], + [Method to check whether dependent libraries are shared objects]) +_LT_DECL([], [file_magic_cmd], [1], + [Command to use when deplibs_check_method = "file_magic"]) +_LT_DECL([], [file_magic_glob], [1], + [How to find potential files when deplibs_check_method = "file_magic"]) +_LT_DECL([], [want_nocaseglob], [1], + [Find potential files using nocaseglob when deplibs_check_method = "file_magic"]) +])# _LT_CHECK_MAGIC_METHOD + + +# LT_PATH_NM +# ---------- +# find the pathname to a BSD- or MS-compatible name lister +AC_DEFUN([LT_PATH_NM], +[AC_REQUIRE([AC_PROG_CC])dnl +AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, +[if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM=$NM +else + lt_nm_to_check=${ac_tool_prefix}nm + if test -n "$ac_tool_prefix" && test "$build" = "$host"; then + lt_nm_to_check="$lt_nm_to_check nm" + fi + for lt_tmp_nm in $lt_nm_to_check; do + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + tmp_nm=$ac_dir/$lt_tmp_nm + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the 'sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty + case $build_os in + mingw*) lt_bad_file=conftest.nm/nofile ;; + *) lt_bad_file=/dev/null ;; + esac + case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in + *$lt_bad_file* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break 2 + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break 2 + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + ;; + esac + fi + done + IFS=$lt_save_ifs + done + : ${lt_cv_path_NM=no} +fi]) +if test no != "$lt_cv_path_NM"; then + NM=$lt_cv_path_NM +else + # Didn't find any BSD compatible name lister, look for dumpbin. + if test -n "$DUMPBIN"; then : + # Let the user override the test. + else + AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) + case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in + *COFF*) + DUMPBIN="$DUMPBIN -symbols -headers" + ;; + *) + DUMPBIN=: + ;; + esac + fi + AC_SUBST([DUMPBIN]) + if test : != "$DUMPBIN"; then + NM=$DUMPBIN + fi +fi +test -z "$NM" && NM=nm +AC_SUBST([NM]) +_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl + +AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], + [lt_cv_nm_interface="BSD nm" + echo "int some_variable = 0;" > conftest.$ac_ext + (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$ac_compile" 2>conftest.err) + cat conftest.err >&AS_MESSAGE_LOG_FD + (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) + (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) + cat conftest.err >&AS_MESSAGE_LOG_FD + (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD) + cat conftest.out >&AS_MESSAGE_LOG_FD + if $GREP 'External.*some_variable' conftest.out > /dev/null; then + lt_cv_nm_interface="MS dumpbin" + fi + rm -f conftest*]) +])# LT_PATH_NM + +# Old names: +AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) +AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_PROG_NM], []) +dnl AC_DEFUN([AC_PROG_NM], []) + +# _LT_CHECK_SHAREDLIB_FROM_LINKLIB +# -------------------------------- +# how to determine the name of the shared library +# associated with a specific link library. +# -- PORTME fill in with the dynamic library characteristics +m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], +[m4_require([_LT_DECL_EGREP]) +m4_require([_LT_DECL_OBJDUMP]) +m4_require([_LT_DECL_DLLTOOL]) +AC_CACHE_CHECK([how to associate runtime and link libraries], +lt_cv_sharedlib_from_linklib_cmd, +[lt_cv_sharedlib_from_linklib_cmd='unknown' + +case $host_os in +cygwin* | mingw* | pw32* | cegcc*) + # two different shell functions defined in ltmain.sh; + # decide which one to use based on capabilities of $DLLTOOL + case `$DLLTOOL --help 2>&1` in + *--identify-strict*) + lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib + ;; + *) + lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback + ;; + esac + ;; +*) + # fallback: assume linklib IS sharedlib + lt_cv_sharedlib_from_linklib_cmd=$ECHO + ;; +esac +]) +sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd +test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO + +_LT_DECL([], [sharedlib_from_linklib_cmd], [1], + [Command to associate shared and link libraries]) +])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB + + +# _LT_PATH_MANIFEST_TOOL +# ---------------------- +# locate the manifest tool +m4_defun([_LT_PATH_MANIFEST_TOOL], +[AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) +test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt +AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], + [lt_cv_path_mainfest_tool=no + echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD + $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out + cat conftest.err >&AS_MESSAGE_LOG_FD + if $GREP 'Manifest Tool' conftest.out > /dev/null; then + lt_cv_path_mainfest_tool=yes + fi + rm -f conftest*]) +if test yes != "$lt_cv_path_mainfest_tool"; then + MANIFEST_TOOL=: +fi +_LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl +])# _LT_PATH_MANIFEST_TOOL + + +# _LT_DLL_DEF_P([FILE]) +# --------------------- +# True iff FILE is a Windows DLL '.def' file. +# Keep in sync with func_dll_def_p in the libtool script +AC_DEFUN([_LT_DLL_DEF_P], +[dnl + test DEF = "`$SED -n dnl + -e '\''s/^[[ ]]*//'\'' dnl Strip leading whitespace + -e '\''/^\(;.*\)*$/d'\'' dnl Delete empty lines and comments + -e '\''s/^\(EXPORTS\|LIBRARY\)\([[ ]].*\)*$/DEF/p'\'' dnl + -e q dnl Only consider the first "real" line + $1`" dnl +])# _LT_DLL_DEF_P + + +# LT_LIB_M +# -------- +# check for math library +AC_DEFUN([LT_LIB_M], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +LIBM= +case $host in +*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) + # These system don't have libm, or don't need it + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM=-lmw) + AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") + ;; +*) + AC_CHECK_LIB(m, cos, LIBM=-lm) + ;; +esac +AC_SUBST([LIBM]) +])# LT_LIB_M + +# Old name: +AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_CHECK_LIBM], []) + + +# _LT_COMPILER_NO_RTTI([TAGNAME]) +# ------------------------------- +m4_defun([_LT_COMPILER_NO_RTTI], +[m4_require([_LT_TAG_COMPILER])dnl + +_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= + +if test yes = "$GCC"; then + case $cc_basename in + nvcc*) + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; + *) + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; + esac + + _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], + lt_cv_prog_compiler_rtti_exceptions, + [-fno-rtti -fno-exceptions], [], + [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) +fi +_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], + [Compiler flag to turn off builtin functions]) +])# _LT_COMPILER_NO_RTTI + + +# _LT_CMD_GLOBAL_SYMBOLS +# ---------------------- +m4_defun([_LT_CMD_GLOBAL_SYMBOLS], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([LT_PATH_NM])dnl +AC_REQUIRE([LT_PATH_LD])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_TAG_COMPILER])dnl + +# Check for command to grab the raw symbol name followed by C symbol from nm. +AC_MSG_CHECKING([command to parse $NM output from $compiler object]) +AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], +[ +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[[BCDEGRST]]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[[BCDT]]' + ;; +cygwin* | mingw* | pw32* | cegcc*) + symcode='[[ABCDGISTW]]' + ;; +hpux*) + if test ia64 = "$host_cpu"; then + symcode='[[ABCDEGRST]]' + fi + ;; +irix* | nonstopux*) + symcode='[[BCDEGRST]]' + ;; +osf*) + symcode='[[BCDEGQRST]]' + ;; +solaris*) + symcode='[[BCDRT]]' + ;; +sco3.2v5*) + symcode='[[DT]]' + ;; +sysv4.2uw2*) + symcode='[[DT]]' + ;; +sysv5* | sco5v6* | unixware* | OpenUNIX*) + symcode='[[ABDT]]' + ;; +sysv4) + symcode='[[DFNSTU]]' + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[[ABCDGIRSTW]]' ;; +esac + +if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Gets list of data symbols to import. + lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'" + # Adjust the below global symbol transforms to fixup imported variables. + lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" + lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" + lt_c_name_lib_hook="\ + -e 's/^I .* \(lib.*\)$/ {\"\1\", (void *) 0},/p'\ + -e 's/^I .* \(.*\)$/ {\"lib\1\", (void *) 0},/p'" +else + # Disable hooks by default. + lt_cv_sys_global_symbol_to_import= + lt_cdecl_hook= + lt_c_name_hook= + lt_c_name_lib_hook= +fi + +# Transform an extracted symbol line into a proper C declaration. +# Some systems (esp. on ia64) link data and code symbols differently, +# so use this general approach. +lt_cv_sys_global_symbol_to_cdecl="sed -n"\ +$lt_cdecl_hook\ +" -e 's/^T .* \(.*\)$/extern int \1();/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n"\ +$lt_c_name_hook\ +" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" + +# Transform an extracted symbol line into symbol name with lib prefix and +# symbol address. +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\ +$lt_c_name_lib_hook\ +" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ +" -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"lib\1\", (void *) \&\1},/p'" + +# Handle CRLF in mingw tool chain +opt_cr= +case $build_os in +mingw*) + opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# Try without a prefix underscore, then with it. +for ac_symprfx in "" "_"; do + + # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. + symxfrm="\\1 $ac_symprfx\\2 \\2" + + # Write the raw and C identifiers. + if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Fake it for dumpbin and say T for any non-static function, + # D for any global variable and I for any imported variable. + # Also find C++ and __fastcall symbols from MSVC++, + # which start with @ or ?. + lt_cv_sys_global_symbol_pipe="$AWK ['"\ +" {last_section=section; section=\$ 3};"\ +" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ +" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ +" /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\ +" /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\ +" /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\ +" \$ 0!~/External *\|/{next};"\ +" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ +" {if(hide[section]) next};"\ +" {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\ +" {split(\$ 0,a,/\||\r/); split(a[2],s)};"\ +" s[1]~/^[@?]/{print f,s[1],s[1]; next};"\ +" s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ +" ' prfx=^$ac_symprfx]" + else + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" + fi + lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" + + # Check to see that the pipe works correctly. + pipe_works=no + + rm -f conftest* + cat > conftest.$ac_ext <<_LT_EOF +#ifdef __cplusplus +extern "C" { +#endif +char nm_test_var; +void nm_test_func(void); +void nm_test_func(void){} +#ifdef __cplusplus +} +#endif +int main(){nm_test_var='a';nm_test_func();return(0);} +_LT_EOF + + if AC_TRY_EVAL(ac_compile); then + # Now try to grab the symbols. + nlist=conftest.nm + if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if $GREP ' nm_test_var$' "$nlist" >/dev/null; then + if $GREP ' nm_test_func$' "$nlist" >/dev/null; then + cat <<_LT_EOF > conftest.$ac_ext +/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ +#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE +/* DATA imports from DLLs on WIN32 can't be const, because runtime + relocations are performed -- see ld's documentation on pseudo-relocs. */ +# define LT@&t@_DLSYM_CONST +#elif defined __osf__ +/* This system does not cope well with relocations in const data. */ +# define LT@&t@_DLSYM_CONST +#else +# define LT@&t@_DLSYM_CONST const +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +_LT_EOF + # Now generate the symbol file. + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' + + cat <<_LT_EOF >> conftest.$ac_ext + +/* The mapping between symbol names and symbols. */ +LT@&t@_DLSYM_CONST struct { + const char *name; + void *address; +} +lt__PROGRAM__LTX_preloaded_symbols[[]] = +{ + { "@PROGRAM@", (void *) 0 }, +_LT_EOF + $SED "s/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext + cat <<\_LT_EOF >> conftest.$ac_ext + {0, (void *) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt__PROGRAM__LTX_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif +_LT_EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + lt_globsym_save_LIBS=$LIBS + lt_globsym_save_CFLAGS=$CFLAGS + LIBS=conftstm.$ac_objext + CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" + if AC_TRY_EVAL(ac_link) && test -s conftest$ac_exeext; then + pipe_works=yes + fi + LIBS=$lt_globsym_save_LIBS + CFLAGS=$lt_globsym_save_CFLAGS + else + echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD + fi + else + echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD + cat conftest.$ac_ext >&5 + fi + rm -rf conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test yes = "$pipe_works"; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done +]) +if test -z "$lt_cv_sys_global_symbol_pipe"; then + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + AC_MSG_RESULT(failed) +else + AC_MSG_RESULT(ok) +fi + +# Response file support. +if test "$lt_cv_nm_interface" = "MS dumpbin"; then + nm_file_list_spec='@' +elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then + nm_file_list_spec='@' +fi + +_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], + [Take the output of nm and produce a listing of raw symbols and C names]) +_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], + [Transform the output of nm in a proper C declaration]) +_LT_DECL([global_symbol_to_import], [lt_cv_sys_global_symbol_to_import], [1], + [Transform the output of nm into a list of symbols to manually relocate]) +_LT_DECL([global_symbol_to_c_name_address], + [lt_cv_sys_global_symbol_to_c_name_address], [1], + [Transform the output of nm in a C name address pair]) +_LT_DECL([global_symbol_to_c_name_address_lib_prefix], + [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], + [Transform the output of nm in a C name address pair when lib prefix is needed]) +_LT_DECL([nm_interface], [lt_cv_nm_interface], [1], + [The name lister interface]) +_LT_DECL([], [nm_file_list_spec], [1], + [Specify filename containing input files for $NM]) +]) # _LT_CMD_GLOBAL_SYMBOLS + + +# _LT_COMPILER_PIC([TAGNAME]) +# --------------------------- +m4_defun([_LT_COMPILER_PIC], +[m4_require([_LT_TAG_COMPILER])dnl +_LT_TAGVAR(lt_prog_compiler_wl, $1)= +_LT_TAGVAR(lt_prog_compiler_pic, $1)= +_LT_TAGVAR(lt_prog_compiler_static, $1)= + +m4_if([$1], [CXX], [ + # C++ specific cases for pic, static, wl, etc. + if test yes = "$GXX"; then + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test ia64 = "$host_cpu"; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the '-m68020' flag to GCC prevents building anything better, + # like '-m68040'. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + mingw* | cygwin* | os2* | pw32* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + case $host_os in + os2*) + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' + ;; + esac + ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + *djgpp*) + # DJGPP does not support shared libraries at all + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + haiku*) + # PIC is the default for Haiku. + # The "-static" flag exists, but is broken. + _LT_TAGVAR(lt_prog_compiler_static, $1)= + ;; + interix[[3-9]]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + hpux*) + # PIC is the default for 64-bit PA HP-UX, but not for 32-bit + # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag + # sets the default TLS model and affects inlining. + case $host_cpu in + hppa*64*) + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + else + case $host_os in + aix[[4-9]]*) + # All AIX code is PIC. + if test ia64 = "$host_cpu"; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + chorus*) + case $cc_basename in + cxch68*) + # Green Hills C++ Compiler + # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" + ;; + esac + ;; + mingw* | cygwin* | os2* | pw32* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + dgux*) + case $cc_basename in + ec++*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + ghcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + freebsd* | dragonfly*) + # FreeBSD uses GNU C++ + ;; + hpux9* | hpux10* | hpux11*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' + if test ia64 != "$host_cpu"; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + fi + ;; + aCC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + ;; + *) + ;; + esac + ;; + interix*) + # This is c89, which is MS Visual C++ (no shared libs) + # Anyone wants to do a port? + ;; + irix5* | irix6* | nonstopux*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + # CC pic flag -KPIC is the default. + ;; + *) + ;; + esac + ;; + linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + case $cc_basename in + KCC*) + # KAI C++ Compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + ecpc* ) + # old Intel C++ for x86_64, which still supported -KPIC. + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + icpc* ) + # Intel C++, used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + cxx*) + # Compaq C++ + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*) + # IBM XL 8.0, 9.0 on PPC and BlueGene + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + esac + ;; + esac + ;; + lynxos*) + ;; + m88k*) + ;; + mvs*) + case $cc_basename in + cxx*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' + ;; + *) + ;; + esac + ;; + netbsd*) + ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + ;; + RCC*) + # Rational C++ 2.4.1 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + cxx*) + # Digital/Compaq C++ + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + *) + ;; + esac + ;; + psos*) + ;; + solaris*) + case $cc_basename in + CC* | sunCC*) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + gcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + ;; + *) + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + lcc*) + # Lucid + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + *) + ;; + esac + ;; + vxworks*) + ;; + *) + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +], +[ + if test yes = "$GCC"; then + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test ia64 = "$host_cpu"; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the '-m68020' flag to GCC prevents building anything better, + # like '-m68040'. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + case $host_os in + os2*) + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' + ;; + esac + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + + haiku*) + # PIC is the default for Haiku. + # The "-static" flag exists, but is broken. + _LT_TAGVAR(lt_prog_compiler_static, $1)= + ;; + + hpux*) + # PIC is the default for 64-bit PA HP-UX, but not for 32-bit + # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag + # sets the default TLS model and affects inlining. + case $host_cpu in + hppa*64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + + interix[[3-9]]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + enable_shared=no + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + + case $cc_basename in + nvcc*) # Cuda Compiler Driver 2.2 + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' + if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" + fi + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + if test ia64 = "$host_cpu"; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + case $cc_basename in + nagfor*) + # NAG Fortran compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + esac + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + case $host_os in + os2*) + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' + ;; + esac + ;; + + hpux9* | hpux10* | hpux11*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC (with -KPIC) is the default. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + case $cc_basename in + # old Intel for x86_64, which still supported -KPIC. + ecc*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + # icc used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + icc* | ifort*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + # Lahey Fortran 8.1. + lf95*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' + _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' + ;; + nagfor*) + # NAG Fortran compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + tcc*) + # Fabrice Bellard et al's Tiny C Compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + ccc*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All Alpha code is PIC. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + xl* | bgxl* | bgf* | mpixl*) + # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) + # Sun Fortran 8.3 passes all unrecognized flags to the linker + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='' + ;; + *Sun\ F* | *Sun*Fortran*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + *Sun\ C*) + # Sun C 5.9 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + ;; + *Intel*\ [[CF]]*Compiler*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + *Portland\ Group*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + esac + ;; + esac + ;; + + newsos6) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + + osf3* | osf4* | osf5*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All OSF/1 code is PIC. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + rdos*) + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + solaris*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + case $cc_basename in + f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; + *) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; + esac + ;; + + sunos4*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + unicos*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + + uts4*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + *) + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +]) +case $host_os in + # For platforms that do not support PIC, -DPIC is meaningless: + *djgpp*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" + ;; +esac + +AC_CACHE_CHECK([for $compiler option to produce PIC], + [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], + [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) +_LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then + _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], + [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], + [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], + [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in + "" | " "*) ;; + *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; + esac], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) +fi +_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], + [Additional compiler flags for building library objects]) + +_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], + [How to pass a linker flag through the compiler]) +# +# Check to make sure the static flag actually works. +# +wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" +_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], + _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), + $lt_tmp_static_flag, + [], + [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) +_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], + [Compiler flag to prevent dynamic linking]) +])# _LT_COMPILER_PIC + + +# _LT_LINKER_SHLIBS([TAGNAME]) +# ---------------------------- +# See if the linker supports building shared libraries. +m4_defun([_LT_LINKER_SHLIBS], +[AC_REQUIRE([LT_PATH_LD])dnl +AC_REQUIRE([LT_PATH_NM])dnl +m4_require([_LT_PATH_MANIFEST_TOOL])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl +m4_require([_LT_TAG_COMPILER])dnl +AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) +m4_if([$1], [CXX], [ + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] + case $host_os in + aix[[4-9]]*) + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to GNU nm, but means don't demangle to AIX nm. + # Without the "-l" option, or with the "-B" option, AIX nm treats + # weak defined symbols like other global defined symbols, whereas + # GNU nm marks them as "W". + # While the 'weak' keyword is ignored in the Export File, we need + # it in the Import File for the 'aix-soname' feature, so we have + # to replace the "-B" option with "-P" for AIX nm. + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' + else + _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' + fi + ;; + pw32*) + _LT_TAGVAR(export_symbols_cmds, $1)=$ltdll_cmds + ;; + cygwin* | mingw* | cegcc*) + case $cc_basename in + cl*) + _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + ;; + *) + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] + ;; + esac + ;; + *) + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + ;; + esac +], [ + runpath_var= + _LT_TAGVAR(allow_undefined_flag, $1)= + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(archive_cmds, $1)= + _LT_TAGVAR(archive_expsym_cmds, $1)= + _LT_TAGVAR(compiler_needs_object, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + _LT_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(hardcode_automatic, $1)=no + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(hardcode_libdir_separator, $1)= + _LT_TAGVAR(hardcode_minus_L, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_TAGVAR(inherit_rpath, $1)=no + _LT_TAGVAR(link_all_deplibs, $1)=unknown + _LT_TAGVAR(module_cmds, $1)= + _LT_TAGVAR(module_expsym_cmds, $1)= + _LT_TAGVAR(old_archive_from_new_cmds, $1)= + _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= + _LT_TAGVAR(thread_safe_flag_spec, $1)= + _LT_TAGVAR(whole_archive_flag_spec, $1)= + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + _LT_TAGVAR(include_expsyms, $1)= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ' (' and ')$', so one must not match beginning or + # end of line. Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc', + # as well as any symbol that contains 'd'. + _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + # Exclude shared library initialization/finalization symbols. +dnl Note also adjust exclude_expsyms for C++ above. + extract_expsyms_cmds= + + case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test yes != "$GCC"; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd* | bitrig*) + with_gnu_ld=no + ;; + esac + + _LT_TAGVAR(ld_shlibs, $1)=yes + + # On some targets, GNU ld is compatible enough with the native linker + # that we're better off using the native interface for both. + lt_use_gnu_ld_interface=no + if test yes = "$with_gnu_ld"; then + case $host_os in + aix*) + # The AIX port of GNU ld has always aspired to compatibility + # with the native linker. However, as the warning in the GNU ld + # block says, versions before 2.19.5* couldn't really create working + # shared libraries, regardless of the interface used. + case `$LD -v 2>&1` in + *\ \(GNU\ Binutils\)\ 2.19.5*) ;; + *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;; + *\ \(GNU\ Binutils\)\ [[3-9]]*) ;; + *) + lt_use_gnu_ld_interface=yes + ;; + esac + ;; + *) + lt_use_gnu_ld_interface=yes + ;; + esac + fi + + if test yes = "$lt_use_gnu_ld_interface"; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='$wl' + + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + runpath_var=LD_RUN_PATH + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then + _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + supports_anon_versioning=no + case `$LD -v | $SED -e 's/([^)]\+)\s\+//' 2>&1` in + *GNU\ gold*) supports_anon_versioning=yes ;; + *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + + # See if GNU ld supports shared libraries. + case $host_os in + aix[[3-9]]*) + # On AIX/PPC, the GNU linker is very broken + if test ia64 != "$host_cpu"; then + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: the GNU linker, at least up to release 2.19, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to install binutils +*** 2.20 or above, or modify your PATH so that a non-GNU linker is found. +*** You will then need to restart the configuration process. + +_LT_EOF + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='' + ;; + m68k) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file, use it as + # is; otherwise, prepend EXPORTS... + _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + haiku*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + os2*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + shrext_cmds=.dll + _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + + interix[[3-9]]*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) + tmp_diet=no + if test linux-dietlibc = "$host_os"; then + case $cc_basename in + diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) + esac + fi + if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ + && test no = "$tmp_diet" + then + tmp_addflag=' $pic_flag' + tmp_sharedflag='-shared' + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; + pgf77* | pgf90* | pgf95* | pgfortran*) + # Portland Group f77 and f90 compilers + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 + tmp_addflag=' -i_dynamic' ;; + efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 + tmp_addflag=' -i_dynamic -nofor_main' ;; + ifc* | ifort*) # Intel Fortran compiler + tmp_addflag=' -nofor_main' ;; + lf95*) # Lahey Fortran 8.1 + _LT_TAGVAR(whole_archive_flag_spec, $1)= + tmp_sharedflag='--shared' ;; + nagfor*) # NAGFOR 5.3 + tmp_sharedflag='-Wl,-shared' ;; + xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) + tmp_sharedflag='-qmkshrobj' + tmp_addflag= ;; + nvcc*) # Cuda Compiler Driver 2.2 + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + _LT_TAGVAR(compiler_needs_object, $1)=yes + ;; + esac + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) # Sun C 5.9 + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + _LT_TAGVAR(compiler_needs_object, $1)=yes + tmp_sharedflag='-G' ;; + *Sun\ F*) # Sun Fortran 8.3 + tmp_sharedflag='-G' ;; + esac + _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + + if test yes = "$supports_anon_versioning"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' + fi + + case $cc_basename in + tcc*) + _LT_TAGVAR(export_dynamic_flag_spec, $1)='-rdynamic' + ;; + xlf* | bgf* | bgxlf* | mpixlf*) + # IBM XL Fortran 10.1 on PPC cannot create shared libs itself + _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' + if test yes = "$supports_anon_versioning"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' + fi + ;; + esac + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris*) + if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot +*** reliably create shared libraries on SCO systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.16.91.0.3 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + ;; + *) + # For security reasons, it is highly recommended that you always + # use absolute paths for naming shared libraries, and exclude the + # DT_RUNPATH tag from executables and libraries. But doing so + # requires that you compile everything twice, which is a pain. + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + sunos4*) + _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + + if test no = "$_LT_TAGVAR(ld_shlibs, $1)"; then + runpath_var= + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=yes + _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + _LT_TAGVAR(hardcode_direct, $1)=unsupported + fi + ;; + + aix[[4-9]]*) + if test ia64 = "$host_cpu"; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag= + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to GNU nm, but means don't demangle to AIX nm. + # Without the "-l" option, or with the "-B" option, AIX nm treats + # weak defined symbols like other global defined symbols, whereas + # GNU nm marks them as "W". + # While the 'weak' keyword is ignored in the Export File, we need + # it in the Import File for the 'aix-soname' feature, so we have + # to replace the "-B" option with "-P" for AIX nm. + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' + else + _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # have runtime linking enabled, and use it for executables. + # For shared libraries, we enable/disable runtime linking + # depending on the kind of the shared library created - + # when "with_aix_soname,aix_use_runtimelinking" is: + # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables + # "aix,yes" lib.so shared, rtl:yes, for executables + # lib.a static archive + # "both,no" lib.so.V(shr.o) shared, rtl:yes + # lib.a(lib.so.V) shared, rtl:no, for executables + # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a(lib.so.V) shared, rtl:no + # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a static archive + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) + for ld_flag in $LDFLAGS; do + if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then + aix_use_runtimelinking=yes + break + fi + done + if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then + # With aix-soname=svr4, we create the lib.so.V shared archives only, + # so we don't have lib.a shared libs to link our executables. + # We have to force runtime linking in this case. + aix_use_runtimelinking=yes + LDFLAGS="$LDFLAGS -Wl,-brtl" + fi + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_TAGVAR(archive_cmds, $1)='' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='$wl-f,' + case $with_aix_soname,$aix_use_runtimelinking in + aix,*) ;; # traditional, no import file + svr4,* | *,yes) # use import file + # The Import File defines what to hardcode. + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=no + ;; + esac + + if test yes = "$GCC"; then + case $host_os in aix4.[[012]]|aix4.[[012]].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`$CC -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + _LT_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)= + fi + ;; + esac + shared_flag='-shared' + if test yes = "$aix_use_runtimelinking"; then + shared_flag="$shared_flag "'$wl-G' + fi + # Need to ensure runtime linking is disabled for the traditional + # shared library, or the linker may eventually find shared libraries + # /with/ Import File - we do not want to mix them. + shared_flag_aix='-shared' + shared_flag_svr4='-shared $wl-G' + else + # not using gcc + if test ia64 = "$host_cpu"; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test yes = "$aix_use_runtimelinking"; then + shared_flag='$wl-G' + else + shared_flag='$wl-bM:SRE' + fi + shared_flag_aix='$wl-bM:SRE' + shared_flag_svr4='$wl-G' + fi + fi + + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall' + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + _LT_TAGVAR(always_export_symbols, $1)=yes + if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX([$1]) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag + else + if test ia64 = "$host_cpu"; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib' + _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX([$1]) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok' + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok' + if test yes = "$with_gnu_ld"; then + # We only use this code for GNU lds that support --whole-archive. + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' + else + # Exported symbols can be pulled into shared objects from archives + _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' + # -brtl affects multiple linker settings, -berok does not and is overridden later + compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`' + if test svr4 != "$with_aix_soname"; then + # This is similar to how AIX traditionally builds its shared libraries. + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' + fi + if test aix != "$with_aix_soname"; then + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' + else + # used by -dlpreopen to get the symbols + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV $output_objdir/$realname.d/$soname $output_objdir' + fi + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d' + fi + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='' + ;; + m68k) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + ;; + + bsdi[[45]]*) + _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + case $cc_basename in + cl*) + # Native MSVC + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='@' + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=.dll + # FIXME: Setting linknames here is a bad hack. + _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' + _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then + cp "$export_symbols" "$output_objdir/$soname.def"; + echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; + else + $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; + fi~ + $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ + linknames=' + # The linker will not automatically build a static lib if we build a DLL. + # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' + # Don't use ranlib + _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' + _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ + lt_tool_outputfile="@TOOL_OUTPUT@"~ + case $lt_outputfile in + *.exe|*.EXE) ;; + *) + lt_outputfile=$lt_outputfile.exe + lt_tool_outputfile=$lt_tool_outputfile.exe + ;; + esac~ + if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then + $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; + $RM "$lt_outputfile.manifest"; + fi' + ;; + *) + # Assume MSVC wrapper + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=.dll + # FIXME: Setting linknames here is a bad hack. + _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' + # FIXME: Should let the user specify the lib program. + _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + esac + ;; + + darwin* | rhapsody*) + _LT_DARWIN_LINKER_FEATURES($1) + ;; + + dgux*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2.*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | dragonfly*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + hpux9*) + if test yes = "$GCC"; then + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' + else + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_direct, $1)=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + ;; + + hpux10*) + if test yes,no = "$GCC,$with_gnu_ld"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test no = "$with_gnu_ld"; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + fi + ;; + + hpux11*) + if test yes,no = "$GCC,$with_gnu_ld"; then + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + m4_if($1, [], [ + # Older versions of the 11.00 compiler do not understand -b yet + # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) + _LT_LINKER_OPTION([if $CC understands -b], + _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], + [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], + [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])], + [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) + ;; + esac + fi + if test no = "$with_gnu_ld"; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + case $host_cpu in + hppa*64*|ia64*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + *) + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test yes = "$GCC"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + # Try to use the -exported_symbol ld option, if it does not + # work, assume that -exports_file does not work either and + # implicitly export all symbols. + # This should be the same for all languages, so no per-tag cache variable. + AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], + [lt_cv_irix_exported_symbol], + [save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null" + AC_LINK_IFELSE( + [AC_LANG_SOURCE( + [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], + [C++], [[int foo (void) { return 0; }]], + [Fortran 77], [[ + subroutine foo + end]], + [Fortran], [[ + subroutine foo + end]])])], + [lt_cv_irix_exported_symbol=yes], + [lt_cv_irix_exported_symbol=no]) + LDFLAGS=$save_LDFLAGS]) + if test yes = "$lt_cv_irix_exported_symbol"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' + fi + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(inherit_rpath, $1)=yes + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + linux*) + case $cc_basename in + tcc*) + # Fabrice Bellard et al's Tiny C Compiler + _LT_TAGVAR(ld_shlibs, $1)=yes + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + newsos6) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *nto* | *qnx*) + ;; + + openbsd* | bitrig*) + if test -f /usr/libexec/ld.so; then + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + fi + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + os2*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + shrext_cmds=.dll + _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + + osf3*) + if test yes = "$GCC"; then + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + else + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test yes = "$GCC"; then + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + else + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp' + + # Both c and cxx compiler support -rpath directly + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + solaris*) + _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' + if test yes = "$GCC"; then + wlarc='$wl' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + else + case `$CC -V 2>&1` in + *"Compilers 5.0"*) + wlarc='' + _LT_TAGVAR(archive_cmds, $1)='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' + ;; + *) + wlarc='$wl' + _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + ;; + esac + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands '-z linker_flag'. GCC discards it without '$wl', + # but is careful enough not to reorder. + # Supported since Solaris 2.6 (maybe 2.5.1?) + if test yes = "$GCC"; then + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' + fi + ;; + esac + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + sunos4*) + if test sequent = "$host_vendor"; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4) + case $host_vendor in + sni) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' + _LT_TAGVAR(hardcode_direct, $1)=no + ;; + motorola) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4.3*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + _LT_TAGVAR(ld_shlibs, $1)=yes + fi + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) + _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + + if test yes = "$GCC"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We CANNOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' + _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport' + runpath_var='LD_RUN_PATH' + + if test yes = "$GCC"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + uts4*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + + if test sni = "$host_vendor"; then + case $host in + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Blargedynsym' + ;; + esac + fi + fi +]) +AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) +test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no + +_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld + +_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl +_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl +_LT_DECL([], [extract_expsyms_cmds], [2], + [The commands to extract the exported symbol list from a shared archive]) + +# +# Do we need to explicitly link libc? +# +case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in +x|xyes) + # Assume -lc should be added + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + + if test yes,yes = "$GCC,$enable_shared"; then + case $_LT_TAGVAR(archive_cmds, $1) in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + AC_CACHE_CHECK([whether -lc should be explicitly linked in], + [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), + [$RM conftest* + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + if AC_TRY_EVAL(ac_compile) 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) + pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) + _LT_TAGVAR(allow_undefined_flag, $1)= + if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) + then + lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no + else + lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes + fi + _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $RM conftest* + ]) + _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1) + ;; + esac + fi + ;; +esac + +_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], + [Whether or not to add -lc for building shared libraries]) +_LT_TAGDECL([allow_libtool_libs_with_static_runtimes], + [enable_shared_with_static_runtimes], [0], + [Whether or not to disallow shared libs when runtime libs are static]) +_LT_TAGDECL([], [export_dynamic_flag_spec], [1], + [Compiler flag to allow reflexive dlopens]) +_LT_TAGDECL([], [whole_archive_flag_spec], [1], + [Compiler flag to generate shared objects directly from archives]) +_LT_TAGDECL([], [compiler_needs_object], [1], + [Whether the compiler copes with passing no objects directly]) +_LT_TAGDECL([], [old_archive_from_new_cmds], [2], + [Create an old-style archive from a shared archive]) +_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], + [Create a temporary old-style archive to link instead of a shared archive]) +_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) +_LT_TAGDECL([], [archive_expsym_cmds], [2]) +_LT_TAGDECL([], [module_cmds], [2], + [Commands used to build a loadable module if different from building + a shared archive.]) +_LT_TAGDECL([], [module_expsym_cmds], [2]) +_LT_TAGDECL([], [with_gnu_ld], [1], + [Whether we are building with GNU ld or not]) +_LT_TAGDECL([], [allow_undefined_flag], [1], + [Flag that allows shared libraries with undefined symbols to be built]) +_LT_TAGDECL([], [no_undefined_flag], [1], + [Flag that enforces no undefined symbols]) +_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], + [Flag to hardcode $libdir into a binary during linking. + This must work even if $libdir does not exist]) +_LT_TAGDECL([], [hardcode_libdir_separator], [1], + [Whether we need a single "-rpath" flag with a separated argument]) +_LT_TAGDECL([], [hardcode_direct], [0], + [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes + DIR into the resulting binary]) +_LT_TAGDECL([], [hardcode_direct_absolute], [0], + [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes + DIR into the resulting binary and the resulting library dependency is + "absolute", i.e impossible to change by setting $shlibpath_var if the + library is relocated]) +_LT_TAGDECL([], [hardcode_minus_L], [0], + [Set to "yes" if using the -LDIR flag during linking hardcodes DIR + into the resulting binary]) +_LT_TAGDECL([], [hardcode_shlibpath_var], [0], + [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR + into the resulting binary]) +_LT_TAGDECL([], [hardcode_automatic], [0], + [Set to "yes" if building a shared library automatically hardcodes DIR + into the library and all subsequent libraries and executables linked + against it]) +_LT_TAGDECL([], [inherit_rpath], [0], + [Set to yes if linker adds runtime paths of dependent libraries + to runtime path list]) +_LT_TAGDECL([], [link_all_deplibs], [0], + [Whether libtool must link a program against all its dependency libraries]) +_LT_TAGDECL([], [always_export_symbols], [0], + [Set to "yes" if exported symbols are required]) +_LT_TAGDECL([], [export_symbols_cmds], [2], + [The commands to list exported symbols]) +_LT_TAGDECL([], [exclude_expsyms], [1], + [Symbols that should not be listed in the preloaded symbols]) +_LT_TAGDECL([], [include_expsyms], [1], + [Symbols that must always be exported]) +_LT_TAGDECL([], [prelink_cmds], [2], + [Commands necessary for linking programs (against libraries) with templates]) +_LT_TAGDECL([], [postlink_cmds], [2], + [Commands necessary for finishing linking programs]) +_LT_TAGDECL([], [file_list_spec], [1], + [Specify filename containing input files]) +dnl FIXME: Not yet implemented +dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], +dnl [Compiler flag to generate thread safe objects]) +])# _LT_LINKER_SHLIBS + + +# _LT_LANG_C_CONFIG([TAG]) +# ------------------------ +# Ensure that the configuration variables for a C compiler are suitably +# defined. These variables are subsequently used by _LT_CONFIG to write +# the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_C_CONFIG], +[m4_require([_LT_DECL_EGREP])dnl +lt_save_CC=$CC +AC_LANG_PUSH(C) + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}' + +_LT_TAG_COMPILER +# Save the default compiler, since it gets overwritten when the other +# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. +compiler_DEFAULT=$CC + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + LT_SYS_DLOPEN_SELF + _LT_CMD_STRIPLIB + + # Report what library types will actually be built + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test no = "$can_build_shared" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test yes = "$enable_shared" && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + + aix[[4-9]]*) + if test ia64 != "$host_cpu"; then + case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in + yes,aix,yes) ;; # shared object as lib.so file only + yes,svr4,*) ;; # shared object as lib.so archive member only + yes,*) enable_static=no ;; # shared object in lib.a archive as well + esac + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test yes = "$enable_shared" || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_CONFIG($1) +fi +AC_LANG_POP +CC=$lt_save_CC +])# _LT_LANG_C_CONFIG + + +# _LT_LANG_CXX_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for a C++ compiler are suitably +# defined. These variables are subsequently used by _LT_CONFIG to write +# the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_CXX_CONFIG], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_PATH_MANIFEST_TOOL])dnl +if test -n "$CXX" && ( test no != "$CXX" && + ( (test g++ = "$CXX" && `g++ -v >/dev/null 2>&1` ) || + (test g++ != "$CXX"))); then + AC_PROG_CXXCPP +else + _lt_caught_CXX_error=yes +fi + +AC_LANG_PUSH(C++) +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(compiler_needs_object, $1)=no +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for C++ test sources. +ac_ext=cpp + +# Object file extension for compiled C++ test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the CXX compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test yes != "$_lt_caught_CXX_error"; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="int some_variable = 0;" + + # Code to be used in simple link tests + lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC=$CC + lt_save_CFLAGS=$CFLAGS + lt_save_LD=$LD + lt_save_GCC=$GCC + GCC=$GXX + lt_save_with_gnu_ld=$with_gnu_ld + lt_save_path_LD=$lt_cv_path_LD + if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then + lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx + else + $as_unset lt_cv_prog_gnu_ld + fi + if test -n "${lt_cv_path_LDCXX+set}"; then + lt_cv_path_LD=$lt_cv_path_LDCXX + else + $as_unset lt_cv_path_LD + fi + test -z "${LDCXX+set}" || LD=$LDCXX + CC=${CXX-"c++"} + CFLAGS=$CXXFLAGS + compiler=$CC + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + + if test -n "$compiler"; then + # We don't want -fno-exception when compiling C++ code, so set the + # no_builtin_flag separately + if test yes = "$GXX"; then + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' + else + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= + fi + + if test yes = "$GXX"; then + # Set up default GNU C++ configuration + + LT_PATH_LD + + # Check if GNU C++ uses GNU ld as the underlying linker, since the + # archiving commands below assume that GNU ld is being used. + if test yes = "$with_gnu_ld"; then + _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' + + # If archive_cmds runs LD, not CC, wlarc should be empty + # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to + # investigate it a little bit more. (MM) + wlarc='$wl' + + # ancient GNU ld didn't support --whole-archive et. al. + if eval "`$CC -print-prog-name=ld` --help 2>&1" | + $GREP 'no-whole-archive' > /dev/null; then + _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + with_gnu_ld=no + wlarc= + + # A generic and very simple default shared library creation + # command for GNU C++ for the case where it uses the native + # linker, instead of GNU ld. If possible, this setting should + # overridden to take advantage of the native linker features on + # the platform it is being used on. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + fi + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + + else + GXX=no + with_gnu_ld=no + wlarc= + fi + + # PORTME: fill in a description of your system's C++ link characteristics + AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) + _LT_TAGVAR(ld_shlibs, $1)=yes + case $host_os in + aix3*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aix[[4-9]]*) + if test ia64 = "$host_cpu"; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag= + else + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # have runtime linking enabled, and use it for executables. + # For shared libraries, we enable/disable runtime linking + # depending on the kind of the shared library created - + # when "with_aix_soname,aix_use_runtimelinking" is: + # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables + # "aix,yes" lib.so shared, rtl:yes, for executables + # lib.a static archive + # "both,no" lib.so.V(shr.o) shared, rtl:yes + # lib.a(lib.so.V) shared, rtl:no, for executables + # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a(lib.so.V) shared, rtl:no + # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a static archive + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) + for ld_flag in $LDFLAGS; do + case $ld_flag in + *-brtl*) + aix_use_runtimelinking=yes + break + ;; + esac + done + if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then + # With aix-soname=svr4, we create the lib.so.V shared archives only, + # so we don't have lib.a shared libs to link our executables. + # We have to force runtime linking in this case. + aix_use_runtimelinking=yes + LDFLAGS="$LDFLAGS -Wl,-brtl" + fi + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_TAGVAR(archive_cmds, $1)='' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='$wl-f,' + case $with_aix_soname,$aix_use_runtimelinking in + aix,*) ;; # no import file + svr4,* | *,yes) # use import file + # The Import File defines what to hardcode. + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=no + ;; + esac + + if test yes = "$GXX"; then + case $host_os in aix4.[[012]]|aix4.[[012]].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`$CC -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + _LT_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)= + fi + esac + shared_flag='-shared' + if test yes = "$aix_use_runtimelinking"; then + shared_flag=$shared_flag' $wl-G' + fi + # Need to ensure runtime linking is disabled for the traditional + # shared library, or the linker may eventually find shared libraries + # /with/ Import File - we do not want to mix them. + shared_flag_aix='-shared' + shared_flag_svr4='-shared $wl-G' + else + # not using gcc + if test ia64 = "$host_cpu"; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test yes = "$aix_use_runtimelinking"; then + shared_flag='$wl-G' + else + shared_flag='$wl-bM:SRE' + fi + shared_flag_aix='$wl-bM:SRE' + shared_flag_svr4='$wl-G' + fi + fi + + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall' + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to + # export. + _LT_TAGVAR(always_export_symbols, $1)=yes + if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + # The "-G" linker flag allows undefined symbols. + _LT_TAGVAR(no_undefined_flag, $1)='-bernotok' + # Determine the default libpath from the value encoded in an empty + # executable. + _LT_SYS_MODULE_PATH_AIX([$1]) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" + + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag + else + if test ia64 = "$host_cpu"; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib' + _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX([$1]) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok' + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok' + if test yes = "$with_gnu_ld"; then + # We only use this code for GNU lds that support --whole-archive. + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' + else + # Exported symbols can be pulled into shared objects from archives + _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' + # -brtl affects multiple linker settings, -berok does not and is overridden later + compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`' + if test svr4 != "$with_aix_soname"; then + # This is similar to how AIX traditionally builds its shared + # libraries. Need -bnortl late, we may have -brtl in LDFLAGS. + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' + fi + if test aix != "$with_aix_soname"; then + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' + else + # used by -dlpreopen to get the symbols + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV $output_objdir/$realname.d/$soname $output_objdir' + fi + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d' + fi + fi + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + chorus*) + case $cc_basename in + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + cygwin* | mingw* | pw32* | cegcc*) + case $GXX,$cc_basename in + ,cl* | no,cl*) + # Native MSVC + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='@' + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=.dll + # FIXME: Setting linknames here is a bad hack. + _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' + _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then + cp "$export_symbols" "$output_objdir/$soname.def"; + echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; + else + $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; + fi~ + $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ + linknames=' + # The linker will not automatically build a static lib if we build a DLL. + # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + # Don't use ranlib + _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' + _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ + lt_tool_outputfile="@TOOL_OUTPUT@"~ + case $lt_outputfile in + *.exe|*.EXE) ;; + *) + lt_outputfile=$lt_outputfile.exe + lt_tool_outputfile=$lt_tool_outputfile.exe + ;; + esac~ + func_to_tool_file "$lt_outputfile"~ + if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then + $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; + $RM "$lt_outputfile.manifest"; + fi' + ;; + *) + # g++ + # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file, use it as + # is; otherwise, prepend EXPORTS... + _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + darwin* | rhapsody*) + _LT_DARWIN_LINKER_FEATURES($1) + ;; + + os2*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + shrext_cmds=.dll + _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + + dgux*) + case $cc_basename in + ec++*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + ghcx*) + # Green Hills C++ Compiler + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + freebsd2.*) + # C++ shared libraries reported to be fairly broken before + # switch to ELF + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + freebsd-elf*) + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + ;; + + freebsd* | dragonfly*) + # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF + # conventions + _LT_TAGVAR(ld_shlibs, $1)=yes + ;; + + haiku*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + hpux9*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aCC*) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + ;; + *) + if test yes = "$GXX"; then + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + hpux10*|hpux11*) + if test no = "$with_gnu_ld"; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + case $host_cpu in + hppa*64*|ia64*) + ;; + *) + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + ;; + esac + fi + case $host_cpu in + hppa*64*|ia64*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + *) + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + ;; + esac + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aCC*) + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + ;; + *) + if test yes = "$GXX"; then + if test no = "$with_gnu_ld"; then + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + fi + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + interix[[3-9]]*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + irix5* | irix6*) + case $cc_basename in + CC*) + # SGI C++ + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + + # Archives containing C++ object files must be created using + # "CC -ar", where "CC" is the IRIX C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' + ;; + *) + if test yes = "$GXX"; then + if test no = "$with_gnu_ld"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` -o $lib' + fi + fi + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + esac + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(inherit_rpath, $1)=yes + ;; + + linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib $wl-retain-symbols-file,$export_symbols; mv \$templib $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' + ;; + icpc* | ecpc* ) + # Intel C++ + with_gnu_ld=yes + # version 8.0 and above of icpc choke on multiply defined symbols + # if we add $predep_objects and $postdep_objects, however 7.1 and + # earlier do not add the objects themselves. + case `$CC -V 2>&1` in + *"Version 7."*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + ;; + *) # Version 8.0 or newer + tmp_idyn= + case $host_cpu in + ia64*) tmp_idyn=' -i_dynamic';; + esac + _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + ;; + esac + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + case `$CC -V` in + *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*) + _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ + compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' + _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ + $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ + $RANLIB $oldlib' + _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + ;; + *) # Version 6 and above use weak symbols + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl--rpath $wl$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + ;; + cxx*) + # Compaq C++ + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib $wl-retain-symbols-file $wl$export_symbols' + + runpath_var=LD_RUN_PATH + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' + ;; + xl* | mpixl* | bgxl*) + # IBM XL 8.0 on PPC, with GNU ld + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' + _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + if test yes = "$supports_anon_versioning"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' + fi + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file $wl$export_symbols' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + _LT_TAGVAR(compiler_needs_object, $1)=yes + + # Not sure whether something based on + # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 + # would be better. + output_verbose_link_cmd='func_echo_all' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + esac + ;; + esac + ;; + + lynxos*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + m88k*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + mvs*) + case $cc_basename in + cxx*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' + wlarc= + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + fi + # Workaround some broken pre-1.5 toolchains + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' + ;; + + *nto* | *qnx*) + _LT_TAGVAR(ld_shlibs, $1)=yes + ;; + + openbsd* | bitrig*) + if test -f /usr/libexec/ld.so; then + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file,$export_symbols -o $lib' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' + fi + output_verbose_link_cmd=func_echo_all + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Archives containing C++ object files must be created using + # the KAI C++ compiler. + case $host in + osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; + *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; + esac + ;; + RCC*) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + cxx*) + case $host in + osf3*) + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $soname `test -n "$verstring" && func_echo_all "$wl-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + ;; + *) + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ + echo "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname $wl-input $wl$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~ + $RM $lib.exp' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + ;; + *) + if test yes,no = "$GXX,$with_gnu_ld"; then + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' + case $host in + osf3*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + psos*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + lcc*) + # Lucid + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + solaris*) + case $cc_basename in + CC* | sunCC*) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_TAGVAR(archive_cmds_need_lc,$1)=yes + _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G$allow_undefined_flag $wl-M $wl$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands '-z linker_flag'. + # Supported since Solaris 2.6 (maybe 2.5.1?) + _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' + ;; + esac + _LT_TAGVAR(link_all_deplibs, $1)=yes + + output_verbose_link_cmd='func_echo_all' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + gcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' + + # The C++ compiler must be used to create the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' + ;; + *) + # GNU C++ compiler with Solaris linker + if test yes,no = "$GXX,$with_gnu_ld"; then + _LT_TAGVAR(no_undefined_flag, $1)=' $wl-z ${wl}defs' + if $CC --version | $GREP -v '^2\.7' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared $pic_flag -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + else + # g++ 2.7 appears to require '-G' NOT '-shared' on this + # platform. + _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + fi + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $wl$libdir' + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' + ;; + esac + fi + ;; + esac + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) + _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We CANNOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' + _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport' + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ + '"$_LT_TAGVAR(old_archive_cmds, $1)" + _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ + '"$_LT_TAGVAR(reload_cmds, $1)" + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + vxworks*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + + AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) + test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no + + _LT_TAGVAR(GCC, $1)=$GXX + _LT_TAGVAR(LD, $1)=$LD + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_SYS_HIDDEN_LIBDEPS($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + CC=$lt_save_CC + CFLAGS=$lt_save_CFLAGS + LDCXX=$LD + LD=$lt_save_LD + GCC=$lt_save_GCC + with_gnu_ld=$lt_save_with_gnu_ld + lt_cv_path_LDCXX=$lt_cv_path_LD + lt_cv_path_LD=$lt_save_path_LD + lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld + lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld +fi # test yes != "$_lt_caught_CXX_error" + +AC_LANG_POP +])# _LT_LANG_CXX_CONFIG + + +# _LT_FUNC_STRIPNAME_CNF +# ---------------------- +# func_stripname_cnf prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +# +# This function is identical to the (non-XSI) version of func_stripname, +# except this one can be used by m4 code that may be executed by configure, +# rather than the libtool script. +m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl +AC_REQUIRE([_LT_DECL_SED]) +AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) +func_stripname_cnf () +{ + case @S|@2 in + .*) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%\\\\@S|@2\$%%"`;; + *) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%@S|@2\$%%"`;; + esac +} # func_stripname_cnf +])# _LT_FUNC_STRIPNAME_CNF + + +# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) +# --------------------------------- +# Figure out "hidden" library dependencies from verbose +# compiler output when linking a shared library. +# Parse the compiler output and extract the necessary +# objects, libraries and library flags. +m4_defun([_LT_SYS_HIDDEN_LIBDEPS], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl +# Dependencies to place before and after the object being linked: +_LT_TAGVAR(predep_objects, $1)= +_LT_TAGVAR(postdep_objects, $1)= +_LT_TAGVAR(predeps, $1)= +_LT_TAGVAR(postdeps, $1)= +_LT_TAGVAR(compiler_lib_search_path, $1)= + +dnl we can't use the lt_simple_compile_test_code here, +dnl because it contains code intended for an executable, +dnl not a library. It's possible we should let each +dnl tag define a new lt_????_link_test_code variable, +dnl but it's only used here... +m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF +int a; +void foo (void) { a = 0; } +_LT_EOF +], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF +class Foo +{ +public: + Foo (void) { a = 0; } +private: + int a; +}; +_LT_EOF +], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF + subroutine foo + implicit none + integer*4 a + a=0 + return + end +_LT_EOF +], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF + subroutine foo + implicit none + integer a + a=0 + return + end +_LT_EOF +], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF +public class foo { + private int a; + public void bar (void) { + a = 0; + } +}; +_LT_EOF +], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF +package foo +func foo() { +} +_LT_EOF +]) + +_lt_libdeps_save_CFLAGS=$CFLAGS +case "$CC $CFLAGS " in #( +*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; +*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; +*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; +esac + +dnl Parse the compiler output and extract the necessary +dnl objects, libraries and library flags. +if AC_TRY_EVAL(ac_compile); then + # Parse the compiler output and extract the necessary + # objects, libraries and library flags. + + # Sentinel used to keep track of whether or not we are before + # the conftest object file. + pre_test_object_deps_done=no + + for p in `eval "$output_verbose_link_cmd"`; do + case $prev$p in + + -L* | -R* | -l*) + # Some compilers place space between "-{L,R}" and the path. + # Remove the space. + if test x-L = "$p" || + test x-R = "$p"; then + prev=$p + continue + fi + + # Expand the sysroot to ease extracting the directories later. + if test -z "$prev"; then + case $p in + -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; + -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; + -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; + esac + fi + case $p in + =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; + esac + if test no = "$pre_test_object_deps_done"; then + case $prev in + -L | -R) + # Internal compiler library paths should come after those + # provided the user. The postdeps already come after the + # user supplied libs so there is no need to process them. + if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then + _LT_TAGVAR(compiler_lib_search_path, $1)=$prev$p + else + _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} $prev$p" + fi + ;; + # The "-l" case would never come before the object being + # linked, so don't bother handling this case. + esac + else + if test -z "$_LT_TAGVAR(postdeps, $1)"; then + _LT_TAGVAR(postdeps, $1)=$prev$p + else + _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} $prev$p" + fi + fi + prev= + ;; + + *.lto.$objext) ;; # Ignore GCC LTO objects + *.$objext) + # This assumes that the test object file only shows up + # once in the compiler output. + if test "$p" = "conftest.$objext"; then + pre_test_object_deps_done=yes + continue + fi + + if test no = "$pre_test_object_deps_done"; then + if test -z "$_LT_TAGVAR(predep_objects, $1)"; then + _LT_TAGVAR(predep_objects, $1)=$p + else + _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" + fi + else + if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then + _LT_TAGVAR(postdep_objects, $1)=$p + else + _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" + fi + fi + ;; + + *) ;; # Ignore the rest. + + esac + done + + # Clean up. + rm -f a.out a.exe +else + echo "libtool.m4: error: problem compiling $1 test program" +fi + +$RM -f confest.$objext +CFLAGS=$_lt_libdeps_save_CFLAGS + +# PORTME: override above test on systems where it is broken +m4_if([$1], [CXX], +[case $host_os in +interix[[3-9]]*) + # Interix 3.5 installs completely hosed .la files for C++, so rather than + # hack all around it, let's just trust "g++" to DTRT. + _LT_TAGVAR(predep_objects,$1)= + _LT_TAGVAR(postdep_objects,$1)= + _LT_TAGVAR(postdeps,$1)= + ;; +esac +]) + +case " $_LT_TAGVAR(postdeps, $1) " in +*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; +esac + _LT_TAGVAR(compiler_lib_search_dirs, $1)= +if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then + _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | $SED -e 's! -L! !g' -e 's!^ !!'` +fi +_LT_TAGDECL([], [compiler_lib_search_dirs], [1], + [The directories searched by this compiler when creating a shared library]) +_LT_TAGDECL([], [predep_objects], [1], + [Dependencies to place before and after the objects being linked to + create a shared library]) +_LT_TAGDECL([], [postdep_objects], [1]) +_LT_TAGDECL([], [predeps], [1]) +_LT_TAGDECL([], [postdeps], [1]) +_LT_TAGDECL([], [compiler_lib_search_path], [1], + [The library search path used internally by the compiler when linking + a shared library]) +])# _LT_SYS_HIDDEN_LIBDEPS + + +# _LT_LANG_F77_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for a Fortran 77 compiler are +# suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_F77_CONFIG], +[AC_LANG_PUSH(Fortran 77) +if test -z "$F77" || test no = "$F77"; then + _lt_disable_F77=yes +fi + +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for f77 test sources. +ac_ext=f + +# Object file extension for compiled f77 test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the F77 compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test yes != "$_lt_disable_F77"; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="\ + subroutine t + return + end +" + + # Code to be used in simple link tests + lt_simple_link_test_code="\ + program t + end +" + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC=$CC + lt_save_GCC=$GCC + lt_save_CFLAGS=$CFLAGS + CC=${F77-"f77"} + CFLAGS=$FFLAGS + compiler=$CC + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + GCC=$G77 + if test -n "$compiler"; then + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test no = "$can_build_shared" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test yes = "$enable_shared" && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + aix[[4-9]]*) + if test ia64 != "$host_cpu"; then + case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in + yes,aix,yes) ;; # shared object as lib.so file only + yes,svr4,*) ;; # shared object as lib.so archive member only + yes,*) enable_static=no ;; # shared object in lib.a archive as well + esac + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test yes = "$enable_shared" || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_TAGVAR(GCC, $1)=$G77 + _LT_TAGVAR(LD, $1)=$LD + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + GCC=$lt_save_GCC + CC=$lt_save_CC + CFLAGS=$lt_save_CFLAGS +fi # test yes != "$_lt_disable_F77" + +AC_LANG_POP +])# _LT_LANG_F77_CONFIG + + +# _LT_LANG_FC_CONFIG([TAG]) +# ------------------------- +# Ensure that the configuration variables for a Fortran compiler are +# suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_FC_CONFIG], +[AC_LANG_PUSH(Fortran) + +if test -z "$FC" || test no = "$FC"; then + _lt_disable_FC=yes +fi + +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for fc test sources. +ac_ext=${ac_fc_srcext-f} + +# Object file extension for compiled fc test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the FC compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test yes != "$_lt_disable_FC"; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="\ + subroutine t + return + end +" + + # Code to be used in simple link tests + lt_simple_link_test_code="\ + program t + end +" + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC=$CC + lt_save_GCC=$GCC + lt_save_CFLAGS=$CFLAGS + CC=${FC-"f95"} + CFLAGS=$FCFLAGS + compiler=$CC + GCC=$ac_cv_fc_compiler_gnu + + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + + if test -n "$compiler"; then + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test no = "$can_build_shared" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test yes = "$enable_shared" && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + aix[[4-9]]*) + if test ia64 != "$host_cpu"; then + case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in + yes,aix,yes) ;; # shared object as lib.so file only + yes,svr4,*) ;; # shared object as lib.so archive member only + yes,*) enable_static=no ;; # shared object in lib.a archive as well + esac + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test yes = "$enable_shared" || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_TAGVAR(GCC, $1)=$ac_cv_fc_compiler_gnu + _LT_TAGVAR(LD, $1)=$LD + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_SYS_HIDDEN_LIBDEPS($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + GCC=$lt_save_GCC + CC=$lt_save_CC + CFLAGS=$lt_save_CFLAGS +fi # test yes != "$_lt_disable_FC" + +AC_LANG_POP +])# _LT_LANG_FC_CONFIG + + +# _LT_LANG_GCJ_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for the GNU Java Compiler compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_GCJ_CONFIG], +[AC_REQUIRE([LT_PROG_GCJ])dnl +AC_LANG_SAVE + +# Source file extension for Java test sources. +ac_ext=java + +# Object file extension for compiled Java test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="class foo {}" + +# Code to be used in simple link tests +lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_CFLAGS=$CFLAGS +lt_save_GCC=$GCC +GCC=yes +CC=${GCJ-"gcj"} +CFLAGS=$GCJFLAGS +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_TAGVAR(LD, $1)=$LD +_LT_CC_BASENAME([$compiler]) + +# GCJ did not exist at the time GCC didn't implicitly link libc in. +_LT_TAGVAR(archive_cmds_need_lc, $1)=no + +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds + +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) +fi + +AC_LANG_RESTORE + +GCC=$lt_save_GCC +CC=$lt_save_CC +CFLAGS=$lt_save_CFLAGS +])# _LT_LANG_GCJ_CONFIG + + +# _LT_LANG_GO_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for the GNU Go compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_GO_CONFIG], +[AC_REQUIRE([LT_PROG_GO])dnl +AC_LANG_SAVE + +# Source file extension for Go test sources. +ac_ext=go + +# Object file extension for compiled Go test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="package main; func main() { }" + +# Code to be used in simple link tests +lt_simple_link_test_code='package main; func main() { }' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_CFLAGS=$CFLAGS +lt_save_GCC=$GCC +GCC=yes +CC=${GOC-"gccgo"} +CFLAGS=$GOFLAGS +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_TAGVAR(LD, $1)=$LD +_LT_CC_BASENAME([$compiler]) + +# Go did not exist at the time GCC didn't implicitly link libc in. +_LT_TAGVAR(archive_cmds_need_lc, $1)=no + +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds + +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) +fi + +AC_LANG_RESTORE + +GCC=$lt_save_GCC +CC=$lt_save_CC +CFLAGS=$lt_save_CFLAGS +])# _LT_LANG_GO_CONFIG + + +# _LT_LANG_RC_CONFIG([TAG]) +# ------------------------- +# Ensure that the configuration variables for the Windows resource compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_RC_CONFIG], +[AC_REQUIRE([LT_PROG_RC])dnl +AC_LANG_SAVE + +# Source file extension for RC test sources. +ac_ext=rc + +# Object file extension for compiled RC test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' + +# Code to be used in simple link tests +lt_simple_link_test_code=$lt_simple_compile_test_code + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_CFLAGS=$CFLAGS +lt_save_GCC=$GCC +GCC= +CC=${RC-"windres"} +CFLAGS= +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_CC_BASENAME([$compiler]) +_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + +if test -n "$compiler"; then + : + _LT_CONFIG($1) +fi + +GCC=$lt_save_GCC +AC_LANG_RESTORE +CC=$lt_save_CC +CFLAGS=$lt_save_CFLAGS +])# _LT_LANG_RC_CONFIG + + +# LT_PROG_GCJ +# ----------- +AC_DEFUN([LT_PROG_GCJ], +[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], + [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], + [AC_CHECK_TOOL(GCJ, gcj,) + test set = "${GCJFLAGS+set}" || GCJFLAGS="-g -O2" + AC_SUBST(GCJFLAGS)])])[]dnl +]) + +# Old name: +AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_GCJ], []) + + +# LT_PROG_GO +# ---------- +AC_DEFUN([LT_PROG_GO], +[AC_CHECK_TOOL(GOC, gccgo,) +]) + + +# LT_PROG_RC +# ---------- +AC_DEFUN([LT_PROG_RC], +[AC_CHECK_TOOL(RC, windres,) +]) + +# Old name: +AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_RC], []) + + +# _LT_DECL_EGREP +# -------------- +# If we don't have a new enough Autoconf to choose the best grep +# available, choose the one first in the user's PATH. +m4_defun([_LT_DECL_EGREP], +[AC_REQUIRE([AC_PROG_EGREP])dnl +AC_REQUIRE([AC_PROG_FGREP])dnl +test -z "$GREP" && GREP=grep +_LT_DECL([], [GREP], [1], [A grep program that handles long lines]) +_LT_DECL([], [EGREP], [1], [An ERE matcher]) +_LT_DECL([], [FGREP], [1], [A literal string matcher]) +dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too +AC_SUBST([GREP]) +]) + + +# _LT_DECL_OBJDUMP +# -------------- +# If we don't have a new enough Autoconf to choose the best objdump +# available, choose the one first in the user's PATH. +m4_defun([_LT_DECL_OBJDUMP], +[AC_CHECK_TOOL(OBJDUMP, objdump, false) +test -z "$OBJDUMP" && OBJDUMP=objdump +_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) +AC_SUBST([OBJDUMP]) +]) + +# _LT_DECL_DLLTOOL +# ---------------- +# Ensure DLLTOOL variable is set. +m4_defun([_LT_DECL_DLLTOOL], +[AC_CHECK_TOOL(DLLTOOL, dlltool, false) +test -z "$DLLTOOL" && DLLTOOL=dlltool +_LT_DECL([], [DLLTOOL], [1], [DLL creation program]) +AC_SUBST([DLLTOOL]) +]) + +# _LT_DECL_SED +# ------------ +# Check for a fully-functional sed program, that truncates +# as few characters as possible. Prefer GNU sed if found. +m4_defun([_LT_DECL_SED], +[AC_PROG_SED +test -z "$SED" && SED=sed +Xsed="$SED -e 1s/^X//" +_LT_DECL([], [SED], [1], [A sed program that does not truncate output]) +_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], + [Sed that helps us avoid accidentally triggering echo(1) options like -n]) +])# _LT_DECL_SED + +m4_ifndef([AC_PROG_SED], [ +############################################################ +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_SED. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # +############################################################ + +m4_defun([AC_PROG_SED], +[AC_MSG_CHECKING([for a sed that does not truncate output]) +AC_CACHE_VAL(lt_cv_path_SED, +[# Loop through the user's path and test for sed and gsed. +# Then use that list of sed's as ones to test for truncation. +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for lt_ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then + lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" + fi + done + done +done +IFS=$as_save_IFS +lt_ac_max=0 +lt_ac_count=0 +# Add /usr/xpg4/bin/sed as it is typically found on Solaris +# along with /bin/sed that truncates output. +for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do + test ! -f "$lt_ac_sed" && continue + cat /dev/null > conftest.in + lt_ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >conftest.in + # Check for GNU sed and select it if it is found. + if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then + lt_cv_path_SED=$lt_ac_sed + break + fi + while true; do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo >>conftest.nl + $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break + cmp -s conftest.out conftest.nl || break + # 10000 chars as input seems more than enough + test 10 -lt "$lt_ac_count" && break + lt_ac_count=`expr $lt_ac_count + 1` + if test "$lt_ac_count" -gt "$lt_ac_max"; then + lt_ac_max=$lt_ac_count + lt_cv_path_SED=$lt_ac_sed + fi + done +done +]) +SED=$lt_cv_path_SED +AC_SUBST([SED]) +AC_MSG_RESULT([$SED]) +])#AC_PROG_SED +])#m4_ifndef + +# Old name: +AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_SED], []) + + +# _LT_CHECK_SHELL_FEATURES +# ------------------------ +# Find out whether the shell is Bourne or XSI compatible, +# or has some other useful features. +m4_defun([_LT_CHECK_SHELL_FEATURES], +[if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + lt_unset=unset +else + lt_unset=false +fi +_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl + +# test EBCDIC or ASCII +case `echo X|tr X '\101'` in + A) # ASCII based system + # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr + lt_SP2NL='tr \040 \012' + lt_NL2SP='tr \015\012 \040\040' + ;; + *) # EBCDIC based system + lt_SP2NL='tr \100 \n' + lt_NL2SP='tr \r\n \100\100' + ;; +esac +_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl +_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl +])# _LT_CHECK_SHELL_FEATURES + + +# _LT_PATH_CONVERSION_FUNCTIONS +# ----------------------------- +# Determine what file name conversion functions should be used by +# func_to_host_file (and, implicitly, by func_to_host_path). These are needed +# for certain cross-compile configurations and native mingw. +m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_MSG_CHECKING([how to convert $build file names to $host format]) +AC_CACHE_VAL(lt_cv_to_host_file_cmd, +[case $host in + *-*-mingw* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 + ;; + *-*-cygwin* ) + lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 + ;; + * ) # otherwise, assume *nix + lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 + ;; + esac + ;; + *-*-cygwin* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin + ;; + *-*-cygwin* ) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; + * ) # otherwise, assume *nix + lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin + ;; + esac + ;; + * ) # unhandled hosts (and "normal" native builds) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; +esac +]) +to_host_file_cmd=$lt_cv_to_host_file_cmd +AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) +_LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], + [0], [convert $build file names to $host format])dnl + +AC_MSG_CHECKING([how to convert $build file names to toolchain format]) +AC_CACHE_VAL(lt_cv_to_tool_file_cmd, +[#assume ordinary cross tools, or native build. +lt_cv_to_tool_file_cmd=func_convert_file_noop +case $host in + *-*-mingw* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 + ;; + esac + ;; +esac +]) +to_tool_file_cmd=$lt_cv_to_tool_file_cmd +AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) +_LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], + [0], [convert $build files to toolchain format])dnl +])# _LT_PATH_CONVERSION_FUNCTIONS diff --git a/m4/ln.m4 b/m4/ln.m4 new file mode 100644 index 0000000..b2ccbea --- /dev/null +++ b/m4/ln.m4 @@ -0,0 +1,51 @@ +dnl -*- Autoconf -*- +dnl Copyright (C) 1993-2017 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License as published by the Free Software Foundation; +dnl either version 2 of the License, or (at your option) any later version. +dnl As a special exception to the GNU General Public License, this file +dnl may be distributed as part of a program that contains a configuration +dnl script generated by Autoconf, under the same distribution terms as +dnl the rest of that program. + +dnl From Bruno Haible, Marcus Daniels, Sam Steingold. + +AC_PREREQ([2.13]) + +AC_DEFUN([CL_PROG_LN], +[ + AC_CACHE_CHECK([how to make hard links], [cl_cv_prog_LN], + [rm -f conftestdata conftestfile + echo data > conftestfile + if ln conftestfile conftestdata 2>/dev/null; then + cl_cv_prog_LN=ln + else + cl_cv_prog_LN="cp -p" + fi + rm -f conftestdata conftestfile + ]) + LN="$cl_cv_prog_LN" + AC_SUBST([LN]) +]) + +AC_DEFUN([CL_PROG_LN_S], +[ + AC_REQUIRE([CL_PROG_LN]) + dnl Make a symlink if possible; otherwise try a hard link. On filesystems + dnl which support neither symlink nor hard link, use a plain copy. + AC_CACHE_CHECK([whether ln -s works], [cl_cv_prog_LN_S_works], + [rm -f conftestdata + if ln -s X conftestdata 2>/dev/null; then + cl_cv_prog_LN_S_works=yes + else + cl_cv_prog_LN_S_works=no + fi + rm -f conftestdata + ]) + if test $cl_cv_prog_LN_S_works = yes; then + LN_S="ln -s" + else + LN_S="$cl_cv_prog_LN" + fi + AC_SUBST([LN_S]) +]) diff --git a/m4/ltoptions.m4 b/m4/ltoptions.m4 new file mode 100644 index 0000000..94b0829 --- /dev/null +++ b/m4/ltoptions.m4 @@ -0,0 +1,437 @@ +# Helper functions for option handling. -*- Autoconf -*- +# +# Copyright (C) 2004-2005, 2007-2009, 2011-2015 Free Software +# Foundation, Inc. +# Written by Gary V. Vaughan, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 8 ltoptions.m4 + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) + + +# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) +# ------------------------------------------ +m4_define([_LT_MANGLE_OPTION], +[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) + + +# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) +# --------------------------------------- +# Set option OPTION-NAME for macro MACRO-NAME, and if there is a +# matching handler defined, dispatch to it. Other OPTION-NAMEs are +# saved as a flag. +m4_define([_LT_SET_OPTION], +[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl +m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), + _LT_MANGLE_DEFUN([$1], [$2]), + [m4_warning([Unknown $1 option '$2'])])[]dnl +]) + + +# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) +# ------------------------------------------------------------ +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +m4_define([_LT_IF_OPTION], +[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) + + +# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) +# ------------------------------------------------------- +# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME +# are set. +m4_define([_LT_UNLESS_OPTIONS], +[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), + [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), + [m4_define([$0_found])])])[]dnl +m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 +])[]dnl +]) + + +# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) +# ---------------------------------------- +# OPTION-LIST is a space-separated list of Libtool options associated +# with MACRO-NAME. If any OPTION has a matching handler declared with +# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about +# the unknown option and exit. +m4_defun([_LT_SET_OPTIONS], +[# Set options +m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), + [_LT_SET_OPTION([$1], _LT_Option)]) + +m4_if([$1],[LT_INIT],[ + dnl + dnl Simply set some default values (i.e off) if boolean options were not + dnl specified: + _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no + ]) + _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no + ]) + dnl + dnl If no reference was made to various pairs of opposing options, then + dnl we run the default mode handler for the pair. For example, if neither + dnl 'shared' nor 'disable-shared' was passed, we enable building of shared + dnl archives by default: + _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) + _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) + _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) + _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], + [_LT_ENABLE_FAST_INSTALL]) + _LT_UNLESS_OPTIONS([LT_INIT], [aix-soname=aix aix-soname=both aix-soname=svr4], + [_LT_WITH_AIX_SONAME([aix])]) + ]) +])# _LT_SET_OPTIONS + + +## --------------------------------- ## +## Macros to handle LT_INIT options. ## +## --------------------------------- ## + +# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) +# ----------------------------------------- +m4_define([_LT_MANGLE_DEFUN], +[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) + + +# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) +# ----------------------------------------------- +m4_define([LT_OPTION_DEFINE], +[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl +])# LT_OPTION_DEFINE + + +# dlopen +# ------ +LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes +]) + +AU_DEFUN([AC_LIBTOOL_DLOPEN], +[_LT_SET_OPTION([LT_INIT], [dlopen]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the 'dlopen' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) + + +# win32-dll +# --------- +# Declare package support for building win32 dll's. +LT_OPTION_DEFINE([LT_INIT], [win32-dll], +[enable_win32_dll=yes + +case $host in +*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) + ;; +esac + +test -z "$AS" && AS=as +_LT_DECL([], [AS], [1], [Assembler program])dnl + +test -z "$DLLTOOL" && DLLTOOL=dlltool +_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl + +test -z "$OBJDUMP" && OBJDUMP=objdump +_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl +])# win32-dll + +AU_DEFUN([AC_LIBTOOL_WIN32_DLL], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +_LT_SET_OPTION([LT_INIT], [win32-dll]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the 'win32-dll' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) + + +# _LT_ENABLE_SHARED([DEFAULT]) +# ---------------------------- +# implement the --enable-shared flag, and supports the 'shared' and +# 'disable-shared' LT_INIT options. +# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. +m4_define([_LT_ENABLE_SHARED], +[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([shared], + [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], + [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for pkg in $enableval; do + IFS=$lt_save_ifs + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS=$lt_save_ifs + ;; + esac], + [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) + + _LT_DECL([build_libtool_libs], [enable_shared], [0], + [Whether or not to build shared libraries]) +])# _LT_ENABLE_SHARED + +LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) + +# Old names: +AC_DEFUN([AC_ENABLE_SHARED], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) +]) + +AC_DEFUN([AC_DISABLE_SHARED], +[_LT_SET_OPTION([LT_INIT], [disable-shared]) +]) + +AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) +AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_ENABLE_SHARED], []) +dnl AC_DEFUN([AM_DISABLE_SHARED], []) + + + +# _LT_ENABLE_STATIC([DEFAULT]) +# ---------------------------- +# implement the --enable-static flag, and support the 'static' and +# 'disable-static' LT_INIT options. +# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. +m4_define([_LT_ENABLE_STATIC], +[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([static], + [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], + [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for pkg in $enableval; do + IFS=$lt_save_ifs + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS=$lt_save_ifs + ;; + esac], + [enable_static=]_LT_ENABLE_STATIC_DEFAULT) + + _LT_DECL([build_old_libs], [enable_static], [0], + [Whether or not to build static libraries]) +])# _LT_ENABLE_STATIC + +LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) + +# Old names: +AC_DEFUN([AC_ENABLE_STATIC], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) +]) + +AC_DEFUN([AC_DISABLE_STATIC], +[_LT_SET_OPTION([LT_INIT], [disable-static]) +]) + +AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) +AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_ENABLE_STATIC], []) +dnl AC_DEFUN([AM_DISABLE_STATIC], []) + + + +# _LT_ENABLE_FAST_INSTALL([DEFAULT]) +# ---------------------------------- +# implement the --enable-fast-install flag, and support the 'fast-install' +# and 'disable-fast-install' LT_INIT options. +# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. +m4_define([_LT_ENABLE_FAST_INSTALL], +[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([fast-install], + [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], + [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for pkg in $enableval; do + IFS=$lt_save_ifs + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS=$lt_save_ifs + ;; + esac], + [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) + +_LT_DECL([fast_install], [enable_fast_install], [0], + [Whether or not to optimize for fast installation])dnl +])# _LT_ENABLE_FAST_INSTALL + +LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) + +# Old names: +AU_DEFUN([AC_ENABLE_FAST_INSTALL], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you put +the 'fast-install' option into LT_INIT's first parameter.]) +]) + +AU_DEFUN([AC_DISABLE_FAST_INSTALL], +[_LT_SET_OPTION([LT_INIT], [disable-fast-install]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you put +the 'disable-fast-install' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) +dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) + + +# _LT_WITH_AIX_SONAME([DEFAULT]) +# ---------------------------------- +# implement the --with-aix-soname flag, and support the `aix-soname=aix' +# and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT +# is either `aix', `both' or `svr4'. If omitted, it defaults to `aix'. +m4_define([_LT_WITH_AIX_SONAME], +[m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl +shared_archive_member_spec= +case $host,$enable_shared in +power*-*-aix[[5-9]]*,yes) + AC_MSG_CHECKING([which variant of shared library versioning to provide]) + AC_ARG_WITH([aix-soname], + [AS_HELP_STRING([--with-aix-soname=aix|svr4|both], + [shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])], + [case $withval in + aix|svr4|both) + ;; + *) + AC_MSG_ERROR([Unknown argument to --with-aix-soname]) + ;; + esac + lt_cv_with_aix_soname=$with_aix_soname], + [AC_CACHE_VAL([lt_cv_with_aix_soname], + [lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT) + with_aix_soname=$lt_cv_with_aix_soname]) + AC_MSG_RESULT([$with_aix_soname]) + if test aix != "$with_aix_soname"; then + # For the AIX way of multilib, we name the shared archive member + # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o', + # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File. + # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag, + # the AIX toolchain works better with OBJECT_MODE set (default 32). + if test 64 = "${OBJECT_MODE-32}"; then + shared_archive_member_spec=shr_64 + else + shared_archive_member_spec=shr + fi + fi + ;; +*) + with_aix_soname=aix + ;; +esac + +_LT_DECL([], [shared_archive_member_spec], [0], + [Shared archive member basename, for filename based shared library versioning on AIX])dnl +])# _LT_WITH_AIX_SONAME + +LT_OPTION_DEFINE([LT_INIT], [aix-soname=aix], [_LT_WITH_AIX_SONAME([aix])]) +LT_OPTION_DEFINE([LT_INIT], [aix-soname=both], [_LT_WITH_AIX_SONAME([both])]) +LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])]) + + +# _LT_WITH_PIC([MODE]) +# -------------------- +# implement the --with-pic flag, and support the 'pic-only' and 'no-pic' +# LT_INIT options. +# MODE is either 'yes' or 'no'. If omitted, it defaults to 'both'. +m4_define([_LT_WITH_PIC], +[AC_ARG_WITH([pic], + [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], + [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], + [lt_p=${PACKAGE-default} + case $withval in + yes|no) pic_mode=$withval ;; + *) + pic_mode=default + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for lt_pkg in $withval; do + IFS=$lt_save_ifs + if test "X$lt_pkg" = "X$lt_p"; then + pic_mode=yes + fi + done + IFS=$lt_save_ifs + ;; + esac], + [pic_mode=m4_default([$1], [default])]) + +_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl +])# _LT_WITH_PIC + +LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) +LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) + +# Old name: +AU_DEFUN([AC_LIBTOOL_PICMODE], +[_LT_SET_OPTION([LT_INIT], [pic-only]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the 'pic-only' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) + +## ----------------- ## +## LTDL_INIT Options ## +## ----------------- ## + +m4_define([_LTDL_MODE], []) +LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], + [m4_define([_LTDL_MODE], [nonrecursive])]) +LT_OPTION_DEFINE([LTDL_INIT], [recursive], + [m4_define([_LTDL_MODE], [recursive])]) +LT_OPTION_DEFINE([LTDL_INIT], [subproject], + [m4_define([_LTDL_MODE], [subproject])]) + +m4_define([_LTDL_TYPE], []) +LT_OPTION_DEFINE([LTDL_INIT], [installable], + [m4_define([_LTDL_TYPE], [installable])]) +LT_OPTION_DEFINE([LTDL_INIT], [convenience], + [m4_define([_LTDL_TYPE], [convenience])]) diff --git a/m4/ltsugar.m4 b/m4/ltsugar.m4 new file mode 100644 index 0000000..48bc934 --- /dev/null +++ b/m4/ltsugar.m4 @@ -0,0 +1,124 @@ +# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- +# +# Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software +# Foundation, Inc. +# Written by Gary V. Vaughan, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 6 ltsugar.m4 + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) + + +# lt_join(SEP, ARG1, [ARG2...]) +# ----------------------------- +# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their +# associated separator. +# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier +# versions in m4sugar had bugs. +m4_define([lt_join], +[m4_if([$#], [1], [], + [$#], [2], [[$2]], + [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) +m4_define([_lt_join], +[m4_if([$#$2], [2], [], + [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) + + +# lt_car(LIST) +# lt_cdr(LIST) +# ------------ +# Manipulate m4 lists. +# These macros are necessary as long as will still need to support +# Autoconf-2.59, which quotes differently. +m4_define([lt_car], [[$1]]) +m4_define([lt_cdr], +[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], + [$#], 1, [], + [m4_dquote(m4_shift($@))])]) +m4_define([lt_unquote], $1) + + +# lt_append(MACRO-NAME, STRING, [SEPARATOR]) +# ------------------------------------------ +# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'. +# Note that neither SEPARATOR nor STRING are expanded; they are appended +# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). +# No SEPARATOR is output if MACRO-NAME was previously undefined (different +# than defined and empty). +# +# This macro is needed until we can rely on Autoconf 2.62, since earlier +# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. +m4_define([lt_append], +[m4_define([$1], + m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) + + + +# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) +# ---------------------------------------------------------- +# Produce a SEP delimited list of all paired combinations of elements of +# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list +# has the form PREFIXmINFIXSUFFIXn. +# Needed until we can rely on m4_combine added in Autoconf 2.62. +m4_define([lt_combine], +[m4_if(m4_eval([$# > 3]), [1], + [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl +[[m4_foreach([_Lt_prefix], [$2], + [m4_foreach([_Lt_suffix], + ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, + [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) + + +# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) +# ----------------------------------------------------------------------- +# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited +# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. +m4_define([lt_if_append_uniq], +[m4_ifdef([$1], + [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], + [lt_append([$1], [$2], [$3])$4], + [$5])], + [lt_append([$1], [$2], [$3])$4])]) + + +# lt_dict_add(DICT, KEY, VALUE) +# ----------------------------- +m4_define([lt_dict_add], +[m4_define([$1($2)], [$3])]) + + +# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) +# -------------------------------------------- +m4_define([lt_dict_add_subkey], +[m4_define([$1($2:$3)], [$4])]) + + +# lt_dict_fetch(DICT, KEY, [SUBKEY]) +# ---------------------------------- +m4_define([lt_dict_fetch], +[m4_ifval([$3], + m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), + m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) + + +# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) +# ----------------------------------------------------------------- +m4_define([lt_if_dict_fetch], +[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], + [$5], + [$6])]) + + +# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) +# -------------------------------------------------------------- +m4_define([lt_dict_filter], +[m4_if([$5], [], [], + [lt_join(m4_quote(m4_default([$4], [[, ]])), + lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), + [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl +]) diff --git a/m4/ltversion.m4 b/m4/ltversion.m4 new file mode 100644 index 0000000..fa04b52 --- /dev/null +++ b/m4/ltversion.m4 @@ -0,0 +1,23 @@ +# ltversion.m4 -- version numbers -*- Autoconf -*- +# +# Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc. +# Written by Scott James Remnant, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# @configure_input@ + +# serial 4179 ltversion.m4 +# This file is part of GNU Libtool + +m4_define([LT_PACKAGE_VERSION], [2.4.6]) +m4_define([LT_PACKAGE_REVISION], [2.4.6]) + +AC_DEFUN([LTVERSION_VERSION], +[macro_version='2.4.6' +macro_revision='2.4.6' +_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) +_LT_DECL(, macro_revision, 0) +]) diff --git a/m4/lt~obsolete.m4 b/m4/lt~obsolete.m4 new file mode 100644 index 0000000..c6b26f8 --- /dev/null +++ b/m4/lt~obsolete.m4 @@ -0,0 +1,99 @@ +# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- +# +# Copyright (C) 2004-2005, 2007, 2009, 2011-2015 Free Software +# Foundation, Inc. +# Written by Scott James Remnant, 2004. +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 5 lt~obsolete.m4 + +# These exist entirely to fool aclocal when bootstrapping libtool. +# +# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN), +# which have later been changed to m4_define as they aren't part of the +# exported API, or moved to Autoconf or Automake where they belong. +# +# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN +# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us +# using a macro with the same name in our local m4/libtool.m4 it'll +# pull the old libtool.m4 in (it doesn't see our shiny new m4_define +# and doesn't know about Autoconf macros at all.) +# +# So we provide this file, which has a silly filename so it's always +# included after everything else. This provides aclocal with the +# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything +# because those macros already exist, or will be overwritten later. +# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. +# +# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. +# Yes, that means every name once taken will need to remain here until +# we give up compatibility with versions before 1.7, at which point +# we need to keep only those names which we still refer to. + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) + +m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) +m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) +m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) +m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) +m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) +m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) +m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) +m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) +m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) +m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) +m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) +m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) +m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) +m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) +m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) +m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) +m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) +m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) +m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) +m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) +m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) +m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) +m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) +m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) +m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) +m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) +m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) +m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) +m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) +m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) +m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) +m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) +m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) +m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) +m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) +m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) +m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) +m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) +m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) +m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) +m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) +m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) +m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) +m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) +m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) +m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) +m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) +m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) +m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) +m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) +m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) +m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) +m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) +m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) +m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) +m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) +m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) diff --git a/m4/mach-vm.m4 b/m4/mach-vm.m4 new file mode 100644 index 0000000..bb376a1 --- /dev/null +++ b/m4/mach-vm.m4 @@ -0,0 +1,22 @@ +dnl -*- Autoconf -*- +dnl Copyright (C) 1993-2017 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License as published by the Free Software Foundation; +dnl either version 2 of the License, or (at your option) any later version. +dnl As a special exception to the GNU General Public License, this file +dnl may be distributed as part of a program that contains a configuration +dnl script generated by Autoconf, under the same distribution terms as +dnl the rest of that program. + +dnl From Bruno Haible, Marcus Daniels, Sam Steingold. + +AC_PREREQ([2.57]) + +AC_DEFUN([CL_MACH_VM], +[ + CL_LINK_CHECK([vm_allocate], + [cl_cv_func_vm], + [], + [vm_allocate(); task_self();], + [AC_DEFINE([HAVE_MACH_VM],[],[have vm_allocate() and task_self() functions])]) +]) diff --git a/m4/mmap.m4 b/m4/mmap.m4 new file mode 100644 index 0000000..d149052 --- /dev/null +++ b/m4/mmap.m4 @@ -0,0 +1,140 @@ +dnl -*- Autoconf -*- +dnl Copyright (C) 1993-2017 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License as published by the Free Software Foundation; +dnl either version 2 of the License, or (at your option) any later version. +dnl As a special exception to the GNU General Public License, this file +dnl may be distributed as part of a program that contains a configuration +dnl script generated by Autoconf, under the same distribution terms as +dnl the rest of that program. + +dnl From Bruno Haible, Marcus Daniels, Sam Steingold. + +AC_PREREQ([2.57]) + +AC_DEFUN([FFCALL_MMAP], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_CHECK_HEADER([sys/mman.h], [], [no_mmap=1]) + if test -z "$no_mmap"; then + AC_CHECK_FUNC([mmap], [], [no_mmap=1]) + if test -z "$no_mmap"; then + AC_DEFINE([HAVE_MMAP], [], [have and the mmap() function]) + AC_CACHE_CHECK([for working mmap], [ffcall_cv_func_mmap_works], + [if test $cross_compiling = no; then + mmap_prog_1=' + #include + #ifdef HAVE_UNISTD_H + #include + #endif + #include + #include + #include + int main () + { + ' + mmap_prog_2=' + if (mmap(NULL,0x100000,PROT_READ|PROT_WRITE,flags,fd,0) == (void*)-1) + exit(1); + exit(0); + } + ' + AC_TRY_RUN(GL_NOCRASH + [$mmap_prog_1 + int flags = MAP_ANON | MAP_PRIVATE; + int fd = -1; + nocrash_init(); + $mmap_prog_2 + ], + [have_mmap_anon=1 + ffcall_cv_func_mmap_anon=yes], + [], + [dnl When cross-compiling, don't assume anything. + : + ]) + AC_TRY_RUN(GL_NOCRASH + [$mmap_prog_1 + int flags = MAP_ANONYMOUS | MAP_PRIVATE; + int fd = -1; + nocrash_init(); + $mmap_prog_2 + ], + [have_mmap_anon=1 + ffcall_cv_func_mmap_anonymous=yes], + [], + [dnl When cross-compiling, don't assume anything. + : + ]) + AC_TRY_RUN(GL_NOCRASH + [$mmap_prog_1 + #ifndef MAP_FILE + #define MAP_FILE 0 + #endif + int flags = MAP_FILE | MAP_PRIVATE; + int fd = open("/dev/zero",O_RDONLY,0666); + if (fd<0) + exit(1); + nocrash_init(); + $mmap_prog_2 + ], + [have_mmap_devzero=1 + ffcall_cv_func_mmap_devzero=yes], + [], + [dnl When cross-compiling, don't assume anything. + : + ]) + if test -n "$have_mmap_anon" -o -n "$have_mmap_devzero"; then + ffcall_cv_func_mmap_works=yes + else + ffcall_cv_func_mmap_works=no + fi + else + dnl When cross-compiling, assume the known behaviour. + dnl If we don't know, don't assume anything. + case "$host_os" in + aix* | cygwin* | darwin* | hpux* | irix* | linux* | solaris*) + ffcall_cv_func_mmap_works="guessing yes" ;; + *) + ffcall_cv_func_mmap_works="guessing no" ;; + esac + case "$host_os" in + aix* | cygwin* | darwin* | linux* | solaris*) + ffcall_cv_func_mmap_anon="guessing yes" ;; + *) + ffcall_cv_func_mmap_anon="guessing no" ;; + esac + case "$host_os" in + aix* | cygwin* | hpux* | linux* | solaris*) + ffcall_cv_func_mmap_anonymous="guessing yes" ;; + *) + ffcall_cv_func_mmap_anonymous="guessing no" ;; + esac + case "$host_os" in + aix* | cygwin* | hpux* | irix* | linux* | solaris*) + ffcall_cv_func_mmap_devzero="guessing yes" ;; + *) + ffcall_cv_func_mmap_devzero="guessing no" ;; + esac + fi + ]) + case "$ffcall_cv_func_mmap_anon" in + *yes) + AC_DEFINE([HAVE_MMAP_ANON], [], + [ defines MAP_ANON and mmaping with MAP_ANON works]) + ;; + esac + case "$ffcall_cv_func_mmap_anonymous" in + *yes) + AC_DEFINE([HAVE_MMAP_ANONYMOUS], [], + [ defines MAP_ANONYMOUS and mmaping with MAP_ANONYMOUS works]) + ;; + esac + case "$ffcall_cv_func_mmap_devzero" in + *yes) + AC_DEFINE([HAVE_MMAP_DEVZERO], [], + [mmaping of the special device /dev/zero works]) + ;; + esac + fi + fi +]) diff --git a/m4/mprotect.m4 b/m4/mprotect.m4 new file mode 100644 index 0000000..6836ed9 --- /dev/null +++ b/m4/mprotect.m4 @@ -0,0 +1,152 @@ +dnl -*- Autoconf -*- +dnl Copyright (C) 1993-2017 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License as published by the Free Software Foundation; +dnl either version 2 of the License, or (at your option) any later version. +dnl As a special exception to the GNU General Public License, this file +dnl may be distributed as part of a program that contains a configuration +dnl script generated by Autoconf, under the same distribution terms as +dnl the rest of that program. + +dnl From Bruno Haible, Marcus Daniels, Sam Steingold. + +AC_PREREQ([2.57]) + +AC_DEFUN([FFCALL_MPROTECT], +[ + AC_REQUIRE([CL_GETPAGESIZE]) + AC_REQUIRE([FFCALL_MMAP]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_CHECK_FUNCS([mprotect]) + if test $ac_cv_func_mprotect = yes; then + AC_CACHE_CHECK([for working mprotect], [cl_cv_func_mprotect_works], + [if test $cross_compiling = no; then + mprotect_prog=' + #include + /* declare malloc() */ + #include + #ifdef HAVE_UNISTD_H + #include + #endif + /* declare getpagesize() and mprotect() */ + #include + #ifndef HAVE_GETPAGESIZE + #include + #define getpagesize() PAGESIZE + #else + ]AC_LANG_EXTERN[ + RETGETPAGESIZETYPE getpagesize (void); + #endif + char foo; + int main () + { + unsigned long pagesize = getpagesize(); + #define page_align(address) (char*)((unsigned long)(address) & -pagesize) + ' + AC_TRY_RUN( + [$mprotect_prog + if ((pagesize-1) & pagesize) exit(1); + exit(0); + } + ], + [], + [no_mprotect=1], + [dnl When cross-compiling, don't assume anything. + no_mprotect=1 + ]) + mprotect_prog="$mprotect_prog"' + char* area = (char*) malloc(6*pagesize); + char* fault_address = area + pagesize*7/2; + ' + if test -z "$no_mprotect"; then + AC_TRY_RUN(GL_NOCRASH + [$mprotect_prog + nocrash_init(); + if (mprotect(page_align(fault_address),pagesize,PROT_NONE) < 0) + exit(0); + foo = *fault_address; /* this should cause an exception or signal */ + exit(0); + } + ], + [no_mprotect=1], + [], + [dnl When cross-compiling, don't assume anything. + : + ]) + fi + if test -z "$no_mprotect"; then + AC_TRY_RUN(GL_NOCRASH + [$mprotect_prog + nocrash_init(); + if (mprotect(page_align(fault_address),pagesize,PROT_NONE) < 0) + exit(0); + *fault_address = 'z'; /* this should cause an exception or signal */ + exit(0); + } + ], + [no_mprotect=1], + [], + [dnl When cross-compiling, don't assume anything. + : + ]) + fi + if test -z "$no_mprotect"; then + AC_TRY_RUN(GL_NOCRASH + [$mprotect_prog + nocrash_init(); + if (mprotect(page_align(fault_address),pagesize,PROT_READ) < 0) + exit(0); + *fault_address = 'z'; /* this should cause an exception or signal */ + exit(0); + } + ], + [no_mprotect=1], + [], + [dnl When cross-compiling, don't assume anything. + : + ]) + fi + if test -z "$no_mprotect"; then + AC_TRY_RUN(GL_NOCRASH + [$mprotect_prog + nocrash_init(); + if (mprotect(page_align(fault_address),pagesize,PROT_READ) < 0) + exit(1); + if (mprotect(page_align(fault_address),pagesize,PROT_READ|PROT_WRITE) < 0) + exit(1); + *fault_address = 'z'; /* this should not cause an exception or signal */ + exit(0); + } + ], + [], + [no_mprotect=1], + [dnl When cross-compiling, don't assume anything. + : + ]) + fi + if test -z "$no_mprotect"; then + cl_cv_func_mprotect_works=yes + else + cl_cv_func_mprotect_works=no + fi + else + dnl When cross-compiling, assume the known behaviour. + dnl If we don't know, don't assume anything. + case "$host_os" in + aix* | cygwin* | darwin* | hpux* | irix* | linux* | solaris*) + cl_cv_func_mprotect_works="guessing yes" ;; + mingw*) + cl_cv_func_mprotect_works="guessing no" ;; + *) + cl_cv_func_mprotect_works="guessing no" ;; + esac + fi + ]) + case "$cl_cv_func_mprotect_works" in + *yes) + AC_DEFINE([HAVE_WORKING_MPROTECT], [], + [have a working mprotect() function]) + ;; + esac + fi +]) diff --git a/m4/proto.m4 b/m4/proto.m4 new file mode 100644 index 0000000..6c38419 --- /dev/null +++ b/m4/proto.m4 @@ -0,0 +1,33 @@ +dnl -*- Autoconf -*- +dnl Copyright (C) 1993-2017 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License as published by the Free Software Foundation; +dnl either version 2 of the License, or (at your option) any later version. +dnl As a special exception to the GNU General Public License, this file +dnl may be distributed as part of a program that contains a configuration +dnl script generated by Autoconf, under the same distribution terms as +dnl the rest of that program. + +dnl From Bruno Haible, Marcus Daniels, Sam Steingold. + +AC_PREREQ([2.13]) + +dnl CL_PROTO(IDENTIFIER, ACTION-IF-NOT-FOUND, FINAL-PROTOTYPE) +AC_DEFUN([CL_PROTO], +[ + AC_MSG_CHECKING([for $1 declaration]) + AC_CACHE_VAL([cl_cv_proto_$1], [$2 + cl_cv_proto_$1="$3"]) + cl_cv_proto_$1=`echo "[$]cl_cv_proto_$1" | tr -s ' ' | sed -e 's/( /(/'` + AC_MSG_RESULT([$]{ac_t:- + }[$][cl_cv_proto_$1]) +]) + +dnl CL_PROTO_RET(INCLUDES, DECL, CACHE-ID, TYPE-IF-OK, TYPE-IF-FAILS) +AC_DEFUN([CL_PROTO_RET], +[ + AC_TRY_COMPILE([$1] +AC_LANG_EXTERN +[$2 +], [], [$3="$4"], [$3="$5"]) +]) diff --git a/m4/shm.m4 b/m4/shm.m4 new file mode 100644 index 0000000..8a34b19 --- /dev/null +++ b/m4/shm.m4 @@ -0,0 +1,80 @@ +dnl -*- Autoconf -*- +dnl Copyright (C) 1993-2017 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License as published by the Free Software Foundation; +dnl either version 2 of the License, or (at your option) any later version. +dnl As a special exception to the GNU General Public License, this file +dnl may be distributed as part of a program that contains a configuration +dnl script generated by Autoconf, under the same distribution terms as +dnl the rest of that program. + +dnl From Bruno Haible, Marcus Daniels, Sam Steingold. + +AC_PREREQ([2.57]) + +AC_DEFUN([CL_SHM_H], +[ + AC_BEFORE([$0], [CL_SHM_RMID]) + AC_CHECK_HEADERS([sys/shm.h]) + if test $ac_cv_header_sys_shm_h = yes; then + AC_CHECK_HEADERS([sys/ipc.h]) + fi +]) + +AC_DEFUN([CL_SHM], +[ + AC_BEFORE([$0], [CL_SHM_RMID]) + AC_REQUIRE([CL_SHM_H]) + AC_REQUIRE([AC_CANONICAL_HOST]) + if test $ac_cv_header_sys_shm_h = yes -a "$ac_cv_header_sys_ipc_h" = yes; then + # This test is from Marcus Daniels + AC_CACHE_CHECK([for working shared memory], [cl_cv_sys_shm_works], + [AC_TRY_RUN( + [#include + #include + #include + #include + /* try attaching a single segment to multiple addresses */ + #define segsize 0x10000 + #define attaches 128 + #define base_addr 0x01000000 + int main () + { + int shmid; + int i; + char* addr; + char* result; + if ((shmid = shmget(IPC_PRIVATE,segsize,0400)) < 0) + exit(1); + for (i=0, addr = (char*)0x01000000; i and and shared memory works]) + AC_CHECK_HEADERS([sys/sysmacros.h]) + ;; + *) ;; + esac +]) diff --git a/m4/smallstruct.m4 b/m4/smallstruct.m4 new file mode 100644 index 0000000..48e2dc9 --- /dev/null +++ b/m4/smallstruct.m4 @@ -0,0 +1,66 @@ +dnl -*- Autoconf -*- +dnl Copyright (C) 1993-2017 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License as published by the Free Software Foundation; +dnl either version 2 of the License, or (at your option) any later version. +dnl As a special exception to the GNU General Public License, this file +dnl may be distributed as part of a program that contains a configuration +dnl script generated by Autoconf, under the same distribution terms as +dnl the rest of that program. + +dnl From Bruno Haible, Marcus Daniels, Sam Steingold. + +AC_PREREQ([2.13]) + +AC_DEFUN([SSR_DOC],[whether small structs are returned in registers]) +AC_DEFUN([FFCALL_SMALL_STRUCT_RETURN], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([gl_HOST_CPU_C_ABI]) + AC_CACHE_CHECK([SSR_DOC], [ffcall_cv_c_struct_return_small], + [AC_TRY_RUN(GL_NOCRASH + [typedef struct { long x; } foo; + long y; + foo foofun () { foo f; f.x = y; return f; } + long (*fun) () = (long (*) ()) foofun; + int main() + { nocrash_init(); + y = 37; if ((*fun)() != 37) return 1; + y = 55; if ((*fun)() != 55) return 1; + return 0; + } + ], + [ffcall_cv_c_struct_return_small=yes], + [ffcall_cv_c_struct_return_small=no], + [dnl When cross-compiling, guess depending on the ABI. + dnl If we don't know, don't assume anything. There are even weirder + dnl return value passing conventions than pcc. + case "$HOST_CPU_C_ABI" in + alpha) ffcall_cv_c_struct_return_small="guessing no" ;; + arm | armhf | arm64) ffcall_cv_c_struct_return_small="guessing yes" ;; + hppa | hppa64) ffcall_cv_c_struct_return_small="guessing yes" ;; + i386) + case "$host_os" in + cygwin* | darwin* | mingw*) ffcall_cv_c_struct_return_small="guessing yes" ;; + linux* | solaris*) ffcall_cv_c_struct_return_small="guessing no" ;; + *) ffcall_cv_c_struct_return_small="guessing no" ;; + esac + ;; + ia64) ffcall_cv_c_struct_return_small="guessing yes" ;; + mips | mipsn32) ffcall_cv_c_struct_return_small="guessing no" ;; + mips64) ffcall_cv_c_struct_return_small="guessing yes" ;; + powerpc | powerpc64) ffcall_cv_c_struct_return_small="guessing no" ;; + powerpc64-elfv2) ffcall_cv_c_struct_return_small="guessing yes" ;; + s390 | s390x) ffcall_cv_c_struct_return_small="guessing no" ;; + sparc) ffcall_cv_c_struct_return_small="guessing no" ;; + sparc64) ffcall_cv_c_struct_return_small="guessing yes" ;; + x86_64) ffcall_cv_c_struct_return_small="guessing yes" ;; + *) ffcall_cv_c_struct_return_small="guessing no" ;; + esac + ]) + ]) + case "$ffcall_cv_c_struct_return_small" in + *yes) AC_DEFINE([__SMALL_STRUCT_RETURN__], [], SSR_DOC) ;; + *no) ;; + esac +]) diff --git a/testcases.c b/testcases.c new file mode 100644 index 0000000..084693c --- /dev/null +++ b/testcases.c @@ -0,0 +1,807 @@ +/* + * Copyright 1993 Bill Triggs + * Copyright 1995-2019 Bruno Haible + * + * 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, see . + */ + +/* This file defines test functions of selected signatures, that exercise + dark corners of the various ABIs. */ + +#include + +FILE* out; + +#define uchar unsigned char +#define ushort unsigned short +#define uint unsigned int +#define ulong unsigned long + +typedef struct { char x; } Char; +typedef struct { short x; } Short; +typedef struct { int x; } Int; +typedef struct { long x; } Long; +typedef struct { float x; } Float; +typedef struct { double x; } Double; +typedef struct { char c; float f; } A; +typedef struct { double d; int i[3]; } B; +typedef struct { long l1; long l2; } J; +typedef struct { long l1; long l2; long l3; long l4; } K; +typedef struct { long l1; long l2; long l3; long l4; long l5; long l6; } L; +typedef struct { char x1; } Size1; +typedef struct { char x1; char x2; } Size2; +typedef struct { char x1; char x2; char x3; } Size3; +typedef struct { char x1; char x2; char x3; char x4; } Size4; +typedef struct { + char x1; char x2; char x3; char x4; char x5; char x6; char x7; +} Size7; +typedef struct { + char x1; char x2; char x3; char x4; char x5; char x6; char x7; char x8; +} Size8; +typedef struct { + char x1; char x2; char x3; char x4; char x5; char x6; char x7; char x8; + char x9; char x10; char x11; char x12; +} Size12; +typedef struct { + char x1; char x2; char x3; char x4; char x5; char x6; char x7; char x8; + char x9; char x10; char x11; char x12; char x13; char x14; char x15; +} Size15; +typedef struct { + char x1; char x2; char x3; char x4; char x5; char x6; char x7; char x8; + char x9; char x10; char x11; char x12; char x13; char x14; char x15; char x16; +} Size16; +typedef struct { char c[3]; } T; +typedef struct { char c[33],c1; } X; + +char c1='a', c2=127, c3=(char)128, c4=(char)255, c5=-1; +short s1=32767, s2=(short)32768, s3=3, s4=4, s5=5, s6=6, s7=7, s8=8, s9=9; +int i1=1, i2=2, i3=3, i4=4, i5=5, i6=6, i7=7, i8=8, i9=9, i10=11, i11=12, + i12=13, i13=14, i14=15, i15=16, i16=17, i17=18, i18=19, i19=20, i20=21, + i21=22, i22=23, i23=24, i24=25, i25=26, i26=27, i27=28, i28=29, i29=30, + i30=31, i31=32, i32=33; +long l1=1, l2=2, l3=3, l4=4, l5=5, l6=6, l7=7, l8=8, l9=9; +long long ll1 = 3875056143130689530LL; +float f1=0.1, f2=0.2, f3=0.3, f4=0.4, f5=0.5, f6=0.6, f7=0.7, f8=0.8, f9=0.9, + f10=1.1, f11=1.2, f12=1.3, f13=1.4, f14=1.5, f15=1.6, f16=1.7, f17=1.8, + f18=1.9, f19=2.1, f20=2.2, f21=2.3, f22=2.4, f23=2.5, f24=2.6; +double d1=0.1, d2=0.2, d3=0.3, d4=0.4, d5=0.5, d6=0.6, d7=0.7, d8=0.8, d9=0.9, + d10=1.1, d11=1.2, d12=1.3, d13=1.4, d14=1.5, d15=1.6, d16=1.7, d17=1.8; + +uchar uc1='a', uc2=127, uc3=128, uc4=255, uc5=(uchar)-1; +ushort us1=1, us2=2, us3=3, us4=4, us5=5, us6=6, us7=7, us8=8, us9=9; +uint ui1=1, ui2=2, ui3=3, ui4=4, ui5=5, ui6=6, ui7=7, ui8=8, ui9=9; +ulong ul1=1, ul2=2, ul3=3, ul4=4, ul5=5, ul6=6, ul7=7, ul8=8, ul9=9; + +char *str1="hello",str2[]="goodbye",*str3="still here?"; +Char C1={'A'}, C2={'B'}, C3={'C'}, C4={'\377'}, C5={(char)(-1)}; +Short S1={1}, S2={2}, S3={3}, S4={4}, S5={5}, S6={6}, S7={7}, S8={8}, S9={9}; +Int I1={1}, I2={2}, I3={3}, I4={4}, I5={5}, I6={6}, I7={7}, I8={8}, I9={9}; +Float F1={0.1}, F2={0.2}, F3={0.3}, F4={0.4}, F5={0.5}, F6={0.6}, F7={0.7}, F8={0.8}, F9={0.9}; +Double D1={0.1}, D2={0.2}, D3={0.3}, D4={0.4}, D5={0.5}, D6={0.6}, D7={0.7}, D8={0.8}, D9={0.9}; + +A A1={'a',0.1},A2={'b',0.2},A3={'\377',0.3}; +B B1={0.1,{1,2,3}},B2={0.2,{5,4,3}}; +J J1={47,11},J2={73,55}; +K K1={19,69,12,28}; +L L1={561,1105,1729,2465,2821,6601}; /* A002997 */ +Size1 Size1_1={'a'}; +Size2 Size2_1={'a','b'}; +Size3 Size3_1={'a','b','c'}; +Size4 Size4_1={'a','b','c','d'}; +Size7 Size7_1={'a','b','c','d','e','f','g'}; +Size8 Size8_1={'a','b','c','d','e','f','g','h'}; +Size12 Size12_1={'a','b','c','d','e','f','g','h','i','j','k','l'}; +Size15 Size15_1={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o'}; +Size16 Size16_1={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p'}; +T T1={'t','h','e'},T2={'f','o','x'}; +X X1={"abcdefghijklmnopqrstuvwxyzABCDEF",'G'}, X2={"123",'9'}, X3={"return-return-return",'R'}; + +/* void tests */ +void v_v (void) +{ + fprintf(out,"void f(void):\n"); + fflush(out); +} + +/* int tests */ +int i_v (void) +{ + int r=99; + fprintf(out,"int f(void):"); + fflush(out); + return r; +} +int i_i (int a) +{ + int r=a+1; + fprintf(out,"int f(int):(%d)",a); + fflush(out); + return r; +} +int i_i2 (int a, int b) +{ + int r=a+b; + fprintf(out,"int f(2*int):(%d,%d)",a,b); + fflush(out); + return r; +} +int i_i4 (int a, int b, int c, int d) +{ + int r=a+b+c+d; + fprintf(out,"int f(4*int):(%d,%d,%d,%d)",a,b,c,d); + fflush(out); + return r; +} +int i_i8 (int a, int b, int c, int d, int e, int f, int g, int h) +{ + int r=a+b+c+d+e+f+g+h; + fprintf(out,"int f(8*int):(%d,%d,%d,%d,%d,%d,%d,%d)",a,b,c,d,e,f,g,h); + fflush(out); + return r; +} +int i_i16 (int a, int b, int c, int d, int e, int f, int g, int h, + int i, int j, int k, int l, int m, int n, int o, int p) +{ + int r=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p; + fprintf(out,"int f(16*int):(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)", + a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p); + fflush(out); + return r; +} +int i_i32 (int a, int b, int c, int d, int e, int f, int g, int h, + int i, int j, int k, int l, int m, int n, int o, int p, + int aa, int ab, int ac, int ad, int ae, int af, int ag, int ah, + int ai, int aj, int ak, int al, int am, int an, int ao, int ap) +{ + int r=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+aa+ab+ac+ad+ae+af+ag+ah+ai+aj+ak+al+am+an+ao+ap; + fprintf(out,"int f(32*int):(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)", + a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an,ao,ap); + fflush(out); + return r; +} + +/* float tests */ +float f_f (float a) +{ + float r=a+1.0; + fprintf(out,"float f(float):(%g)",a); + fflush(out); + return r; +} +float f_f2 (float a, float b) +{ + float r=a+b; + fprintf(out,"float f(2*float):(%g,%g)",a,b); + fflush(out); + return r; +} +float f_f4 (float a, float b, float c, float d) +{ + float r=a+b+c+d; + fprintf(out,"float f(4*float):(%g,%g,%g,%g)",a,b,c,d); + fflush(out); + return r; +} +float f_f8 (float a, float b, float c, float d, float e, float f, + float g, float h) +{ + float r=a+b+c+d+e+f+g+h; + fprintf(out,"float f(8*float):(%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h); + fflush(out); + return r; +} +float f_f16 (float a, float b, float c, float d, float e, float f, float g, float h, + float i, float j, float k, float l, float m, float n, float o, float p) +{ + float r=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p; + fprintf(out,"float f(16*float):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p); + fflush(out); + return r; +} +float f_f24 (float a, float b, float c, float d, float e, float f, float g, float h, + float i, float j, float k, float l, float m, float n, float o, float p, + float q, float s, float t, float u, float v, float w, float x, float y) +{ + float r=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+s+t+u+v+w+x+y; + fprintf(out,"float f(24*float):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,s,t,u,v,w,x,y); + fflush(out); + return r; +} + +/* double tests */ +double d_d (double a) +{ + double r=a+1.0; + fprintf(out,"double f(double):(%g)",a); + fflush(out); + return r; +} +double d_d2 (double a, double b) +{ + double r=a+b; + fprintf(out,"double f(2*double):(%g,%g)",a,b); + fflush(out); + return r; +} +double d_d4 (double a, double b, double c, double d) +{ + double r=a+b+c+d; + fprintf(out,"double f(4*double):(%g,%g,%g,%g)",a,b,c,d); + fflush(out); + return r; +} +double d_d8 (double a, double b, double c, double d, double e, double f, + double g, double h) +{ + double r=a+b+c+d+e+f+g+h; + fprintf(out,"double f(8*double):(%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h); + fflush(out); + return r; +} +double d_d16 (double a, double b, double c, double d, double e, double f, + double g, double h, double i, double j, double k, double l, + double m, double n, double o, double p) +{ + double r=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p; + fprintf(out,"double f(16*double):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p); + fflush(out); + return r; +} + +/* pointer tests */ +void* vp_vpdpcpsp (void* a, double* b, char* c, Int* d) +{ + void* ret = (char*)b + 1; + fprintf(out,"void* f(void*,double*,char*,Int*):(0x%p,0x%p,0x%p,0x%p)",a,b,c,d); + fflush(out); + return ret; +} + +/* mixed number tests */ +uchar uc_ucsil (uchar a, ushort b, uint c, ulong d) +{ + uchar r = (uchar)-1; + fprintf(out,"uchar f(uchar,ushort,uint,ulong):(%u,%u,%u,%lu)",a,b,c,d); + fflush(out); + return r; +} +double d_iidd (int a, int b, double c, double d) +{ + double r = a+b+c+d; + fprintf(out,"double f(int,int,double,double):(%d,%d,%g,%g)",a,b,c,d); + fflush(out); + return r; +} +double d_iiidi (int a, int b, int c, double d, int e) +{ + double r = a+b+c+d+e; + fprintf(out,"double f(int,int,int,double,int):(%d,%d,%d,%g,%d)",a,b,c,d,e); + fflush(out); + return r; +} +double d_idid (int a, double b, int c, double d) +{ + double r = a+b+c+d; + fprintf(out,"double f(int,double,int,double):(%d,%g,%d,%g)",a,b,c,d); + fflush(out); + return r; +} +double d_fdi (float a, double b, int c) +{ + double r = a+b+c; + fprintf(out,"double f(float,double,int):(%g,%g,%d)",a,b,c); + fflush(out); + return r; +} +ushort us_cdcd (char a, double b, char c, double d) +{ + ushort r = (ushort)(a + b + c + d); + fprintf(out,"ushort f(char,double,char,double):('%c',%g,'%c',%g)",a,b,c,d); + fflush(out); + return r; +} + +long long ll_iiilli (int a, int b, int c, long long d, int e) +{ + long long r = (long long)(int)a+(long long)(int)b+(long long)(int)c+d+(long long)(int)e; + fprintf(out,"long long f(int,int,int,long long,int):(%d,%d,%d,0x%lx%08lx,%d)",a,b,c,(long)(d>>32),(long)(d&0xffffffff),e); + fflush(out); + return r; +} +long long ll_flli (float a, long long b, int c) +{ + long long r = (long long)(int)a + b + (long long)c; + fprintf(out,"long long f(float,long long,int):(%g,0x%lx%08lx,0x%lx)",a,(long)(b>>32),(long)(b&0xffffffff),(long)c); + fflush(out); + return r; +} + +float f_fi (float a, int z) +{ + float r = a+z; + fprintf(out,"float f(float,int):(%g,%d)",a,z); + fflush(out); + return r; +} +float f_f2i (float a, float b, int z) +{ + float r = a+b+z; + fprintf(out,"float f(2*float,int):(%g,%g,%d)",a,b,z); + fflush(out); + return r; +} +float f_f3i (float a, float b, float c, int z) +{ + float r = a+b+c+z; + fprintf(out,"float f(3*float,int):(%g,%g,%g,%d)",a,b,c,z); + fflush(out); + return r; +} +float f_f4i (float a, float b, float c, float d, int z) +{ + float r = a+b+c+d+z; + fprintf(out,"float f(4*float,int):(%g,%g,%g,%g,%d)",a,b,c,d,z); + fflush(out); + return r; +} +float f_f7i (float a, float b, float c, float d, float e, float f, float g, + int z) +{ + float r = a+b+c+d+e+f+g+z; + fprintf(out,"float f(7*float,int):(%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,z); + fflush(out); + return r; +} +float f_f8i (float a, float b, float c, float d, float e, float f, float g, + float h, int z) +{ + float r = a+b+c+d+e+f+g+h+z; + fprintf(out,"float f(8*float,int):(%g,%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,h,z); + fflush(out); + return r; +} +float f_f12i (float a, float b, float c, float d, float e, float f, float g, + float h, float i, float j, float k, float l, int z) +{ + float r = a+b+c+d+e+f+g+h+i+j+k+l+z; + fprintf(out,"float f(12*float,int):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,h,i,j,k,l,z); + fflush(out); + return r; +} +float f_f13i (float a, float b, float c, float d, float e, float f, float g, + float h, float i, float j, float k, float l, float m, int z) +{ + float r = a+b+c+d+e+f+g+h+i+j+k+l+m+z; + fprintf(out,"float f(13*float,int):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,h,i,j,k,l,m,z); + fflush(out); + return r; +} + +double d_di (double a, int z) +{ + double r = a+z; + fprintf(out,"double f(double,int):(%g,%d)",a,z); + fflush(out); + return r; +} +double d_d2i (double a, double b, int z) +{ + double r = a+b+z; + fprintf(out,"double f(2*double,int):(%g,%g,%d)",a,b,z); + fflush(out); + return r; +} +double d_d3i (double a, double b, double c, int z) +{ + double r = a+b+c+z; + fprintf(out,"double f(3*double,int):(%g,%g,%g,%d)",a,b,c,z); + fflush(out); + return r; +} +double d_d4i (double a, double b, double c, double d, int z) +{ + double r = a+b+c+d+z; + fprintf(out,"double f(4*double,int):(%g,%g,%g,%g,%d)",a,b,c,d,z); + fflush(out); + return r; +} +double d_d7i (double a, double b, double c, double d, double e, double f, + double g, int z) +{ + double r = a+b+c+d+e+f+g+z; + fprintf(out,"double f(7*double,int):(%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,z); + fflush(out); + return r; +} +double d_d8i (double a, double b, double c, double d, double e, double f, + double g, double h, int z) +{ + double r = a+b+c+d+e+f+g+h+z; + fprintf(out,"double f(8*double,int):(%g,%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,h,z); + fflush(out); + return r; +} +double d_d12i (double a, double b, double c, double d, double e, double f, + double g, double h, double i, double j, double k, double l, + int z) +{ + double r = a+b+c+d+e+f+g+h+i+j+k+l+z; + fprintf(out,"double f(12*double,int):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,h,i,j,k,l,z); + fflush(out); + return r; +} +double d_d13i (double a, double b, double c, double d, double e, double f, + double g, double h, double i, double j, double k, double l, + double m, int z) +{ + double r = a+b+c+d+e+f+g+h+i+j+k+l+m+z; + fprintf(out,"double f(13*double,int):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,h,i,j,k,l,m,z); + fflush(out); + return r; +} + +/* small structure return tests */ +Size1 S1_v (void) +{ + fprintf(out,"Size1 f(void):"); + fflush(out); + return Size1_1; +} +Size2 S2_v (void) +{ + fprintf(out,"Size2 f(void):"); + fflush(out); + return Size2_1; +} +Size3 S3_v (void) +{ + fprintf(out,"Size3 f(void):"); + fflush(out); + return Size3_1; +} +Size4 S4_v (void) +{ + fprintf(out,"Size4 f(void):"); + fflush(out); + return Size4_1; +} +Size7 S7_v (void) +{ + fprintf(out,"Size7 f(void):"); + fflush(out); + return Size7_1; +} +Size8 S8_v (void) +{ + fprintf(out,"Size8 f(void):"); + fflush(out); + return Size8_1; +} +Size12 S12_v (void) +{ + fprintf(out,"Size12 f(void):"); + fflush(out); + return Size12_1; +} +Size15 S15_v (void) +{ + fprintf(out,"Size15 f(void):"); + fflush(out); + return Size15_1; +} +Size16 S16_v (void) +{ + fprintf(out,"Size16 f(void):"); + fflush(out); + return Size16_1; +} + +/* structure tests */ +Int I_III (Int a, Int b, Int c) +{ + Int r; + r.x = a.x + b.x + c.x; + fprintf(out,"Int f(Int,Int,Int):({%d},{%d},{%d})",a.x,b.x,c.x); + fflush(out); + return r; +} +Char C_CdC (Char a, double b, Char c) +{ + Char r; + r.x = (a.x + c.x)/2; + fprintf(out,"Char f(Char,double,Char):({'%c'},%g,{'%c'})",a.x,b,c.x); + fflush(out); + return r; +} +Float F_Ffd (Float a, float b, double c) +{ + Float r; + r.x = a.x + b + c; + fprintf(out,"Float f(Float,float,double):({%g},%g,%g)",a.x,b,c); + fflush(out); + return r; +} +Double D_fDd (float a, Double b, double c) +{ + Double r; + r.x = a + b.x + c; + fprintf(out,"Double f(float,Double,double):(%g,{%g},%g)",a,b.x,c); + fflush(out); + return r; +} +Double D_Dfd (Double a, float b, double c) +{ + Double r; + r.x = a.x + b + c; + fprintf(out,"Double f(Double,float,double):({%g},%g,%g)",a.x,b,c); + fflush(out); + return r; +} +J J_JiJ (J a, int b, J c) +{ + J r; + r.l1 = a.l1+c.l1; r.l2 = a.l2+b+c.l2; + fprintf(out,"J f(J,int,J):({%ld,%ld},%d,{%ld,%ld})",a.l1,a.l2,b,c.l1,c.l2); + fflush(out); + return r; +} +T T_TcT (T a, char b, T c) +{ + T r; + r.c[0]='b'; r.c[1]=c.c[1]; r.c[2]=c.c[2]; + fprintf(out,"T f(T,char,T):({\"%c%c%c\"},'%c',{\"%c%c%c\"})",a.c[0],a.c[1],a.c[2],b,c.c[0],c.c[1],c.c[2]); + fflush(out); + return r; +} +X X_BcdB (B a, char b, double c, B d) +{ + static X xr={"return val",'R'}; + X r; + r = xr; + r.c1 = b; + fprintf(out,"X f(B,char,double,B):({%g,{%d,%d,%d}},'%c',%g,{%g,{%d,%d,%d}})", + a.d,a.i[0],a.i[1],a.i[2],b,c,d.d,d.i[0],d.i[1],d.i[2]); + fflush(out); + return r; +} + +/* Test for cases where some argument (especially structure, 'long long', or + 'double') may be passed partially in general-purpose argument registers + and partially on the stack. Different ABIs pass between 4 and 8 arguments + (or none) in general-purpose argument registers. */ + +long l_l0J (J b, long c) +{ + long r = b.l1 + b.l2 + c; + fprintf(out,"long f(J,long):(%ld,%ld,%ld)",b.l1,b.l2,c); + fflush(out); + return r; +} +long l_l1J (long a1, J b, long c) +{ + long r = a1 + b.l1 + b.l2 + c; + fprintf(out,"long f(long,J,long):(%ld,%ld,%ld,%ld)",a1,b.l1,b.l2,c); + fflush(out); + return r; +} +long l_l2J (long a1, long a2, J b, long c) +{ + long r = a1 + a2 + b.l1 + b.l2 + c; + fprintf(out,"long f(2*long,J,long):(%ld,%ld,%ld,%ld,%ld)",a1,a2,b.l1,b.l2,c); + fflush(out); + return r; +} +long l_l3J (long a1, long a2, long a3, J b, long c) +{ + long r = a1 + a2 + a3 + b.l1 + b.l2 + c; + fprintf(out,"long f(3*long,J,long):(%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,b.l1,b.l2,c); + fflush(out); + return r; +} +long l_l4J (long a1, long a2, long a3, long a4, J b, long c) +{ + long r = a1 + a2 + a3 + a4 + b.l1 + b.l2 + c; + fprintf(out,"long f(4*long,J,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,a4,b.l1,b.l2,c); + fflush(out); + return r; +} +long l_l5J (long a1, long a2, long a3, long a4, long a5, J b, long c) +{ + long r = a1 + a2 + a3 + a4 + a5 + b.l1 + b.l2 + c; + fprintf(out,"long f(5*long,J,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,a4,a5,b.l1,b.l2,c); + fflush(out); + return r; +} +long l_l6J (long a1, long a2, long a3, long a4, long a5, long a6, J b, long c) +{ + long r = a1 + a2 + a3 + a4 + a5 + a6 + b.l1 + b.l2 + c; + fprintf(out,"long f(6*long,J,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,a4,a5,a6,b.l1,b.l2,c); + fflush(out); + return r; +} +long l_l7J (long a1, long a2, long a3, long a4, long a5, long a6, long a7, J b, long c) +{ + long r = a1 + a2 + a3 + a4 + a5 + a6 + a7 + b.l1 + b.l2 + c; + fprintf(out,"long f(7*long,J,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,a4,a5,a6,a7,b.l1,b.l2,c); + fflush(out); + return r; +} +long l_l0K (K b, long c) +{ + long r = b.l1 + b.l2 + b.l3 + b.l4 + c; + fprintf(out,"long f(K,long):(%ld,%ld,%ld,%ld,%ld)",b.l1,b.l2,b.l3,b.l4,c); + fflush(out); + return r; +} +long l_l1K (long a1, K b, long c) +{ + long r = a1 + b.l1 + b.l2 + b.l3 + b.l4 + c; + fprintf(out,"long f(long,K,long):(%ld,%ld,%ld,%ld,%ld,%ld)",a1,b.l1,b.l2,b.l3,b.l4,c); + fflush(out); + return r; +} +long l_l2K (long a1, long a2, K b, long c) +{ + long r = a1 + a2 + b.l1 + b.l2 + b.l3 + b.l4 + c; + fprintf(out,"long f(2*long,K,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,b.l1,b.l2,b.l3,b.l4,c); + fflush(out); + return r; +} +long l_l3K (long a1, long a2, long a3, K b, long c) +{ + long r = a1 + a2 + a3 + b.l1 + b.l2 + b.l3 + b.l4 + c; + fprintf(out,"long f(3*long,K,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,b.l1,b.l2,b.l3,b.l4,c); + fflush(out); + return r; +} +long l_l4K (long a1, long a2, long a3, long a4, K b, long c) +{ + long r = a1 + a2 + a3 + a4 + b.l1 + b.l2 + b.l3 + b.l4 + c; + fprintf(out,"long f(4*long,K,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,a4,b.l1,b.l2,b.l3,b.l4,c); + fflush(out); + return r; +} +long l_l5K (long a1, long a2, long a3, long a4, long a5, K b, long c) +{ + long r = a1 + a2 + a3 + a4 + a5 + b.l1 + b.l2 + b.l3 + b.l4 + c; + fprintf(out,"long f(5*long,K,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,a4,a5,b.l1,b.l2,b.l3,b.l4,c); + fflush(out); + return r; +} +long l_l6K (long a1, long a2, long a3, long a4, long a5, long a6, K b, long c) +{ + long r = a1 + a2 + a3 + a4 + a5 + a6 + b.l1 + b.l2 + b.l3 + b.l4 + c; + fprintf(out,"long f(6*long,K,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,a4,a5,a6,b.l1,b.l2,b.l3,b.l4,c); + fflush(out); + return r; +} +/* These tests is crafted on the knowledge that for all known ABIs: + * 17 > number of floating-point argument registers, + * 3 < number of general-purpose argument registers < 3 + 6. */ +float f_f17l3L (float a, float b, float c, float d, float e, float f, float g, + float h, float i, float j, float k, float l, float m, float n, + float o, float p, float q, + long s, long t, long u, L z) +{ + float r = a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+s+t+u+z.l1+z.l2+z.l3+z.l4+z.l5+z.l6; + fprintf(out,"float f(17*float,3*int,L):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,s,t,u,z.l1,z.l2,z.l3,z.l4,z.l5,z.l6); + fflush(out); + return r; +} +double d_d17l3L (double a, double b, double c, double d, double e, double f, + double g, double h, double i, double j, double k, double l, + double m, double n, double o, double p, double q, + long s, long t, long u, L z) +{ + double r = a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+s+t+u+z.l1+z.l2+z.l3+z.l4+z.l5+z.l6; + fprintf(out,"double f(17*double,3*int,L):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,s,t,u,z.l1,z.l2,z.l3,z.l4,z.l5,z.l6); + fflush(out); + return r; +} + +long long ll_l2ll (long a1, long a2, long long b, long c) +{ + long long r = (long long) (a1 + a2) + b + c; + fprintf(out,"long long f(2*long,long long,long):(%ld,%ld,0x%lx%08lx,%ld)",a1,a2,(long)(b>>32),(long)(b&0xffffffff),c); + fflush(out); + return r; +} +long long ll_l3ll (long a1, long a2, long a3, long long b, long c) +{ + long long r = (long long) (a1 + a2 + a3) + b + c; + fprintf(out,"long long f(3*long,long long,long):(%ld,%ld,%ld,0x%lx%08lx,%ld)",a1,a2,a3,(long)(b>>32),(long)(b&0xffffffff),c); + fflush(out); + return r; +} +long long ll_l4ll (long a1, long a2, long a3, long a4, long long b, long c) +{ + long long r = (long long) (a1 + a2 + a3 + a4) + b + c; + fprintf(out,"long long f(4*long,long long,long):(%ld,%ld,%ld,%ld,0x%lx%08lx,%ld)",a1,a2,a3,a4,(long)(b>>32),(long)(b&0xffffffff),c); + fflush(out); + return r; +} +long long ll_l5ll (long a1, long a2, long a3, long a4, long a5, long long b, long c) +{ + long long r = (long long) (a1 + a2 + a3 + a4 + a5) + b + c; + fprintf(out,"long long f(5*long,long long,long):(%ld,%ld,%ld,%ld,%ld,0x%lx%08lx,%ld)",a1,a2,a3,a4,a5,(long)(b>>32),(long)(b&0xffffffff),c); + fflush(out); + return r; +} +long long ll_l6ll (long a1, long a2, long a3, long a4, long a5, long a6, long long b, long c) +{ + long long r = (long long) (a1 + a2 + a3 + a4 + a5 + a6) + b + c; + fprintf(out,"long long f(6*long,long long,long):(%ld,%ld,%ld,%ld,%ld,%ld,0x%lx%08lx,%ld)",a1,a2,a3,a4,a5,a6,(long)(b>>32),(long)(b&0xffffffff),c); + fflush(out); + return r; +} +long long ll_l7ll (long a1, long a2, long a3, long a4, long a5, long a6, long a7, long long b, long c) +{ + long long r = (long long) (a1 + a2 + a3 + a4 + a5 + a6 + a7) + b + c; + fprintf(out,"long long f(7*long,long long,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,0x%lx%08lx,%ld)",a1,a2,a3,a4,a5,a6,a7,(long)(b>>32),(long)(b&0xffffffff),c); + fflush(out); + return r; +} + +double d_l2d (long a1, long a2, double b, long c) +{ + double r = (double) (a1 + a2) + b + c; + fprintf(out,"double f(2*long,double,long):(%ld,%ld,%g,%ld)",a1,a2,b,c); + fflush(out); + return r; +} +double d_l3d (long a1, long a2, long a3, double b, long c) +{ + double r = (double) (a1 + a2 + a3) + b + c; + fprintf(out,"double f(3*long,double,long):(%ld,%ld,%ld,%g,%ld)",a1,a2,a3,b,c); + fflush(out); + return r; +} +double d_l4d (long a1, long a2, long a3, long a4, double b, long c) +{ + double r = (double) (a1 + a2 + a3 + a4) + b + c; + fprintf(out,"double f(4*long,double,long):(%ld,%ld,%ld,%ld,%g,%ld)",a1,a2,a3,a4,b,c); + fflush(out); + return r; +} +double d_l5d (long a1, long a2, long a3, long a4, long a5, double b, long c) +{ + double r = (double) (a1 + a2 + a3 + a4 + a5) + b + c; + fprintf(out,"double f(5*long,double,long):(%ld,%ld,%ld,%ld,%ld,%g,%ld)",a1,a2,a3,a4,a5,b,c); + fflush(out); + return r; +} +double d_l6d (long a1, long a2, long a3, long a4, long a5, long a6, double b, long c) +{ + double r = (double) (a1 + a2 + a3 + a4 + a5 + a6) + b + c; + fprintf(out,"double f(6*long,double,long):(%ld,%ld,%ld,%ld,%ld,%ld,%g,%ld)",a1,a2,a3,a4,a5,a6,b,c); + fflush(out); + return r; +} +double d_l7d (long a1, long a2, long a3, long a4, long a5, long a6, long a7, double b, long c) +{ + double r = (double) (a1 + a2 + a3 + a4 + a5 + a6 + a7) + b + c; + fprintf(out,"double f(7*long,double,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%g,%ld)",a1,a2,a3,a4,a5,a6,a7,b,c); + fflush(out); + return r; +} + +/* This function is used to verify that structs larger than 2 words are really + passed by value, not accidentally by reference. */ +void v_clobber_K (K k) +{ + k.l1 += 1; + k.l2 += 10; + k.l3 += 100; + k.l4 += 1000; +} diff --git a/trampoline/COPYING b/trampoline/COPYING new file mode 100644 index 0000000..a3d1815 --- /dev/null +++ b/trampoline/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, 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) + + 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/trampoline/Makefile.devel b/trampoline/Makefile.devel new file mode 100644 index 0000000..ec9e0ae --- /dev/null +++ b/trampoline/Makefile.devel @@ -0,0 +1,217 @@ +# This is the developer's -*-Makefile-*-, not the user's makefile. +# Do not use it unless you know exactly what you do! + +THISFILE = Makefile.devel +RM = rm -f + +# ============ Rules that require cross-compilation tools ============ + +GCC = gcc +GCCFLAGS = -O2 -fomit-frame-pointer -fPIC +CPP = $(GCC) -E +CROSS_TOOL = cross + +precompiled : \ + cache-sparc-macro.S cache-sparc64-macro.S \ + cache-alpha-macro.S \ + cache-hppa-macro.S cache-hppa64-macro.S \ + cache-powerpc-linux-macro.S cache-powerpc-macos.s \ + cache-powerpc64-elfv2-macro.S + + +cache-sparc-linux.s : cache-sparc.c $(THISFILE) + $(CROSS_TOOL) sparc-linux gcc -V 3.1 $(GCCFLAGS) -D__sparc__ -S cache-sparc.c -o cache-sparc-linux.s + +cache-sparc-macro.S : cache-sparc-linux.s ../common/asm-sparc.sh ../common/noexecstack.h $(THISFILE) + (echo '#include "asm-sparc.h"' ; ../common/asm-sparc.sh < cache-sparc-linux.s ; cat ../common/noexecstack.h) > cache-sparc-macro.S + +cache-sparc64-linux.s : cache-sparc.c $(THISFILE) + $(CROSS_TOOL) sparc64-linux gcc -V 4.0.2 $(GCCFLAGS) -D__sparc64__ -S cache-sparc.c -o cache-sparc64-linux.s + +cache-sparc64-macro.S : cache-sparc64-linux.s ../common/asm-sparc.sh ../common/noexecstack.h $(THISFILE) + (echo '#include "asm-sparc.h"' ; ../common/asm-sparc.sh < cache-sparc64-linux.s ; cat ../common/noexecstack.h) > cache-sparc64-macro.S + + +cache-alpha-linux.s : cache-alpha.c $(THISFILE) + $(CROSS_TOOL) alpha-linux gcc -V 4.0.2 $(GCCFLAGS) -D__alpha__ -S cache-alpha.c -o cache-alpha-linux.s + +cache-alpha-macro.S : cache-alpha-linux.s ../common/asm-alpha.sh ../common/noexecstack.h $(THISFILE) + (../common/asm-alpha.sh < cache-alpha-linux.s ; cat ../common/noexecstack.h) > cache-alpha-macro.S + + +cache-hppa-linux.s : cache-hppa.c $(THISFILE) + $(CROSS_TOOL) hppa-linux gcc -V 3.1 $(GCCFLAGS) -D__hppa__ -S cache-hppa.c -o cache-hppa-linux.s + +cache-hppa-macro.S : cache-hppa-linux.s ../common/asm-hppa.sh ../common/noexecstack.h $(THISFILE) + (echo '#include "asm-hppa.h"' ; ../common/asm-hppa.sh < cache-hppa-linux.s ; cat ../common/noexecstack.h) > cache-hppa-macro.S + + +cache-hppa64-linux.s : cache-hppa.c $(THISFILE) + $(CROSS_TOOL) hppa64-linux gcc -V 3.1 $(GCCFLAGS) -D__hppa64__ -S cache-hppa.c -o cache-hppa64-linux.s + +cache-hppa64-macro.S : cache-hppa64-linux.s ../common/asm-hppa64.sh ../common/noexecstack.h $(THISFILE) + (echo '#include "asm-hppa64.h"' ; ../common/asm-hppa64.sh < cache-hppa64-linux.s ; cat ../common/noexecstack.h) > cache-hppa64-macro.S + + +cache-powerpc-linux.s : cache-powerpc.c $(THISFILE) + $(CROSS_TOOL) powerpc-linux gcc -V 3.3.6 -mno-power -mno-power2 -mno-powerpc $(GCCFLAGS) -D__powerpc__ -S cache-powerpc.c -o cache-powerpc-linux.s + +cache-powerpc-linux-macro.S : cache-powerpc-linux.s ../common/asm-powerpc.sh ../common/noexecstack.h $(THISFILE) + (../common/asm-powerpc.sh < cache-powerpc-linux.s ; cat ../common/noexecstack.h) > cache-powerpc-linux-macro.S + +cache-powerpc-macos.s : cache-powerpc.c $(THISFILE) + $(CROSS_TOOL) powerpc-darwin gcc -V 3.3.6 $(GCCFLAGS) -D__powerpc__ -S cache-powerpc.c -o cache-powerpc-macos.s + + +cache-powerpc64-elfv2-linux.s : cache-powerpc64.c $(THISFILE) + $(CROSS_TOOL) powerpc64le-linux gcc-5.4.0 -mabi=elfv2 -mcpu=power4 -mlittle-endian $(GCCFLAGS) -D__powerpc64__ -S cache-powerpc64.c -o cache-powerpc64-elfv2-linux-le.s + $(CROSS_TOOL) powerpc64le-linux gcc-5.4.0 -mabi=elfv2 -mcpu=power4 -mbig-endian $(GCCFLAGS) -D__powerpc64__ -S cache-powerpc64.c -o cache-powerpc64-elfv2-linux-be.s + cmp cache-powerpc64-elfv2-linux-le.s cache-powerpc64-elfv2-linux-be.s > /dev/null + mv cache-powerpc64-elfv2-linux-le.s cache-powerpc64-elfv2-linux.s + $(RM) cache-powerpc64-elfv2-linux-be.s + +cache-powerpc64-elfv2-macro.S : cache-powerpc64-elfv2-linux.s ../common/asm-powerpc.sh ../common/noexecstack.h $(THISFILE) + (../common/asm-powerpc.sh < cache-powerpc64-elfv2-linux.s ; cat ../common/noexecstack.h) > cache-powerpc64-elfv2-macro.S + + +# --------------- Older rules --------------- + +OLDGCCFLAGS = -O2 -fomit-frame-pointer +ASPREFIX = /usr1/gnu/lib + +proto-precompiled : proto-i386.s proto-m68k.s proto-mips.s proto-mipsn32.s proto-mips64.s proto-sparc.s proto-sparc64.s proto-alpha.s proto-hppa.s proto-hppa64.s proto-arm.s proto-arm64.s proto-powerpc-aix.s proto-powerpc-sysv4.s proto-powerpc-macos.s proto-powerpc64-aix.s proto-powerpc64-elfv2.s proto-ia64.s proto-x86_64.s proto-x86_64-x32.s proto-s390.s proto-s390x.s proto-riscv32.s proto-riscv64.s + +proto-i386.s : proto.c + $(GCC) -V 2.7.2 -b i486-linuxaout $(OLDGCCFLAGS) -D__i386__ -S proto.c -o $@ + +proto-m68k.s : proto.c + $(GCC) -V egcs-2.91.57 -b m68k-sun $(OLDGCCFLAGS) -D__m68k__ -S proto.c -o $@ + +proto-mips.s : proto.c + $(GCC) -V 2.95.2 -b mips-sgi $(OLDGCCFLAGS) -D__mips__ -S proto.c -o $@ -mabicalls + +proto-mipsn32.s : proto.c + $(GCC) -V 2.95.2 -b mips-sgi-irix6 $(OLDGCCFLAGS) -D__mipsn32__ -S proto.c -o $@ -mabicalls + +proto-mips64.s : proto64.c + $(GCC) -V 2.95.2 -b mips-sgi -mips3 -mlong64 $(OLDGCCFLAGS) -D__mips64__ -S proto64.c -o $@ -mabicalls + +proto-sparc.s : proto.c + $(GCC) -V 2.95.2 -b sparc-sun $(OLDGCCFLAGS) -D__sparc__ -S proto.c -o $@ + +proto-sparc64.s : proto64.c + sparc64-linux-gcc -V 2.95.2 -b sparc64-linux $(OLDGCCFLAGS) -D__sparc64__ -S proto64.c -o $@ + +proto-alpha.s : proto64.c + $(GCC) -V 2.7.2 -b alpha-dec-osf $(OLDGCCFLAGS) -D__alpha__ -S proto64.c -o $@ + +proto-hppa.s : proto.c + $(GCC) -V 2.6.3 -b hppa1.0-hpux $(OLDGCCFLAGS) -D__hppa__ -S proto.c -o $@ + +proto-hppa64.s : proto64.c + $(CROSS_TOOL) hppa64-linux gcc -V 3.1 $(OLDGCCFLAGS) -D__hppa64__ -S proto64.c -o $@ + +proto-arm.s : proto.c + $(GCC) -V 2.6.3 -b arm-acorn-riscix $(OLDGCCFLAGS) -D__arm__ -S proto.c -o $@ + +proto-arm64.s : proto64.c + $(CROSS_TOOL) aarch64-linux gcc-5.4.0 $(OLDGCCFLAGS) -D__arm64__ -S proto64.c -o $@ + +proto-powerpc-aix.s : proto.c + $(GCC) -V 2.95.2 -b rs6000 -mno-power -mno-power2 -mno-powerpc -mnew-mnemonics $(OLDGCCFLAGS) -D__powerpc__ -S proto.c -o $@ + +proto-powerpc-sysv4.s : proto.c + $(GCC) -V 2.95.2 -b ppc-linux -mno-power -mno-power2 -mno-powerpc $(OLDGCCFLAGS) -D__powerpc__ -S proto.c -o $@ + +proto-powerpc-macos.s : proto.c + $(GCC) -V 3.3.2 -b powerpc-darwin $(OLDGCCFLAGS) -D__powerpc__ -S proto.c -o $@ + +proto-powerpc64-aix.s : proto64.c + $(CROSS_TOOL) powerpc64-linux gcc $(OLDGCCFLAGS) -D__powerpc64__ -S proto64.c -o $@ + +proto-powerpc64-elfv2.s : proto64.c + $(CROSS_TOOL) powerpc64le-linux gcc -mabi=elfv2 $(OLDGCCFLAGS) -D__powerpc64__ -S proto64.c -o $@ + +proto-ia64.s : proto64.c + $(GCC) -V 2.9-ia64-000216 -b ia64-hp-linux $(OLDGCCFLAGS) -D__ia64__ -S proto64.c -o $@ + +proto-x86_64.s : proto64.c + $(GCC) -V 3.2.2 -b x86_64-suse-linux $(OLDGCCFLAGS) -D__x86_64__ -S proto64.c -o $@ + +proto-x86_64-x32.s : proto.c + $(CROSS_TOOL) x86_64-linux gcc-5.4.0 -mx32 $(OLDGCCFLAGS) -fno-asynchronous-unwind-tables -D__x86_64__ -D__x86_64_x32__ -S proto.c -o $@ + +proto-s390.s : proto.c + $(CROSS_TOOL) s390-linux gcc -V 3.1 $(OLDGCCFLAGS) -D__s390__ -S proto.c -o $@ + +proto-s390x.s : proto64.c + $(CROSS_TOOL) s390x-linux gcc-5.4.0 $(OLDGCCFLAGS) -D__s390x__ -S proto64.c -o $@ + +proto-riscv32.s : proto.c + $(CROSS_TOOL) riscv32-linux gcc-7.3.0 $(OLDGCCFLAGS) -D__riscv32__ -S proto.c -o $@ + +proto-riscv64.s : proto64.c + $(CROSS_TOOL) riscv64-linux gcc-7.3.0 $(OLDGCCFLAGS) -D__riscv64__ -S proto64.c -o $@ + +tramp-i386.o : tramp-i386.s + $(ASPREFIX)/i486-linux/bin/as tramp-i386.s -o $@ + +tramp-m68k.o : tramp-m68k.s + $(ASPREFIX)/m68k-sun/bin/as tramp-m68k.s -o $@ + +tramp-mips.o : tramp-mips.s + $(ASPREFIX)/mips-sgi/bin/as tramp-mips.s -o $@ + +tramp-mips64.o : tramp-mips64.s + $(ASPREFIX)/mips-sgi/bin/as -mips3 -membedded-pic tramp-mips64.s -o $@ + +tramp-sparc.o : tramp-sparc.s + $(ASPREFIX)/sparc-sun/bin/as tramp-sparc.s -o $@ + +tramp-sparc64.o : tramp-sparc64.s + $(ASPREFIX)/sparc64-linux/bin/as tramp-sparc64.s -o $@ + +tramp-alpha.o : tramp-alpha.s + $(ASPREFIX)/alpha-dec-osf/bin/as tramp-alpha.s -o $@ + +tramp-hppa.o : tramp-hppa.s + $(ASPREFIX)/hppa1.0-hpux/bin/as tramp-hppa.s -o $@ + +tramp-hppa64.o : tramp-hppa64.s + $(CROSS_TOOL) hppa64-linux as tramp-hppa64.s -o $@ + +tramp-arm.o : tramp-arm.s + $(ASPREFIX)/arm-acorn-riscix/bin/as tramp-arm.s -o $@ + +tramp-arm64.o : tramp-arm64.s + $(CROSS_TOOL) aarch64-linux as tramp-arm64.s -o $@ + +tramp-powerpc-old.o : tramp-powerpc-old.s + $(ASPREFIX)/rs6000/bin/as tramp-powerpc-old.s -o $@ + +tramp-powerpc-sysv4.o : tramp-powerpc-sysv4.s + $(ASPREFIX)/ppc-linux/bin/as tramp-powerpc-sysv4.s -o $@ + +tramp-powerpc64-elfv2.o : tramp-powerpc64-elfv2.s + $(CROSS_TOOL) powerpc64le-linux as tramp-powerpc64-elfv2.s -o $@ + +tramp-ia64.o : tramp-ia64.s + /nue/usr/ia64-hp-linux/bin/as tramp-ia64.s -o $@ + +tramp-x86_64.o : tramp-x86_64.s + $(ASPREFIX)/x86_64-suse-linux/bin/as tramp-x86_64.s -o $@ + +tramp-x86_64-x32.o : tramp-x86_64-x32.s + $(CROSS_TOOL) x86_64-linux as tramp-x86_64-x32.s -o $@ + +tramp-s390.o : tramp-s390.s + $(CROSS_TOOL) s390-linux as tramp-s390.s -o $@ + +tramp-s390x.o : tramp-s390x.s + $(CROSS_TOOL) s390x-linux as tramp-s390x.s -o $@ + +tramp-riscv32.o : tramp-riscv32.s + $(CROSS_TOOL) riscv32-linux as tramp-riscv32.s -o $@ + +tramp-riscv64.o : tramp-riscv64.s + $(CROSS_TOOL) riscv64-linux as tramp-riscv64.s -o $@ diff --git a/trampoline/Makefile.in b/trampoline/Makefile.in new file mode 100644 index 0000000..529f977 --- /dev/null +++ b/trampoline/Makefile.in @@ -0,0 +1,272 @@ +# Makefile for trampoline + +#### Start of system configuration section. #### + +HOST = @host@ +CPU = @HOST_CPU_C_ABI@ +OS = @host_os@ + +# Directories used by "make": +srcdir = @srcdir@ + +# Directories used by "make install": +prefix = @prefix@ +local_prefix = /usr/local +exec_prefix = @exec_prefix@ +libdir = @libdir@ +includedir = @includedir@ +mandir = @mandir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +htmldir = $(datadir)/html + +# Programs used by "make": +# C compiler +CC = @CC@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +# C++ compiler +CXX = @CXX@ +CXXFLAGS = @CXXFLAGS@ +# Both C and C++ compiler +CPPFLAGS = @CPPFLAGS@ +INCLUDES = -I. -I$(srcdir) -I.. +INCLUDES_WITH_GNULIB = $(INCLUDES) -I../gnulib-lib -I$(srcdir)/../gnulib-lib +ASPFLAGS = `if test @AS_UNDERSCORE@ = true; then echo '-DASM_UNDERSCORE'; fi` +LDFLAGS = @LDFLAGS@ +LIBTOOL = @LIBTOOL@ +LIBTOOL_COMPILE = $(LIBTOOL) --mode=compile +LIBTOOL_LINK = $(LIBTOOL) --mode=link +LIBTOOL_INSTALL = $(LIBTOOL) --mode=install +LIBTOOL_UNINSTALL = $(LIBTOOL) --mode=uninstall +AR = @AR@ +AR_FLAGS = rc +RANLIB = @RANLIB@ +RM = rm -f +@SET_MAKE@ + +# Programs used by "make install": +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ + +# Libtool options for linking with the thread library. +LTLIBTHREAD = @LTLIBTHREAD@ + +#### End of system configuration section. #### + +SHELL = /bin/sh + +# Needed by $(LIBTOOL). +top_builddir = .. + +OBJECTS = trampoline.lo @CPU_OBJECTS@ + +# Limit the set of exported symbols, on those platforms where libtool supports it. +# Currently this excludes the symbols from gnulib modules. +LIBTRAMPOLINE_EXPORTED_SYMBOLS_REGEX = 'trampoline' + +# Before making a release, change this according to the libtool documentation, +# section "Library interface versions". +LIBTRAMPOLINE_VERSION_INFO = 1:2:0 + +all : $(OBJECTS) libtrampoline.la $(srcdir)/trampoline.3 $(srcdir)/trampoline.html + +trampoline.lo : $(srcdir)/trampoline.c $(srcdir)/trampoline.h + $(LIBTOOL_COMPILE) $(CC) $(INCLUDES_WITH_GNULIB) $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/trampoline.c + +tramp-hppa.lo : tramp-hppa.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c tramp-hppa.s + +tramp-hppa.s : $(srcdir)/tramp-hppa-macro.S $(srcdir)/../common/noexecstack.h + $(CPP) $(ASPFLAGS) -I$(srcdir)/../common $(srcdir)/tramp-hppa-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e "s,!,',g" > tramp-hppa.s + +tramp-hppa64.lo : tramp-hppa64.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c tramp-hppa64.s + +tramp-hppa64.s : $(srcdir)/tramp-hppa64-macro.S $(srcdir)/../common/noexecstack.h + $(CPP) $(ASPFLAGS) -I$(srcdir)/../common $(srcdir)/tramp-hppa64-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e "s,!,',g" > tramp-hppa64.s + +tramp-powerpc.lo : tramp-powerpc.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c tramp-powerpc.s + +tramp-powerpc.s : $(srcdir)/tramp-powerpc-aix.S + $(CPP) $(srcdir)/tramp-powerpc-aix.S > tramp-powerpc.s + +tramp-powerpc64.lo : tramp-powerpc64.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c tramp-powerpc64.s + +tramp-powerpc64.s : $(srcdir)/tramp-powerpc64-aix.S $(srcdir)/../common/noexecstack.h + $(CPP) -I$(srcdir)/../common $(srcdir)/tramp-powerpc64-aix.S > tramp-powerpc64.s + +tramp-ia64.lo : tramp-ia64.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c tramp-ia64.s + +tramp-ia64.s : $(srcdir)/tramp-ia64-macro.S $(srcdir)/../common/noexecstack.h + $(CPP) $(ASPFLAGS) -I$(srcdir)/../common $(srcdir)/tramp-ia64-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > tramp-ia64.s + +cache-sparc.lo : cache-sparc.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c cache-sparc.s + +cache-sparc.s : $(srcdir)/cache-sparc-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../common - < $(srcdir)/cache-sparc-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,\. ,.,g' -e 's,//.*$$,,' -e 's,\$$,#,g' -e 's,# ,#,g' > cache-sparc.s + +cache-sparc64.lo : cache-sparc64.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c cache-sparc64.s + +cache-sparc64.s : $(srcdir)/cache-sparc64-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../common - < $(srcdir)/cache-sparc64-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,\. ,.,g' -e 's,//.*$$,,' -e 's,\$$,#,g' -e 's,# ,#,g' > cache-sparc64.s + +cache-alpha.lo : cache-alpha.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c cache-alpha.s + +cache-alpha.s : $(srcdir)/cache-alpha-macro.S + $(CPP) $(ASPFLAGS) $(srcdir)/cache-alpha-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > cache-alpha.s + +cache-hppa.lo : cache-hppa.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c cache-hppa.s + +cache-hppa.s : $(srcdir)/cache-hppa-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../common $(srcdir)/cache-hppa-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e "s,!,',g" > cache-hppa.s + +cache-hppa64.lo : cache-hppa64.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c cache-hppa64.s + +cache-hppa64.s : $(srcdir)/cache-hppa64-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../common $(srcdir)/cache-hppa64-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e "s,!,',g" > cache-hppa64.s + +cache-powerpc.lo : cache-powerpc.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c cache-powerpc.s + +cache-powerpc.s : $(srcdir)/cache-powerpc-linux-macro.S $(srcdir)/cache-powerpc-macos.s + case "$(OS)" in \ + macos* | darwin*) syntax=macos;; \ + *) syntax=linux;; \ + esac; \ + case $${syntax} in \ + macos) \ + grep -v '\.machine' $(srcdir)/cache-powerpc-$${syntax}.s > cache-powerpc.s || exit 1 ;; \ + linux) \ + $(CPP) $(ASPFLAGS) $(srcdir)/cache-powerpc-$${syntax}-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > cache-powerpc.s || exit 1 ;; \ + *) \ + cp $(srcdir)/cache-powerpc-$${syntax}.s cache-powerpc.s || exit 1 ;; \ + esac + +cache-powerpc64-elfv2.lo : cache-powerpc64-elfv2.s + $(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c cache-powerpc64-elfv2.s + +cache-powerpc64-elfv2.s : $(srcdir)/cache-powerpc64-elfv2-macro.S + $(CPP) $(ASPFLAGS) $(srcdir)/cache-powerpc64-elfv2-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > cache-powerpc64-elfv2.s + +libtrampoline.la : $(OBJECTS) ../gnulib-lib/libgnu.la + $(LIBTOOL_LINK) $(CC) -o libtrampoline.la -rpath $(libdir) -no-undefined -export-symbols-regex $(LIBTRAMPOLINE_EXPORTED_SYMBOLS_REGEX) -version-info $(LIBTRAMPOLINE_VERSION_INFO) $(OBJECTS) ../gnulib-lib/libgnu.la $(LDFLAGS) $(LTLIBTHREAD) + +install : all force + mkdir -p $(DESTDIR)$(prefix) + mkdir -p $(DESTDIR)$(exec_prefix) + mkdir -p $(DESTDIR)$(libdir) + $(LIBTOOL_INSTALL) $(INSTALL_DATA) libtrampoline.la $(DESTDIR)$(libdir)/libtrampoline.la + mkdir -p $(DESTDIR)$(includedir) + $(INSTALL_DATA) $(srcdir)/trampoline.h $(DESTDIR)$(includedir)/trampoline.h + mkdir -p $(DESTDIR)$(mandir) + mkdir -p $(DESTDIR)$(mandir)/man3 + $(INSTALL_DATA) $(srcdir)/trampoline.3 $(DESTDIR)$(mandir)/man3/trampoline.3 + mkdir -p $(DESTDIR)$(datadir) + mkdir -p $(DESTDIR)$(htmldir) + $(INSTALL_DATA) $(srcdir)/trampoline.html $(DESTDIR)$(htmldir)/trampoline.html + +installdirs : force + mkdir -p $(DESTDIR)$(prefix) + mkdir -p $(DESTDIR)$(exec_prefix) + mkdir -p $(DESTDIR)$(libdir) + mkdir -p $(DESTDIR)$(includedir) + mkdir -p $(DESTDIR)$(mandir) + mkdir -p $(DESTDIR)$(mandir)/man3 + mkdir -p $(DESTDIR)$(datadir) + mkdir -p $(DESTDIR)$(htmldir) + +uninstall : force + $(LIBTOOL_UNINSTALL) $(RM) $(DESTDIR)$(libdir)/libtrampoline.la + $(RM) $(DESTDIR)$(includedir)/trampoline.h + $(RM) $(DESTDIR)$(mandir)/man3/trampoline.3 + $(RM) $(DESTDIR)$(htmldir)/trampoline.html + +test1.@OBJEXT@ : $(srcdir)/test1.c $(srcdir)/trampoline.h + $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/test1.c + +test1 : test1.@OBJEXT@ libtrampoline.la + $(LIBTOOL_LINK) $(CC) $(CFLAGS) @GCC_X_NONE@ test1.@OBJEXT@ libtrampoline.la $(LDFLAGS) -o test1 + +test2.@OBJEXT@ : $(srcdir)/test2.c $(srcdir)/trampoline.h + $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/test2.c + +test2 : test2.@OBJEXT@ libtrampoline.la + $(LIBTOOL_LINK) $(CC) $(CFLAGS) @GCC_X_NONE@ test2.@OBJEXT@ libtrampoline.la $(LDFLAGS) -o test2 + +test2-c++.@OBJEXT@ : $(srcdir)/test2-c++.cc $(srcdir)/test2.c $(srcdir)/trampoline.h + $(CXX) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS) -c $(srcdir)/test2-c++.cc + +test2-c++ : test2-c++.@OBJEXT@ libtrampoline.la + $(LIBTOOL_LINK) $(CXX) $(CXXFLAGS) @GCC_X_NONE@ test2-c++.@OBJEXT@ libtrampoline.la $(LDFLAGS) -o test2-c++ + +check1 : all test1 + ./test1 + +check : all test1 test2 + ./test1 + ./test2 +@IF_CXX@ ./test2-c++ + touch tests.passed.$(HOST) +@IF_CXX@check : test2-c++ + +extracheck : check + +mostlyclean : clean + +clean : force + $(RM) $(OBJECTS) `echo $(OBJECTS) | sed -e 's/\.lo/.@OBJEXT@/g'` tramp-hppa.s tramp-hppa64.s tramp-powerpc.s tramp-powerpc64.s tramp-ia64.s cache-sparc.s cache-sparc64.s cache-alpha.s cache-hppa.s cache-hppa64.s cache-powerpc.s cache-powerpc64-elfv2.s libtrampoline.* core + $(RM) -r .libs _libs + $(RM) test1.@OBJEXT@ test1 test2.@OBJEXT@ test2 test2-c++.@OBJEXT@ test2-c++ + +distclean : clean + $(RM) Makefile tests.passed.* + +maintainer-clean : distclean + + +# List of source files (committed in version control or generated by Makefile.devel). +SOURCE_FILES = \ + COPYING \ + PLATFORMS PORTING README trampoline.3 trampoline.html \ + Makefile.devel \ + Makefile.maint \ + Makefile.in \ + trampoline.h \ + trampoline.c \ + tramp-hppa-macro.S \ + tramp-hppa64-macro.S \ + tramp-powerpc-aix.S \ + tramp-powerpc64-aix.S \ + tramp-ia64-macro.S \ + cache.c \ + cache-alpha.c cache-alpha-linux.s cache-alpha-macro.S \ + cache-hppa.c cache-hppa-linux.s cache-hppa-macro.S cache-hppa64-linux.s cache-hppa64-macro.S \ + cache-powerpc.c cache-powerpc-linux.s cache-powerpc-linux-macro.S cache-powerpc-macos.s \ + cache-powerpc64.c cache-powerpc64-elfv2-linux.s cache-powerpc64-elfv2-macro.S \ + cache-sparc.c cache-sparc-linux.s cache-sparc-macro.S cache-sparc64-linux.s cache-sparc64-macro.S \ + test1.c \ + test2.c test2-c++.cc +# List of distributed files generated by Makefile.maint. +GENERATED_FILES = \ + trampoline.man +# List of distributed files. +DISTFILES = $(SOURCE_FILES) $(GENERATED_FILES) + +distdir : $(DISTFILES) + for file in $(DISTFILES); do \ + if test -f $$file; then dir='.'; else dir='$(srcdir)'; fi; \ + cp -p "$$dir/$$file" '$(distdir)'/$$file || exit 1; \ + done + + +force : diff --git a/trampoline/Makefile.maint b/trampoline/Makefile.maint new file mode 100644 index 0000000..7356d20 --- /dev/null +++ b/trampoline/Makefile.maint @@ -0,0 +1,18 @@ +# maintainer -*-Makefile-*- + +RM = rm -f + +# ==================== Easily regeneratable files ==================== + +ROFF_MAN = groff -Tutf8 -mandoc + +all : trampoline.man + +trampoline.man : trampoline.3 + $(ROFF_MAN) trampoline.3 > trampoline.man + +totally-clean : force + $(RM) trampoline.man + + +force : diff --git a/trampoline/PLATFORMS b/trampoline/PLATFORMS new file mode 100644 index 0000000..c4108d4 --- /dev/null +++ b/trampoline/PLATFORMS @@ -0,0 +1,40 @@ +Supported CPUs: (Put the GNU config.guess values here.) + i386 i486-unknown-linux, i686-unknown-gnu0.9, i386-unknown-sysv4.0, + i386-pc-solaris2.6, i386-pc-solaris2.10, + i486-unknown-sco3.2v4.2, i386-pc-cygwin32, i386-w64-mingw32, + i586-unknown-freebsd11.0, i386-unknown-dragonfly3.8, + i386-unknown-netbsdelf7.0, i386-unknown-openbsd6.0, + i586-pc-haiku, i386-pc-minix + m68k m68k-next-bsd, m68k-next-nextstep3, m68k-sun-sunos4.0, + m68k-unknown-linux + mips mips-sgi-irix4.0.5, mips-sgi-irix5.2, mips-sgi-irix5.3, + mips-sgi-irix6.2, mips-sgi-irix6.4, mips-sgi-irix6.5, + mips-unknown-linux, mips64-unknown-linux + sparc sparc-sun-sunos4.1.1, sparc-sun-solaris2.3, + sparc-sun-solaris2.4, sparc-sun-solaris2.10, + sparc64-sun-solaris2.10, sparc-unknown-linux, + sparc64-unknown-linux, + sparc-unknown-netbsdelf7.1, sparc64-unknown-netbsd8.0 + alpha alpha-dec-osf3.0, alpha-dec-osf4.0, alphaev67-unknown-linux + hppa hppa1.0-hp-hpux8.00, hppa1.1-hp-hpux9.05, hppa1.1-hp-hpux10.01, + hppa2.0-hp-hpux10.20, hppa2.0w-hp-hpux11.31, hppa-unknown-linux + hppa64 hppa64-hp-hpux11.31 + arm armv5tejl-unknown-linux, armv6l-unknown-linux, + armv7l-unknown-linux + arm64 aarch64-unknown-linux + powerpc powerpc-ibm-aix4.1.4.0, powerpc-ibm-aix7.1.3.0, + powerpc-unknown-linux, powerpc-apple-darwin6.8, + powerpc-apple-darwin9.8.0 + powerpc64 powerpc-ibm-aix7.1.3.0 (gcc -maix64, xlc -q64; AR="ar -X 64"), + powerpc64-unknown-linux (gcc -m64), + powerpc64le-unknown-linux (gcc) + ia64 ia64-unknown-linux + x86_64 x86_64-suse-linux, x86_64-unknown-linux (gcc -mx32), + x86_64-pc-solaris2.10, x86_64-pc-cygwin, x86_64-w64-mingw32, + x86_64-unknown-freebsd11.0, x86_64-unknown-netbsd7.0, + x86_64-unknown-openbsd6.0 + s390 s390x-ibm-linux + s390x s390x-ibm-linux + riscv32 riscv32-unknown-linux + riscv64 riscv64-unknown-linux + diff --git a/trampoline/PORTING b/trampoline/PORTING new file mode 100644 index 0000000..46b6042 --- /dev/null +++ b/trampoline/PORTING @@ -0,0 +1,95 @@ +The list of CPUs and platforms TRAMPOLINE has been ported to can be found +at the top of file trampoline.c. + +To port TRAMPOLINE to a new platform, three issues may have to be resolved: +A. a new CPU - how to build the trampoline? +B. a new OS - how to make code in malloc'ed memory executable? +C. a new CPU or OS - how to flush the instruction cache? + + +A. a new CPU - how to build the trampoline? + + The trampoline is a short sequence of machine instructions which puts + the constant into , then jumps to

. The only + registers that are allowed to be modified are call-used registers. No + stack manipulations are allowed since the trampoline has to pass its + arguments along to the function at
. + + 1. To find out which instructions are available for "move"/"store" and + "jump", compile proto.c for your CPU: + + make -f Makefile.devel proto-${CPU}.s + or + gcc -O2 -fomit-frame-pointer -S proto.c -o proto-${CPU}.s + + 2. Write down the instructions for the trampoline in a file tramp-${CPU}.s, + using constants for , ,
. Assemble it: + + gcc -c tramp-${CPU}.s + + Verify that the jump actually goes to
. (Beware: Some CPUs have + program-counter relative jumps.) + + gdb tramp-${CPU}.o + disassemble tramp + + 3. Take a hex dump of tramp-${CPU}.o + + hexdump -e '"%06.6_ax " 16/1 " %02X" "\n"' < tramp-${CPU}.o + or + od -tx1 -Ax < tramp-${CPU}.o + or + od -x +x < tramp-${CPU}.o + + Look out for the magic numbers you used for , and +
. + + 4. Write the code which builds up a trampoline in memory, in trampoline.c. + + 5. Try it: + + make + make check1 + + 6. Write the is_tramp() macro and the tramp_xxx() accessor macros + in trampoline.c. + + 7. Try it: + + make + make check + + +B. a new OS - how to make code in malloc'ed memory executable? + + ‘configure’ will find out whether code stored in malloc'ed memory is + executable, or whether virtual memory protections have to be set in order + to allow this. (The test is pretty simple: it copies a small function + to malloc'ed memory and tries to executed it. The test could also fail + because the compiler produced non-position-independent code or because + of alignment issues.) + + To set virtual memory protections on a page of memory, your system should + provide the mprotect() and getpagesize() functions. If it does not, find + a substitute. + + +C. a new CPU or OS - how to flush the instruction cache? + + CPUs which have separate data and instruction caches need to flush + (part of) the instruction cache when alloc_trampoline() is called. + (There may have been an old trampoline at the same location, and the + instruction cache is not updated when the new trampoline is built. + The effect can be that when the new trampoline is called, the old one + will still be executed.) + + To flush the instruction cache, some CPUs have special instruction which + can be put into gcc "asm" statements. On some CPUs these instructions are + privileged, you therefore need to call some system or library function. + On other CPUs, the only way to flush the instruction cache is to execute + a long sequence of "nop" or "jump" instructions. This is hairy. + + +When you are done with porting to a new platform, or even if TRAMPOLINE +passes the "make check" out of the box without modifications, please report +your results to the author of TRAMPOLINE, for inclusion in the next release. diff --git a/trampoline/README b/trampoline/README new file mode 100644 index 0000000..01595c7 --- /dev/null +++ b/trampoline/README @@ -0,0 +1,70 @@ +trampoline - closures as first-class C functions. + +This library implements closures as first-class C functions. A closure +consists of a regular C function and a piece of data which gets passed to +the C function when the closure is called. + +Typical uses of closures are nested functions in programming languages, +and call-back functions passed to other libraries. + + +Installation instructions: + + Configure the parent directory. Then: + cd trampoline + make + make check + make install + + +Files in this package: + + Documentation: + + README this text + COPYING free software license + PLATFORMS list of supported platforms + trampoline.3 manual page in Unix man format + trampoline.html manual page in HTML format + + Source: + + trampoline.h include file + trampoline.c implementation of the library functions + tramp-hppa.s the trampoline for hppa, in assembly language + tramp-powerpc.S the trampoline for powerpc, in assembly language + cache.c how to flush the instruction cache, now unused + test1.c test program + test2.c test program + + Building: + + Makefile.in Makefile master + + Porting: + + PORTING porting instructions + Makefile.devel developer's Makefile + proto.c sample source containing assignment and jumping + proto-*.s its translation to assembly language + tramp-*.s the trampoline, in assembly language + tramp-*.o the trampoline, in binary form + + +Copyright notice: + +Copyright 1995-2017 Bruno Haible + +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, see . + diff --git a/trampoline/cache-alpha-linux.s b/trampoline/cache-alpha-linux.s new file mode 100644 index 0000000..6754a16 --- /dev/null +++ b/trampoline/cache-alpha-linux.s @@ -0,0 +1,20 @@ + .set noreorder + .set volatile + .set noat + .set nomacro + .text + .align 2 + .align 4 + .globl __TR_clear_cache + .ent __TR_clear_cache +$__TR_clear_cache..ng: +__TR_clear_cache: + .frame $30,0,$26,0 + .prologue 0 + .set macro + call_pal 0x86 + .set nomacro + ret $31,($26),1 + .end __TR_clear_cache + .ident "GCC: (GNU) 4.0.2" + .section .note.GNU-stack,"",@progbits diff --git a/trampoline/cache-alpha-macro.S b/trampoline/cache-alpha-macro.S new file mode 100644 index 0000000..e350f4c --- /dev/null +++ b/trampoline/cache-alpha-macro.S @@ -0,0 +1,21 @@ + .set noreorder + .set volatile + .set noat + .set nomacro + .text + .align 2 + .align 4 + .globl __TR_clear_cache + .ent __TR_clear_cache +$__TR_clear_cache..ng: +__TR_clear_cache: + .frame $30,0,$26,0 + .prologue 0 + .set macro + call_pal 0x86 + .set nomacro + ret $31,($26),1 + .end __TR_clear_cache +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/trampoline/cache-alpha.c b/trampoline/cache-alpha.c new file mode 100644 index 0000000..ad20947 --- /dev/null +++ b/trampoline/cache-alpha.c @@ -0,0 +1,24 @@ +/* Instruction cache flushing for alpha */ + +/* + * Copyright 1997 Bruno Haible + * + * 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, see . + */ + +void __TR_clear_cache (void) +{ + /* Taken from gforth-0.3.0. */ + asm volatile ("call_pal 0x86"); /* imb (instruction-memory barrier) */ +} diff --git a/trampoline/cache-hppa-linux.s b/trampoline/cache-hppa-linux.s new file mode 100644 index 0000000..b9c9a6d --- /dev/null +++ b/trampoline/cache-hppa-linux.s @@ -0,0 +1,33 @@ + .LEVEL 1.1 + .text + .align 4 +.globl __TR_clear_cache + .type __TR_clear_cache,@function +__TR_clear_cache: + .PROC + .CALLINFO FRAME=0,NO_CALLS + .ENTRY +#APP + fdc 0(0,%r26) + fdc 0(0,%r25) + sync + mfsp %sr0,%r20 + ldsid (0,%r26),%r26 + mtsp %r26,%sr0 + fic 0(%sr0,%r26) + fic 0(%sr0,%r25) + sync + mtsp %r20,%sr0 + nop + nop + nop + nop + nop + nop +#NO_APP + bv,n %r0(%r2) + .EXIT + .PROCEND +.Lfe1: + .size __TR_clear_cache,.Lfe1-__TR_clear_cache + .ident "GCC: (GNU) 3.1" diff --git a/trampoline/cache-hppa-macro.S b/trampoline/cache-hppa-macro.S new file mode 100644 index 0000000..7c39646 --- /dev/null +++ b/trampoline/cache-hppa-macro.S @@ -0,0 +1,36 @@ +#include "asm-hppa.h" + .LEVEL 1.1 + IMPORT_MILLICODE($$dyncall) + TEXT1() + TEXT2() + .align 4 +GLOBL(__TR_clear_cache) + DECLARE_FUNCTION(__TR_clear_cache) +DEF(__TR_clear_cache) + .PROC + .CALLINFO FRAME=0,NO_CALLS + .ENTRY + fdc 0(0,%r26) + fdc 0(0,%r25) + sync + mfsp %sr0,%r20 + ldsid (0,%r26),%r26 + mtsp %r26,%sr0 + fic 0(%sr0,%r26) + fic 0(%sr0,%r25) + sync + mtsp %r20,%sr0 + nop + nop + nop + nop + nop + nop + bv,n %r0(%r2) + .EXIT + .PROCEND +DEF(L(fe1)) + FUNEND(__TR_clear_cache) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/trampoline/cache-hppa.c b/trampoline/cache-hppa.c new file mode 100644 index 0000000..2174716 --- /dev/null +++ b/trampoline/cache-hppa.c @@ -0,0 +1,65 @@ +/* Instruction cache flushing for hppa */ + +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +#ifdef __hppa64__ +/* Tell GCC not to clobber the registers that are call-saved in the HP C + calling convention. */ +register long arg0 __asm__("r26"); +register long arg1 __asm__("r25"); +register long arg2 __asm__("r24"); +register long arg3 __asm__("r23"); +register long arg4 __asm__("r22"); +register long arg5 __asm__("r21"); +register long arg6 __asm__("r20"); +register long arg7 __asm__("r19"); +#endif + +/* + * This assumes that the range [first_addr..last_addr] lies in at most two + * cache lines. + */ +void __TR_clear_cache (char* first_addr, char* last_addr) +{ + register int tmp1; + register int tmp2; + /* Flush the relevant data cache lines. (Yes, this is needed. I tried it.) */ + asm volatile ("fdc 0(0,%0)" + "\n\t" "fdc 0(0,%1)" + "\n\t" "sync" + : + : "r" (first_addr), "r" (last_addr) + ); + /* Flush the relevant instruction cache lines. */ + asm volatile ("mfsp %%sr0,%1" + "\n\t" "ldsid (0,%4),%0" + "\n\t" "mtsp %0,%%sr0" + "\n\t" "fic 0(%%sr0,%2)" + "\n\t" "fic 0(%%sr0,%3)" + "\n\t" "sync" + "\n\t" "mtsp %1,%%sr0" + "\n\t" "nop" + "\n\t" "nop" + "\n\t" "nop" + "\n\t" "nop" + "\n\t" "nop" + "\n\t" "nop" + : "=r" (tmp1), "=r" (tmp2) + : "r" (first_addr), "r" (last_addr), "r" (first_addr) + ); +} diff --git a/trampoline/cache-hppa64-linux.s b/trampoline/cache-hppa64-linux.s new file mode 100644 index 0000000..928f35f --- /dev/null +++ b/trampoline/cache-hppa64-linux.s @@ -0,0 +1,35 @@ + .LEVEL 2.0w + .text + .align 8 +.globl __TR_clear_cache + .type __TR_clear_cache,@function +__TR_clear_cache: + .PROC + .CALLINFO FRAME=128,NO_CALLS + .ENTRY + ldo 128(%r30),%r30 +#APP + fdc 0(0,%r26) + fdc 0(0,%r25) + sync + mfsp %sr0,%r31 + ldsid (0,%r26),%r28 + mtsp %r28,%sr0 + fic 0(%sr0,%r26) + fic 0(%sr0,%r25) + sync + mtsp %r31,%sr0 + nop + nop + nop + nop + nop + nop +#NO_APP + bve (%r2) + ldo -128(%r30),%r30 + .EXIT + .PROCEND +.Lfe1: + .size __TR_clear_cache,.Lfe1-__TR_clear_cache + .ident "GCC: (GNU) 3.1" diff --git a/trampoline/cache-hppa64-macro.S b/trampoline/cache-hppa64-macro.S new file mode 100644 index 0000000..e5344ae --- /dev/null +++ b/trampoline/cache-hppa64-macro.S @@ -0,0 +1,37 @@ +#include "asm-hppa64.h" + .LEVEL 2.0w + TEXT1() + TEXT2() + .align 8 +GLOBL(__TR_clear_cache) + DECLARE_FUNCTION(__TR_clear_cache) +DEF(__TR_clear_cache) + .PROC + .CALLINFO FRAME=128,NO_CALLS + .ENTRY + ldo 128(%r30),%r30 + fdc 0(0,%r26) + fdc 0(0,%r25) + sync + mfsp %sr0,%r31 + ldsid (0,%r26),%r28 + mtsp %r28,%sr0 + fic 0(%sr0,%r26) + fic 0(%sr0,%r25) + sync + mtsp %r31,%sr0 + nop + nop + nop + nop + nop + nop + bve (%r2) + ldo -128(%r30),%r30 + .EXIT + .PROCEND +DEF(L(fe1)) + FUNEND(__TR_clear_cache) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/trampoline/cache-powerpc-linux-macro.S b/trampoline/cache-powerpc-linux-macro.S new file mode 100644 index 0000000..6dc7e1a --- /dev/null +++ b/trampoline/cache-powerpc-linux-macro.S @@ -0,0 +1,37 @@ + .file "cache-powerpc.c" + .section ".text" + .align 2 + .globl __TR_clear_cache + .type __TR_clear_cache, @function +__TR_clear_cache: + .extern __mulh + .extern __mull + .extern __divss + .extern __divus + .extern __quoss + .extern __quous + stwu 1,-32(1) + icbi 0,3; dcbf 0,3 + addi 0,3,4 + icbi 0,0; dcbf 0,0 + addi 9,3,8 + icbi 0,9; dcbf 0,9 + addi 0,3,12 + icbi 0,0; dcbf 0,0 + addi 9,3,16 + icbi 0,9; dcbf 0,9 + addi 0,3,20 + icbi 0,0; dcbf 0,0 + addi 9,3,24 + icbi 0,9; dcbf 0,9 + addi 0,3,28 + icbi 0,0; dcbf 0,0 + addi 3,3,32 + icbi 0,3; dcbf 0,3 + sync; isync + addi 1,1,32 + blr + .size __TR_clear_cache, .-__TR_clear_cache +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/trampoline/cache-powerpc-linux.s b/trampoline/cache-powerpc-linux.s new file mode 100644 index 0000000..0fb871e --- /dev/null +++ b/trampoline/cache-powerpc-linux.s @@ -0,0 +1,54 @@ + .file "cache-powerpc.c" + .section ".text" + .align 2 + .globl __TR_clear_cache + .type __TR_clear_cache, @function +__TR_clear_cache: + .extern __mulh + .extern __mull + .extern __divss + .extern __divus + .extern __quoss + .extern __quous + stwu 1,-32(1) +#APP + icbi 0,3; dcbf 0,3 +#NO_APP + addi 0,3,4 +#APP + icbi 0,0; dcbf 0,0 +#NO_APP + addi 9,3,8 +#APP + icbi 0,9; dcbf 0,9 +#NO_APP + addi 0,3,12 +#APP + icbi 0,0; dcbf 0,0 +#NO_APP + addi 9,3,16 +#APP + icbi 0,9; dcbf 0,9 +#NO_APP + addi 0,3,20 +#APP + icbi 0,0; dcbf 0,0 +#NO_APP + addi 9,3,24 +#APP + icbi 0,9; dcbf 0,9 +#NO_APP + addi 0,3,28 +#APP + icbi 0,0; dcbf 0,0 +#NO_APP + addi 3,3,32 +#APP + icbi 0,3; dcbf 0,3 + sync; isync +#NO_APP + addi 1,1,32 + blr + .size __TR_clear_cache, .-__TR_clear_cache + .section .note.GNU-stack,"",@progbits + .ident "GCC: (GNU) 3.3.6" diff --git a/trampoline/cache-powerpc-macos.s b/trampoline/cache-powerpc-macos.s new file mode 100644 index 0000000..ba869fb --- /dev/null +++ b/trampoline/cache-powerpc-macos.s @@ -0,0 +1,23 @@ +.text + .align 2 + .globl ___TR_clear_cache +___TR_clear_cache: + icbi 0,r3; dcbf 0,r3 + addi r0,r3,4 + icbi 0,r0; dcbf 0,r0 + addi r9,r3,8 + icbi 0,r9; dcbf 0,r9 + addi r0,r3,12 + icbi 0,r0; dcbf 0,r0 + addi r9,r3,16 + icbi 0,r9; dcbf 0,r9 + addi r0,r3,20 + icbi 0,r0; dcbf 0,r0 + addi r9,r3,24 + icbi 0,r9; dcbf 0,r9 + addi r0,r3,28 + icbi 0,r0; dcbf 0,r0 + addi r3,r3,32 + icbi 0,r3; dcbf 0,r3 + sync; isync + blr diff --git a/trampoline/cache-powerpc.c b/trampoline/cache-powerpc.c new file mode 100644 index 0000000..b204d22 --- /dev/null +++ b/trampoline/cache-powerpc.c @@ -0,0 +1,35 @@ +/* Instruction cache flushing for powerpc, not on AIX */ + +/* + * Copyright 1997-2017 Bruno Haible + * + * 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, see . + */ + +void __TR_clear_cache (char* first_addr) +{ + /* Taken from egcs-1.1.2/gcc/config/rs6000/tramp.asm. */ + /* The number of asm statements here depends on the value of TRAMP_LENGTH + for __powerpcsysv4__. */ + asm volatile ("icbi 0,%0; dcbf 0,%0" : : "r" (first_addr)); + asm volatile ("icbi 0,%0; dcbf 0,%0" : : "r" (first_addr+4)); + asm volatile ("icbi 0,%0; dcbf 0,%0" : : "r" (first_addr+8)); + asm volatile ("icbi 0,%0; dcbf 0,%0" : : "r" (first_addr+12)); + asm volatile ("icbi 0,%0; dcbf 0,%0" : : "r" (first_addr+16)); + asm volatile ("icbi 0,%0; dcbf 0,%0" : : "r" (first_addr+20)); + asm volatile ("icbi 0,%0; dcbf 0,%0" : : "r" (first_addr+24)); + asm volatile ("icbi 0,%0; dcbf 0,%0" : : "r" (first_addr+28)); + asm volatile ("icbi 0,%0; dcbf 0,%0" : : "r" (first_addr+32)); + asm volatile ("sync; isync"); +} diff --git a/trampoline/cache-powerpc64-elfv2-linux.s b/trampoline/cache-powerpc64-elfv2-linux.s new file mode 100644 index 0000000..2cc82f5 --- /dev/null +++ b/trampoline/cache-powerpc64-elfv2-linux.s @@ -0,0 +1,54 @@ + .file "cache-powerpc64.c" + .machine power4 + .abiversion 2 + .section ".toc","aw" + .section ".text" + .align 2 + .p2align 4,,15 + .globl __TR_clear_cache + .type __TR_clear_cache, @function +__TR_clear_cache: +#APP + # 25 "cache-powerpc64.c" 1 + icbi 0,3; dcbf 0,3 + # 0 "" 2 +#NO_APP + addi 9,3,4 +#APP + # 26 "cache-powerpc64.c" 1 + icbi 0,9; dcbf 0,9 + # 0 "" 2 +#NO_APP + addi 9,3,8 +#APP + # 27 "cache-powerpc64.c" 1 + icbi 0,9; dcbf 0,9 + # 0 "" 2 +#NO_APP + addi 9,3,12 +#APP + # 28 "cache-powerpc64.c" 1 + icbi 0,9; dcbf 0,9 + # 0 "" 2 +#NO_APP + addi 9,3,16 +#APP + # 29 "cache-powerpc64.c" 1 + icbi 0,9; dcbf 0,9 + # 0 "" 2 +#NO_APP + addi 3,3,20 +#APP + # 30 "cache-powerpc64.c" 1 + icbi 0,3; dcbf 0,3 + # 0 "" 2 + # 31 "cache-powerpc64.c" 1 + sync; isync + # 0 "" 2 +#NO_APP + blr + .long 0 + .byte 0,0,0,0,0,0,0,0 + .size __TR_clear_cache,.-__TR_clear_cache + .ident "GCC: (GNU) 5.4.0" + .section .note.GNU-stack,"",@progbits diff --git a/trampoline/cache-powerpc64-elfv2-macro.S b/trampoline/cache-powerpc64-elfv2-macro.S new file mode 100644 index 0000000..98cb970 --- /dev/null +++ b/trampoline/cache-powerpc64-elfv2-macro.S @@ -0,0 +1,43 @@ + .file "cache-powerpc64.c" + .machine power4 + .abiversion 2 + .section ".toc","aw" + .section ".text" + .align 2 + .p2align 4,,15 + .globl __TR_clear_cache + .type __TR_clear_cache, @function +__TR_clear_cache: + # 25 "cache-powerpc64.c" 1 + icbi 0,3; dcbf 0,3 + # 0 "" 2 + addi 9,3,4 + # 26 "cache-powerpc64.c" 1 + icbi 0,9; dcbf 0,9 + # 0 "" 2 + addi 9,3,8 + # 27 "cache-powerpc64.c" 1 + icbi 0,9; dcbf 0,9 + # 0 "" 2 + addi 9,3,12 + # 28 "cache-powerpc64.c" 1 + icbi 0,9; dcbf 0,9 + # 0 "" 2 + addi 9,3,16 + # 29 "cache-powerpc64.c" 1 + icbi 0,9; dcbf 0,9 + # 0 "" 2 + addi 3,3,20 + # 30 "cache-powerpc64.c" 1 + icbi 0,3; dcbf 0,3 + # 0 "" 2 + # 31 "cache-powerpc64.c" 1 + sync; isync + # 0 "" 2 + blr + .long 0 + .byte 0,0,0,0,0,0,0,0 + .size __TR_clear_cache,.-__TR_clear_cache +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/trampoline/cache-powerpc64.c b/trampoline/cache-powerpc64.c new file mode 100644 index 0000000..8baba8c --- /dev/null +++ b/trampoline/cache-powerpc64.c @@ -0,0 +1,32 @@ +/* Instruction cache flushing for powerpc64, not the AIX ABI */ + +/* + * Copyright 1997-2017 Bruno Haible + * + * 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, see . + */ + +void __TR_clear_cache (char* first_addr) +{ + /* Taken from egcs-1.1.2/gcc/config/rs6000/tramp.asm. */ + /* The number of asm statements here depends on the value of TRAMP_LENGTH-3*8 + for __powerpc64_elfv2__. */ + asm volatile ("icbi 0,%0; dcbf 0,%0" : : "r" (first_addr)); + asm volatile ("icbi 0,%0; dcbf 0,%0" : : "r" (first_addr+4)); + asm volatile ("icbi 0,%0; dcbf 0,%0" : : "r" (first_addr+8)); + asm volatile ("icbi 0,%0; dcbf 0,%0" : : "r" (first_addr+12)); + asm volatile ("icbi 0,%0; dcbf 0,%0" : : "r" (first_addr+16)); + asm volatile ("icbi 0,%0; dcbf 0,%0" : : "r" (first_addr+20)); + asm volatile ("sync; isync"); +} diff --git a/trampoline/cache-sparc-linux.s b/trampoline/cache-sparc-linux.s new file mode 100644 index 0000000..a59943c --- /dev/null +++ b/trampoline/cache-sparc-linux.s @@ -0,0 +1,15 @@ + .file "cache-sparc.c" + .section ".text" + .align 4 + .global __TR_clear_cache_4 + .type __TR_clear_cache_4,#function + .proc 020 +__TR_clear_cache_4: + !#PROLOGUE# 0 + iflush %o0+0;iflush %o0+8;iflush %o0+16;iflush %o0+24 + nop + retl + nop +.LLfe1: + .size __TR_clear_cache_4,.LLfe1-__TR_clear_cache_4 + .ident "GCC: (GNU) 3.1" diff --git a/trampoline/cache-sparc-macro.S b/trampoline/cache-sparc-macro.S new file mode 100644 index 0000000..d9ec5bc --- /dev/null +++ b/trampoline/cache-sparc-macro.S @@ -0,0 +1,17 @@ +#include "asm-sparc.h" + .section ".text" + .align 4 + .global C(__TR_clear_cache_4) + DECLARE_FUNCTION(__TR_clear_cache_4) + .proc 020 +FUNBEGIN(__TR_clear_cache_4) + !$PROLOGUE$ 0 + iflush %o0+0;iflush %o0+8;iflush %o0+16;iflush %o0+24 + nop + retl + nop +L(Lfe1): + FUNEND(__TR_clear_cache_4) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/trampoline/cache-sparc.c b/trampoline/cache-sparc.c new file mode 100644 index 0000000..83981e2 --- /dev/null +++ b/trampoline/cache-sparc.c @@ -0,0 +1,31 @@ +/* Instruction cache flushing for sparc */ + +/* + * Copyright 1996-1999 Bruno Haible + * + * 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, see . + */ + +/* + * This assumes that the range [first_addr..last_addr] lies in at most four + * cache lines. + */ +void __TR_clear_cache_4 (char* first_addr, char* last_addr) +{ + asm volatile ("iflush %0+0;" /* the +0 is needed by gas, says gforth-0.3.0 */ + "iflush %0+8;" + "iflush %0+16;" + "iflush %0+24" + : : "r" (first_addr)); +} diff --git a/trampoline/cache-sparc64-linux.s b/trampoline/cache-sparc64-linux.s new file mode 100644 index 0000000..2951612 --- /dev/null +++ b/trampoline/cache-sparc64-linux.s @@ -0,0 +1,13 @@ + .file "cache-sparc.c" + .section ".text" + .align 4 + .global __TR_clear_cache_4 + .type __TR_clear_cache_4, #function + .proc 020 +__TR_clear_cache_4: + iflush %o0+0;iflush %o0+8;iflush %o0+16;iflush %o0+24 + jmp %o7+8 + nop + .size __TR_clear_cache_4, .-__TR_clear_cache_4 + .ident "GCC: (GNU) 4.0.2" + .section ".note.GNU-stack" diff --git a/trampoline/cache-sparc64-macro.S b/trampoline/cache-sparc64-macro.S new file mode 100644 index 0000000..5e5da94 --- /dev/null +++ b/trampoline/cache-sparc64-macro.S @@ -0,0 +1,14 @@ +#include "asm-sparc.h" + .section ".text" + .align 4 + .global C(__TR_clear_cache_4) + DECLARE_FUNCTION(__TR_clear_cache_4) + .proc 020 +FUNBEGIN(__TR_clear_cache_4) + iflush %o0+0;iflush %o0+8;iflush %o0+16;iflush %o0+24 + jmp %o7+8 + nop + FUNEND(__TR_clear_cache_4) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/trampoline/cache.c b/trampoline/cache.c new file mode 100644 index 0000000..7d34af9 --- /dev/null +++ b/trampoline/cache.c @@ -0,0 +1,143 @@ +/* This file is derived from gcc-2.6.3/libgcc2.c, section L_clear_cache */ + +/* Copyright (C) 1989-2017 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 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, see . */ + + +/* Clear part of an instruction cache. */ + +/* Our emphasis here is _not_ to clear as few cache lines as possible + * or with as few machine instructions as possible, but to do it _right_. + */ + + + +/* This code is apparently untested!! */ + +/* This is from Andreas Stolcke . */ +#if defined(__mips__) || defined(__mips64__) +#include +#define CLEAR_INSN_CACHE(BEG, END) \ + cacheflush (BEG, END - BEG, BCACHE) +#endif + +void +__TR_clear_cache (beg, end) + char *beg, *end; +{ +#ifdef CLEAR_INSN_CACHE + CLEAR_INSN_CACHE (beg, end); +#else +#ifdef INSN_CACHE_SIZE /* This is actually dead code!! */ +#define INSN_CACHE_PLANE_SIZE (INSN_CACHE_SIZE / INSN_CACHE_DEPTH) + static char array[INSN_CACHE_SIZE + INSN_CACHE_PLANE_SIZE + INSN_CACHE_LINE_WIDTH]; + static int initialized = 0; + int offset; + void *start_addr; + void *end_addr; + typedef (*function_ptr) (); + +#if (INSN_CACHE_SIZE / INSN_CACHE_LINE_WIDTH) < 16 + /* It's cheaper to clear the whole cache. + Put in a series of jump instructions so that calling the beginning + of the cache will clear the whole thing. */ + + if (! initialized) + { + int ptr = (((int) array + INSN_CACHE_LINE_WIDTH - 1) + & -INSN_CACHE_LINE_WIDTH); + int end_ptr = ptr + INSN_CACHE_SIZE; + + while (ptr < end_ptr) + { + *(INSTRUCTION_TYPE *)ptr + = JUMP_AHEAD_INSTRUCTION + INSN_CACHE_LINE_WIDTH; + ptr += INSN_CACHE_LINE_WIDTH; + } + *(INSTRUCTION_TYPE *)(ptr - INSN_CACHE_LINE_WIDTH) = RETURN_INSTRUCTION; + + initialized = 1; + } + + /* Call the beginning of the sequence. */ + (((function_ptr) (((int) array + INSN_CACHE_LINE_WIDTH - 1) + & -INSN_CACHE_LINE_WIDTH)) + ()); + +#else /* Cache is large. */ + + if (! initialized) + { + int ptr = (((int) array + INSN_CACHE_LINE_WIDTH - 1) + & -INSN_CACHE_LINE_WIDTH); + + while (ptr < (int) array + sizeof array) + { + *(INSTRUCTION_TYPE *)ptr = RETURN_INSTRUCTION; + ptr += INSN_CACHE_LINE_WIDTH; + } + + initialized = 1; + } + + /* Find the location in array that occupies the same cache line as BEG. */ + + offset = ((int) beg & -INSN_CACHE_LINE_WIDTH) & (INSN_CACHE_PLANE_SIZE - 1); + start_addr = (((int) (array + INSN_CACHE_PLANE_SIZE - 1) + & -INSN_CACHE_PLANE_SIZE) + + offset); + + /* Compute the cache alignment of the place to stop clearing. */ +#if 0 /* This is not needed for gcc's purposes. */ + /* If the block to clear is bigger than a cache plane, + we clear the entire cache, and OFFSET is already correct. */ + if (end < beg + INSN_CACHE_PLANE_SIZE) +#endif + offset = (((int) (end + INSN_CACHE_LINE_WIDTH - 1) + & -INSN_CACHE_LINE_WIDTH) + & (INSN_CACHE_PLANE_SIZE - 1)); + +#if INSN_CACHE_DEPTH > 1 + end_addr = (start_addr & -INSN_CACHE_PLANE_SIZE) + offset; + if (end_addr <= start_addr) + end_addr += INSN_CACHE_PLANE_SIZE; + + for (plane = 0; plane < INSN_CACHE_DEPTH; plane++) + { + int addr = start_addr + plane * INSN_CACHE_PLANE_SIZE; + int stop = end_addr + plane * INSN_CACHE_PLANE_SIZE; + + while (addr != stop) + { + /* Call the return instruction at ADDR. */ + ((function_ptr) addr) (); + + addr += INSN_CACHE_LINE_WIDTH; + } + } +#else /* just one plane */ + do + { + /* Call the return instruction at START_ADDR. */ + ((function_ptr) start_addr) (); + + start_addr += INSN_CACHE_LINE_WIDTH; + } + while ((start_addr % INSN_CACHE_SIZE) != offset); +#endif /* just one plane */ +#endif /* Cache is large */ +#endif /* Cache exists */ +#endif /* CLEAR_INSN_CACHE */ +} diff --git a/trampoline/test1.c b/trampoline/test1.c new file mode 100644 index 0000000..d447ac3 --- /dev/null +++ b/trampoline/test1.c @@ -0,0 +1,45 @@ +/* Trampoline test */ + +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +#include +#include + +#include "trampoline.h" + +#define MAGIC1 0x9db9af42 +#define MAGIC2 0x614a13c9 + +static int magic = MAGIC1; + +void* function_data; + +int f (int x) +{ return *(int*)function_data + x; } + +int main () +{ + trampoline_function_t cf = alloc_trampoline((trampoline_function_t)&f, &function_data, &magic); + /* calling cf shall set function_data = &magic and then call f(x), + * thus returning magic + x. + */ + if (((*cf)(MAGIC2) == MAGIC1+MAGIC2) && (function_data == &magic)) + { free_trampoline(cf); printf("Works, test1 passed.\n"); exit(0); } + else + { printf("Doesn't work!\n"); exit(1); } +} diff --git a/trampoline/test2-c++.cc b/trampoline/test2-c++.cc new file mode 100644 index 0000000..6c7dfff --- /dev/null +++ b/trampoline/test2-c++.cc @@ -0,0 +1,18 @@ +/* + * Copyright 2017 Bruno Haible + * + * 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, see . + */ + +#include "test2.c" diff --git a/trampoline/test2.c b/trampoline/test2.c new file mode 100644 index 0000000..2ee55da --- /dev/null +++ b/trampoline/test2.c @@ -0,0 +1,51 @@ +/* Trampoline accessor test */ + +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +#include +#include + +#include "trampoline.h" + +int f (int x) +{ return x; } + +void* variable; + +static int data; + +int main () +{ + trampoline_function_t cf = alloc_trampoline((trampoline_function_t)&f, &variable, &data); + if (is_trampoline((void*)&f)) + { printf("is_trampoline(&f) returns true!\n"); exit(1); } +#if !defined(__cplusplus) + if (is_trampoline((void*)&main)) + { printf("is_trampoline(&main) returns true!\n"); exit(1); } +#endif + if (!is_trampoline((void*)cf)) + { printf("is_trampoline() returns false!\n"); exit(1); } + if (trampoline_address(cf) != (trampoline_function_t)&f) + { printf("trampoline_address() doesn't work!\n"); exit(1); } + if (trampoline_variable(cf) != &variable) + { printf("trampoline_variable() doesn't work!\n"); exit(1); } + if (trampoline_data(cf) != &data) + { printf("trampoline_data() doesn't work!\n"); exit(1); } + printf("test2 passed.\n"); + exit(0); +} diff --git a/trampoline/tramp-hppa-macro.S b/trampoline/tramp-hppa-macro.S new file mode 100644 index 0000000..4cc60ad --- /dev/null +++ b/trampoline/tramp-hppa-macro.S @@ -0,0 +1,53 @@ +; Trampoline for hppa CPU + +; Copyright 1997-2017 Bruno Haible +; +; 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, see . + +; Available registers: %r1, %r19, %r20, %r21, %r22, %r29, %r31. + + .code + .IMPORT $global$,DATA + .IMPORT $$dyncall,MILLICODE + .code + + .align 4 + .EXPORT tramp,ENTRY,PRIV_LEV=3,ARGW0=GR,ARGW1=GR + .label tramp + .PROC + .CALLINFO FRAME=0,NO_CALLS + .ENTRY +; The closure pointer is already in register %r19. +; Move into register %r20. + ldw 0(0,%r19),%r20 +; Move into register %r22 + ldw 4(0,%r19),%r22 +; Move
into register %r21. + ldw 8(0,%r19),%r21 +; Store into . + stw %r22,0(0,%r20) +; Jump to %r21. + bb,>=,n %r21,30,tramp_2 + depi 0,31,2,%r21 + ldw 4(0,%r21),%r19 + ldw 0(0,%r21),%r21 + .label tramp_2 + ldsid (0,%r21),%r1 + mtsp %r1,%sr0 + be,n 0(%sr0,%r21) + nop + .EXIT + .PROCEND + +#include "noexecstack.h" diff --git a/trampoline/tramp-hppa64-macro.S b/trampoline/tramp-hppa64-macro.S new file mode 100644 index 0000000..2f7b8af --- /dev/null +++ b/trampoline/tramp-hppa64-macro.S @@ -0,0 +1,50 @@ +; Trampoline for hppa64 CPU + +; Copyright 2017 Bruno Haible +; +; 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, see . + +; Available registers: %r1, %r27, %r31. +; %r27 has a fixed meaning at function calls: pic_base (a.k.a. gp or dp). +; %r31 has a fixed meaning as millicode return pointer (mrp). + +#include "asm-hppa64.h" + + .LEVEL 2.0w + TEXT1() + TEXT2() + .align 8 + GLOBL(tramp) + DECLARE_FUNCTION(tramp) +DEF(tramp) + .PROC + .CALLINFO FRAME=0,NO_CALLS + .ENTRY +; The closure pointer is already in register %r27. +; Move into . + ldd 0(%r27),%r31 ; get + ldd 8(%r27),%r1 ; get + std %r1,0(%r31) ; store in +; Jump to . + ldd 16(%r27),%r27 ; get + ldd 16(%r27),%r1 + ldd 24(%r27),%r27 + bve (%r1) ; jump to + nop + .EXIT + .PROCEND +DEF(L(fe1)) + FUNEND(tramp) + +#include "noexecstack.h" diff --git a/trampoline/tramp-ia64-macro.S b/trampoline/tramp-ia64-macro.S new file mode 100644 index 0000000..1b694b8 --- /dev/null +++ b/trampoline/tramp-ia64-macro.S @@ -0,0 +1,46 @@ +/* Trampoline for ia64 CPU */ + +/* + * Copyright 2001-2017 Bruno Haible + * + * 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, see . + */ + +/* Available registers: r14 ... r31, r9 ... r11, r2 ... r3. */ + + .text + .align 16 + .global tramp# + .proc tramp# +tramp: + /* The closure pointer is already in register r1. */ + ld8 r14 = [r1] /* Move
into register r14. */ + adds r15 = 8, r1 + adds r16 = 16, r1 + ;; + /* Jump to r14. */ + ld8 r18 = [r14] + ld8 r15 = [r15] /* Move into register r15. */ + adds r17 = 8, r14 + ;; + ld8 r16 = [r16] /* Move into register r16. */ + ld8 r1 = [r17] + mov b6 = r18 + ;; + st8 [r15] = r16 /* Store into . */ + br b6 + ;; + .endp tramp# + +#include "noexecstack.h" diff --git a/trampoline/tramp-powerpc-aix.S b/trampoline/tramp-powerpc-aix.S new file mode 100644 index 0000000..a36634b --- /dev/null +++ b/trampoline/tramp-powerpc-aix.S @@ -0,0 +1,51 @@ +/* Trampoline for powerpc CPU with AIX calling convention */ + +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +/* Available registers: r0, r11, r12. */ +/* However, r0 is special in that it cannot be used as a base register. */ + + .globl tramp + .globl .tramp +.csect tramp[DS] +tramp: + .long .tramp, 0, 0 +.csect .text[PR] +.tramp: +/* Move into */ + lwz 11,0(2) /* get */ + lwz 12,4(2) /* get */ + stw 12,0(11) +/* Get */ + lwz 12,8(2) +/* + * gcc-2.6.3 source says: + * A function pointer is a pointer to a data area whose first word contains + * the actual address of the function, whose second word contains a pointer + * to its TOC, and whose third word contains a value to place in the static + * chain register (r11). + */ + lwz 11,8(12) /* pass static chain in r11 */ + lwz 2,4(12) /* pass TOC in r2 */ + lwz 0,0(12) /* actual code address */ + mtctr 0 + bctr + +_section_.text: +.csect .data[RW] + .long _section_.text diff --git a/trampoline/tramp-powerpc64-aix.S b/trampoline/tramp-powerpc64-aix.S new file mode 100644 index 0000000..7fd0f66 --- /dev/null +++ b/trampoline/tramp-powerpc64-aix.S @@ -0,0 +1,57 @@ +/* Trampoline for powerpc64 CPU with AIX calling convention */ + +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +/* Available registers: r0, r11, r12. */ +/* However, r0 is special in that it cannot be used as a base register. */ + + .machine "ppc64" + +#ifdef _AIX + .rename H.4.NO_SYMBOL{PR},"" + .lglobl H.4.NO_SYMBOL{PR} + + .globl .tramp + .csect H.4.NO_SYMBOL{PR},7 +#else + .globl tramp + .globl .tramp +tramp: + .quad .tramp +#endif +.tramp: +/* Move into */ + ld 11,0(2) /* get */ + ld 12,8(2) /* get */ + std 12,0(11) +/* Get */ + ld 12,16(2) +/* + * gcc-2.6.3 source says: + * A function pointer is a pointer to a data area whose first word contains + * the actual address of the function, whose second word contains a pointer + * to its TOC, and whose third word contains a value to place in the static + * chain register (r11). + */ + ld 11,16(12) /* pass static chain in r11 */ + ld 2,8(12) /* pass TOC in r2 */ + ld 0,0(12) /* actual code address */ + mtctr 0 + bctr + +#include "noexecstack.h" diff --git a/trampoline/trampoline.3 b/trampoline/trampoline.3 new file mode 100644 index 0000000..09d33ac --- /dev/null +++ b/trampoline/trampoline.3 @@ -0,0 +1,124 @@ +.\" Copyright (C) 1995-2017 Bruno Haible +.\" +.\" This manual is free documentation. It is dually licensed under the +.\" GNU FDL and the GNU GPL. This means that you can redistribute this +.\" manual under either of these two licenses, at your choice. +.\" +.\" This manual is covered by the GNU FDL. Permission is granted to copy, +.\" distribute and/or modify this document under the terms of the +.\" GNU Free Documentation License (FDL), either version 1.2 of the +.\" License, or (at your option) any later version published by the +.\" Free Software Foundation (FSF); with no Invariant Sections, with no +.\" Front-Cover Text, and with no Back-Cover Texts. +.\" A copy of the license is at . +.\" +.\" This manual is covered by the GNU GPL. You can redistribute it and/or +.\" modify it under the terms of the GNU General Public License (GPL), either +.\" version 2 of the License, or (at your option) any later version published +.\" by the Free Software Foundation (FSF). +.\" A copy of the license is at . +.\" +.TH TRAMPOLINE 3 "1 January 2017" +.SH NAME +trampoline \- closures as first-class C functions +.SH SYNOPSIS +.B #include +.LP +.B function = alloc_trampoline(address, variable, data); +.LP +.B free_trampoline(function); +.LP +.nf +.B is_trampoline(function) +.B trampoline_address(function) +.B trampoline_variable(function) +.B trampoline_data(function) +.fi +.SH DESCRIPTION +.LP +These functions implement +.I closures +as first-class C functions. +A closure consists of a regular C function and a piece of data +which gets passed to the C function when the closure is called. + +Closures as +.I first-class C functions +means that they fit into a function +pointer and can be called exactly like any other C function. +.IB function " = alloc_trampoline(" address ", " variable ", " data ")" +allocates a closure. When +.I function +gets called, it stores +.I data +in the variable +.I variable +and calls the C function at +.IR address . +The function at +.I address +is responsible for fetching +.I data +out of +.I variable +immediately, before execution of any other function call. + +This is much like +.BR gcc "'s" +local functions, except that the GNU C local functions have dynamic extent +(i.e. are deallocated when the creating function returns), while +.I trampoline +provides functions with indefinite extent: +.I function +is only deallocated when +.BI free_trampoline( function ) +is called. + +.BI "is_trampoline(" function ")" +checks whether the C function +.I function +was produced by a call to +.IR alloc_trampoline . +If this returns true, the arguments given to +.I alloc_trampoline +can be retrieved: +.RS 4 +.LP +.BI "trampoline_address(" function ")" +returns +.IR address , +.LP +.BI "trampoline_variable(" function ")" +returns +.IR variable , +.LP +.BI "trampoline_data(" function ")" +returns +.IR data . +.RE + +.SH SEE ALSO +.BR gcc (1), +.BR stdarg (3), +.BR callback (3) + +.SH BUGS +Passing the data through a global variable is not reentrant. Don't call +trampoline functions from within signal handlers. This is fixed in the +.BR callback (3) +package. + +.SH PORTING +The way +.B gcc +builds local functions is described in the gcc source, file +.RI gcc-2.6.3/config/ cpu / cpu .h. + +.SH AUTHOR + +Bruno Haible + +.SH ACKNOWLEDGEMENTS + +Many ideas were cribbed from the gcc source. + diff --git a/trampoline/trampoline.c b/trampoline/trampoline.c new file mode 100644 index 0000000..79f2c92 --- /dev/null +++ b/trampoline/trampoline.c @@ -0,0 +1,1741 @@ +/* Trampoline construction */ + +/* + * Copyright 1995-2019 Bruno Haible + * + * 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, see . + */ + + +#include "config.h" +#include "trampoline.h" + +#if defined(__hppa__) && !defined(__hppa64__) +#if 0 +#define __hppaold__ /* Old trampoline, real machine code. */ +#else +#define __hppanew__ /* New trampoline, just a closure. */ +#endif +#endif +#if defined(__hppa64__) +#if 0 +#define __hppa64old__ /* Old trampoline, real machine code. */ +#else +#define __hppa64new__ /* New trampoline, just a closure. */ +#endif +#endif +#if defined(__powerpc__) && !defined(__powerpc64__) +#if !defined(_AIX) +#define __powerpcsysv4__ /* SysV.4 ABI, real machine code. */ +#else +#define __powerpcaix__ /* AIX ABI, just a closure. */ +#endif +#endif +#if defined(__powerpc64__) && !defined(__powerpc64_elfv2__) +#define __powerpc64aix__ /* AIX ABI, just a closure. */ +#endif +#if defined(__hppanew__) || defined(__hppa64new__) +/* + * A function pointer is a biased pointer to a data area whose first word + * (hppa) or third word (hppa64) contains the actual address of the function. + */ +extern void tramp (); /* trampoline prototype */ +/* We don't need to take any special measures to make the code executable + * since the actual instructions are in the text segment. + */ +#ifndef CODE_EXECUTABLE +#define CODE_EXECUTABLE +#endif +#endif +#if defined(__powerpcaix__) || defined(__powerpc64aix__) || defined(__ia64__) +/* + * A function pointer is a pointer to a data area whose first word contains + * the actual address of the function. + */ +extern void (*tramp) (); /* trampoline prototype */ +/* We don't need to take any special measures to make the code executable + * since the actual instructions are in the text segment. + */ +#ifndef CODE_EXECUTABLE +#define CODE_EXECUTABLE +#endif +#endif + +#ifndef CODE_EXECUTABLE + /* How do we make the trampoline's code executable? */ + #if defined(HAVE_MACH_VM) || defined(HAVE_WORKING_MPROTECT) + #if HAVE_MPROTECT_AFTER_MALLOC_CAN_EXEC > 0 + /* mprotect() [or equivalent] the malloc'ed area. */ + #define EXECUTABLE_VIA_MALLOC_THEN_MPROTECT + #elif HAVE_MPROTECT_AFTER_MMAP_CAN_EXEC > 0 + /* mprotect() [or equivalent] the mmap'ed area. */ + #define EXECUTABLE_VIA_MMAP_THEN_MPROTECT + #elif defined(HAVE_MMAP_SHARED_CAN_EXEC) + #define EXECUTABLE_VIA_MMAP_FILE_SHARED + #else + #error "Don't know how to make memory pages executable." + #endif + #else + #ifdef HAVE_MMAP + /* Use an mmap'ed page. */ + #define EXECUTABLE_VIA_MMAP + #else + #ifdef HAVE_SHM + /* Use an shmat'ed page. */ + #define EXECUTABLE_VIA_SHM + #else + #if defined(_WIN32) && ! defined(__CYGWIN__) /* native Windows */ + #define EXECUTABLE_VIA_VIRTUALALLOC + #else + ?? + #endif + #endif + #endif + #endif +#endif + +#include /* declares fprintf() */ + +#include +#include /* declares abort(), malloc(), free() */ +#ifdef HAVE_UNISTD_H +#include +#endif + +/* Define intptr_t, uintptr_t. */ +#include + +/* Declare getpagesize(). */ +#ifdef HAVE_GETPAGESIZE +#ifdef __cplusplus +extern "C" RETGETPAGESIZETYPE getpagesize (void); +#else +extern RETGETPAGESIZETYPE getpagesize (void); +#endif +#else +#ifdef HAVE_SYS_PARAM_H +#include +#else +/* Not Unix, e.g. mingw32 */ +#define PAGESIZE 4096 +#endif +#define getpagesize() PAGESIZE +#endif + +/* Declare mprotect() or equivalent. */ +#if defined(EXECUTABLE_VIA_MALLOC_THEN_MPROTECT) || defined(EXECUTABLE_VIA_MMAP_THEN_MPROTECT) +#ifdef HAVE_MACH_VM +#include +#include +#ifdef __osf__ +#include +#endif +#include +#else +#include +#include +#endif +#endif + +/* Declare mmap(). */ +#if defined(EXECUTABLE_VIA_MMAP) || defined(EXECUTABLE_VIA_MMAP_FILE_SHARED) +#include +#include +#if !defined(PROT_EXEC) && defined(PROT_EXECUTE) /* Irix 4.0.5 needs this */ +#define PROT_EXEC PROT_EXECUTE +#endif +#endif + +/* Declare open(). */ +#if defined(EXECUTABLE_VIA_MMAP_DEVZERO) || defined(EXECUTABLE_VIA_MMAP_FILE_SHARED) +#include +#include +#include +#endif + +/* Declare shmget(), shmat(), shmctl(). */ +#ifdef EXECUTABLE_VIA_SHM +#include +#include +#include +#ifdef HAVE_SYS_SYSMACROS_H +#include +#endif +#endif + +/* Declare VirtualAlloc(), GetSystemInfo. */ +#ifdef EXECUTABLE_VIA_VIRTUALALLOC +#define WIN32_LEAN_AND_MEAN +#define WIN32_EXTRA_LEAN +#include +#endif + +/* Some old mmap() implementations require the flag MAP_FILE whenever you pass + an fd >= 0. */ +#ifndef MAP_FILE +#define MAP_FILE 0 +#endif +/* Some old mmap() implementations require the flag MAP_VARIABLE whenever you + pass an addr == NULL. */ +#ifndef MAP_VARIABLE +#define MAP_VARIABLE 0 +#endif + +/* Support for instruction cache flush. */ +#ifdef __i386__ +#if defined(_WIN32) && ! defined(__CYGWIN__) /* native Windows */ +#define WIN32_LEAN_AND_MEAN +#define WIN32_EXTRA_LEAN +#include +#endif +#endif +#if defined(__mips__) || defined(__mipsn32__) || defined(__mips64__) || defined(__riscv32__) || defined(__riscv64__) +#ifdef HAVE_SYS_CACHECTL_H /* IRIX, Linux */ +#include +#else +#ifdef __OpenBSD__ +#include +#endif +#endif +#endif +/* Inline assembly function for instruction cache flush. */ +#if defined(__sparc__) || defined(__sparc64__) || defined(__alpha__) || defined(__hppaold__) || defined(__hppa64old__) || defined(__powerpcsysv4__) || defined(__powerpc64_elfv2__) +#if defined(__sparc__) || defined(__sparc64__) +extern void __TR_clear_cache_4(); +#else +extern void __TR_clear_cache(); +#endif +#endif + +/* Support for multithread-safe coding. */ +#include "glthread/lock.h" + +#if !defined(CODE_EXECUTABLE) && defined(EXECUTABLE_VIA_MMAP_FILE_SHARED) +/* Opens a file descriptor and attempts to make it non-inheritable. */ +static int open_noinherit (const char *filename, int flags, int mode) +{ +# if O_CLOEXEC + return open (filename, flags | O_CLOEXEC, mode); +# else + int fd = open (filename, flags, mode); +# ifdef F_SETFD + if (fd >= 0) + { + int flags = fcntl (fd, F_GETFD, 0); + if (flags >= 0) + fcntl (fd, F_SETFD, flags | FD_CLOEXEC); + } +# endif + return fd; +# endif +} +#endif + +/* Length and alignment of trampoline */ +#ifdef __i386__ +#define TRAMP_LENGTH 15 +#define TRAMP_ALIGN 16 /* 4 for a i386, 16 for a i486 */ +#endif +#ifdef __m68k__ +#define TRAMP_LENGTH 18 +#define TRAMP_ALIGN 16 +#endif +#if defined(__mipsold__) && !defined(__mipsn32__) +#define TRAMP_LENGTH 32 +#define TRAMP_ALIGN 4 +#endif +#if (defined(__mips__) || defined(__mipsn32__)) && !defined(__mips64__) +#define TRAMP_LENGTH 36 +#define TRAMP_ALIGN 4 +#endif +#ifdef __mips64old__ +#define TRAMP_LENGTH 84 +#define TRAMP_ALIGN 4 +#endif +#ifdef __mips64__ +#define TRAMP_LENGTH 48 +#define TRAMP_ALIGN 8 +#endif +#if defined(__sparc__) && !defined(__sparc64__) +#define TRAMP_LENGTH 28 +#define TRAMP_ALIGN 16 +#endif +#ifdef __sparc64__ +#define TRAMP_LENGTH 48 +#define TRAMP_ALIGN 16 +#endif +#ifdef __alpha__ +#define TRAMP_LENGTH 48 +#define TRAMP_ALIGN 8 +#endif +#ifdef __hppaold__ +#define TRAMP_LENGTH 56 +#define TRAMP_ALIGN 16 +#endif +#ifdef __hppanew__ +#define TRAMP_LENGTH 20 +#define TRAMP_ALIGN 16 +#define TRAMP_BIAS 2 +#endif +#ifdef __hppa64old__ +#define TRAMP_LENGTH 96 +#define TRAMP_ALIGN 8 +#define TRAMP_BIAS 64 +#endif +#ifdef __hppa64new__ +#define TRAMP_LENGTH 56 +#define TRAMP_ALIGN 8 +#endif +#if defined(__arm__) || defined(__armhf__) +#define TRAMP_LENGTH 36 +#define TRAMP_ALIGN 4 +#endif +#ifdef __arm64__ +#define TRAMP_LENGTH 48 +#define TRAMP_ALIGN 8 +#endif +#ifdef __powerpcsysv4__ +#define TRAMP_LENGTH 36 +#define TRAMP_ALIGN 4 +#endif +#ifdef __powerpcaix__ +#define TRAMP_LENGTH 24 +#define TRAMP_ALIGN 4 +#endif +#ifdef __powerpc64_elfv2__ +#define TRAMP_LENGTH 48 +#define TRAMP_ALIGN 8 +#endif +#ifdef __powerpc64aix__ +#define TRAMP_LENGTH 48 +#define TRAMP_ALIGN 8 +#endif +#ifdef __ia64__ +#define TRAMP_LENGTH 40 +#define TRAMP_ALIGN 16 +#endif +#ifdef __x86_64__ +#ifdef __x86_64_x32__ +#define TRAMP_LENGTH 18 +#define TRAMP_ALIGN 4 +#else +#define TRAMP_LENGTH 32 +#define TRAMP_ALIGN 16 +#endif +#endif +#if defined(__s390__) && !defined(__s390x__) +#define TRAMP_LENGTH 40 +#define TRAMP_ALIGN 4 +#endif +#if defined(__s390x__) +#define TRAMP_LENGTH 64 +#define TRAMP_ALIGN 8 +#endif +#if defined(__riscv32__) +#define TRAMP_LENGTH 36 +#define TRAMP_ALIGN 4 +#endif +#if defined(__riscv64__) +#define TRAMP_LENGTH 48 +#define TRAMP_ALIGN 8 +#endif + +#ifndef TRAMP_BIAS +#define TRAMP_BIAS 0 +#endif + +#if !defined(CODE_EXECUTABLE) +static long pagesize = 0; +#endif + +#if !defined(CODE_EXECUTABLE) && (defined(EXECUTABLE_VIA_MMAP_DEVZERO) || defined(EXECUTABLE_VIA_MMAP_FILE_SHARED)) + +/* Variables needed for obtaining memory pages via mmap(). */ +#if defined(EXECUTABLE_VIA_MMAP_DEVZERO) +static int zero_fd; +#endif +#if defined(EXECUTABLE_VIA_MMAP_FILE_SHARED) +static int file_fd; +static long file_length; +#endif + +/* Initialization of these variables. */ +static void for_mmap_init (void) +{ +#if defined(EXECUTABLE_VIA_MMAP_DEVZERO) + zero_fd = open("/dev/zero",O_RDONLY,0644); + if (zero_fd < 0) + { fprintf(stderr,"trampoline: Cannot open /dev/zero!\n"); abort(); } +#endif +#if defined(EXECUTABLE_VIA_MMAP_FILE_SHARED) + { + char filename[100]; + sprintf(filename, "%s/trampdata-%d-%ld", "/tmp", getpid (), random ()); + file_fd = open_noinherit (filename, O_CREAT | O_RDWR | O_TRUNC, 0700); + if (file_fd < 0) + { fprintf(stderr,"trampoline: Cannot open %s!\n",filename); abort(); } + /* Remove the file from the file system as soon as possible, to make + sure there is no leftover after this process terminates or crashes. */ + unlink(filename); + } + file_length = 0; +#endif +} + +/* Once-only initializer for these variables. */ +gl_once_define(static, for_mmap_once) + +#endif + +#if !defined(CODE_EXECUTABLE) && !defined(EXECUTABLE_VIA_MALLOC_THEN_MPROTECT) +/* AIX doesn't support mprotect() in malloc'ed memory. Must get pages of + * memory with execute permission via mmap(). Then keep a free list of + * free trampolines. + */ +static char* freelist = NULL; +/* Lock that protects the freelist from simultaneous access from multiple + threads. */ +gl_lock_define_initialized(static, freelist_lock) +#endif + +trampoline_function_t alloc_trampoline (trampoline_function_t address, void** variable, void* data) +{ + char* function; + char* function_x; + +#if !defined(CODE_EXECUTABLE) + /* First, get the page size once and for all. */ + if (!pagesize) + { + /* Simultaneous execution of this initialization in multiple threads + is OK. */ +#if defined(EXECUTABLE_VIA_VIRTUALALLOC) + /* GetSystemInfo + + */ + SYSTEM_INFO info; + GetSystemInfo(&info); + pagesize = info.dwPageSize; +#elif defined(HAVE_MACH_VM) + pagesize = vm_page_size; +#else + pagesize = getpagesize(); +#endif +#if defined(EXECUTABLE_VIA_MMAP_DEVZERO) || defined(EXECUTABLE_VIA_MMAP_FILE_SHARED) + /* Use a once-only initializer here, since simultaneous execution of + for_mmap_init() in multiple threads must be avoided. */ + gl_once (for_mmap_once, for_mmap_init); +#endif + } +#endif + + /* 1. Allocate room */ + +#if !defined(CODE_EXECUTABLE) && !defined(EXECUTABLE_VIA_MALLOC_THEN_MPROTECT) + gl_lock_lock(freelist_lock); + if (freelist == NULL) + { /* Get a new page. */ + char* page; + char* page_end; +#ifdef EXECUTABLE_VIA_VIRTUALALLOC + /* VirtualAlloc + + */ + page = VirtualAlloc(NULL,pagesize,MEM_COMMIT,PAGE_EXECUTE_READWRITE); + if (page == NULL) + { fprintf(stderr,"trampoline: Out of virtual memory!\n"); abort(); } + page_end = page + pagesize; +#else +#ifdef EXECUTABLE_VIA_MMAP_FILE_SHARED + char* page_x; + /* Extend the file by one page. */ + long new_file_length = file_length + pagesize; + if (ftruncate(file_fd,new_file_length) < 0) + { fprintf(stderr,"trampoline: Cannot extend backing file!\n"); abort(); } + /* Create separate mappings for writing and for executing. */ + page = (char*)mmap(NULL,pagesize,PROT_READ|PROT_WRITE,MAP_SHARED,file_fd,file_length); + page_x = (char*)mmap(NULL,pagesize,PROT_READ|PROT_EXEC,MAP_SHARED,file_fd,file_length); + if (page == (char*)(-1) || page_x == (char*)(-1)) + { fprintf(stderr,"trampoline: Out of virtual memory!\n"); abort(); } + file_length = new_file_length; + page_end = page + pagesize; + /* Link the two pages together. */ + ((intptr_t*)page)[0] = page_x - page; + page = (char*)(((uintptr_t)page + sizeof(intptr_t) + TRAMP_ALIGN-1) & -TRAMP_ALIGN); +#else +#ifdef EXECUTABLE_VIA_MMAP_THEN_MPROTECT +#ifdef HAVE_MMAP_ANONYMOUS + /* Use mmap with the MAP_ANONYMOUS or MAP_ANON flag. */ + page = mmap(NULL, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_VARIABLE, -1, 0); +#else + /* Use mmap on /dev/zero. */ + page = mmap(NULL, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FILE | MAP_VARIABLE, zero_fd, 0); +#endif +#endif +#ifdef EXECUTABLE_VIA_MMAP +#ifdef HAVE_MMAP_ANONYMOUS + /* Use mmap with the MAP_ANONYMOUS or MAP_ANON flag. */ + page = mmap(NULL, pagesize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS | MAP_VARIABLE, -1, 0); +#else + /* Use mmap on /dev/zero. */ + page = mmap(NULL, pagesize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_FILE | MAP_VARIABLE, zero_fd, 0); +#endif +#endif +#ifdef EXECUTABLE_VIA_SHM + int shmid = shmget(IPC_PRIVATE, pagesize, 0700|IPC_CREAT); + if (shmid<0) + { page = (char*)(-1); } + else + { page = shmat(shmid, 0, 0); shmctl(shmid, IPC_RMID, 0); } +#endif + if (page == (char*)(-1)) + { fprintf(stderr,"trampoline: Out of virtual memory!\n"); abort(); } + page_end = page + pagesize; +#endif +#endif + /* Fill it with free trampolines. */ + { char** last = &freelist; + while (page+TRAMP_LENGTH <= page_end) + { *last = page; last = (char**)page; + page = (char*)(((uintptr_t)page + TRAMP_LENGTH + TRAMP_ALIGN-1) & -TRAMP_ALIGN); + } + *last = NULL; + } } + function = freelist; freelist = *(char**)freelist; + gl_lock_unlock(freelist_lock); +#else + { char* room = (char*) malloc(sizeof(void*) + TRAMP_LENGTH + TRAMP_ALIGN-1); + if (!room) + { fprintf(stderr,"trampoline: Out of virtual memory!\n"); abort(); } + function = (char*)(((uintptr_t)room + sizeof(void*) + TRAMP_ALIGN-1) & -TRAMP_ALIGN); + ((char**)function)[-1] = room; /* backpointer for free_trampoline() */ + } +#endif + +#if !defined(CODE_EXECUTABLE) && defined(EXECUTABLE_VIA_MMAP_FILE_SHARED) + /* Find the executable address corresponding to the writable address. */ + { uintptr_t page = (uintptr_t) function & -(intptr_t)pagesize; + function_x = function + ((intptr_t*)page)[0]; + } +#else + function_x = function; +#endif + + /* 2. Fill out the trampoline */ +#ifdef __i386__ + /* function: + * movl $, C7 05 + * jmp
E9
- + * here: + */ + *(short *) (function + 0) = 0x05C7; + *(long *) (function + 2) = (long) variable; + *(long *) (function + 6) = (long) data; + *(char *) (function +10) = 0xE9; + *(long *) (function +11) = (long) address - (long) (function_x + 15); +#define is_tramp(function) \ + *(unsigned short *) (function + 0) == 0x05C7 && \ + *(unsigned char *) (function +10) == 0xE9 +#define tramp_address(function) \ + *(long *) (function +11) + (long) (function + 15) +#define tramp_variable(function) \ + *(long *) (function + 2) +#define tramp_data(function) \ + *(long *) (function + 6) +#endif +#ifdef __m68k__ + /* function: + * movel #, 23 FC + * jmp
4E F9
+ * nop 4E 71 + */ + *(short *) (function + 0) = 0x23FC; + *(long *) (function + 2) = (long) data; + *(long *) (function + 6) = (long) variable; + *(short *) (function +10) = 0x4EF9; + *(long *) (function +12) = (long) address; + *(short *) (function +16) = 0x4E71; +#define is_tramp(function) \ + *(unsigned short *) (function + 0) == 0x23FC && \ + *(unsigned short *) (function +10) == 0x4EF9 && \ + *(unsigned short *) (function +16) == 0x4E71 +#define tramp_address(function) \ + *(long *) (function +12) +#define tramp_variable(function) \ + *(long *) (function + 6) +#define tramp_data(function) \ + *(long *) (function + 2) +#endif +#if defined(__mipsold__) && !defined(__mipsn32__) + /* function: + * li $2,&0xffff0000 3C 02 hi16() + * ori $2,$2,&0xffff 34 42 lo16() + * sw $2, 3C 01 hi16() + * AC 22 lo16() + * li $25,
&0xffff0000 3C 19 hi16(
) + * ori $25,$25,
&0xffff 37 39 lo16(
) + * j $25 03 20 00 08 + * nop 00 00 00 00 + */ + /* What about big endian / little endian ?? */ + *(short *) (function + 0) = 0x3C02; + *(short *) (function + 2) = (unsigned long) data >> 16; + *(short *) (function + 4) = 0x3442; + *(short *) (function + 6) = (unsigned long) data & 0xffff; + *(short *) (function + 8) = 0x3C01; + *(short *) (function +10) = (unsigned long) variable >> 16; + *(short *) (function +12) = 0xAC22; + *(short *) (function +14) = (unsigned long) variable & 0xffff; + *(short *) (function +16) = 0x3C19; + *(short *) (function +18) = (unsigned long) address >> 16; + *(short *) (function +20) = 0x3739; + *(short *) (function +22) = (unsigned long) address & 0xffff; + *(long *) (function +24) = 0x03200008; + *(long *) (function +28) = 0x00000000; +#define is_tramp(function) \ + *(unsigned short *) (function + 0) == 0x3C02 && \ + *(unsigned short *) (function + 4) == 0x3442 && \ + *(unsigned short *) (function + 8) == 0x3C01 && \ + *(unsigned short *) (function +12) == 0xAC22 && \ + *(unsigned short *) (function +16) == 0x3C19 && \ + *(unsigned short *) (function +20) == 0x3739 && \ + *(unsigned long *) (function +24) == 0x03200008 && \ + *(unsigned long *) (function +28) == 0x00000000 +#define hilo(hiword,loword) \ + (((unsigned long) (hiword) << 16) | (unsigned long) (loword)) +#define tramp_address(function) \ + hilo(*(unsigned short *) (function +18), *(unsigned short *) (function +22)) +#define tramp_variable(function) \ + hilo(*(unsigned short *) (function +10), *(unsigned short *) (function +14)) +#define tramp_data(function) \ + hilo(*(unsigned short *) (function + 2), *(unsigned short *) (function + 6)) +#endif +#if (defined(__mips__) || defined(__mipsn32__)) && !defined(__mips64__) + /* function: + * lw $2,24($25) 8F 22 00 18 + * lw $3,28($25) 8F 23 00 1C + * sw $3,0($2) AC 43 00 00 + * lw $25,32($25) 8F 39 00 20 + * j $25 03 20 00 08 + * nop 00 00 00 00 + * .word + * .word + * .word
+ */ + *(unsigned int *) (function + 0) = 0x8F220018; + *(unsigned int *) (function + 4) = 0x8F23001C; + *(unsigned int *) (function + 8) = 0xAC430000; + *(unsigned int *) (function +12) = 0x8F390020; + *(unsigned int *) (function +16) = 0x03200008; + *(unsigned int *) (function +20) = 0x00000000; + *(unsigned int *) (function +24) = (unsigned int) variable; + *(unsigned int *) (function +28) = (unsigned int) data; + *(unsigned int *) (function +32) = (unsigned int) address; +#define TRAMP_CODE_LENGTH 24 +#define is_tramp(function) \ + *(int *) (function + 0) == 0x8F220018 && \ + *(int *) (function + 4) == 0x8F23001C && \ + *(int *) (function + 8) == 0xAC430000 && \ + *(int *) (function +12) == 0x8F390020 && \ + *(int *) (function +16) == 0x03200008 && \ + *(int *) (function +20) == 0x00000000 +#define tramp_address(function) \ + *(unsigned int *) (function +32) +#define tramp_variable(function) \ + *(unsigned int *) (function +24) +#define tramp_data(function) \ + *(unsigned int *) (function +28) +#endif +#ifdef __mips64old__ + /* function: + * dli $2, 3C 02 hi16(hi32()) + * 34 42 lo16(hi32()) + * 00 02 14 38 + * 34 42 hi16(lo32()) + * 00 02 14 38 + * 34 42 lo16(lo32()) + * dli $3, 3C 03 hi16(hi32()) + * 34 63 lo16(hi32()) + * 00 03 1C 38 + * 34 63 hi16(lo32()) + * 00 03 1C 38 + * 34 63 lo16(lo32()) + * sd $3,0($2) FC 43 00 00 + * dli $25,
3C 19 hi16(hi32(
)) + * 37 39 lo16(hi32(
)) + * 00 19 CC 38 + * 37 39 hi16(lo32(
)) + * 00 19 CC 38 + * 37 39 lo16(lo32(
)) + * j $25 03 20 00 08 + * nop 00 00 00 00 + */ + /* What about big endian / little endian ?? */ + *(short *) (function + 0) = 0x3C02; + *(short *) (function + 2) = (unsigned long) variable >> 48; + *(short *) (function + 4) = 0x3442; + *(short *) (function + 6) = ((unsigned long) variable >> 32) & 0xffff; + *(int *) (function + 8) = 0x00021438; + *(short *) (function +12) = 0x3442; + *(short *) (function +14) = ((unsigned long) variable >> 16) & 0xffff; + *(int *) (function +16) = 0x00021438; + *(short *) (function +20) = 0x3442; + *(short *) (function +22) = (unsigned long) variable & 0xffff; + *(short *) (function +24) = 0x3C03; + *(short *) (function +26) = (unsigned long) data >> 48; + *(short *) (function +28) = 0x3463; + *(short *) (function +30) = ((unsigned long) data >> 32) & 0xffff; + *(int *) (function +32) = 0x00031C38; + *(short *) (function +36) = 0x3463; + *(short *) (function +38) = ((unsigned long) data >> 16) & 0xffff; + *(int *) (function +40) = 0x00031C38; + *(short *) (function +44) = 0x3463; + *(short *) (function +46) = (unsigned long) data & 0xffff; + *(int *) (function +48) = 0xFC430000; + *(short *) (function +52) = 0x3C19; + *(short *) (function +54) = (unsigned long) address >> 48; + *(short *) (function +56) = 0x3739; + *(short *) (function +58) = ((unsigned long) address >> 32) & 0xffff; + *(int *) (function +60) = 0x0019CC38; + *(short *) (function +64) = 0x3739; + *(short *) (function +66) = ((unsigned long) address >> 16) & 0xffff; + *(int *) (function +68) = 0x0019CC38; + *(short *) (function +72) = 0x3739; + *(short *) (function +74) = (unsigned long) address & 0xffff; + *(int *) (function +76) = 0x03200008; + *(int *) (function +80) = 0x00000000; +#define is_tramp(function) \ + *(unsigned short *) (function + 0) == 0x3C02 && \ + *(unsigned short *) (function + 4) == 0x3442 && \ + *(unsigned int *) (function + 8) == 0x00021438 && \ + *(unsigned short *) (function +12) == 0x3442 && \ + *(unsigned int *) (function +16) == 0x00021438 && \ + *(unsigned short *) (function +20) == 0x3442 && \ + *(unsigned short *) (function +24) == 0x3C03 && \ + *(unsigned short *) (function +28) == 0x3463 && \ + *(unsigned int *) (function +32) == 0x00031C38 && \ + *(unsigned short *) (function +36) == 0x3463 && \ + *(unsigned int *) (function +40) == 0x00031C38 && \ + *(unsigned short *) (function +44) == 0x3463 && \ + *(unsigned int *) (function +48) == 0xFC430000 && \ + *(unsigned short *) (function +52) == 0x3C19 && \ + *(unsigned short *) (function +56) == 0x3739 && \ + *(unsigned int *) (function +60) == 0x0019CC38 && \ + *(unsigned short *) (function +64) == 0x3739 && \ + *(unsigned int *) (function +68) == 0x0019CC38 && \ + *(unsigned short *) (function +72) == 0x3739 && \ + *(unsigned int *) (function +76) == 0x03200008 && \ + *(unsigned int *) (function +80) == 0x00000000 +#define hilo(word3,word2,word1,word0) \ + (((unsigned long) (word3) << 48) | ((unsigned long) (word2) << 32) | \ + ((unsigned long) (word1) << 16) | (unsigned long) (word0)) +#define tramp_address(function) \ + hilo(*(unsigned short *) (function +54), \ + *(unsigned short *) (function +58), \ + *(unsigned short *) (function +66), \ + *(unsigned short *) (function +74)) +#define tramp_variable(function) \ + hilo(*(unsigned short *) (function + 2), \ + *(unsigned short *) (function + 6), \ + *(unsigned short *) (function +14), \ + *(unsigned short *) (function +22)) +#define tramp_data(function) \ + hilo(*(unsigned short *) (function +26), \ + *(unsigned short *) (function +30), \ + *(unsigned short *) (function +38), \ + *(unsigned short *) (function +46)) +#endif +#ifdef __mips64__ + /* function: + * ld $2,24($25) DF 22 00 18 + * ld $3,32($25) DF 23 00 20 + * sd $3,0($2) FC 43 00 00 + * ld $25,40($25) DF 39 00 28 + * j $25 03 20 00 08 + * nop 00 00 00 00 + * .dword + * .dword + * .dword
+ */ + *(unsigned int *) (function + 0) = 0xDF220018; + *(unsigned int *) (function + 4) = 0xDF230020; + *(unsigned int *) (function + 8) = 0xFC430000; + *(unsigned int *) (function +12) = 0xDF390028; + *(unsigned int *) (function +16) = 0x03200008; + *(unsigned int *) (function +20) = 0x00000000; + *(unsigned long *) (function +24) = (unsigned long) variable; + *(unsigned long *) (function +32) = (unsigned long) data; + *(unsigned long *) (function +40) = (unsigned long) address; +#define TRAMP_CODE_LENGTH 24 +#define is_tramp(function) \ + *(unsigned int *) (function + 0) == 0xDF220018 && \ + *(unsigned int *) (function + 4) == 0xDF230020 && \ + *(unsigned int *) (function + 8) == 0xFC430000 && \ + *(unsigned int *) (function +12) == 0xDF390028 && \ + *(unsigned int *) (function +16) == 0x03200008 && \ + *(unsigned int *) (function +20) == 0x00000000 +#define tramp_address(function) \ + *(unsigned long *) (function +40) +#define tramp_variable(function) \ + *(unsigned long *) (function +24) +#define tramp_data(function) \ + *(unsigned long *) (function +32) +#endif +#if defined(__sparc__) && !defined(__sparc64__) + /* function: + * sethi %hi(),%g1 03000000 | ( >> 10) + * sethi %hi(),%g2 05000000 | ( >> 10) + * or %g2,%lo(),%g2 8410A000 | ( & 0x3ff) + * st %g2,[%g1+%lo()] C4206000 | ( & 0x3ff) + * sethi %hi(
),%g1 03000000 | (
>> 10) + * jmp %g1+%lo(
) 81C06000 | (
& 0x3ff) + * nop 01000000 + */ +#define hi(word) ((unsigned long) (word) >> 10) +#define lo(word) ((unsigned long) (word) & 0x3ff) + *(long *) (function + 0) = 0x03000000 | hi(variable); + *(long *) (function + 4) = 0x05000000 | hi(data); + *(long *) (function + 8) = 0x8410A000 | lo(data); + *(long *) (function +12) = 0xC4206000 | lo(variable); + *(long *) (function +16) = 0x03000000 | hi(address); + *(long *) (function +20) = 0x81C06000 | lo(address); + *(long *) (function +24) = 0x01000000; +#define is_tramp(function) \ + (*(long *) (function + 0) & 0xffc00000) == 0x03000000 && \ + (*(long *) (function + 4) & 0xffc00000) == 0x05000000 && \ + (*(long *) (function + 8) & 0xfffffc00) == 0x8410A000 && \ + (*(long *) (function +12) & 0xfffffc00) == 0xC4206000 && \ + (*(long *) (function +16) & 0xffc00000) == 0x03000000 && \ + (*(long *) (function +20) & 0xfffffc00) == 0x81C06000 && \ + *(long *) (function +24) == 0x01000000 +#define hilo(hiword,loword) (((hiword) << 10) | ((loword) & 0x3ff)) +#define tramp_address(function) \ + hilo(*(long *) (function +16), *(long *) (function +20)) +#define tramp_variable(function) \ + hilo(*(long *) (function + 0), *(long *) (function +12)) +#define tramp_data(function) \ + hilo(*(long *) (function + 4), *(long *) (function + 8)) +#endif +#ifdef __sparc64__ + /* function: + * rd %pc,%g1 83414000 + * ldx [%g1+24],%g2 C4586018 + * ldx [%g1+32],%g3 C6586020 + * ldx [%g1+40],%g1 C2586028 + * jmp %g1 81C04000 + * stx %g3,[%g2] C6708000 + * .long high32() >> 32 + * .long low32() & 0xffffffff + * .long high32() >> 32 + * .long low32() & 0xffffffff + * .long high32(
)
>> 32 + * .long low32(
)
& 0xffffffff + */ + *(int *) (function + 0) = 0x83414000; + *(int *) (function + 4) = 0xC4586018; + *(int *) (function + 8) = 0xC6586020; + *(int *) (function +12) = 0xC2586028; + *(int *) (function +16) = 0x81C04000; + *(int *) (function +20) = 0xC6708000; + *(long *) (function +24) = (long) variable; + *(long *) (function +32) = (long) data; + *(long *) (function +40) = (long) address; +#define TRAMP_CODE_LENGTH 24 +#define is_tramp(function) \ + *(int *) (function + 0) == 0x83414000 && \ + *(int *) (function + 4) == 0xC4586018 && \ + *(int *) (function + 8) == 0xC6586020 && \ + *(int *) (function +12) == 0xC2586028 && \ + *(int *) (function +16) == 0x81C04000 && \ + *(int *) (function +20) == 0xC6708000 +#define tramp_address(function) \ + *(long *) (function +40) +#define tramp_variable(function) \ + *(long *) (function +24) +#define tramp_data(function) \ + *(long *) (function +32) +#endif +#ifdef __alpha__ + /* function: + * br $1,function..ng 00 00 20 C0 + * function..ng: + * ldq $2,20($1) 14 00 41 A4 + * ldq $3,28($1) 1C 00 61 A4 + * ldq $27,36($1) 24 00 61 A7 + * stq $2,0($3) 00 00 43 B4 + * jmp $31,($27),0 00 00 FB 6B + * .quad + * .quad + * .quad
+ */ + { static int code [6] = + { 0xC0200000, 0xA4410014, 0xA461001C, 0xA7610024, 0xB4430000, 0x6BFB0000 }; + int i; + for (i=0; i<6; i++) { ((int *) function)[i] = code[i]; } + ((long *) function)[3] = (long) data; + ((long *) function)[4] = (long) variable; + ((long *) function)[5] = (long) address; + } +#define TRAMP_CODE_LENGTH 24 +#define is_tramp(function) \ + ((int *) function)[0] == 0xC0200000 && \ + ((int *) function)[1] == 0xA4410014 && \ + ((int *) function)[2] == 0xA461001C && \ + ((int *) function)[3] == 0xA7610024 && \ + ((int *) function)[4] == 0xB4430000 && \ + ((int *) function)[5] == 0x6BFB0000 +#define tramp_address(function) \ + ((long *) function)[5] +#define tramp_variable(function) \ + ((long *) function)[4] +#define tramp_data(function) \ + ((long *) function)[3] +#endif +#ifdef __hppaold__ + /* function: + * ldil L',%r20 22800000 | hi() + * ldil L',%r19 22600000 | hi() + * ldo R'(%r20),%r20 36940000 | lo() + * stw %r20,R'(%r19) 6A740000 | lo() + * ldil L'
,%r21 22A00000 | hi(
) + * ldo R'
(%r21),%r21 36B50000 | lo(
) + * bb,>=,n %r21,30,function2 C7D5C012 + * depi 0,31,2,%r21 D6A01C1E + * ldw 4(0,%r21),%r19 4AB30008 + * ldw 0(0,%r21),%r21 4AB50000 + * function2: + * ldsid (0,%r21),%r1 02A010A1 + * mtsp %r1,%sr0 00011820 + * be,n 0(%sr0,%r21) E2A00002 + * nop 08000240 + */ + /* When decoding a 21-bit argument in an instruction, the hppa performs + * the following bit manipulation: + * assemble21: x[20]...x[0] + * --> x[0] x[11]...x[1] x[15]..x[14] x[20]...x[16] x[13]..x[12] + * When encoding a 21-bit argument into an instruction, we need the + * to perform the reverse permutation: + * permute21: y[20]...y[0] + * --> y[6]...y[2] y[8]..y[7] y[1]..y[0] y[19]...y[9] y[20] + */ +#define assemble21(x) \ + ((((x) & 0x1) << 20) | (((x) & 0xFFE) << 8) | \ + (((x) & 0xC000) >> 7) | (((x) & 0x1F0000) >> 14) | (((x) & 0x3000) >> 12)) +#define permute21(y) \ + ((((y) & 0x7C) << 14) | (((y) & 0x180) << 7) | (((y) & 0x3) << 12) | \ + (((y) & 0xFFE00) >> 8) | (((y) & 0x100000) >> 20)) +#define hi(word) permute21((unsigned long) (word) >> 11) +#define lo(word) (((unsigned long) (word) & 0x7FF) << 1) + *(long *) (function + 0) = 0x22800000 | hi(data); + *(long *) (function + 4) = 0x22600000 | hi(variable); + *(long *) (function + 8) = 0x36940000 | lo(data); + *(long *) (function +12) = 0x6A740000 | lo(variable); + *(long *) (function +16) = 0x22A00000 | hi(address); + *(long *) (function +20) = 0x36B50000 | lo(address); + *(long *) (function +24) = 0xC7D5C012; + *(long *) (function +28) = 0xD6A01C1E; + *(long *) (function +32) = 0x4AB30008; + *(long *) (function +36) = 0x4AB50000; + *(long *) (function +40) = 0x02A010A1; + *(long *) (function +44) = 0x00011820; + *(long *) (function +48) = 0xE2A00002; + *(long *) (function +52) = 0x08000240; +#define is_tramp(function) \ + ((long) function & 3) == 0 && \ + (*(long *) (function + 0) & 0xffe00000) == 0x22800000 && \ + (*(long *) (function + 4) & 0xffe00000) == 0x22600000 && \ + (*(long *) (function + 8) & 0xfffff000) == 0x36940000 && \ + (*(long *) (function +12) & 0xfffff000) == 0x6A740000 && \ + (*(long *) (function +16) & 0xffe00000) == 0x22A00000 && \ + (*(long *) (function +20) & 0xfffff000) == 0x36B50000 && \ + *(long *) (function +24) == 0xC7D5C012 && \ + *(long *) (function +28) == 0xD6A01C1E && \ + *(long *) (function +32) == 0x4AB30008 && \ + *(long *) (function +36) == 0x4AB50000 && \ + *(long *) (function +40) == 0x02A010A1 && \ + *(long *) (function +44) == 0x00011820 && \ + *(long *) (function +48) == 0xE2A00002 && \ + *(long *) (function +52) == 0x08000240 +#define hilo(hiword,loword) \ + ((assemble21((unsigned long) (hiword)) << 11) | \ + (((unsigned long) (loword) & 0xFFE) >> 1) \ + ) +#define tramp_address(function) \ + hilo(*(long *) (function +16), *(long *) (function +20)) +#define tramp_variable(function) \ + hilo(*(long *) (function + 4), *(long *) (function +12)) +#define tramp_data(function) \ + hilo(*(long *) (function + 0), *(long *) (function + 8)) +#endif +#ifdef __hppanew__ + /* function: + * .long tramp + * .long closure + * closure: + * .long + * .long + * .long
+ */ + { /* work around a bug in gcc 3.* */ + void* tramp_address = &tramp; + *(long *) (function + 0) = ((long *) ((char*)tramp_address-2))[0]; + *(long *) (function + 4) = (long) (function + 8); + *(long *) (function + 8) = (long) variable; + *(long *) (function +12) = (long) data; + *(long *) (function +16) = (long) address; + } +#define TRAMP_CODE_LENGTH 0 +#define is_tramp(function) \ + ((long *) function)[0] == ((long *) ((char*)tramp_address-2))[0] +#define tramp_address(function) \ + ((long *) function)[4] +#define tramp_variable(function) \ + ((long *) function)[2] +#define tramp_data(function) \ + ((long *) function)[3] +#endif +#ifdef __hppa64old__ + /* function: + * mfia %r27 000014BB + * ldd 40(%r27),%r31 537F0050 + * ldd 48(%r27),%r1 53610060 + * std %r1,0(%r31) 0FE112C0 + * ldd 56(%r27),%r27 537B0070 + * ldd 16(%r27),%r1 53610020 + * ldd 24(%r27),%r27 537B0030 + * bve (%r1) E820D000 + * nop 08000240 + * .align 8 + * .dword + * .dword + * .dword
+ * function_pointer: + * .dword 0 + * .dword 0 + * .dword function + * .dword 0 + */ + *(int *) (function + 0) = 0x000014BB; + *(int *) (function + 4) = 0x537F0050; + *(int *) (function + 8) = 0x53610060; + *(int *) (function +12) = 0x0FE112C0; + *(int *) (function +16) = 0x537B0070; + *(int *) (function +20) = 0x53610020; + *(int *) (function +24) = 0x537B0030; + *(int *) (function +28) = 0xE820D000; + *(int *) (function +32) = 0x08000240; + *(long *) (function +40) = (long)variable; + *(long *) (function +48) = (long)data; + *(long *) (function +56) = (long)address; + *(long *) (function +64) = (long)0; + *(long *) (function +72) = (long)0; + *(long *) (function +80) = (long)function; + *(long *) (function +88) = (long)0; +#define TRAMP_CODE_LENGTH 36 +#define is_tramp(function) \ + *(int *) (function + 0) == 0x000014BB && \ + *(int *) (function + 4) == 0x537F0050 && \ + *(int *) (function + 8) == 0x53610060 && \ + *(int *) (function +12) == 0x0FE112C0 && \ + *(int *) (function +16) == 0x537B0070 && \ + *(int *) (function +20) == 0x53610020 && \ + *(int *) (function +24) == 0x537B0030 && \ + *(int *) (function +28) == 0xE820D000 && \ + *(int *) (function +32) == 0x08000240 +#define tramp_address(function) \ + (*(unsigned long *) (function +56)) +#define tramp_variable(function) \ + (*(unsigned long *) (function +40)) +#define tramp_data(function) \ + (*(unsigned long *) (function +48)) +#endif +#ifdef __hppa64new__ + /* function: + * .dword 0 + * .dword 0 + * .dword tramp + * .dword closure + * closure: + * .dword + * .dword + * .dword
+ */ + *(long *) (function + 0) = 0; + *(long *) (function + 8) = 0; + *(long *) (function +16) = ((long *) (void*) &tramp)[2]; + *(long *) (function +24) = (long) (function + 32); + *(long *) (function +32) = (long) variable; + *(long *) (function +40) = (long) data; + *(long *) (function +48) = (long) address; +#define TRAMP_CODE_LENGTH 0 +#define is_tramp(function) \ + ((long *) function)[2] == ((long *) (void*) &tramp)[2] && \ + ((long *) function)[3] == (long) (function + 32) +#define tramp_address(function) \ + ((long *) function)[6] +#define tramp_variable(function) \ + ((long *) function)[4] +#define tramp_data(function) \ + ((long *) function)[5] +#endif +#if defined(__arm__) || defined(__armhf__) + /* function: + * stmfd sp!,{r0} E92D0001 + * ldr r0,[pc,#16] E59F000C + * ldr ip,[pc,#16] E59FC00C + * str r0,[ip] E58C0000 + * ldmfd sp!,{r0} E8BD0001 + * ldr pc,[pc,#4] E59FF004 + * _data: + * .word + * _variable: + * .word + * _address: + * .word
+ */ + { + ((long *) function)[0] = 0xE92D0001; + ((long *) function)[1] = 0xE59F000C; + ((long *) function)[2] = 0xE59FC00C; + ((long *) function)[3] = 0xE58C0000; + ((long *) function)[4] = 0xE8BD0001; + ((long *) function)[5] = 0xE59FF004; + ((long *) function)[6] = (long)data; + ((long *) function)[7] = (long)variable; + ((long *) function)[8] = (long)address; + } +#define TRAMP_CODE_LENGTH 24 +#define is_tramp(function) \ + ((long *) function)[0] == 0xE92D0001 && \ + ((long *) function)[1] == 0xE59F000C && \ + ((long *) function)[2] == 0xE59FC00C && \ + ((long *) function)[3] == 0xE58C0000 && \ + ((long *) function)[4] == 0xE8BD0001 && \ + ((long *) function)[5] == 0xE59FF004 +#define tramp_address(function) \ + ((long *) function)[8] +#define tramp_variable(function) \ + ((long *) function)[7] +#define tramp_data(function) \ + ((long *) function)[6] +#endif +#ifdef __arm64__ + /* function: + * ldr x9,.+24 580000C9 + * ldr x10,.+28 580000EA + * ldr x11,.+32 5800010B + * str x9,[x10] F9000149 + * br x11 D61F0160 + * nop D503201F + * .xword + * .xword + * .xword
+ */ + *(int *) (function + 0) = 0x580000C9; + *(int *) (function + 4) = 0x580000EA; + *(int *) (function + 8) = 0x5800010B; + *(int *) (function +12) = 0xF9000149; + *(int *) (function +16) = 0xD61F0160; + *(int *) (function +20) = 0xD503201F; + *(long *) (function +24) = (unsigned long) data; + *(long *) (function +32) = (unsigned long) variable; + *(long *) (function +40) = (unsigned long) address; +#define TRAMP_CODE_LENGTH 24 +#define is_tramp(function) \ + *(unsigned int *) (function + 0) == 0x580000C9 && \ + *(unsigned int *) (function + 4) == 0x580000EA && \ + *(unsigned int *) (function + 8) == 0x5800010B && \ + *(unsigned int *) (function +12) == 0xF9000149 && \ + *(unsigned int *) (function +16) == 0xD61F0160 && \ + *(unsigned int *) (function +20) == 0xD503201F +#define tramp_address(function) \ + (*(unsigned long *) (function +40)) +#define tramp_variable(function) \ + (*(unsigned long *) (function +32)) +#define tramp_data(function) \ + (*(unsigned long *) (function +24)) +#endif +#ifdef __powerpcsysv4__ + /* function: + * {liu|lis} 11,hi16() 3D 60 hi16() + * {oril|ori} 11,11,lo16() 61 6B lo16() + * {liu|lis} 12,hi16() 3D 80 hi16() + * {oril|ori} 12,12,lo16() 61 8C lo16() + * {st|stw} 12,0(11) 91 8B 00 00 + * {liu|lis} 0,hi16(
) 3C 00 hi16(
) + * {oril|ori} 0,0,lo16(
) 60 00 lo16(
) + * mtctr 0 7C 09 03 A6 + * bctr 4E 80 04 20 + */ + *(short *) (function + 0) = 0x3D60; + *(short *) (function + 2) = (unsigned long) variable >> 16; + *(short *) (function + 4) = 0x616B; + *(short *) (function + 6) = (unsigned long) variable & 0xffff; + *(short *) (function + 8) = 0x3D80; + *(short *) (function +10) = (unsigned long) data >> 16; + *(short *) (function +12) = 0x618C; + *(short *) (function +14) = (unsigned long) data & 0xffff; + *(long *) (function +16) = 0x918B0000; + *(short *) (function +20) = 0x3C00; + *(short *) (function +22) = (unsigned long) address >> 16; + *(short *) (function +24) = 0x6000; + *(short *) (function +26) = (unsigned long) address & 0xffff; + *(long *) (function +28) = 0x7C0903A6; + *(long *) (function +32) = 0x4E800420; +#define is_tramp(function) \ + *(unsigned short *) (function + 0) == 0x3D60 && \ + *(unsigned short *) (function + 4) == 0x616B && \ + *(unsigned short *) (function + 8) == 0x3D80 && \ + *(unsigned short *) (function +12) == 0x618C && \ + *(unsigned long *) (function +16) == 0x918B0000 && \ + *(unsigned short *) (function +20) == 0x3C00 && \ + *(unsigned short *) (function +24) == 0x6000 && \ + *(unsigned long *) (function +28) == 0x7C0903A6 && \ + *(unsigned long *) (function +32) == 0x4E800420 +#define hilo(hiword,loword) \ + (((unsigned long) (hiword) << 16) | (unsigned long) (loword)) +#define tramp_address(function) \ + hilo(*(unsigned short *) (function +22), *(unsigned short *) (function +26)) +#define tramp_variable(function) \ + hilo(*(unsigned short *) (function + 2), *(unsigned short *) (function + 6)) +#define tramp_data(function) \ + hilo(*(unsigned short *) (function +10), *(unsigned short *) (function +14)) +#endif +#ifdef __powerpcaix__ + /* function: + * .long .tramp + * .long .mytoc + * .long 0 + * .mytoc: + * .long + * .long + * .long
+ */ + *(long *) (function + 0) = ((long *) &tramp)[0]; + *(long *) (function + 4) = (long) (function + 12); + *(long *) (function + 8) = 0; + *(long *) (function +12) = (long) variable; + *(long *) (function +16) = (long) data; + *(long *) (function +20) = (long) address; +#define TRAMP_CODE_LENGTH 0 +#define is_tramp(function) \ + ((long *) function)[0] == ((long *) &tramp)[0] +#define tramp_address(function) \ + ((long *) function)[5] +#define tramp_variable(function) \ + ((long *) function)[3] +#define tramp_data(function) \ + ((long *) function)[4] +#endif +#ifdef __powerpc64_elfv2__ + /* function: + * ld 11,24(12) 18 00 6C E9 + * ld 0,32(12) 20 00 0C E8 + * std 0,0(11) 00 00 0B F8 + * ld 12,40(12) 28 00 8C E9 + * mtctr 12 A6 03 89 7D + * bctr 20 04 80 4E + * .quad + * .quad + * .quad
+ */ + *(int *) (function + 0) = 0xE96C0018; + *(int *) (function + 4) = 0xE80C0020; + *(int *) (function + 8) = 0xF80B0000; + *(int *) (function +12) = 0xE98C0028; + *(int *) (function +16) = 0x7D8903A6; + *(int *) (function +20) = 0x4E800420; + *(long *) (function +24) = (unsigned long) variable; + *(long *) (function +32) = (unsigned long) data; + *(long *) (function +40) = (unsigned long) address; +#define TRAMP_CODE_LENGTH 24 +#define is_tramp(function) \ + *(unsigned int *) (function + 0) == 0xE96C0018 && \ + *(unsigned int *) (function + 4) == 0xE80C0020 && \ + *(unsigned int *) (function + 8) == 0xF80B0000 && \ + *(unsigned int *) (function +12) == 0xE98C0028 && \ + *(unsigned int *) (function +16) == 0x7D8903A6 && \ + *(unsigned int *) (function +20) == 0x4E800420 +#define tramp_address(function) \ + (*(unsigned long *) (function +40)) +#define tramp_variable(function) \ + (*(unsigned long *) (function +24)) +#define tramp_data(function) \ + (*(unsigned long *) (function +32)) +#endif +#ifdef __powerpc64aix__ + /* function: + * .quad .tramp + * .quad .mytoc + * .quad 0 + * .mytoc: + * .quad + * .quad + * .quad
+ */ + *(long *) (function + 0) = ((long *) &tramp)[0]; + *(long *) (function + 8) = (long) (function + 24); + *(long *) (function +16) = 0; + *(long *) (function +24) = (long) variable; + *(long *) (function +32) = (long) data; + *(long *) (function +40) = (long) address; +#define TRAMP_CODE_LENGTH 0 +#define is_tramp(function) \ + ((long *) function)[0] == ((long *) &tramp)[0] +#define tramp_address(function) \ + ((long *) function)[5] +#define tramp_variable(function) \ + ((long *) function)[3] +#define tramp_data(function) \ + ((long *) function)[4] +#endif +#ifdef __ia64__ + /* function: + * data8 tramp + * data8 closure + * closure: + * data8
+ * data8 + * data8 + */ + *(long *) (function + 0) = (long) &tramp; + *(long *) (function + 8) = (long) (function + 16); + *(long *) (function +16) = (long) address; + *(long *) (function +24) = (long) variable; + *(long *) (function +32) = (long) data; +#define TRAMP_CODE_LENGTH 0 +#define is_tramp(function) \ + ((long *) function)[0] == (long) &tramp +#define tramp_address(function) \ + ((long *) function)[2] +#define tramp_variable(function) \ + ((long *) function)[3] +#define tramp_data(function) \ + ((long *) function)[4] +#endif +#ifdef __x86_64__ +#ifdef __x86_64_x32__ + /* function: + * movl $, C7 04 25 + * movl $
,%eax B8
+ * jmp *%rax FF E0 + */ + *(int *) (function + 0) = ((unsigned long) variable << 24) | 0x2504C7; + *(int *) (function + 4) = ((unsigned long) data << 24) | ((unsigned long) variable >> 8); + *(int *) (function + 8) = 0xB8000000 | ((unsigned long) data >> 8); + *(int *) (function +12) = (unsigned long) address; + *(short *) (function +16) = 0xE0FF; +#define is_tramp(function) \ + (*(unsigned long *) (function + 0) & 0x00FFFFFF) == 0x2504C7 && \ + (*(unsigned long *) (function + 8) & 0xFF000000) == 0xB8000000 && \ + *(unsigned short *) (function +16) == 0xE0FF +#define tramp_address(function) \ + (*(unsigned int *) (function +12)) +#define tramp_variable(function) \ + ((*(unsigned long *) (function + 0) >> 24) | \ + (*(unsigned long *) (function + 4) << 8)) +#define tramp_data(function) \ + ((*(unsigned long *) (function + 4) >> 24) | \ + (*(unsigned long *) (function + 8) << 8)) +#else + /* function: + * movabsq $,%rax 48 B8 + * movabsq %rax, 48 A3 + * movabsq $
,%rax 48 B8
+ * jmp *%rax FF E0 + */ + *(short *) (function + 0) = 0xB848; + *(short *) (function + 2) = (unsigned long long) data & 0xffff; + *(int *) (function + 4) = ((unsigned long long) data >> 16) & 0xffffffff; + *(short *) (function + 8) = ((unsigned long long) data >> 48) & 0xffff; + *(short *) (function +10) = 0xA348; + *(int *) (function +12) = (unsigned long long) variable & 0xffffffff; + *(int *) (function +16) = ((unsigned long long) variable >> 32) & 0xffffffff; + *(short *) (function +20) = 0xB848; + *(short *) (function +22) = (unsigned long long) address & 0xffff; + *(int *) (function +24) = ((unsigned long long) address >> 16) & 0xffffffff; + *(short *) (function +28) = ((unsigned long long) address >> 48) & 0xffff; + *(short *) (function +30) = 0xE0FF; +#define is_tramp(function) \ + *(unsigned short *) (function + 0) == 0xB848 && \ + *(unsigned short *) (function +10) == 0xA348 && \ + *(unsigned short *) (function +20) == 0xB848 && \ + *(unsigned short *) (function +30) == 0xE0FF +#define hilo(hiword,loword) \ + (((unsigned long long) (hiword) << 32) | (unsigned long long) (loword)) +#define himidlo(hishort,midword,loshort) \ + (((unsigned long long) (hishort) << 48) | (unsigned long long) (midword) << 16 \ + | (unsigned long long) (loshort)) +#define tramp_address(function) \ + himidlo(*(unsigned short *) (function +28), \ + *(unsigned int *) (function +24), \ + *(unsigned short *) (function +22)) +#define tramp_variable(function) \ + hilo(*(unsigned int *) (function +16), *(unsigned int *) (function +12)) +#define tramp_data(function) \ + himidlo(*(unsigned short *) (function + 8), \ + *(unsigned int *) (function + 4), \ + *(unsigned short *) (function + 2)) +#endif +#endif +#if defined(__s390__) && !defined(__s390x__) + /* function: + * bras %r1,.L1 A7150002 + * .L1: + * l %r0,data-.L1(%r1) 58001018 + * l %r1,variable-.L1(%r1) 5810101C + * st %r0,0(%r1) 50001000 + * bras %r1,.L2 A7150002 + * .L2: + * l %r1,function-.L2(%r1) 58101010 + * br %r1 07F1 + * nop 0707 + * data: .long + * variable: .long + * address: .long
+ */ + *(int *) (function + 0) = 0xA7150002; + *(int *) (function + 4) = 0x58001018; + *(int *) (function + 8) = 0x5810101C; + *(int *) (function +12) = 0x50001000; + *(int *) (function +16) = 0xA7150002; + *(int *) (function +20) = 0x58101010; + *(int *) (function +24) = 0x07F10707; + *(int *) (function +28) = (unsigned int) data; + *(int *) (function +32) = (unsigned int) variable; + *(int *) (function +36) = (unsigned int) address; +#define TRAMP_CODE_LENGTH 28 +#define is_tramp(function) \ + *(unsigned int *) (function + 0) == 0xA7150002 && \ + *(unsigned int *) (function + 4) == 0x58001018 && \ + *(unsigned int *) (function + 8) == 0x5810101C && \ + *(unsigned int *) (function +12) == 0x50001000 && \ + *(unsigned int *) (function +16) == 0xA7150002 && \ + *(unsigned int *) (function +20) == 0x58101010 && \ + *(unsigned int *) (function +24) == 0x07F10707 +#define tramp_address(function) \ + *(unsigned int *) (function +36) +#define tramp_variable(function) \ + *(unsigned int *) (function +32) +#define tramp_data(function) \ + *(unsigned int *) (function +28) +#endif +#ifdef __s390x__ + /* function: + * larl %r1,.L1 C01000000003 + * .L1: + * lg %r0,data-.L1(%r1) E30010220004 + * lg %r1,variable-.L1(%r1) E310102A0004 + * stg %r0,0(%r1) E30010000024 + * larl %r1,.L2 C01000000003 + * .L2: + * lg %r1,function-.L2(%r1) E310101A0004 + * br %r1 07F1 + * nop 0707 + * data: .quad + * variable: .quad + * address: .quad
+ */ + *(int *) (function + 0) = 0xC0100000; + *(int *) (function + 4) = 0x0003E300; + *(int *) (function + 8) = 0x10220004; + *(int *) (function +12) = 0xE310102A; + *(int *) (function +16) = 0x0004E300; + *(int *) (function +20) = 0x10000024; + *(int *) (function +24) = 0xC0100000; + *(int *) (function +28) = 0x0003E310; + *(int *) (function +32) = 0x101A0004; + *(int *) (function +36) = 0x07F10707; + *(long *) (function +40) = (unsigned long) data; + *(long *) (function +48) = (unsigned long) variable; + *(long *) (function +56) = (unsigned long) address; +#define TRAMP_CODE_LENGTH 40 +#define is_tramp(function) \ + *(unsigned int *) (function + 0) == 0xC0100000 && \ + *(unsigned int *) (function + 4) == 0x0003E300 && \ + *(unsigned int *) (function + 8) == 0x10220004 && \ + *(unsigned int *) (function +12) == 0xE310102A && \ + *(unsigned int *) (function +16) == 0x0004E300 && \ + *(unsigned int *) (function +20) == 0x10000024 && \ + *(unsigned int *) (function +24) == 0xC0100000 && \ + *(unsigned int *) (function +28) == 0x0003E310 && \ + *(unsigned int *) (function +32) == 0x101A0004 && \ + *(unsigned int *) (function +36) == 0x07F10707 +#define tramp_address(function) \ + (*(unsigned long *) (function +56)) +#define tramp_variable(function) \ + (*(unsigned long *) (function +48)) +#define tramp_data(function) \ + (*(unsigned long *) (function +40)) +#endif +#ifdef __riscv32__ + /* function: + * auipc t3,0 00000E17 + * lw t0,24(t3) 018E2283 + * lw t1,28(t3) 01CE2303 + * lw t2,32(t3) 020E2383 + * sw t0,(t1) 00532023 + * jr t2 00038067 + * data: .word + * variable: .word + * address: .word
+ */ + *(int *) (function + 0) = 0x00000E17; + *(int *) (function + 4) = 0x018E2283; + *(int *) (function + 8) = 0x01CE2303; + *(int *) (function +12) = 0x020E2383; + *(int *) (function +16) = 0x00532023; + *(int *) (function +20) = 0x00038067; + *(int *) (function +24) = (unsigned int) data; + *(int *) (function +28) = (unsigned int) variable; + *(int *) (function +32) = (unsigned int) address; +#define TRAMP_CODE_LENGTH 24 +#define is_tramp(function) \ + *(unsigned int *) (function + 0) == 0x00000E17 && \ + *(unsigned int *) (function + 4) == 0x018E2283 && \ + *(unsigned int *) (function + 8) == 0x01CE2303 && \ + *(unsigned int *) (function +12) == 0x020E2383 && \ + *(unsigned int *) (function +16) == 0x00532023 && \ + *(unsigned int *) (function +20) == 0x00038067 +#define tramp_address(function) \ + (*(unsigned int *) (function +32)) +#define tramp_variable(function) \ + (*(unsigned int *) (function +28)) +#define tramp_data(function) \ + (*(unsigned int *) (function +24)) +#endif +#ifdef __riscv64__ + /* function: + * auipc t3,0 00000E17 + * ld t0,24(t3) 018E3283 + * ld t1,32(t3) 020E3303 + * ld t2,40(t3) 028E3383 + * sd t0,(t1) 00533023 + * jr t2 00038067 + * data: .quad + * variable: .quad + * address: .quad
+ */ + *(int *) (function + 0) = 0x00000E17; + *(int *) (function + 4) = 0x018E3283; + *(int *) (function + 8) = 0x020E3303; + *(int *) (function +12) = 0x028E3383; + *(int *) (function +16) = 0x00533023; + *(int *) (function +20) = 0x00038067; + *(long *) (function +24) = (unsigned long) data; + *(long *) (function +32) = (unsigned long) variable; + *(long *) (function +40) = (unsigned long) address; +#define TRAMP_CODE_LENGTH 24 +#define is_tramp(function) \ + *(unsigned int *) (function + 0) == 0x00000E17 && \ + *(unsigned int *) (function + 4) == 0x018E3283 && \ + *(unsigned int *) (function + 8) == 0x020E3303 && \ + *(unsigned int *) (function +12) == 0x028E3383 && \ + *(unsigned int *) (function +16) == 0x00533023 && \ + *(unsigned int *) (function +20) == 0x00038067 +#define tramp_address(function) \ + (*(unsigned long *) (function +40)) +#define tramp_variable(function) \ + (*(unsigned long *) (function +32)) +#define tramp_data(function) \ + (*(unsigned long *) (function +24)) +#endif + + /* 3. Set memory protection to "executable" */ + +#if !defined(CODE_EXECUTABLE) +#if defined(EXECUTABLE_VIA_MALLOC_THEN_MPROTECT) || defined(EXECUTABLE_VIA_MMAP_THEN_MPROTECT) + /* Call mprotect on the pages that contain the range. */ + { uintptr_t start_addr = (uintptr_t) function; + uintptr_t end_addr = (uintptr_t) (function + TRAMP_LENGTH); + start_addr = start_addr & -pagesize; + end_addr = (end_addr + pagesize-1) & -pagesize; + {uintptr_t len = end_addr - start_addr; +#if defined(HAVE_MACH_VM) + if (vm_protect(task_self(),start_addr,len,0,VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE) != KERN_SUCCESS) +#else + if (mprotect((void*)start_addr, len, PROT_READ|PROT_WRITE|PROT_EXEC) < 0) +#endif + { fprintf(stderr,"trampoline: cannot make memory executable\n"); abort(); } + }} +#endif +#endif + + /* 4. Flush instruction cache */ + /* We need this because some CPUs have separate data cache and instruction + * cache. The freshly built trampoline is visible to the data cache, but not + * maybe not to the instruction cache. This is hairy. + */ + /* TRAMP_CODE_LENGTH = length of the machine instructions. */ +#ifndef TRAMP_CODE_LENGTH +#define TRAMP_CODE_LENGTH TRAMP_LENGTH +#endif +#if !(defined(__hppanew__) || defined(__hppa64new__) || defined(__powerpcaix__) || defined(__powerpc64aix__) || defined(__ia64__)) + /* Only needed if we really set up machine instructions. */ +#ifdef __i386__ +#if defined(_WIN32) + while (!FlushInstructionCache(GetCurrentProcess(),function_x,TRAMP_CODE_LENGTH)) + continue; +#endif +#endif +#ifdef __m68k__ +#if defined(__NetBSD__) && defined(__GNUC__) + { register uintptr_t _beg __asm__ ("%a1") = (uintptr_t) function_x; + register uintptr_t _len __asm__ ("%d1") = TRAMP_CODE_LENGTH; + __asm__ __volatile__ ( + "move%.l %#0x80000004,%/d0\n\t" /* CC_EXTPURGE | C_IPURGE */ + "trap #12" /* kernel call ‘cachectl’ */ + : + : "a" (_beg), "d" (_len) + : "%a0", "%a1", "%d0", "%d1" /* call-used registers */ + ); + } +#endif +#if defined(__linux__) && defined(__GNUC__) + { register uintptr_t _beg __asm__ ("%d1") = (uintptr_t) function_x; + register uintptr_t _len __asm__ ("%d4") = TRAMP_CODE_LENGTH + 32; + __asm__ __volatile__ ( + "move%.l %#123,%/d0\n\t" + "move%.l %#1,%/d2\n\t" + "move%.l %#3,%/d3\n\t" + "trap %#0" + : + : "d" (_beg), "d" (_len) + : "%d0", "%d2", "%d3" + ); + } +#endif +#if defined(AUX) && defined(__GNUC__) + /* sysm68k(105, addr, scope, cache, len) */ + __asm__ __volatile__ ( + "move%.l %1,%/sp@-\n\t" + "move%.l %#3,%/sp@-\n\t" + "move%.l %#1,%/sp@-\n\t" + "move%.l %0,%/sp@-\n\t" + "move%.l %#105,%/sp@-\n\t" + "move%.l %#0,%/sp@-\n\t" + "move%.l %#38,%/sp@-\n\t" + "trap %#0\n\t" + "add%.l %#24,%/sp" + : + : "r" (function_x), "g" ((int)TRAMP_CODE_LENGTH) + : "%d0" + ); +#endif +#endif +#if defined(__mips__) || defined(__mipsn32__) || defined(__mips64__) + cacheflush(function_x,TRAMP_CODE_LENGTH,ICACHE); + /* gforth-0.3.0 uses BCACHE instead of ICACHE. Why?? */ +#endif +#if defined(__sparc__) || defined(__sparc64__) + /* This assumes that the trampoline fits in at most four cache lines. */ + __TR_clear_cache_4(function_x,function_x+TRAMP_CODE_LENGTH-1); +#endif +#ifdef __alpha__ + __TR_clear_cache(); +#endif +#if defined(__hppa__) || defined(__hppa64__) + /* This assumes that the trampoline fits in at most two cache lines. */ + __TR_clear_cache(function_x,function_x+TRAMP_CODE_LENGTH-1); +#endif +#if defined(__arm__) || defined(__armhf__) || defined(__arm64__) + /* On ARM, cache flushing can only be done through a system call. + GCC implements it for Linux with EABI, through an "swi 0" with code + 0xf0002. For other systems, it may be an "swi 0x9f0002", + an "swi 0xf00000", or similar. */ + /* On ARM64, cache flushing is done through special instructions, + and the length of the cache lines must be determined at runtime. + See gcc/libgcc/config/aarch64/sync-cache.c. */ +#if defined(__GNUC__) + /* Use the GCC built-in. */ + __clear_cache((void*)function_x,(void*)(function_x+TRAMP_CODE_LENGTH)); +#else + #error "Don't know how to implement clear_cache on this platform." +#endif +#endif +#if defined(__powerpc__) || defined(__powerpc64__) + __TR_clear_cache(function_x); +#endif +#if defined(__riscv32__) || defined(__riscv64__) +#if defined(__linux__) + /* Use the libc function. */ + __riscv_flush_icache((void*)function_x,(void*)(function_x+TRAMP_CODE_LENGTH),0); +#elif defined(__GNUC__) + __asm__ __volatile__ ("fence.i"); +#endif +#endif +#endif + + /* 5. Return. */ + return (trampoline_function_t) (function_x + TRAMP_BIAS); +} + +void free_trampoline (trampoline_function_t function) +{ +#if TRAMP_BIAS + function = (trampoline_function_t)((char*)function - TRAMP_BIAS); +#endif +#if !defined(CODE_EXECUTABLE) && !defined(EXECUTABLE_VIA_MALLOC_THEN_MPROTECT) +#ifdef EXECUTABLE_VIA_MMAP_FILE_SHARED + /* Find the writable address corresponding to the executable address. */ + { uintptr_t page_x = (uintptr_t) function & -(intptr_t)pagesize; + function -= ((intptr_t*)page_x)[0]; + } +#endif + *(char**)function = freelist; freelist = (char*)function; + /* It is probably not worth calling munmap() for entirely freed pages. */ +#else + free(((char**)function)[-1]); +#endif +} + +int is_trampoline (void* function) +{ +#ifdef is_tramp +#ifdef __hppanew__ + void* tramp_address = &tramp; + if (!(((uintptr_t)function & 3) == (TRAMP_BIAS & 3))) return 0; +#endif + return ((is_tramp(((char*)function - TRAMP_BIAS))) ? 1 : 0); +#else + abort(); +#endif +} + +trampoline_function_t trampoline_address (trampoline_function_t function) +{ +#ifdef tramp_address + return (trampoline_function_t)(tramp_address(((char*)function - TRAMP_BIAS))); +#else + abort(); +#endif +} + +void** trampoline_variable (trampoline_function_t function) +{ +#ifdef tramp_variable + return (void**)(tramp_variable(((char*)function - TRAMP_BIAS))); +#else + abort(); +#endif +} + +void* trampoline_data (trampoline_function_t function) +{ +#ifdef tramp_data + return (void*)(tramp_data(((char*)function - TRAMP_BIAS))); +#else + abort(); +#endif +} diff --git a/trampoline/trampoline.h b/trampoline/trampoline.h new file mode 100644 index 0000000..3e93ae3 --- /dev/null +++ b/trampoline/trampoline.h @@ -0,0 +1,85 @@ +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +#ifndef _TRAMPOLINE_H +#define _TRAMPOLINE_H + +#include "ffcall-version.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* This type denotes an opaque function pointer. + You need to cast it to an actual function pointer type (with correct return + type) before you can actually invoke it. */ +#ifdef __cplusplus +typedef int (*trampoline_function_t) (...); +#else +typedef int (*trampoline_function_t) (); +#endif + + +/* Allocates a trampoline. + It returns a function pointer that takes the same parameters and returns the + same type as ADDRESS. + When invoked, it first stores DATA at the location pointed to by VARIABLE, + then invokes ADDRESS with the same arguments. It returns the value returned + by ADDRESS. + The trampoline has indefinite extent. It can be accessed until a call to + free_trampoline(). + */ +extern trampoline_function_t alloc_trampoline (trampoline_function_t /* ADDRESS */, void** /* VARIABLE */, void* /* DATA */); + +/* Frees the memory used by a trampoline. + FUNCTION must be the result of an alloc_trampoline() invocation. + After this call, FUNCTION must not be used any more - neither invoked, + not used as an argument to other functions. + */ +extern void free_trampoline (trampoline_function_t /* FUNCTION */); + + +/* Tests whether a given pointer is a function pointer returned by + alloc_trampoline(). Returns 1 for yes, 0 for no. + If yes, it can be cast to trampoline_function_t. + */ +extern int is_trampoline (void* /* FUNCTION */); + +/* Returns the ADDRESS argument passed to the alloc_trampoline() invocation. + FUNCTION must be the result of an alloc_trampoline() invocation. + */ +extern trampoline_function_t trampoline_address (trampoline_function_t /* FUNCTION */); + +/* Returns the VARIABLE argument passed to the alloc_trampoline() invocation. + FUNCTION must be the result of an alloc_trampoline() invocation. + */ +extern void** trampoline_variable (trampoline_function_t /* FUNCTION */); + +/* Returns the DATA argument passed to the alloc_trampoline() invocation. + FUNCTION must be the result of an alloc_trampoline() invocation. + */ +extern void* trampoline_data (trampoline_function_t /* FUNCTION */); + + +#ifdef __cplusplus +} +#endif + + +#endif /* _TRAMPOLINE_H */ diff --git a/trampoline/trampoline.html b/trampoline/trampoline.html new file mode 100644 index 0000000..ab4be00 --- /dev/null +++ b/trampoline/trampoline.html @@ -0,0 +1,144 @@ + + + + TRAMPOLINE manual page + + +

TRAMPOLINE manual page

+ + +

+ +


+ + +

Name

+
+ +trampoline - closures as first-class C functions + + +

Synopsis

+
+ +
+#include <trampoline.h>
+function = alloc_trampoline(address, variable, data);
+free_trampoline(function);
+is_trampoline(function)
+trampoline_address(function)
+trampoline_variable(function)
+trampoline_data(function)
+
+ + +

Description

+
+ +These functions implement closures as first-class +C functions. A closure consists of a regular C function and a +piece of data which gets passed to the C function when the +closure is called. +

+Closures as first-class C functions means that they fit +into a function pointer and can be called exactly like any +other C function. +function = alloc_trampoline(address, variable, data) +allocates a closure. +When function gets called, it stores +data in the variable variable + and calls the C function at address. +The function at address is responsible for +fetching data out of variable + immediately, before execution of any other function call. +

+This is much like gcc's local functions, except that the +GNU C local functions have dynamic extent (i.e. are +deallocated when the creating function returns), while trampoline + provides functions with indefinite extent: function +is only deallocated when free_trampoline(function) is +called. +

+is_trampoline(function) +checks whether the C function function +was produced by a call to alloc_trampoline. +If this returns true, the arguments given to alloc_trampoline +can be retrieved: +

    +
  • trampoline_address(function) returns address, +
  • trampoline_variable(function) returns variable, +
  • trampoline_data(function) returns data. +
+ + +

See also

+
+gcc(1), stdarg(3), callback(3) + + +

Bugs

+
+ +Passing the data through a global variable is not reentrant. Don't +call trampoline functions from within signal +handlers. This is fixed in the callback(3) package. + + +

Porting

+
+ +The way gcc builds local functions is described in the gcc +source, file gcc-2.6.3/config/cpu/cpu.h. + + +

Author

+
+ +Bruno Haible <bruno@clisp.org> + + +

Acknowledgements

+
+ +Many ideas were cribbed from the gcc source. +

+ +


+ +
TRAMPOLINE manual page
+Bruno Haible <bruno@clisp.org> +
+

+Last modified: 1 January 2017. + + + diff --git a/trampoline/trampoline.man b/trampoline/trampoline.man new file mode 100644 index 0000000..2262814 --- /dev/null +++ b/trampoline/trampoline.man @@ -0,0 +1,75 @@ +TRAMPOLINE(3) Library Functions Manual TRAMPOLINE(3) + + + +NAME + trampoline - closures as first-class C functions + +SYNOPSIS + #include  + + function = alloc_trampoline(address, variable, data); + + free_trampoline(function); + + is_trampoline(function) + trampoline_address(function) + trampoline_variable(function) + trampoline_data(function) + +DESCRIPTION + These functions implement closures as first-class C functions. A clo‐ + sure consists of a regular C function and a piece of data which gets + passed to the C function when the closure is called. + + Closures as first-class C functions means that they fit into a function + pointer and can be called exactly like any other C function. function + = alloc_trampoline(address, variable, data) allocates a closure. When + function gets called, it stores data in the variable variable and calls + the C function at address. The function at address is responsible for + fetching data out of variable immediately, before execution of any + other function call. + + This is much like gcc's local functions, except that the GNU C local + functions have dynamic extent (i.e. are deallocated when the creating + function returns), while trampoline provides functions with indefinite + extent: function is only deallocated when free_trampoline(function) is + called. + + is_trampoline(function) checks whether the C function function was pro‐ + duced by a call to alloc_trampoline. If this returns true, the argu‐ + ments given to alloc_trampoline can be retrieved: + + trampoline_address(function) returns address, + + trampoline_variable(function) returns variable, + + trampoline_data(function) returns data. + + +SEE ALSO + gcc(1), stdarg(3), callback(3) + + +BUGS + Passing the data through a global variable is not reentrant. Don't call + trampoline functions from within signal handlers. This is fixed in the + callback(3) package. + + +PORTING + The way gcc builds local functions is described in the gcc source, file + gcc-2.6.3/config/cpu/cpu.h. + + +AUTHOR + Bruno Haible + + +ACKNOWLEDGEMENTS + Many ideas were cribbed from the gcc source. + + + + + 1 January 2017 TRAMPOLINE(3) diff --git a/vacall/COPYING b/vacall/COPYING new file mode 100644 index 0000000..a3d1815 --- /dev/null +++ b/vacall/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, 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) + + 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/vacall/Makefile.devel b/vacall/Makefile.devel new file mode 100644 index 0000000..3b76a44 --- /dev/null +++ b/vacall/Makefile.devel @@ -0,0 +1,308 @@ +# This is the developer's -*-Makefile-*-, not the user's makefile. +# Do not use it unless you know exactly what you do! + +THISFILE = Makefile.devel +LN = ln -s +RM = rm -f + +# ============ Rules that require cross-compilation tools ============ + +GCC = gcc +GCCFLAGS = -I.. -I../dummy -O2 -fno-omit-frame-pointer +SED = sed +CROSS_TOOL = cross + +precompiled : \ + vacall-i386-macro.S \ + vacall-m68k.mit.S vacall-m68k.motorola.S \ + vacall-mipseb-macro.S vacall-mipsel-macro.S vacall-mipsn32eb-macro.S vacall-mipsn32el-macro.S vacall-mips64eb-macro.S vacall-mips64el-macro.S \ + vacall-sparc-macro.S vacall-sparc64-macro.S \ + vacall-alpha-macro.S \ + vacall-hppa-macro.S vacall-hppa64-macro.S \ + vacall-arm-macro.S vacall-armhf-macro.S \ + vacall-arm64-macro.S \ + vacall-powerpc-aix.s vacall-powerpc-linux-macro.S vacall-powerpc-sysv4-macro.S vacall-powerpc-macos.s vacall-powerpc64-aix.s vacall-powerpc64-linux.S vacall-powerpc64-elfv2-linux.S \ + vacall-ia64-macro.S \ + vacall-x86_64-macro.S vacall-x86_64-x32-linux.s vacall-x86_64-windows-macro.S \ + vacall-s390-macro.S vacall-s390x-macro.S \ + vacall-riscv32-ilp32d-macro.S vacall-riscv64-lp64d-macro.S + + +vacall-i386-linux.s : vacall-i386.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) i386-linux gcc -V 3.1 $(GCCFLAGS) -D__i386__ -S vacall-i386.c -o vacall-i386-linux.s + +vacall-i386-linux-pic.s : vacall-i386.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) i386-linux gcc -V 3.1 $(GCCFLAGS) -fPIC -D__i386__ -S vacall-i386.c -o vacall-i386-linux-pic.s + +vacall-i386-macro.S : vacall-i386-linux.s vacall-i386-linux-pic.s ../common/asm-i386.sh ../common/noexecstack.h $(THISFILE) + (echo '#include "asm-i386.h"' ; echo '#ifdef __PIC__' ; sed -e '/\.align.*,0x90$$/d' < vacall-i386-linux-pic.s | sed -e 's/vacall_function/C(vacall_function)/g' | ../common/asm-i386.sh ; echo '#else' ; sed -e '/\.align.*,0x90$$/d' < vacall-i386-linux.s | sed -e 's/vacall_function/C(vacall_function)/g' | ../common/asm-i386.sh ; echo '#endif' ; cat ../common/noexecstack.h) > vacall-i386-macro.S + + +vacall-m68k-linux.s : vacall-m68k.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) m68k-linux gcc -V 3.1 $(GCCFLAGS) -D__m68k__ -S vacall-m68k.c -o vacall-m68k-linux.s + +vacall-m68k-sun.s : vacall-m68k.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) m68k-sun gcc -V 3.1 $(GCCFLAGS) -D__m68k__ -S vacall-m68k.c -o vacall-m68k-sun.s + +vacall-m68k.mit.S : vacall-m68k-sun.s ../common/asm-m68k.sh ../common/noexecstack.h $(THISFILE) + (echo '#include "asm-m68k.h"' ; ../common/asm-m68k.sh mit < vacall-m68k-sun.s ; cat ../common/noexecstack.h) > vacall-m68k.mit.S + +vacall-m68k.motorola.S : vacall-m68k-linux.s ../common/asm-m68k.sh ../common/noexecstack.h $(THISFILE) + (echo '#include "asm-m68k.h"' ; ../common/asm-m68k.sh motorola < vacall-m68k-linux.s | sed -e 's/vacall_function/C(vacall_function)/g' ; cat ../common/noexecstack.h) > vacall-m68k.motorola.S + + +vacall-mipseb-linux.s : vacall-mips.c vacall-internal.h vacall.h $(THISFILE) +# For references to global symbols: -mno-explicit-relocs ensures a syntax that the IRIX assembler understands. + $(CROSS_TOOL) mips64-linux gcc-5.4.0 -mabi=32 -mfpxx -march=mips2 -meb -mno-explicit-relocs $(GCCFLAGS) -D__mips__ -S vacall-mips.c -o vacall-mipseb-linux.s + +vacall-mipseb-macro.S : vacall-mipseb-linux.s ../common/asm-mips.sh $(THISFILE) + (echo '#include "asm-mips.h"' ; ../common/asm-mips.sh < vacall-mipseb-linux.s) > vacall-mipseb-macro.S + +vacall-mipsel-linux.s : vacall-mips.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) mips64-linux gcc-5.4.0 -mabi=32 -mfpxx -march=mips2 -mel -mno-explicit-relocs $(GCCFLAGS) -D__mips__ -S vacall-mips.c -o vacall-mipsel-linux.s + +vacall-mipsel-macro.S : vacall-mipsel-linux.s ../common/asm-mips.sh $(THISFILE) + (echo '#include "asm-mips.h"' ; ../common/asm-mips.sh < vacall-mipsel-linux.s) > vacall-mipsel-macro.S + +vacall-mipsn32eb-linux.s : vacall-mipsn32.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) mips64-linux gcc-5.4.0 -mabi=n32 -meb $(GCCFLAGS) -D__mipsn32__ -S vacall-mipsn32.c -o vacall-mipsn32eb-linux.s + +vacall-mipsn32eb-macro.S : vacall-mipsn32eb-linux.s ../common/asm-mips.sh $(THISFILE) + (echo '#include "asm-mips.h"' ; ../common/asm-mips.sh < vacall-mipsn32eb-linux.s) > vacall-mipsn32eb-macro.S + +vacall-mipsn32el-linux.s : vacall-mipsn32.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) mips64-linux gcc-5.4.0 -mabi=n32 -mel $(GCCFLAGS) -D__mipsn32__ -S vacall-mipsn32.c -o vacall-mipsn32el-linux.s + +vacall-mipsn32el-macro.S : vacall-mipsn32el-linux.s ../common/asm-mips.sh $(THISFILE) + (echo '#include "asm-mips.h"' ; ../common/asm-mips.sh < vacall-mipsn32el-linux.s) > vacall-mipsn32el-macro.S + +vacall-mips64eb-linux.s : vacall-mips64.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) mips64-linux gcc-5.4.0 -mabi=64 -meb $(GCCFLAGS) -D__mips64__ -S vacall-mips64.c -o vacall-mips64eb-linux.s + +vacall-mips64eb-macro.S : vacall-mips64eb-linux.s ../common/asm-mips.sh $(THISFILE) + (echo '#include "asm-mips.h"' ; ../common/asm-mips.sh < vacall-mips64eb-linux.s) > vacall-mips64eb-macro.S + +vacall-mips64el-linux.s : vacall-mips64.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) mips64-linux gcc-5.4.0 -mabi=64 -mel $(GCCFLAGS) -D__mips64__ -S vacall-mips64.c -o vacall-mips64el-linux.s + +vacall-mips64el-macro.S : vacall-mips64el-linux.s ../common/asm-mips.sh $(THISFILE) + (echo '#include "asm-mips.h"' ; ../common/asm-mips.sh < vacall-mips64el-linux.s) > vacall-mips64el-macro.S + + +vacall-sparc-linux.s : vacall-sparc.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) sparc-linux gcc -V 3.1 $(GCCFLAGS) -D__sparc__ -S vacall-sparc.c -o vacall-sparc-linux.s + +vacall-sparc-linux-pic.s : vacall-sparc.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) sparc-linux gcc -V 3.1 $(GCCFLAGS) -fPIC -D__sparc__ -S vacall-sparc.c -o vacall-sparc-linux-pic.s + +vacall-sparc-macro.S : vacall-sparc-linux.s vacall-sparc-linux-pic.s ../common/asm-sparc.sh ../common/noexecstack.h $(THISFILE) +# For references to global symbols, we need to distinguish the PIC and non-PIC case. +# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81653 + (echo '#include "asm-sparc.h"' ; echo '#ifdef __PIC__' ; ../common/asm-sparc.sh < vacall-sparc-linux-pic.s | sed -e 's/vacall_function/C(vacall_function)/g' ; echo '#else' ; ../common/asm-sparc.sh < vacall-sparc-linux.s | sed -e 's/vacall_function/C(vacall_function)/g' ; echo '#endif' ; cat ../common/noexecstack.h) > vacall-sparc-macro.S + +vacall-sparc64-linux.s : vacall-sparc64.c vacall-internal.h vacall.h $(THISFILE) +# For references to global symbols in non-PIC mode: +# - -mcmodel=medlow uses 2 instructions, but the code does not work on Solaris (error "ld: fatal: relocation error: R_SPARC_HI22"). +# - -mcmodel=medmid uses 3 instructions, but the code still makes some assumptions about the address space. +# - -mcmodel=medany uses 4 instructions. + $(CROSS_TOOL) sparc64-linux gcc -V 4.0.2 -mcmodel=medany $(GCCFLAGS) -D__sparc64__ -S vacall-sparc64.c -o vacall-sparc64-linux.s + +vacall-sparc64-linux-pic.s : vacall-sparc64.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) sparc64-linux gcc -V 4.0.2 $(GCCFLAGS) -fPIC -D__sparc64__ -S vacall-sparc64.c -o vacall-sparc64-linux-pic.s + +vacall-sparc64-macro.S : vacall-sparc64-linux.s vacall-sparc64-linux-pic.s ../common/asm-sparc.sh ../common/noexecstack.h $(THISFILE) +# For references to global symbols, we need to distinguish the PIC and non-PIC case. +# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81653 + (echo '#include "asm-sparc.h"' ; echo '#ifdef __PIC__' ; ../common/asm-sparc.sh < vacall-sparc64-linux-pic.s | sed -e 's/vacall_function/C(vacall_function)/g' ; echo '#else' ; ../common/asm-sparc.sh < vacall-sparc64-linux.s | sed -e 's/vacall_function/C(vacall_function)/g' ; echo '#endif' ; cat ../common/noexecstack.h) > vacall-sparc64-macro.S + + +vacall-alpha-linux.s : vacall-alpha.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) alpha-linux gcc -V 4.0.2 $(GCCFLAGS) -D__alpha__ -S vacall-alpha.c -o vacall-alpha-linux.s + +vacall-alpha-macro.S : vacall-alpha-linux.s ../common/asm-alpha.sh ../common/noexecstack.h $(THISFILE) + (../common/asm-alpha.sh < vacall-alpha-linux.s ; cat ../common/noexecstack.h) > vacall-alpha-macro.S + + +vacall-hppa-linux.s : vacall-hppa.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) hppa-linux gcc -V 3.1 $(GCCFLAGS) -D__hppa__ -S vacall-hppa.c -o vacall-hppa-linux.s + +vacall-hppa-macro.S : vacall-hppa-linux.s ../common/asm-hppa.sh ../common/noexecstack.h $(THISFILE) + (echo '#include "asm-hppa.h"' ; ../common/asm-hppa.sh < vacall-hppa-linux.s ; echo 'IMPORT_DATA(vacall_function)' ; cat ../common/noexecstack.h) > vacall-hppa-macro.S + +vacall-hppa64-linux.s : vacall-hppa64.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) hppa64-linux gcc -V 3.1 $(GCCFLAGS) -D__hppa64__ -S vacall-hppa64.c -o vacall-hppa64-linux.s + +vacall-hppa64-macro.S : vacall-hppa64-linux.s ../common/asm-hppa64.sh ../common/noexecstack.h $(THISFILE) + (echo '#include "asm-hppa64.h"' ; ../common/asm-hppa64.sh < vacall-hppa64-linux.s ; echo 'IMPORT_DATA(vacall_function)' ; cat ../common/noexecstack.h) > vacall-hppa64-macro.S + + +vacall-arm-linux.s : vacall-arm.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) arm-linux gcc -V 3.1 -mlittle-endian $(GCCFLAGS) -D__arm__ -S vacall-arm.c -o vacall-armel.s + $(CROSS_TOOL) arm-linux gcc -V 3.1 -mbig-endian $(GCCFLAGS) -D__arm__ -S vacall-arm.c -o vacall-armeb.s + cmp vacall-armel.s vacall-armeb.s > /dev/null + cp vacall-armel.s vacall-arm-linux.s + $(RM) vacall-armel.s vacall-armeb.s + +vacall-arm-linux-pic.s : vacall-arm.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) arm-linux gcc -V 3.1 -mlittle-endian $(GCCFLAGS) -fPIC -D__arm__ -S vacall-arm.c -o vacall-armel-pic.s + $(CROSS_TOOL) arm-linux gcc -V 3.1 -mbig-endian $(GCCFLAGS) -fPIC -D__arm__ -S vacall-arm.c -o vacall-armeb-pic.s + cmp vacall-armel-pic.s vacall-armeb-pic.s > /dev/null + cp vacall-armel-pic.s vacall-arm-linux-pic.s + $(RM) vacall-armel-pic.s vacall-armeb-pic.s + +vacall-arm-macro.S : vacall-arm-linux.s vacall-arm-linux-pic.s ../common/asm-arm.sh ../common/noexecstack-arm.h $(THISFILE) + (echo '#include "asm-arm.h"' ; echo '#ifdef __PIC__' ; ../common/asm-arm.sh < vacall-arm-linux-pic.s | sed -e 's/vacall_function/C(vacall_function)/g' ; echo '#else' ; ../common/asm-arm.sh < vacall-arm-linux.s | sed -e 's/vacall_function/C(vacall_function)/g' ; echo '#endif' ; cat ../common/noexecstack-arm.h) > vacall-arm-macro.S + +vacall-armhf-linux.s : vacall-armhf.c vacall-internal.h vacall.h $(THISFILE) +# The option -mabi=aapcs ensures an 8-bytes-aligned stack pointer. + $(CROSS_TOOL) armv7l-linux-gnueabihf gcc-6.3.0 -march=armv6 -mabi=aapcs -mfloat-abi=hard -mlittle-endian $(GCCFLAGS) -D__armhf__ -S vacall-armhf.c -o vacall-armhfel.s + $(CROSS_TOOL) armv7l-linux-gnueabihf gcc-6.3.0 -march=armv6 -mabi=aapcs -mfloat-abi=hard -mbig-endian $(GCCFLAGS) -D__armhf__ -S vacall-armhf.c -o vacall-armhfeb.s + cmp vacall-armhfel.s vacall-armhfeb.s > /dev/null + cp vacall-armhfel.s vacall-armhf-linux.s + $(RM) vacall-armhfel.s vacall-armhfeb.s + +vacall-armhf-linux-pic.s : vacall-armhf.c vacall-internal.h vacall.h $(THISFILE) +# The option -mabi=aapcs ensures an 8-bytes-aligned stack pointer. + $(CROSS_TOOL) armv7l-linux-gnueabihf gcc-6.3.0 -march=armv6 -mabi=aapcs -mfloat-abi=hard -mlittle-endian $(GCCFLAGS) -fPIC -D__armhf__ -S vacall-armhf.c -o vacall-armhfel-pic.s + $(CROSS_TOOL) armv7l-linux-gnueabihf gcc-6.3.0 -march=armv6 -mabi=aapcs -mfloat-abi=hard -mbig-endian $(GCCFLAGS) -fPIC -D__armhf__ -S vacall-armhf.c -o vacall-armhfeb-pic.s + cmp vacall-armhfel-pic.s vacall-armhfeb-pic.s > /dev/null + cp vacall-armhfel-pic.s vacall-armhf-linux-pic.s + $(RM) vacall-armhfel-pic.s vacall-armhfeb-pic.s + +vacall-armhf-macro.S : vacall-armhf-linux.s vacall-armhf-linux-pic.s ../common/asm-arm.sh ../common/noexecstack-arm.h $(THISFILE) + (echo '#include "asm-arm.h"' ; echo '#ifdef __PIC__' ; ../common/asm-arm.sh < vacall-armhf-linux-pic.s | sed -e 's/vacall_function/C(vacall_function)/g' ; echo '#else' ; ../common/asm-arm.sh < vacall-armhf-linux.s | sed -e 's/vacall_function/C(vacall_function)/g' ; echo '#endif' ; cat ../common/noexecstack-arm.h) > vacall-armhf-macro.S + + +vacall-arm64-macro.S : vacall-arm64.c vacall-internal.h vacall.h ../common/asm-arm.sh ../common/noexecstack-arm.h $(THISFILE) + $(CROSS_TOOL) aarch64-linux gcc-5.4.0 -mlittle-endian $(GCCFLAGS) -D__arm64__ -S vacall-arm64.c -o vacall-arm64el.s + $(CROSS_TOOL) aarch64-linux gcc-5.4.0 -mbig-endian $(GCCFLAGS) -D__arm64__ -S vacall-arm64.c -o vacall-arm64eb.s + cmp vacall-arm64el.s vacall-arm64eb.s > /dev/null + (echo '#include "asm-arm.h"' ; ../common/asm-arm.sh < vacall-arm64el.s ; cat ../common/noexecstack-arm.h) > vacall-arm64-macro.S + $(RM) vacall-arm64el.s vacall-arm64eb.s + + +vacall-powerpc-aix.s : vacall-powerpc.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) rs6000-aix gcc -V 3.3.6 -mno-power -mno-power2 -mno-powerpc -mnew-mnemonics $(GCCFLAGS) -D__powerpc__ -S vacall-powerpc.c -o vacall-powerpc-aix.s + echo ' .extern vacall_function[RW]' >> vacall-powerpc-aix.s + +vacall-powerpc-linux.s : vacall-powerpc.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) powerpc-linux gcc -V 3.3.6 -mno-power -mno-power2 -mno-powerpc $(GCCFLAGS) -D__powerpc__ -S vacall-powerpc.c -o vacall-powerpc-linux.s + +vacall-powerpc-linux-macro.S : vacall-powerpc-linux.s ../common/asm-powerpc.sh ../common/noexecstack.h $(THISFILE) + (../common/asm-powerpc.sh < vacall-powerpc-linux.s ; cat ../common/noexecstack.h) > vacall-powerpc-linux-macro.S + +vacall-powerpc-sysv4-macro.S : vacall-powerpc.c vacall-internal.h vacall.h ../common/asm-powerpc.sh ../common/noexecstack.h $(THISFILE) + $(CROSS_TOOL) powerpc-linux gcc -V 3.3.6 -mno-power -mno-power2 -mno-powerpc $(GCCFLAGS) -D__powerpc__ -S vacall-powerpc.c -o vacall-powerpc-sysv4.s + (../common/asm-powerpc.sh < vacall-powerpc-sysv4.s ; cat ../common/noexecstack.h) > vacall-powerpc-sysv4-macro.S + $(RM) vacall-powerpc-sysv4.s + +vacall-powerpc-macos.s : vacall-powerpc.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) powerpc-darwin gcc -V 3.3.6 $(GCCFLAGS) -D__powerpc__ -S vacall-powerpc.c -o vacall-powerpc-macos.s + +vacall-powerpc64-aix.s : vacall-powerpc64.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) rs6000-aix6.1 gcc-5.4.0 -maix64 $(GCCFLAGS) -D__powerpc64__ -S vacall-powerpc64.c -o vacall-powerpc64-aix.s + echo ' .extern vacall_function[UA]' >> vacall-powerpc64-aix.s + +vacall-powerpc64-linux.S : vacall-powerpc64.c vacall-internal.h vacall.h ../common/asm-powerpc.sh ../common/noexecstack.h $(THISFILE) + $(CROSS_TOOL) powerpc64le-linux gcc-5.4.0 -mabi=elfv1 -mcpu=power4 -mlittle-endian $(GCCFLAGS) -D__powerpc64__ -S vacall-powerpc64.c -o vacall-powerpc64-linux-le.s + $(CROSS_TOOL) powerpc64le-linux gcc-5.4.0 -mabi=elfv1 -mcpu=power4 -mbig-endian $(GCCFLAGS) -D__powerpc64__ -S vacall-powerpc64.c -o vacall-powerpc64-linux-be.s + cmp vacall-powerpc64-linux-le.s vacall-powerpc64-linux-be.s > /dev/null + (../common/asm-powerpc.sh < vacall-powerpc64-linux-be.s ; cat ../common/noexecstack.h) > vacall-powerpc64-linux.S + $(RM) vacall-powerpc64-linux-le.s vacall-powerpc64-linux-be.s + +vacall-powerpc64-elfv2-linux.S : vacall-powerpc64.c vacall-internal.h vacall.h ../common/asm-powerpc.sh ../common/noexecstack.h $(THISFILE) + $(CROSS_TOOL) powerpc64le-linux gcc-5.4.0 -mabi=elfv2 -mcpu=power4 -mlittle-endian $(GCCFLAGS) -D__powerpc64__ -D__powerpc64_elfv2__ -S vacall-powerpc64.c -o vacall-powerpc64-elfv2-linux-le.s + $(CROSS_TOOL) powerpc64le-linux gcc-5.4.0 -mabi=elfv2 -mcpu=power4 -mbig-endian $(GCCFLAGS) -D__powerpc64__ -D__powerpc64_elfv2__ -S vacall-powerpc64.c -o vacall-powerpc64-elfv2-linux-be.s +# vacall-powerpc64-elfv2-linux-be.s contains endianness specific optimizations. + (../common/asm-powerpc.sh < vacall-powerpc64-elfv2-linux-le.s ; cat ../common/noexecstack.h) > vacall-powerpc64-elfv2-linux.S + $(RM) vacall-powerpc64-elfv2-linux-le.s vacall-powerpc64-elfv2-linux-be.s + + +vacall-ia64-linux.s : vacall-ia64.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) ia64-linux gcc -V 4.0.1 $(GCCFLAGS) -D__ia64__ -S vacall-ia64.c -o vacall-ia64-linux.s + +vacall-ia64-macro.S : vacall-ia64-linux.s ../common/noexecstack.h $(THISFILE) + cat vacall-ia64-linux.s ../common/noexecstack.h > vacall-ia64-macro.S + + +vacall-x86_64-linux.s : vacall-x86_64.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) x86_64-linux gcc-4.0.2 $(GCCFLAGS) -D__x86_64__ -S vacall-x86_64.c -o vacall-x86_64-linux.s + +vacall-x86_64-macro.S : vacall-x86_64-linux.s ../common/asm-x86_64.sh ../common/noexecstack.h $(THISFILE) + (echo '#include "asm-x86_64.h"' ; ../common/asm-x86_64.sh < vacall-x86_64-linux.s ; cat ../common/noexecstack.h) > vacall-x86_64-macro.S + +vacall-x86_64-x32-linux.s : vacall-x86_64.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) x86_64-linux gcc-5.4.0 -mx32 $(GCCFLAGS) -D__x86_64__ -D__x86_64_x32__ -S vacall-x86_64.c -o vacall-x86_64-x32-linux.s + +vacall-x86_64-windows.s : vacall-x86_64-windows.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) x86_64-linux gcc-5.4.0 -mabi=ms $(GCCFLAGS) -fno-reorder-blocks-and-partition -D__x86_64__ -D_WIN32 -S vacall-x86_64-windows.c -o vacall-x86_64-windows.s + +vacall-x86_64-windows-macro.S : vacall-x86_64-windows.s ../common/asm-x86_64.sh ../common/noexecstack.h $(THISFILE) + (echo '#include "asm-x86_64.h"' ; ../common/asm-x86_64.sh < vacall-x86_64-windows.s ; cat ../common/noexecstack.h) > vacall-x86_64-windows-macro.S + + +vacall-s390-linux.s : vacall-s390.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) s390-linux gcc -V 3.1 $(GCCFLAGS) -D__s390__ -S vacall-s390.c -o vacall-s390-linux.s + +vacall-s390-macro.S : vacall-s390-linux.s ../common/asm-s390.sh ../common/noexecstack.h $(THISFILE) + (../common/asm-s390.sh < vacall-s390-linux.s ; cat ../common/noexecstack.h) > vacall-s390-macro.S + + +vacall-s390x-linux.s : vacall-s390x.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) s390x-linux gcc-5.4.0 $(GCCFLAGS) -D__s390x__ -S vacall-s390x.c -o vacall-s390x-linux.s + +vacall-s390x-macro.S : vacall-s390x-linux.s ../common/asm-s390.sh ../common/noexecstack.h $(THISFILE) + (../common/asm-s390.sh < vacall-s390x-linux.s ; cat ../common/noexecstack.h) > vacall-s390x-macro.S + + +vacall-riscv32-ilp32d-linux.s : vacall-riscv32.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) riscv32-linux gcc-7.3.0 $(GCCFLAGS) -D__riscv32__ -S vacall-riscv32.c -o vacall-riscv32-ilp32d-linux.s + +vacall-riscv32-ilp32d-macro.S : vacall-riscv32-ilp32d-linux.s ../common/asm-riscv.sh ../common/noexecstack.h $(THISFILE) + (../common/asm-riscv.sh < vacall-riscv32-ilp32d-linux.s ; cat ../common/noexecstack.h) > vacall-riscv32-ilp32d-macro.S + + +vacall-riscv64-lp64d-linux.s : vacall-riscv64.c vacall-internal.h vacall.h $(THISFILE) + $(CROSS_TOOL) riscv64-linux gcc-7.3.0 $(GCCFLAGS) -D__riscv64__ -S vacall-riscv64.c -o vacall-riscv64-lp64d-linux.s + +vacall-riscv64-lp64d-macro.S : vacall-riscv64-lp64d-linux.s ../common/asm-riscv.sh ../common/noexecstack.h $(THISFILE) + (../common/asm-riscv.sh < vacall-riscv64-lp64d-linux.s ; cat ../common/noexecstack.h) > vacall-riscv64-lp64d-macro.S + + +# --------------- Rules for debugging test failures --------------- + +tests : tests-i386.s tests-m68k.s tests-mips.s tests-sparc.s tests-alpha.s tests-hppa.s tests-arm.s tests-powerpc.s tests-powerpc64.s tests-ia64.s tests-x86_64.s + true + +tests-i386.s : tests.c vacall.h + $(GCC) -V 2.7.2 -b i486-linuxaout $(GCCFLAGS) -I/usr/include -D__i386__ -S tests.c -o tests-i386.s + +tests-m68k.s : tests.c vacall.h + $(GCC) -V 2.95.2 -b m68k-sun $(GCCFLAGS) -I/usr/include -D__m68k__ -S tests.c -o tests-m68k.s + +tests-mips.s : tests.c vacall.h + $(GCC) -V 2.95.2 -b mips-sgi $(GCCFLAGS) -I/usr/include -D__mips__ -S tests.c -o tests-mips.s + +tests-sparc.s : tests.c vacall.h + $(GCC) -V 2.95.2 -b sparc-sun $(GCCFLAGS) -I/usr/include -D__sparc__ -S tests.c -o tests-sparc.s + +tests-alpha.s : tests.c vacall.h + $(GCC) -V 2.7.2 -b alpha-dec-osf $(GCCFLAGS) -I/usr/include -D__alpha__ -S tests.c -o tests-alpha.s + +tests-hppa.s : tests.c vacall.h + $(GCC) -V 2.6.3 -b hppa1.0-hpux $(GCCFLAGS) -I/usr/include -D__hppa__ -S tests.c -o tests-hppa.s + +tests-arm.s : tests.c vacall.h + $(GCC) -V 2.6.3 -b arm-acorn-riscix $(GCCFLAGS) -I/usr/include -D__arm__ -S tests.c -o tests-arm.s + +tests-powerpc.s : tests.c vacall.h + $(GCC) -V 2.95.2 -b rs6000 $(GCCFLAGS) -I/usr/include -D__powerpc__ -S tests.c -o tests-powerpc.s + +tests-powerpc64.s : tests.c vacall.h + /cross/powerpc64-linux-tools/bin/powerpc64-linux-gcc $(GCCFLAGS) -I/usr/include -D__powerpc64__ -S tests.c -o tests-powerpc64.s + +tests-ia64.s : tests.c vacall.h + $(GCC) -V 2.9-ia64-000216 -b ia64-hp-linux $(GCCFLAGS) -I/usr/include -D__ia64__ -S tests.c -o tests-ia64.s + +tests-x86_64.s : tests.c vacall.h + $(GCC) -V 3.2.2 -b x86_64-suse-linux $(GCCFLAGS) -I/usr/include -D__x86_64__ -S tests.c -o tests-x86_64.s diff --git a/vacall/Makefile.in b/vacall/Makefile.in new file mode 100644 index 0000000..bd6d4bd --- /dev/null +++ b/vacall/Makefile.in @@ -0,0 +1,380 @@ +# Makefile for vacall + +#### Start of system configuration section. #### + +HOST = @host@ +CPU = @HOST_CPU_C_ABI@ +OS = @host_os@ + +# Directories used by "make": +srcdir = @srcdir@ + +# Directories used by "make install": +prefix = @prefix@ +local_prefix = /usr/local +exec_prefix = @exec_prefix@ +libdir = @libdir@ +includedir = @includedir@ +mandir = @mandir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +htmldir = $(datadir)/html + +# Programs used by "make": +# C compiler +CC = @CC@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +# C++ compiler +CXX = @CXX@ +CXXFLAGS = @CXXFLAGS@ +# Both C and C++ compiler +CPPFLAGS = @CPPFLAGS@ +INCLUDES = -I. -I$(srcdir) -I.. -I$(srcdir)/.. +INCLUDES_WITH_GNULIB = $(INCLUDES) -I../gnulib-lib -I$(srcdir)/../gnulib-lib +ASPFLAGS = `if test @AS_UNDERSCORE@ = true; then echo '-DASM_UNDERSCORE'; fi` +LDFLAGS = @LDFLAGS@ +AR = @AR@ +AR_FLAGS = rc +RANLIB = @RANLIB@ +MV = mv +LN = @LN@ +RM = rm -f +@SET_MAKE@ + +# Programs used by "make install": +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ + +#### End of system configuration section. #### + +SHELL = /bin/sh + +OBJECTS = vacall.@OBJEXT@ vacall-libapi.@OBJEXT@ vacall-structcpy.@OBJEXT@ + +all : $(OBJECTS) libvacall.a $(srcdir)/vacall.3 $(srcdir)/vacall.html + +vacall.@OBJEXT@ : vacall-$(CPU).@OBJEXT@ + $(RM) vacall.@OBJEXT@ + $(LN) vacall-$(CPU).@OBJEXT@ vacall.@OBJEXT@ + +@IFNOT_MSVC@vacall-i386.@OBJEXT@ : vacall-i386.s +@IFNOT_MSVC@ $(CC) @GCC_X_NONE@ -c vacall-i386.s + +@IFNOT_MSVC@vacall-i386.s : $(srcdir)/vacall-i386-macro.S +@IFNOT_MSVC@ $(CPP) $(ASPFLAGS) -I$(srcdir)/../common - < $(srcdir)/vacall-i386-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,\. ,.,g' -e 's,@ ,@,g' -e 's,//.*$$,,' -e 's/##//g' > vacall-i386.s + +@IF_MSVC@vacall-i386.@OBJEXT@ : $(srcdir)/vacall-i386-msvc.c +@IF_MSVC@ $(CC) $(INCLUDES) -I$(srcdir)/../common $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/vacall-i386-msvc.c -o vacall-i386.@OBJEXT@ + +vacall-sparc.@OBJEXT@ : vacall-sparc.s + $(CC) @WORKAROUND_BUG_81653@ @GCC_X_NONE@ -c vacall-sparc.s + +vacall-sparc.s : $(srcdir)/vacall-sparc-macro.S + $(CPP) @WORKAROUND_BUG_81653@ $(ASPFLAGS) -I$(srcdir)/../common - < $(srcdir)/vacall-sparc-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,\. ,.,g' -e 's,//.*$$,,' -e 's,\$$,#,g' -e 's,# ,#,g' > vacall-sparc.s + +vacall-sparc64.@OBJEXT@ : vacall-sparc64.s + $(CC) @GCC_X_NONE@ -c vacall-sparc64.s + +vacall-sparc64.s : $(srcdir)/vacall-sparc64-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../common - < $(srcdir)/vacall-sparc64-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,\. ,.,g' -e 's,//.*$$,,' -e 's,\$$,#,g' -e 's,# ,#,g' > vacall-sparc64.s + +vacall-m68k.@OBJEXT@ : vacall-m68k.s + $(CC) @GCC_X_NONE@ -c vacall-m68k.s + +vacall-m68k.s : $(srcdir)/vacall-m68k.mit.S $(srcdir)/vacall-m68k.motorola.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../common $(srcdir)/vacall-m68k.motorola.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' | if test @AS_UNDERSCORE@ = true; then sed -e 's/\$$//g'; else sed -e 's/\$$/%/g'; fi > vacall-m68k.s + +vacall-mips.@OBJEXT@ : vacall-mips.s + $(CC) @GCC_X_NONE@ -c vacall-mips.s + +vacall-mips.s : $(srcdir)/vacall-mips@ENDIANNESS@-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../common $(srcdir)/vacall-mips@ENDIANNESS@-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > vacall-mips.s + +vacall-mipsn32.@OBJEXT@ : vacall-mipsn32.s + $(CC) @GCC_X_NONE@ -c vacall-mipsn32.s + +vacall-mipsn32.s : $(srcdir)/vacall-mipsn32@ENDIANNESS@-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../common $(srcdir)/vacall-mipsn32@ENDIANNESS@-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > vacall-mipsn32.s + +vacall-mips64.@OBJEXT@ : vacall-mips64.s + $(CC) @GCC_X_NONE@ -c vacall-mips64.s + +vacall-mips64.s : $(srcdir)/vacall-mips64@ENDIANNESS@-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../common $(srcdir)/vacall-mips64@ENDIANNESS@-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > vacall-mips64.s + +vacall-alpha.@OBJEXT@ : vacall-alpha.s + $(CC) @GCC_X_NONE@ -c vacall-alpha.s + +vacall-alpha.s : $(srcdir)/vacall-alpha-macro.S + $(CPP) $(ASPFLAGS) $(srcdir)/vacall-alpha-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > vacall-alpha.s + +vacall-hppa.@OBJEXT@ : vacall-hppa.s + $(CC) @GCC_X_NONE@ -c vacall-hppa.s + +vacall-hppa.s : $(srcdir)/vacall-hppa-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../common $(srcdir)/vacall-hppa-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e "s,!,',g" > vacall-hppa.s + +vacall-hppa64.@OBJEXT@ : vacall-hppa64.s + $(CC) @GCC_X_NONE@ -c vacall-hppa64.s + +vacall-hppa64.s : $(srcdir)/vacall-hppa64-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../common $(srcdir)/vacall-hppa64-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e "s,!,',g" > vacall-hppa64.s + +vacall-arm.@OBJEXT@ : vacall-arm.s + $(CC) @GCC_X_NONE@ -c vacall-arm.s + +vacall-arm.s : $(srcdir)/vacall-arm-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../common $(srcdir)/vacall-arm-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//,@,g' -e 's,\$$,#,g' > vacall-arm.s + +vacall-armhf.@OBJEXT@ : vacall-armhf.s + $(CC) @GCC_X_NONE@ -c vacall-armhf.s + +vacall-armhf.s : $(srcdir)/vacall-armhf-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../common $(srcdir)/vacall-armhf-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//,@,g' -e 's,\$$,#,g' > vacall-armhf.s + +vacall-arm64.@OBJEXT@ : vacall-arm64.s + $(CC) @GCC_X_NONE@ -c vacall-arm64.s + +vacall-arm64.s : $(srcdir)/vacall-arm64-macro.S + $(CPP) $(ASPFLAGS) -I$(srcdir)/../common $(srcdir)/vacall-arm64-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//,@,g' -e 's,\$$,#,g' > vacall-arm64.s + +vacall-powerpc.@OBJEXT@ : vacall-powerpc.s + $(CC) @GCC_X_NONE@ -c vacall-powerpc.s + +vacall-powerpc.s : $(srcdir)/vacall-powerpc-aix.s $(srcdir)/vacall-powerpc-linux-macro.S $(srcdir)/vacall-powerpc-macos.s $(srcdir)/vacall-powerpc-sysv4-macro.S + case "$(OS)" in \ + aix*) syntax=aix;; \ + linux* | netbsd* | openbsd*) syntax=linux;; \ + macos* | darwin*) syntax=macos;; \ + *) syntax=sysv4;; \ + esac; \ + case $${syntax} in \ + macos) \ + grep -v '\.machine' $(srcdir)/vacall-powerpc-$${syntax}.s > vacall-powerpc.s || exit 1 ;; \ + linux | sysv4) \ + $(CPP) $(ASPFLAGS) $(srcdir)/vacall-powerpc-$${syntax}-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > vacall-powerpc.s || exit 1 ;; \ + *) \ + cp $(srcdir)/vacall-powerpc-$${syntax}.s vacall-powerpc.s || exit 1 ;; \ + esac + +vacall-powerpc64.@OBJEXT@ : vacall-powerpc64.s + $(CC) @GCC_X_NONE@ -c vacall-powerpc64.s + +vacall-powerpc64.s : $(srcdir)/vacall-powerpc64-aix.s $(srcdir)/vacall-powerpc64-linux.S + case "$(OS)" in \ + aix*) syntax=aix;; \ + *) syntax=linux;; \ + esac; \ + case $${syntax} in \ + linux) \ + $(CPP) $(ASPFLAGS) $(srcdir)/vacall-powerpc64-$${syntax}.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > vacall-powerpc64.s || exit 1 ;; \ + *) \ + cp $(srcdir)/vacall-powerpc64-$${syntax}.s vacall-powerpc64.s || exit 1 ;; \ + esac + +vacall-powerpc64-elfv2.@OBJEXT@ : vacall-powerpc64-elfv2.s + $(CC) @GCC_X_NONE@ -c vacall-powerpc64-elfv2.s + +vacall-powerpc64-elfv2.s : $(srcdir)/vacall-powerpc64-elfv2-linux.S + $(CPP) $(ASPFLAGS) $(srcdir)/vacall-powerpc64-elfv2-linux.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > vacall-powerpc64-elfv2.s + +vacall-ia64.@OBJEXT@ : vacall-ia64.s + $(CC) @GCC_X_NONE@ -c vacall-ia64.s + +vacall-ia64.s : $(srcdir)/vacall-ia64-macro.S + $(CPP) $(ASPFLAGS) $(srcdir)/vacall-ia64-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > vacall-ia64.s + +@IFNOT_MSVC@vacall-x86_64.@OBJEXT@ : vacall-x86_64.s +@IFNOT_MSVC@ $(CC) @GCC_X_NONE@ -c vacall-x86_64.s + +@IFNOT_MSVC@vacall-x86_64.s : $(srcdir)/vacall-x86_64-macro.S $(srcdir)/vacall-x86_64-windows-macro.S +@IFNOT_MSVC@ case "$(OS)" in \ +@IFNOT_MSVC@ cygwin* | mingw*) variant='-windows';; \ +@IFNOT_MSVC@ *) variant='';; \ +@IFNOT_MSVC@ esac; \ +@IFNOT_MSVC@ $(CPP) $(ASPFLAGS) -I$(srcdir)/../common - < $(srcdir)/vacall-x86_64$${variant}-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,\. ,.,g' -e 's,@ ,@,g' -e 's,//.*$$,,' -e 's/##//g' > vacall-x86_64.s + +@IF_MSVC@vacall-x86_64.@OBJEXT@ : vacall-x86_64.asm +@IF_MSVC@ ml64 -c -nologo vacall-x86_64.asm + +@IF_MSVC@vacall-x86_64.asm : $(srcdir)/vacall-x86_64-windows-macro.S +@IF_MSVC@ { echo 'EXTERNDEF vacall_function:QWORD'; $(CPP) $(ASPFLAGS) -I$(srcdir)/../common $(srcdir)/vacall-x86_64-windows-macro.S | grep -v '^#'; echo 'END'; } > vacall-x86_64.asm + +vacall-x86_64-x32.@OBJEXT@ : vacall-x86_64-x32.s + $(CC) @GCC_X_NONE@ -c vacall-x86_64-x32.s + +vacall-x86_64-x32.s : $(srcdir)/vacall-x86_64-x32-linux.s + cp $(srcdir)/vacall-x86_64-x32-linux.s vacall-x86_64-x32.s + +vacall-s390.@OBJEXT@ : vacall-s390.s + $(CC) @GCC_X_NONE@ -c vacall-s390.s + +vacall-s390.s : $(srcdir)/vacall-s390-macro.S + $(CPP) $(ASPFLAGS) $(srcdir)/vacall-s390-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > vacall-s390.s + +vacall-s390x.@OBJEXT@ : vacall-s390x.s + $(CC) @GCC_X_NONE@ -c vacall-s390x.s + +vacall-s390x.s : $(srcdir)/vacall-s390x-macro.S + $(CPP) $(ASPFLAGS) $(srcdir)/vacall-s390x-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > vacall-s390x.s + +vacall-riscv32-ilp32d.@OBJEXT@ : vacall-riscv32-ilp32d.s + $(CC) @GCC_X_NONE@ -c vacall-riscv32-ilp32d.s + +vacall-riscv32-ilp32d.s : $(srcdir)/vacall-riscv32-ilp32d-macro.S + $(CPP) $(ASPFLAGS) $(srcdir)/vacall-riscv32-ilp32d-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > vacall-riscv32-ilp32d.s + +vacall-riscv64-lp64d.@OBJEXT@ : vacall-riscv64-lp64d.s + $(CC) @GCC_X_NONE@ -c vacall-riscv64-lp64d.s + +vacall-riscv64-lp64d.s : $(srcdir)/vacall-riscv64-lp64d-macro.S + $(CPP) $(ASPFLAGS) $(srcdir)/vacall-riscv64-lp64d-macro.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' > vacall-riscv64-lp64d.s + +vacall-libapi.@OBJEXT@ : $(srcdir)/vacall-libapi.c $(srcdir)/vacall-internal.h $(srcdir)/vacall.h ../config.h + $(CC) $(INCLUDES_WITH_GNULIB) $(CPPFLAGS) $(CFLAGS) @DISABLE_TYPE_BASED_ALIASING@ -c $(srcdir)/vacall-libapi.c + +vacall-structcpy.@OBJEXT@ : $(srcdir)/vacall-structcpy.c $(srcdir)/../common/structcpy.c + $(CC) -I$(srcdir)/../common $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/vacall-structcpy.c + +libvacall.a : $(OBJECTS) + $(RM) libvacall.a + $(AR) $(AR_FLAGS) libvacall.a $(OBJECTS) + $(RANLIB) libvacall.a + +install : all force + mkdir -p $(DESTDIR)$(prefix) + mkdir -p $(DESTDIR)$(exec_prefix) + mkdir -p $(DESTDIR)$(libdir) + $(INSTALL_DATA) libvacall.a $(DESTDIR)$(libdir)/libvacall.a + mkdir -p $(DESTDIR)$(includedir) + $(INSTALL_DATA) $(srcdir)/vacall.h $(DESTDIR)$(includedir)/vacall.h + mkdir -p $(DESTDIR)$(mandir) + mkdir -p $(DESTDIR)$(mandir)/man3 + $(INSTALL_DATA) $(srcdir)/vacall.3 $(DESTDIR)$(mandir)/man3/vacall.3 + mkdir -p $(DESTDIR)$(datadir) + mkdir -p $(DESTDIR)$(htmldir) + $(INSTALL_DATA) $(srcdir)/vacall.html $(DESTDIR)$(htmldir)/vacall.html + +installdirs : force + mkdir -p $(DESTDIR)$(prefix) + mkdir -p $(DESTDIR)$(exec_prefix) + mkdir -p $(DESTDIR)$(libdir) + mkdir -p $(DESTDIR)$(includedir) + mkdir -p $(DESTDIR)$(mandir) + mkdir -p $(DESTDIR)$(mandir)/man3 + mkdir -p $(DESTDIR)$(datadir) + mkdir -p $(DESTDIR)$(htmldir) + +uninstall : force + $(RM) $(DESTDIR)$(libdir)/libvacall.a + $(RM) $(DESTDIR)$(includedir)/vacall.h + $(RM) $(DESTDIR)$(mandir)/man3/vacall.3 + $(RM) $(DESTDIR)$(htmldir)/vacall.html + +minitests.@OBJEXT@ : $(srcdir)/minitests.c $(srcdir)/tests.c $(srcdir)/vacall.h + $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/minitests.c + +minitests.s : $(srcdir)/minitests.c $(srcdir)/tests.c $(srcdir)/vacall.h + $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -S $(srcdir)/minitests.c + +minitests : minitests.@OBJEXT@ libvacall.a + $(CC) $(CFLAGS) @GCC_X_NONE@ minitests.@OBJEXT@ libvacall.a $(LDFLAGS) -o minitests + +minitests-c++.@OBJEXT@ : $(srcdir)/minitests-c++.cc $(srcdir)/minitests.c $(srcdir)/tests.c $(srcdir)/vacall.h + $(CXX) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS) -c $(srcdir)/minitests-c++.cc + +minitests-c++ : minitests-c++.@OBJEXT@ libvacall.a + $(CXX) $(CXXFLAGS) @GCC_X_NONE@ minitests-c++.@OBJEXT@ libvacall.a $(LDFLAGS) -o minitests-c++ + +check : all minitests + ./minitests > minitests.out + LC_ALL=C uniq -u < minitests.out > minitests.output.$(HOST) + test '!' -s minitests.output.$(HOST) +@IF_CXX@ ./minitests-c++ > minitests-c++.out +@IF_CXX@ LC_ALL=C uniq -u < minitests-c++.out > minitests-c++.output.$(HOST) +@IF_CXX@ test '!' -s minitests-c++.output.$(HOST) +@IF_CXX@check : minitests-c++ + +tests.@OBJEXT@ : $(srcdir)/tests.c $(srcdir)/vacall.h + $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/tests.c + +tests.s : $(srcdir)/tests.c $(srcdir)/vacall.h + $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -S $(srcdir)/tests.c + +tests : tests.@OBJEXT@ libvacall.a + $(CC) $(CFLAGS) @GCC_X_NONE@ tests.@OBJEXT@ libvacall.a $(LDFLAGS) -o tests + +extracheck : all tests + ./tests > tests.out + LC_ALL=C uniq -u < tests.out > tests.output.$(HOST) + test '!' -s tests.output.$(HOST) + +mostlyclean : clean + +clean : force + $(RM) *.@OBJEXT@ *.a core + $(RM) vacall-i386.s vacall-sparc.s vacall-sparc64.s vacall-m68k.s vacall-mips.s vacall-mipsn32.s vacall-mips64.s vacall-alpha.s vacall-hppa.s vacall-hppa64.s vacall-arm.s vacall-armhf.s vacall-arm64.s vacall-powerpc.s vacall-powerpc64.s vacall-powerpc64-elfv2.s vacall-ia64.s vacall-x86_64.s vacall-x86_64.asm vacall-x86_64-x32.s vacall-s390.s vacall-s390x.s vacall-riscv32-ilp32d.s vacall-riscv64-lp64d.s + $(RM) minitests.@OBJEXT@ minitests.s minitests minitests.out + $(RM) minitests-c++.@OBJEXT@ minitests-c++ minitests-c++.out + $(RM) tests.@OBJEXT@ tests.s tests tests.out + +distclean : clean + $(RM) Makefile minitests.output.* minitests-c++.output.* tests.output.* + +maintainer-clean : distclean + + +# List of source files (committed in version control or generated by Makefile.devel). +SOURCE_FILES = \ + COPYING \ + PLATFORMS README vacall.3 vacall.html \ + Makefile.devel \ + Makefile.maint \ + Makefile.in \ + vacall.h vacall-internal.h \ + vacall-alpha.c vacall-alpha-linux.s vacall-alpha-macro.S \ + vacall-arm.c vacall-arm-linux.s vacall-arm-linux-pic.s vacall-arm-macro.S \ + vacall-armhf.c vacall-armhf-linux.s vacall-armhf-linux-pic.s vacall-armhf-macro.S \ + vacall-arm64.c vacall-arm64-macro.S \ + vacall-hppa.c vacall-hppa-linux.s vacall-hppa-macro.S \ + vacall-hppa64.c vacall-hppa64-linux.s vacall-hppa64-macro.S \ + vacall-i386.c vacall-i386-linux.s vacall-i386-linux-pic.s vacall-i386-macro.S \ + vacall-ia64.c vacall-ia64-linux.s vacall-ia64-macro.S \ + vacall-m68k.c vacall-m68k-linux.s vacall-m68k-sun.s vacall-m68k.mit.S vacall-m68k.motorola.S \ + vacall-mips.c vacall-mipseb-linux.s vacall-mipsel-linux.s vacall-mipseb-macro.S vacall-mipsel-macro.S \ + vacall-mipsn32.c vacall-mipsn32eb-linux.s vacall-mipsn32el-linux.s vacall-mipsn32eb-macro.S vacall-mipsn32el-macro.S \ + vacall-mips64.c vacall-mips64eb-linux.s vacall-mips64el-linux.s vacall-mips64eb-macro.S vacall-mips64el-macro.S \ + vacall-powerpc.c \ + vacall-powerpc-aix.s \ + vacall-powerpc-linux.s vacall-powerpc-linux-macro.S vacall-powerpc-macos.s vacall-powerpc-sysv4-macro.S \ + vacall-powerpc64.c vacall-powerpc64-aix.s vacall-powerpc64-linux.S vacall-powerpc64-elfv2-linux.S \ + vacall-riscv32.c vacall-riscv32-ilp32d-linux.s vacall-riscv32-ilp32d-macro.S \ + vacall-riscv64.c vacall-riscv64-lp64d-linux.s vacall-riscv64-lp64d-macro.S \ + vacall-s390.c vacall-s390-linux.s vacall-s390-macro.S \ + vacall-s390x.c vacall-s390x-linux.s vacall-s390x-macro.S \ + vacall-sparc.c vacall-sparc-linux.s vacall-sparc-linux-pic.s vacall-sparc-macro.S \ + vacall-sparc64.c vacall-sparc64-linux.s vacall-sparc64-linux-pic.s vacall-sparc64-macro.S \ + vacall-x86_64.c vacall-x86_64-linux.s vacall-x86_64-macro.S vacall-x86_64-x32-linux.s \ + vacall-x86_64-windows.c vacall-x86_64-windows.s vacall-x86_64-windows-macro.S \ + vacall-libapi.c \ + vacall-structcpy.c \ + minitests.c minitests-c++.cc \ + tests.c +# List of distributed files generated by Makefile.maint. +GENERATED_FILES = \ + vacall.man \ + vacall-i386-msvc.c +# List of distributed files. +DISTFILES = $(SOURCE_FILES) $(GENERATED_FILES) + +distdir : $(DISTFILES) + for file in $(DISTFILES); do \ + if test -f $$file; then dir='.'; else dir='$(srcdir)'; fi; \ + cp -p "$$dir/$$file" '$(distdir)'/$$file || exit 1; \ + done + + +force : + diff --git a/vacall/Makefile.maint b/vacall/Makefile.maint new file mode 100644 index 0000000..51789a9 --- /dev/null +++ b/vacall/Makefile.maint @@ -0,0 +1,24 @@ +# maintainer -*-Makefile-*- + +LN = ln -s +RM = rm -f + +# ==================== Easily regeneratable files ==================== + +ROFF_MAN = groff -Tutf8 -mandoc + +all : vacall.man \ + vacall-i386-msvc.c + +vacall.man : vacall.3 + $(ROFF_MAN) vacall.3 > vacall.man + +vacall-i386-msvc.c : vacall-i386-macro.S + (echo '#ifdef _MSC_VER' ; echo '#include "vacall.h"' ; echo '#endif' ; cat vacall-i386-macro.S) > vacall-i386-msvc.c + +totally-clean : force + $(RM) vacall.man + $(RM) vacall-i386-msvc.c + + +force : diff --git a/vacall/PLATFORMS b/vacall/PLATFORMS new file mode 100644 index 0000000..f60ac57 --- /dev/null +++ b/vacall/PLATFORMS @@ -0,0 +1,51 @@ +Supported CPUs: (Put the GNU config.guess values here.) + i386 i486-unknown-linux (gcc), i686-unknown-gnu0.9 (gcc), + i386-unknown-sysv4.0 (gcc, /usr/bin/cc, /usr/ucb/cc), + i386-pc-solaris2.6 (gcc), i386-pc-solaris2.10 (gcc, cc), + i486-unknown-sco3.2v4.2 (gcc, cc -Of), i386-pc-cygwin32 (gcc), + i386-w64-mingw32 (gcc, MSVC 14), + i586-unknown-freebsd11.0 (cc), i386-unknown-dragonfly3.8 (gcc), + i386-unknown-netbsdelf7.0 (gcc), i386-unknown-openbsd6.0 (gcc), + i586-pc-haiku (gcc-x86), i386-pc-minix (clang) + m68k m68k-next-nextstep3 (cc), m68k-sun-sunos4.0 (cc), + m68k-unknown-linux (gcc) + mips mips-sgi-irix4.0.5 (gcc, cc -ansi, cc -D__STDC__, cc -cckr), + mips-sgi-irix5.2 (gcc, cc -ansi, cc -D__STDC__, cc -cckr), + mips-sgi-irix5.2 (gcc, cc -ansi, cc -D__STDC__, cc -cckr), + mips-sgi-irix6.2 (cc -32), + mips-sgi-irix6.4 (cc -32, cc -n32, cc -64), + mips-sgi-irix6.5 (cc -32, cc -n32, gcc -mabi=n32), + mips-unknown-linux (gcc -mabi=32), + mips64-unknown-linux (gcc -mabi=n32, -mabi=64) + sparc sparc-sun-sunos4.1.1 (gcc, cc), sparc-sun-solaris2.3 (gcc), + sparc-sun-solaris2.4 (gcc, cc), sparc-sun-solaris2.10 (gcc, cc), + sparc64-sun-solaris2.10 (gcc -m64, cc -xarch=generic64), + sparc-unknown-linux (gcc), sparc64-unknown-linux (gcc), + sparc-unknown-netbsdelf7.1 (gcc), + sparc64-unknown-netbsd8.0 (gcc) + alpha alpha-dec-osf3.0 (gcc, cc), alpha-dec-osf4.0 (gcc, cc), + alphaev67-unknown-linux (gcc) + hppa hppa1.0-hp-hpux8.00 (gcc, cc), hppa1.1-hp-hpux9.05 (cc), + hppa1.1-hp-hpux10.01 (cc), hppa2.0-hp-hpux10.20 (cc +DA1.1), + hppa2.0w-hp-hpux11.31 (cc), hppa-unknown-linux (gcc) + hppa64 hppa64-hp-hpux11.31 (cc +DD64) + arm armv5tejl-unknown-linux (gcc), armv6l-unknown-linux (gcc), + armv7l-unknown-linux (gcc) + arm64 aarch64-unknown-linux (gcc) + powerpc powerpc-ibm-aix4.1.4.0 (cc), powerpc-ibm-aix7.1.3.0 (xlc, gcc), + powerpc-unknown-linux (gcc), powerpc-apple-darwin6.8 (gcc), + powerpc-apple-darwin9.8.0 (gcc) + powerpc64 powerpc-ibm-aix7.1.3.0 (gcc -maix64, xlc -q64; AR="ar -X 64"), + powerpc64-unknown-linux (gcc -m64), + powerpc64le-unknown-linux (gcc) + ia64 ia64-unknown-linux (gcc) + x86_64 x86_64-suse-linux (gcc), x86_64-unknown-linux (gcc -mx32), + x86_64-pc-solaris2.10 (gcc -m64, cc -xarch=generic64), + x86_64-pc-cygwin (gcc), x86_64-w64-mingw32 (gcc, MSVC 14), + x86_64-unknown-freebsd11.0 (cc), x86_64-unknown-netbsd7.0 (gcc), + x86_64-unknown-openbsd6.0 (gcc) + s390 s390x-ibm-linux (gcc -m31) + s390x s390x-ibm-linux (gcc) + riscv32 riscv32-unknown-linux (gcc -mabi=ilp32d) + riscv64 riscv64-unknown-linux (gcc -mabi=lp64d) + diff --git a/vacall/README b/vacall/README new file mode 100644 index 0000000..152436d --- /dev/null +++ b/vacall/README @@ -0,0 +1,78 @@ +vacall - C functions called with variable arguments + +This library allows C functions to be called with variable arguments and +to return variable return values. This is much like the varargs(3) facility, +but also allows the return value to be specified at run time. + +A typical use is the implementation of call-back functions in embedded +interpreters. + + +Installation instructions: + + Configure the parent directory. Then: + cd vacall + make + make check + make install + + +Files in this package: + + Documentation: + + README this text + COPYING free software license + PLATFORMS list of supported platforms + vacall.3 manual page in Unix man format + vacall.man manual page + vacall.html manual page in HTML format + + Source: + + vacall.h main include file + vacall-*.c source for the main interface function + vacall-*.[sS] its translation to assembly language + vacall-libapi.c implementation of other library API + vacall-structcpy.c auxiliary function + tests.c test program + + Building: + + Makefile.in Makefile master + + Porting: + + Makefile.devel developer's Makefile + + +This subdirectory produces a static library. Reason: +The vacall-*.c files access global variables. Such accesses causes +portability problems when combined with the option -fPIC (because of +the small/medium/large memory models and platform dependent assembler +syntax to access the GOT). +Therefore Makefile.devel in this directory compiles the files without -fPIC. +Therefore the resulting object files are not suitable for being put into +a shared library. +Therefore this direcory must + - either not use libtool, + - or pass '-static' to $(LIBTOOL_LINK) when creating libvacall.la. + + +Copyright notice: + +Copyright 1995-2017 Bruno Haible + +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, see . + diff --git a/vacall/minitests-c++.cc b/vacall/minitests-c++.cc new file mode 100644 index 0000000..1738e11 --- /dev/null +++ b/vacall/minitests-c++.cc @@ -0,0 +1,18 @@ +/* + * Copyright 2017 Bruno Haible + * + * 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, see . + */ + +#include "minitests.c" diff --git a/vacall/minitests.c b/vacall/minitests.c new file mode 100644 index 0000000..b0f50fe --- /dev/null +++ b/vacall/minitests.c @@ -0,0 +1,19 @@ +/* + * Copyright 1999-2001 Bruno Haible + * + * 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, see . + */ + +#define SKIP_EXTRA_STRUCTS +#include "tests.c" diff --git a/vacall/tests.c b/vacall/tests.c new file mode 100644 index 0000000..2401a95 --- /dev/null +++ b/vacall/tests.c @@ -0,0 +1,2216 @@ +/* Some random tests for vacall. */ + +/* + * Copyright 1993 Bill Triggs + * Copyright 1995-2019 Bruno Haible + * + * 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, see . + */ + +#include +#include +#include +#include "vacall.h" + +#include "testcases.c" + +#if defined(__m68k__) && defined(__GNUC__) +/* "gcc-2.6.3 -freg-struct-return" returns T = struct { char c[3]; } (which + * has size 4 !) in memory, in contrast to struct { char a,b,c; } and + * struct { char c[4]; } and struct { char a,b,c,d; } which have the same + * size and the same alignment but are returned in registers. I don't know why. + */ +#define SKIP_T +#endif +#if defined(__sparc__) && defined(__sun) && defined(__SUNPRO_C) /* SUNWspro cc */ +/* SunPRO cc miscompiles the simulator function for X_BcdB: d.i[1] is + * temporarily stored in %l2 and put onto the stack from %l2, but in between + * the copy of X has used %l2 as a counter without saving and restoring its + * value. + */ +#define SKIP_X +#endif +#if defined(__mipsn32__) && !defined(__GNUC__) +/* The X test crashes for an unknown reason. */ +#define SKIP_X +#endif + + +void* current_function; + +/* This function simulates the behaviour of current_function. */ +void simulator (va_alist alist) +{ + /* void tests */ + if (current_function == (void*)&v_v) + { + va_start_void(alist); + fprintf(out,"void f(void):\n"); + fflush(out); + va_return_void(alist); + } + + /* int tests */ + else if (current_function == (void*)&i_v) + { + va_start_int(alist); + {int r=99; + fprintf(out,"int f(void):"); + fflush(out); + va_return_int(alist, r); + }} + else if (current_function == (void*)&i_i) + { + va_start_int(alist); + {int a = va_arg_int(alist); + int r=a+1; + fprintf(out,"int f(int):(%d)",a); + fflush(out); + va_return_int(alist, r); + }} + else if (current_function == (void*)&i_i2) + { + va_start_int(alist); + {int a = va_arg_int(alist); + int b = va_arg_int(alist); + int r=a+b; + fprintf(out,"int f(2*int):(%d,%d)",a,b); + fflush(out); + va_return_int(alist, r); + }} + else if (current_function == (void*)&i_i4) + { + va_start_int(alist); + {int a = va_arg_int(alist); + int b = va_arg_int(alist); + int c = va_arg_int(alist); + int d = va_arg_int(alist); + int r=a+b+c+d; + fprintf(out,"int f(4*int):(%d,%d,%d,%d)",a,b,c,d); + fflush(out); + va_return_int(alist, r); + }} + else if (current_function == (void*)&i_i8) + { + va_start_int(alist); + {int a = va_arg_int(alist); + int b = va_arg_int(alist); + int c = va_arg_int(alist); + int d = va_arg_int(alist); + int e = va_arg_int(alist); + int f = va_arg_int(alist); + int g = va_arg_int(alist); + int h = va_arg_int(alist); + int r=a+b+c+d+e+f+g+h; + fprintf(out,"int f(8*int):(%d,%d,%d,%d,%d,%d,%d,%d)",a,b,c,d,e,f,g,h); + fflush(out); + va_return_int(alist, r); + }} + else if (current_function == (void*)&i_i16) + { + va_start_int(alist); + {int a = va_arg_int(alist); + int b = va_arg_int(alist); + int c = va_arg_int(alist); + int d = va_arg_int(alist); + int e = va_arg_int(alist); + int f = va_arg_int(alist); + int g = va_arg_int(alist); + int h = va_arg_int(alist); + int i = va_arg_int(alist); + int j = va_arg_int(alist); + int k = va_arg_int(alist); + int l = va_arg_int(alist); + int m = va_arg_int(alist); + int n = va_arg_int(alist); + int o = va_arg_int(alist); + int p = va_arg_int(alist); + int r=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p; + fprintf(out,"int f(16*int):(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)", + a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p); + fflush(out); + va_return_int(alist, r); + }} + else if (current_function == (void*)&i_i32) + { + va_start_int(alist); + {int a = va_arg_int(alist); + int b = va_arg_int(alist); + int c = va_arg_int(alist); + int d = va_arg_int(alist); + int e = va_arg_int(alist); + int f = va_arg_int(alist); + int g = va_arg_int(alist); + int h = va_arg_int(alist); + int i = va_arg_int(alist); + int j = va_arg_int(alist); + int k = va_arg_int(alist); + int l = va_arg_int(alist); + int m = va_arg_int(alist); + int n = va_arg_int(alist); + int o = va_arg_int(alist); + int p = va_arg_int(alist); + int aa = va_arg_int(alist); + int ab = va_arg_int(alist); + int ac = va_arg_int(alist); + int ad = va_arg_int(alist); + int ae = va_arg_int(alist); + int af = va_arg_int(alist); + int ag = va_arg_int(alist); + int ah = va_arg_int(alist); + int ai = va_arg_int(alist); + int aj = va_arg_int(alist); + int ak = va_arg_int(alist); + int al = va_arg_int(alist); + int am = va_arg_int(alist); + int an = va_arg_int(alist); + int ao = va_arg_int(alist); + int ap = va_arg_int(alist); + int r=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+aa+ab+ac+ad+ae+af+ag+ah+ai+aj+ak+al+am+an+ao+ap; + fprintf(out,"int f(32*int):(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)", + a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an,ao,ap); + fflush(out); + va_return_int(alist, r); + }} + + /* float tests */ + else if (current_function == (void*)&f_f) + { + va_start_float(alist); + {float a = va_arg_float(alist); + float r=a+1.0; + fprintf(out,"float f(float):(%g)",a); + fflush(out); + va_return_float(alist, r); + }} + else if (current_function == (void*)&f_f2) + { + va_start_float(alist); + {float a = va_arg_float(alist); + float b = va_arg_float(alist); + float r=a+b; + fprintf(out,"float f(2*float):(%g,%g)",a,b); + fflush(out); + va_return_float(alist, r); + }} + else if (current_function == (void*)&f_f4) + { + va_start_float(alist); + {float a = va_arg_float(alist); + float b = va_arg_float(alist); + float c = va_arg_float(alist); + float d = va_arg_float(alist); + float r=a+b+c+d; + fprintf(out,"float f(4*float):(%g,%g,%g,%g)",a,b,c,d); + fflush(out); + va_return_float(alist, r); + }} + else if (current_function == (void*)&f_f8) + { + va_start_float(alist); + {float a = va_arg_float(alist); + float b = va_arg_float(alist); + float c = va_arg_float(alist); + float d = va_arg_float(alist); + float e = va_arg_float(alist); + float f = va_arg_float(alist); + float g = va_arg_float(alist); + float h = va_arg_float(alist); + float r=a+b+c+d+e+f+g+h; + fprintf(out,"float f(8*float):(%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h); + fflush(out); + va_return_float(alist, r); + }} + else if (current_function == (void*)&f_f16) + { + va_start_float(alist); + {float a = va_arg_float(alist); + float b = va_arg_float(alist); + float c = va_arg_float(alist); + float d = va_arg_float(alist); + float e = va_arg_float(alist); + float f = va_arg_float(alist); + float g = va_arg_float(alist); + float h = va_arg_float(alist); + float i = va_arg_float(alist); + float j = va_arg_float(alist); + float k = va_arg_float(alist); + float l = va_arg_float(alist); + float m = va_arg_float(alist); + float n = va_arg_float(alist); + float o = va_arg_float(alist); + float p = va_arg_float(alist); + float r=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p; + fprintf(out,"float f(16*float):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p); + fflush(out); + va_return_float(alist, r); + }} + else if (current_function == (void*)&f_f24) + { + va_start_float(alist); + {float a = va_arg_float(alist); + float b = va_arg_float(alist); + float c = va_arg_float(alist); + float d = va_arg_float(alist); + float e = va_arg_float(alist); + float f = va_arg_float(alist); + float g = va_arg_float(alist); + float h = va_arg_float(alist); + float i = va_arg_float(alist); + float j = va_arg_float(alist); + float k = va_arg_float(alist); + float l = va_arg_float(alist); + float m = va_arg_float(alist); + float n = va_arg_float(alist); + float o = va_arg_float(alist); + float p = va_arg_float(alist); + float q = va_arg_float(alist); + float s = va_arg_float(alist); + float t = va_arg_float(alist); + float u = va_arg_float(alist); + float v = va_arg_float(alist); + float w = va_arg_float(alist); + float x = va_arg_float(alist); + float y = va_arg_float(alist); + float r=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+s+t+u+v+w+x+y; + fprintf(out,"float f(24*float):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,s,t,u,v,w,x,y); + fflush(out); + va_return_float(alist, r); + }} + + /* double tests */ + else if (current_function == (void*)&d_d) + { + va_start_double(alist); + {double a = va_arg_double(alist); + double r=a+1.0; + fprintf(out,"double f(double):(%g)",a); + fflush(out); + va_return_double(alist, r); + }} + else if (current_function == (void*)&d_d2) + { + va_start_double(alist); + {double a = va_arg_double(alist); + double b = va_arg_double(alist); + double r=a+b; + fprintf(out,"double f(2*double):(%g,%g)",a,b); + fflush(out); + va_return_double(alist, r); + }} + else if (current_function == (void*)&d_d4) + { + va_start_double(alist); + {double a = va_arg_double(alist); + double b = va_arg_double(alist); + double c = va_arg_double(alist); + double d = va_arg_double(alist); + double r=a+b+c+d; + fprintf(out,"double f(4*double):(%g,%g,%g,%g)",a,b,c,d); + fflush(out); + va_return_double(alist, r); + }} + else if (current_function == (void*)&d_d8) + { + va_start_double(alist); + {double a = va_arg_double(alist); + double b = va_arg_double(alist); + double c = va_arg_double(alist); + double d = va_arg_double(alist); + double e = va_arg_double(alist); + double f = va_arg_double(alist); + double g = va_arg_double(alist); + double h = va_arg_double(alist); + double r=a+b+c+d+e+f+g+h; + fprintf(out,"double f(8*double):(%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h); + fflush(out); + va_return_double(alist, r); + }} + else if (current_function == (void*)&d_d16) + { + va_start_double(alist); + {double a = va_arg_double(alist); + double b = va_arg_double(alist); + double c = va_arg_double(alist); + double d = va_arg_double(alist); + double e = va_arg_double(alist); + double f = va_arg_double(alist); + double g = va_arg_double(alist); + double h = va_arg_double(alist); + double i = va_arg_double(alist); + double j = va_arg_double(alist); + double k = va_arg_double(alist); + double l = va_arg_double(alist); + double m = va_arg_double(alist); + double n = va_arg_double(alist); + double o = va_arg_double(alist); + double p = va_arg_double(alist); + double r=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p; + fprintf(out,"double f(16*double):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p); + fflush(out); + va_return_double(alist, r); + }} + + /* pointer tests */ + else if (current_function == (void*)&vp_vpdpcpsp) + { + va_start_ptr(alist, void*); + {void* a = va_arg_ptr(alist, void*); + double* b = va_arg_ptr(alist, double*); + char* c = va_arg_ptr(alist, char*); + Int* d = va_arg_ptr(alist, Int*); + void* ret = (char*)b + 1; + fprintf(out,"void* f(void*,double*,char*,Int*):(0x%p,0x%p,0x%p,0x%p)",a,b,c,d); + fflush(out); + va_return_ptr(alist, void*, ret); + }} + + /* mixed number tests */ + else if (current_function == (void*)&uc_ucsil) + { + va_start_uchar(alist); + {uchar a = va_arg_uchar(alist); + ushort b = va_arg_ushort(alist); + uint c = va_arg_uint(alist); + ulong d = va_arg_ulong(alist); + uchar r = (uchar)-1; + fprintf(out,"uchar f(uchar,ushort,uint,ulong):(%u,%u,%u,%lu)",a,b,c,d); + fflush(out); + va_return_uchar(alist, r); + }} + else if (current_function == (void*)&d_iidd) + { + va_start_double(alist); + {int a = va_arg_int(alist); + int b = va_arg_int(alist); + double c = va_arg_double(alist); + double d = va_arg_double(alist); + double r=a+b+c+d; + fprintf(out,"double f(int,int,double,double):(%d,%d,%g,%g)",a,b,c,d); + fflush(out); + va_return_double(alist, r); + }} + else if (current_function == (void*)&d_iiidi) + { + va_start_double(alist); + {int a = va_arg_int(alist); + int b = va_arg_int(alist); + int c = va_arg_int(alist); + double d = va_arg_double(alist); + int e = va_arg_int(alist); + double r=a+b+c+d+e; + fprintf(out,"double f(int,int,int,double,int):(%d,%d,%d,%g,%d)",a,b,c,d,e); + fflush(out); + va_return_double(alist, r); + }} + else if (current_function == (void*)&d_idid) + { + va_start_double(alist); + {int a = va_arg_int(alist); + double b = va_arg_double(alist); + int c = va_arg_int(alist); + double d = va_arg_double(alist); + double r=a+b+c+d; + fprintf(out,"double f(int,double,int,double):(%d,%g,%d,%g)",a,b,c,d); + fflush(out); + va_return_double(alist, r); + }} + else if (current_function == (void*)&d_fdi) + { + va_start_double(alist); + {float a = va_arg_float(alist); + double b = va_arg_double(alist); + int c = va_arg_int(alist); + double r=a+b+c; + fprintf(out,"double f(float,double,int):(%g,%g,%d)",a,b,c); + fflush(out); + va_return_double(alist, r); + }} + else if (current_function == (void*)&us_cdcd) + { + va_start_ushort(alist); + {char a = va_arg_char(alist); + double b = va_arg_double(alist); + char c = va_arg_char(alist); + double d = va_arg_double(alist); + ushort r = (ushort)(a + b + c + d); + fprintf(out,"ushort f(char,double,char,double):('%c',%g,'%c',%g)",a,b,c,d); + fflush(out); + va_return_ushort(alist, r); + }} + else if (current_function == (void*)&ll_iiilli) + { + va_start_longlong(alist); + {int a = va_arg_int(alist); + int b = va_arg_int(alist); + int c = va_arg_int(alist); + long long d = va_arg_longlong(alist); + int e = va_arg_int(alist); + long long r = (long long)a + (long long)b + (long long)c + d + (long long)e; + fprintf(out,"long long f(int,int,int,long long,int):(%d,%d,%d,0x%lx%08lx,%d)",a,b,c,(long)(d>>32),(long)(d&0xffffffff),e); + fflush(out); + va_return_longlong(alist, r); + }} + else if (current_function == (void*)&ll_flli) + { + va_start_longlong(alist); + {float a = va_arg_float(alist); + long long b = va_arg_longlong(alist); + int c = va_arg_int(alist); + long long r = (long long)(int)a + b + (long long)c; + fprintf(out,"long long f(float,long long,int):(%g,0x%lx%08lx,0x%lx)",a,(long)(b>>32),(long)(b&0xffffffff),(long)c); + fflush(out); + va_return_longlong(alist, r); + }} + else if (current_function == (void*)&f_fi) + { + va_start_float(alist); + {float a = va_arg_float(alist); + int z = va_arg_int(alist); + float r = a+z; + fprintf(out,"float f(float,int):(%g,%d)",a,z); + fflush(out); + va_return_float(alist, r); + }} + else if (current_function == (void*)&f_f2i) + { + va_start_float(alist); + {float a = va_arg_float(alist); + float b = va_arg_float(alist); + int z = va_arg_int(alist); + float r = a+b+z; + fprintf(out,"float f(2*float,int):(%g,%g,%d)",a,b,z); + fflush(out); + va_return_float(alist, r); + }} + else if (current_function == (void*)&f_f3i) + { + va_start_float(alist); + {float a = va_arg_float(alist); + float b = va_arg_float(alist); + float c = va_arg_float(alist); + int z = va_arg_int(alist); + float r = a+b+c+z; + fprintf(out,"float f(3*float,int):(%g,%g,%g,%d)",a,b,c,z); + fflush(out); + va_return_float(alist, r); + }} + else if (current_function == (void*)&f_f4i) + { + va_start_float(alist); + {float a = va_arg_float(alist); + float b = va_arg_float(alist); + float c = va_arg_float(alist); + float d = va_arg_float(alist); + int z = va_arg_int(alist); + float r = a+b+c+d+z; + fprintf(out,"float f(4*float,int):(%g,%g,%g,%g,%d)",a,b,c,d,z); + fflush(out); + va_return_float(alist, r); + }} + else if (current_function == (void*)&f_f7i) + { + va_start_float(alist); + {float a = va_arg_float(alist); + float b = va_arg_float(alist); + float c = va_arg_float(alist); + float d = va_arg_float(alist); + float e = va_arg_float(alist); + float f = va_arg_float(alist); + float g = va_arg_float(alist); + int z = va_arg_int(alist); + float r = a+b+c+d+e+f+g+z; + fprintf(out,"float f(7*float,int):(%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,z); + fflush(out); + va_return_float(alist, r); + }} + else if (current_function == (void*)&f_f8i) + { + va_start_float(alist); + {float a = va_arg_float(alist); + float b = va_arg_float(alist); + float c = va_arg_float(alist); + float d = va_arg_float(alist); + float e = va_arg_float(alist); + float f = va_arg_float(alist); + float g = va_arg_float(alist); + float h = va_arg_float(alist); + int z = va_arg_int(alist); + float r = a+b+c+d+e+f+g+h+z; + fprintf(out,"float f(8*float,int):(%g,%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,h,z); + fflush(out); + va_return_float(alist, r); + }} + else if (current_function == (void*)&f_f12i) + { + va_start_float(alist); + {float a = va_arg_float(alist); + float b = va_arg_float(alist); + float c = va_arg_float(alist); + float d = va_arg_float(alist); + float e = va_arg_float(alist); + float f = va_arg_float(alist); + float g = va_arg_float(alist); + float h = va_arg_float(alist); + float i = va_arg_float(alist); + float j = va_arg_float(alist); + float k = va_arg_float(alist); + float l = va_arg_float(alist); + int z = va_arg_int(alist); + float r = a+b+c+d+e+f+g+h+i+j+k+l+z; + fprintf(out,"float f(12*float,int):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,h,i,j,k,l,z); + fflush(out); + va_return_float(alist, r); + }} + else if (current_function == (void*)&f_f13i) + { + va_start_float(alist); + {float a = va_arg_float(alist); + float b = va_arg_float(alist); + float c = va_arg_float(alist); + float d = va_arg_float(alist); + float e = va_arg_float(alist); + float f = va_arg_float(alist); + float g = va_arg_float(alist); + float h = va_arg_float(alist); + float i = va_arg_float(alist); + float j = va_arg_float(alist); + float k = va_arg_float(alist); + float l = va_arg_float(alist); + float m = va_arg_float(alist); + int z = va_arg_int(alist); + float r = a+b+c+d+e+f+g+h+i+j+k+l+m+z; + fprintf(out,"float f(13*float,int):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,h,i,j,k,l,m,z); + fflush(out); + va_return_float(alist, r); + }} + else if (current_function == (void*)&d_di) + { + va_start_double(alist); + {double a = va_arg_double(alist); + int z = va_arg_int(alist); + double r = a+z; + fprintf(out,"double f(double,int):(%g,%d)",a,z); + fflush(out); + va_return_double(alist, r); + }} + else if (current_function == (void*)&d_d2i) + { + va_start_double(alist); + {double a = va_arg_double(alist); + double b = va_arg_double(alist); + int z = va_arg_int(alist); + double r = a+b+z; + fprintf(out,"double f(2*double,int):(%g,%g,%d)",a,b,z); + fflush(out); + va_return_double(alist, r); + }} + else if (current_function == (void*)&d_d3i) + { + va_start_double(alist); + {double a = va_arg_double(alist); + double b = va_arg_double(alist); + double c = va_arg_double(alist); + int z = va_arg_int(alist); + double r = a+b+c+z; + fprintf(out,"double f(3*double,int):(%g,%g,%g,%d)",a,b,c,z); + fflush(out); + va_return_double(alist, r); + }} + else if (current_function == (void*)&d_d4i) + { + va_start_double(alist); + {double a = va_arg_double(alist); + double b = va_arg_double(alist); + double c = va_arg_double(alist); + double d = va_arg_double(alist); + int z = va_arg_int(alist); + double r = a+b+c+d+z; + fprintf(out,"double f(4*double,int):(%g,%g,%g,%g,%d)",a,b,c,d,z); + fflush(out); + va_return_double(alist, r); + }} + else if (current_function == (void*)&d_d7i) + { + va_start_double(alist); + {double a = va_arg_double(alist); + double b = va_arg_double(alist); + double c = va_arg_double(alist); + double d = va_arg_double(alist); + double e = va_arg_double(alist); + double f = va_arg_double(alist); + double g = va_arg_double(alist); + int z = va_arg_int(alist); + double r = a+b+c+d+e+f+g+z; + fprintf(out,"double f(7*double,int):(%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,z); + fflush(out); + va_return_double(alist, r); + }} + else if (current_function == (void*)&d_d8i) + { + va_start_double(alist); + {double a = va_arg_double(alist); + double b = va_arg_double(alist); + double c = va_arg_double(alist); + double d = va_arg_double(alist); + double e = va_arg_double(alist); + double f = va_arg_double(alist); + double g = va_arg_double(alist); + double h = va_arg_double(alist); + int z = va_arg_int(alist); + double r = a+b+c+d+e+f+g+h+z; + fprintf(out,"double f(8*double,int):(%g,%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,h,z); + fflush(out); + va_return_double(alist, r); + }} + else if (current_function == (void*)&d_d12i) + { + va_start_double(alist); + {double a = va_arg_double(alist); + double b = va_arg_double(alist); + double c = va_arg_double(alist); + double d = va_arg_double(alist); + double e = va_arg_double(alist); + double f = va_arg_double(alist); + double g = va_arg_double(alist); + double h = va_arg_double(alist); + double i = va_arg_double(alist); + double j = va_arg_double(alist); + double k = va_arg_double(alist); + double l = va_arg_double(alist); + int z = va_arg_int(alist); + double r = a+b+c+d+e+f+g+h+i+j+k+l+z; + fprintf(out,"double f(12*double,int):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,h,i,j,k,l,z); + fflush(out); + va_return_double(alist, r); + }} + else if (current_function == (void*)&d_d13i) + { + va_start_double(alist); + {double a = va_arg_double(alist); + double b = va_arg_double(alist); + double c = va_arg_double(alist); + double d = va_arg_double(alist); + double e = va_arg_double(alist); + double f = va_arg_double(alist); + double g = va_arg_double(alist); + double h = va_arg_double(alist); + double i = va_arg_double(alist); + double j = va_arg_double(alist); + double k = va_arg_double(alist); + double l = va_arg_double(alist); + double m = va_arg_double(alist); + int z = va_arg_int(alist); + double r = a+b+c+d+e+f+g+h+i+j+k+l+m+z; + fprintf(out,"double f(13*double,int):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,h,i,j,k,l,m,z); + fflush(out); + va_return_double(alist, r); + }} + + /* small structure return tests */ + else if (current_function == (void*)&S1_v) + { + Size1 r; + va_start_struct(alist, Size1, 1); + r = Size1_1; + fprintf(out,"Size1 f(void):"); + fflush(out); + va_return_struct(alist, Size1, r); + } + else if (current_function == (void*)&S2_v) + { + Size2 r; + va_start_struct(alist, Size2, 1); + r = Size2_1; + fprintf(out,"Size2 f(void):"); + fflush(out); + va_return_struct(alist, Size2, r); + } + else if (current_function == (void*)&S3_v) + { + Size3 r; + va_start_struct(alist, Size3, 1); + r = Size3_1; + fprintf(out,"Size3 f(void):"); + fflush(out); + va_return_struct(alist, Size3, r); + } + else if (current_function == (void*)&S4_v) + { + Size4 r; + va_start_struct(alist, Size4, 1); + r = Size4_1; + fprintf(out,"Size4 f(void):"); + fflush(out); + va_return_struct(alist, Size4, r); + } + else if (current_function == (void*)&S7_v) + { + Size7 r; + va_start_struct(alist, Size7, 1); + r = Size7_1; + fprintf(out,"Size7 f(void):"); + fflush(out); + va_return_struct(alist, Size7, r); + } + else if (current_function == (void*)&S8_v) + { + Size8 r; + va_start_struct(alist, Size8, 1); + r = Size8_1; + fprintf(out,"Size8 f(void):"); + fflush(out); + va_return_struct(alist, Size8, r); + } + else if (current_function == (void*)&S12_v) + { + Size12 r; + va_start_struct(alist, Size12, 1); + r = Size12_1; + fprintf(out,"Size12 f(void):"); + fflush(out); + va_return_struct(alist, Size12, r); + } + else if (current_function == (void*)&S15_v) + { + Size15 r; + va_start_struct(alist, Size15, 1); + r = Size15_1; + fprintf(out,"Size15 f(void):"); + fflush(out); + va_return_struct(alist, Size15, r); + } + else if (current_function == (void*)&S16_v) + { + Size16 r; + va_start_struct(alist, Size16, 1); + r = Size16_1; + fprintf(out,"Size16 f(void):"); + fflush(out); + va_return_struct(alist, Size16, r); + } + + /* structure tests */ + else if (current_function == (void*)&I_III) + { + Int a; + Int b; + Int c; + Int r; + va_start_struct(alist, Int, 1); + a = va_arg_struct(alist, Int); + b = va_arg_struct(alist, Int); + c = va_arg_struct(alist, Int); + r.x = a.x + b.x + c.x; + fprintf(out,"Int f(Int,Int,Int):({%d},{%d},{%d})",a.x,b.x,c.x); + fflush(out); + va_return_struct(alist, Int, r); + } +#ifndef SKIP_EXTRA_STRUCTS + else if (current_function == (void*)&C_CdC) + { + Char a; + double b; + Char c; + Char r; + va_start_struct(alist, Char, 1); + a = va_arg_struct(alist, Char); + b = va_arg_double(alist); + c = va_arg_struct(alist, Char); + r.x = (a.x + c.x)/2; + fprintf(out,"Char f(Char,double,Char):({'%c'},%g,{'%c'})",a.x,b,c.x); + fflush(out); + va_return_struct(alist, Char, r); + } + else if (current_function == (void*)&F_Ffd) + { + Float a; + float b; + double c; + Float r; + va_start_struct(alist, Float, va_word_splittable_1(float)); + a = va_arg_struct(alist, Float); + b = va_arg_float(alist); + c = va_arg_double(alist); + r.x = a.x + b + c; + fprintf(out,"Float f(Float,float,double):({%g},%g,%g)",a.x,b,c); + fflush(out); + va_return_struct(alist, Float, r); + } + else if (current_function == (void*)&D_fDd) + { + float a; + Double b; + double c; + Double r; + va_start_struct(alist, Double, va_word_splittable_1(double)); + a = va_arg_float(alist); + b = va_arg_struct(alist, Double); + c = va_arg_double(alist); + r.x = a + b.x + c; + fprintf(out,"Double f(float,Double,double):(%g,{%g},%g)",a,b.x,c); + fflush(out); + va_return_struct(alist, Double, r); + } + else if (current_function == (void*)&D_Dfd) + { + Double a; + float b; + double c; + Double r; + va_start_struct(alist, Double, va_word_splittable_1(double)); + a = va_arg_struct(alist, Double); + b = va_arg_float(alist); + c = va_arg_double(alist); + r.x = a.x + b + c; + fprintf(out,"Double f(Double,float,double):({%g},%g,%g)",a.x,b,c); + fflush(out); + va_return_struct(alist, Double, r); + } +#endif + else if (current_function == (void*)&J_JiJ) + { + J a; + int b; + J c; + J r; + va_start_struct(alist, J, va_word_splittable_2(long,long)); + a = va_arg_struct(alist, J); + b = va_arg_int(alist); + c = va_arg_struct(alist, J); + r.l1 = a.l1+c.l1; r.l2 = a.l2+b+c.l2; + fprintf(out,"J f(J,int,J):({%ld,%ld},%d,{%ld,%ld})",a.l1,a.l2,b,c.l1,c.l2); + fflush(out); + va_return_struct(alist, J, r); + } +#ifndef SKIP_EXTRA_STRUCTS + else if (current_function == (void*)&T_TcT) + { + T a; + char b; + T c; + T r; + va_start_struct(alist, T, 1); + a = va_arg_struct(alist, T); + b = va_arg_char(alist); + c = va_arg_struct(alist, T); + r.c[0]='b'; r.c[1]=c.c[1]; r.c[2]=c.c[2]; + fprintf(out,"T f(T,char,T):({\"%c%c%c\"},'%c',{\"%c%c%c\"})",a.c[0],a.c[1],a.c[2],b,c.c[0],c.c[1],c.c[2]); + fflush(out); + va_return_struct(alist, T, r); + } + else if (current_function == (void*)&X_BcdB) + { + B a; + char b; + double c; + B d; + static X xr={"return val",'R'}; + X r; + va_start_struct(alist, X, 0); + a = va_arg_struct(alist, B); + b = va_arg_char(alist); + c = va_arg_double(alist); + d = va_arg_struct(alist, B); + r = xr; + r.c1 = b; + fprintf(out,"X f(B,char,double,B):({%g,{%d,%d,%d}},'%c',%g,{%g,{%d,%d,%d}})", + a.d,a.i[0],a.i[1],a.i[2],b,c,d.d,d.i[0],d.i[1],d.i[2]); + fflush(out); + va_return_struct(alist, X, r); + } +#endif + + /* gpargs boundary tests */ + else if (current_function == (void*)&l_l0J) + { + va_start_long(alist); + {J b = va_arg_struct(alist, J); + long c = va_arg_long(alist); + long r = b.l1 + b.l2 + c; + fprintf(out,"long f(J,long):(%ld,%ld,%ld)",b.l1,b.l2,c); + fflush(out); + va_return_long(alist, r); + }} + else if (current_function == (void*)&l_l1J) + { + va_start_long(alist); + {long a1 = va_arg_long(alist); + J b = va_arg_struct(alist, J); + long c = va_arg_long(alist); + long r = a1 + b.l1 + b.l2 + c; + fprintf(out,"long f(long,J,long):(%ld,%ld,%ld,%ld)",a1,b.l1,b.l2,c); + fflush(out); + va_return_long(alist, r); + }} + else if (current_function == (void*)&l_l2J) + { + va_start_long(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + J b = va_arg_struct(alist, J); + long c = va_arg_long(alist); + long r = a1 + a2 + b.l1 + b.l2 + c; + fprintf(out,"long f(2*long,J,long):(%ld,%ld,%ld,%ld,%ld)",a1,a2,b.l1,b.l2,c); + fflush(out); + va_return_long(alist, r); + }} + else if (current_function == (void*)&l_l3J) + { + va_start_long(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + J b = va_arg_struct(alist, J); + long c = va_arg_long(alist); + long r = a1 + a2 + a3 + b.l1 + b.l2 + c; + fprintf(out,"long f(3*long,J,long):(%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,b.l1,b.l2,c); + fflush(out); + va_return_long(alist, r); + }} + else if (current_function == (void*)&l_l4J) + { + va_start_long(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + J b = va_arg_struct(alist, J); + long c = va_arg_long(alist); + long r = a1 + a2 + a3 + a4 + b.l1 + b.l2 + c; + fprintf(out,"long f(4*long,J,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,a4,b.l1,b.l2,c); + fflush(out); + va_return_long(alist, r); + }} + else if (current_function == (void*)&l_l5J) + { + va_start_long(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + long a5 = va_arg_long(alist); + J b = va_arg_struct(alist, J); + long c = va_arg_long(alist); + long r = a1 + a2 + a3 + a4 + a5 + b.l1 + b.l2 + c; + fprintf(out,"long f(5*long,J,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,a4,a5,b.l1,b.l2,c); + fflush(out); + va_return_long(alist, r); + }} + else if (current_function == (void*)&l_l6J) + { + va_start_long(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + long a5 = va_arg_long(alist); + long a6 = va_arg_long(alist); + J b = va_arg_struct(alist, J); + long c = va_arg_long(alist); + long r = a1 + a2 + a3 + a4 + a5 + a6 + b.l1 + b.l2 + c; + fprintf(out,"long f(6*long,J,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,a4,a5,a6,b.l1,b.l2,c); + fflush(out); + va_return_long(alist, r); + }} + else if (current_function == (void*)&l_l7J) + { + va_start_long(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + long a5 = va_arg_long(alist); + long a6 = va_arg_long(alist); + long a7 = va_arg_long(alist); + J b = va_arg_struct(alist, J); + long c = va_arg_long(alist); + long r = a1 + a2 + a3 + a4 + a5 + a6 + a7 + b.l1 + b.l2 + c; + fprintf(out,"long f(7*long,J,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,a4,a5,a6,a7,b.l1,b.l2,c); + fflush(out); + va_return_long(alist, r); + }} + else if (current_function == (void*)&l_l0K) + { + va_start_long(alist); + {K b = va_arg_struct(alist, K); + long c = va_arg_long(alist); + long r = b.l1 + b.l2 + b.l3 + b.l4 + c; + fprintf(out,"long f(K,long):(%ld,%ld,%ld,%ld,%ld)",b.l1,b.l2,b.l3,b.l4,c); + fflush(out); + va_return_long(alist, r); + }} + else if (current_function == (void*)&l_l1K) + { + va_start_long(alist); + {long a1 = va_arg_long(alist); + K b = va_arg_struct(alist, K); + long c = va_arg_long(alist); + long r = a1 + b.l1 + b.l2 + b.l3 + b.l4 + c; + fprintf(out,"long f(long,K,long):(%ld,%ld,%ld,%ld,%ld,%ld)",a1,b.l1,b.l2,b.l3,b.l4,c); + fflush(out); + va_return_long(alist, r); + }} + else if (current_function == (void*)&l_l2K) + { + va_start_long(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + K b = va_arg_struct(alist, K); + long c = va_arg_long(alist); + long r = a1 + a2 + b.l1 + b.l2 + b.l3 + b.l4 + c; + fprintf(out,"long f(2*long,K,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,b.l1,b.l2,b.l3,b.l4,c); + fflush(out); + va_return_long(alist, r); + }} + else if (current_function == (void*)&l_l3K) + { + va_start_long(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + K b = va_arg_struct(alist, K); + long c = va_arg_long(alist); + long r = a1 + a2 + a3 + b.l1 + b.l2 + b.l3 + b.l4 + c; + fprintf(out,"long f(3*long,K,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,b.l1,b.l2,b.l3,b.l4,c); + fflush(out); + va_return_long(alist, r); + }} + else if (current_function == (void*)&l_l4K) + { + va_start_long(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + K b = va_arg_struct(alist, K); + long c = va_arg_long(alist); + long r = a1 + a2 + a3 + a4 + b.l1 + b.l2 + b.l3 + b.l4 + c; + fprintf(out,"long f(4*long,K,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,a4,b.l1,b.l2,b.l3,b.l4,c); + fflush(out); + va_return_long(alist, r); + }} + else if (current_function == (void*)&l_l5K) + { + va_start_long(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + long a5 = va_arg_long(alist); + K b = va_arg_struct(alist, K); + long c = va_arg_long(alist); + long r = a1 + a2 + a3 + a4 + a5 + b.l1 + b.l2 + b.l3 + b.l4 + c; + fprintf(out,"long f(5*long,K,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,a4,a5,b.l1,b.l2,b.l3,b.l4,c); + fflush(out); + va_return_long(alist, r); + }} + else if (current_function == (void*)&l_l6K) + { + va_start_long(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + long a5 = va_arg_long(alist); + long a6 = va_arg_long(alist); + K b = va_arg_struct(alist, K); + long c = va_arg_long(alist); + long r = a1 + a2 + a3 + a4 + a5 + a6 + b.l1 + b.l2 + b.l3 + b.l4 + c; + fprintf(out,"long f(6*long,K,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,a4,a5,a6,b.l1,b.l2,b.l3,b.l4,c); + fflush(out); + va_return_long(alist, r); + }} + else if (current_function == (void*)&f_f17l3L) + { + va_start_float(alist); + {float a = va_arg_float(alist); + float b = va_arg_float(alist); + float c = va_arg_float(alist); + float d = va_arg_float(alist); + float e = va_arg_float(alist); + float f = va_arg_float(alist); + float g = va_arg_float(alist); + float h = va_arg_float(alist); + float i = va_arg_float(alist); + float j = va_arg_float(alist); + float k = va_arg_float(alist); + float l = va_arg_float(alist); + float m = va_arg_float(alist); + float n = va_arg_float(alist); + float o = va_arg_float(alist); + float p = va_arg_float(alist); + float q = va_arg_float(alist); + long s = va_arg_long(alist); + long t = va_arg_long(alist); + long u = va_arg_long(alist); + L z = va_arg_struct(alist, L); + float r = a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+s+t+u+z.l1+z.l2+z.l3+z.l4+z.l5+z.l6; + fprintf(out,"float f(17*float,3*int,L):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,s,t,u,z.l1,z.l2,z.l3,z.l4,z.l5,z.l6); + fflush(out); + va_return_float(alist, r); + }} + else if (current_function == (void*)&d_d17l3L) + { + va_start_double(alist); + {double a = va_arg_double(alist); + double b = va_arg_double(alist); + double c = va_arg_double(alist); + double d = va_arg_double(alist); + double e = va_arg_double(alist); + double f = va_arg_double(alist); + double g = va_arg_double(alist); + double h = va_arg_double(alist); + double i = va_arg_double(alist); + double j = va_arg_double(alist); + double k = va_arg_double(alist); + double l = va_arg_double(alist); + double m = va_arg_double(alist); + double n = va_arg_double(alist); + double o = va_arg_double(alist); + double p = va_arg_double(alist); + double q = va_arg_double(alist); + long s = va_arg_long(alist); + long t = va_arg_long(alist); + long u = va_arg_long(alist); + L z = va_arg_struct(alist, L); + double r = a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+s+t+u+z.l1+z.l2+z.l3+z.l4+z.l5+z.l6; + fprintf(out,"double f(17*double,3*int,L):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,s,t,u,z.l1,z.l2,z.l3,z.l4,z.l5,z.l6); + fflush(out); + va_return_double(alist, r); + }} + else if (current_function == (void*)&ll_l2ll) + { + va_start_longlong(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long long b = va_arg_longlong(alist); + long c = va_arg_long(alist); + long long r = (long long) (a1 + a2) + b + c; + fprintf(out,"long long f(2*long,long long,long):(%ld,%ld,0x%lx%08lx,%ld)",a1,a2,(long)(b>>32),(long)(b&0xffffffff),c); + fflush(out); + va_return_longlong(alist, r); + }} + else if (current_function == (void*)&ll_l3ll) + { + va_start_longlong(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long long b = va_arg_longlong(alist); + long c = va_arg_long(alist); + long long r = (long long) (a1 + a2 + a3) + b + c; + fprintf(out,"long long f(3*long,long long,long):(%ld,%ld,%ld,0x%lx%08lx,%ld)",a1,a2,a3,(long)(b>>32),(long)(b&0xffffffff),c); + fflush(out); + va_return_longlong(alist, r); + }} + else if (current_function == (void*)&ll_l4ll) + { + va_start_longlong(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + long long b = va_arg_longlong(alist); + long c = va_arg_long(alist); + long long r = (long long) (a1 + a2 + a3 + a4) + b + c; + fprintf(out,"long long f(4*long,long long,long):(%ld,%ld,%ld,%ld,0x%lx%08lx,%ld)",a1,a2,a3,a4,(long)(b>>32),(long)(b&0xffffffff),c); + fflush(out); + va_return_longlong(alist, r); + }} + else if (current_function == (void*)&ll_l5ll) + { + va_start_longlong(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + long a5 = va_arg_long(alist); + long long b = va_arg_longlong(alist); + long c = va_arg_long(alist); + long long r = (long long) (a1 + a2 + a3 + a4 + a5) + b + c; + fprintf(out,"long long f(5*long,long long,long):(%ld,%ld,%ld,%ld,%ld,0x%lx%08lx,%ld)",a1,a2,a3,a4,a5,(long)(b>>32),(long)(b&0xffffffff),c); + fflush(out); + va_return_longlong(alist, r); + }} + else if (current_function == (void*)&ll_l6ll) + { + va_start_longlong(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + long a5 = va_arg_long(alist); + long a6 = va_arg_long(alist); + long long b = va_arg_longlong(alist); + long c = va_arg_long(alist); + long long r = (long long) (a1 + a2 + a3 + a4 + a5 + a6) + b + c; + fprintf(out,"long long f(6*long,long long,long):(%ld,%ld,%ld,%ld,%ld,%ld,0x%lx%08lx,%ld)",a1,a2,a3,a4,a5,a6,(long)(b>>32),(long)(b&0xffffffff),c); + fflush(out); + va_return_longlong(alist, r); + }} + else if (current_function == (void*)&ll_l7ll) + { + va_start_longlong(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + long a5 = va_arg_long(alist); + long a6 = va_arg_long(alist); + long a7 = va_arg_long(alist); + long long b = va_arg_longlong(alist); + long c = va_arg_long(alist); + long long r = (long long) (a1 + a2 + a3 + a4 + a5 + a6 + a7) + b + c; + fprintf(out,"long long f(7*long,long long,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,0x%lx%08lx,%ld)",a1,a2,a3,a4,a5,a6,a7,(long)(b>>32),(long)(b&0xffffffff),c); + fflush(out); + va_return_longlong(alist, r); + }} + else if (current_function == (void*)&d_l2d) + { + va_start_double(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + double b = va_arg_double(alist); + long c = va_arg_long(alist); + double r = (double) (a1 + a2) + b + c; + fprintf(out,"double f(2*long,double,long):(%ld,%ld,%g,%ld)",a1,a2,b,c); + fflush(out); + va_return_double(alist, r); + }} + else if (current_function == (void*)&d_l3d) + { + va_start_double(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + double b = va_arg_double(alist); + long c = va_arg_long(alist); + double r = (double) (a1 + a2 + a3) + b + c; + fprintf(out,"double f(3*long,double,long):(%ld,%ld,%ld,%g,%ld)",a1,a2,a3,b,c); + fflush(out); + va_return_double(alist, r); + }} + else if (current_function == (void*)&d_l4d) + { + va_start_double(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + double b = va_arg_double(alist); + long c = va_arg_long(alist); + double r = (double) (a1 + a2 + a3 + a4) + b + c; + fprintf(out,"double f(4*long,double,long):(%ld,%ld,%ld,%ld,%g,%ld)",a1,a2,a3,a4,b,c); + fflush(out); + va_return_double(alist, r); + }} + else if (current_function == (void*)&d_l5d) + { + va_start_double(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + long a5 = va_arg_long(alist); + double b = va_arg_double(alist); + long c = va_arg_long(alist); + double r = (double) (a1 + a2 + a3 + a4 + a5) + b + c; + fprintf(out,"double f(5*long,double,long):(%ld,%ld,%ld,%ld,%ld,%g,%ld)",a1,a2,a3,a4,a5,b,c); + fflush(out); + va_return_double(alist, r); + }} + else if (current_function == (void*)&d_l6d) + { + va_start_double(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + long a5 = va_arg_long(alist); + long a6 = va_arg_long(alist); + double b = va_arg_double(alist); + long c = va_arg_long(alist); + double r = (double) (a1 + a2 + a3 + a4 + a5 + a6) + b + c; + fprintf(out,"double f(6*long,double,long):(%ld,%ld,%ld,%ld,%ld,%ld,%g,%ld)",a1,a2,a3,a4,a5,a6,b,c); + fflush(out); + va_return_double(alist, r); + }} + else if (current_function == (void*)&d_l7d) + { + va_start_double(alist); + {long a1 = va_arg_long(alist); + long a2 = va_arg_long(alist); + long a3 = va_arg_long(alist); + long a4 = va_arg_long(alist); + long a5 = va_arg_long(alist); + long a6 = va_arg_long(alist); + long a7 = va_arg_long(alist); + double b = va_arg_double(alist); + long c = va_arg_long(alist); + double r = (double) (a1 + a2 + a3 + a4 + a5 + a6 + a7) + b + c; + fprintf(out,"double f(7*long,double,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%g,%ld)",a1,a2,a3,a4,a5,a6,a7,b,c); + fflush(out); + va_return_double(alist, r); + }} + + /* by-value tests */ + else if (current_function == (void*)&v_clobber_K) + { + va_start_void(alist); + {K k = va_arg_struct(alist, K); + k.l1 += 1; + k.l2 += 10; + k.l3 += 100; + k.l4 += 1000; + va_return_void(alist); + }} + + else + { + fprintf(out,"simulate: unknown function\n"); + fflush(out); + } +} + + +/* + * The way we run these tests - first call the function directly, then + * through vacall() - there is the danger that arguments or results seem + * to be passed correctly, but what we are seeing are in fact the vestiges + * (traces) or the previous call. This may seriously fake the test. + * Avoid this by clearing the registers between the first and the second call. + */ +long clear_traces_i (long a, long b, long c, long d, long e, long f, long g, long h, + long i, long j, long k, long l, long m, long n, long o, long p) +{ return 0; } +float clear_traces_f (float a, float b, float c, float d, float e, float f, float g, + float h, float i, float j, float k, float l, float m, float n, + float o, float p) +{ return 0.0; } +double clear_traces_d (double a, double b, double c, double d, double e, double f, double g, + double h, double i, double j, double k, double l, double m, double n, + double o, double p) +{ return 0.0; } +J clear_traces_J (void) +{ J j; j.l1 = j.l2 = 0; return j; } +void clear_traces (void) +{ clear_traces_i(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); + clear_traces_f(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.0); + clear_traces_d(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.0); + clear_traces_J(); +} + +int main (void) +{ + out = stdout; + + vacall_function = &simulator; + + /* void tests */ + v_v(); + clear_traces(); + current_function = (void*) &v_v; ((void (*) (void)) vacall) (); + + /* int tests */ + { int ir; + + ir = i_v(); + fprintf(out,"->%d\n",ir); + fflush(out); + ir = 0; clear_traces(); + current_function = (void*) &i_v; ir = ((int (*) (void)) vacall) (); + fprintf(out,"->%d\n",ir); + fflush(out); + + ir = i_i(i1); + fprintf(out,"->%d\n",ir); + fflush(out); + ir = 0; clear_traces(); + current_function = (void*) &i_i; ir = ((int (*) (int)) vacall) (i1); + fprintf(out,"->%d\n",ir); + fflush(out); + + ir = i_i2(i1,i2); + fprintf(out,"->%d\n",ir); + fflush(out); + ir = 0; clear_traces(); + current_function = (void*) &i_i2; ir = ((int (*) (int,int)) vacall) (i1,i2); + fprintf(out,"->%d\n",ir); + fflush(out); + + ir = i_i4(i1,i2,i3,i4); + fprintf(out,"->%d\n",ir); + fflush(out); + ir = 0; clear_traces(); + current_function = (void*) &i_i4; ir = ((int (*) (int,int,int,int)) vacall) (i1,i2,i3,i4); + fprintf(out,"->%d\n",ir); + fflush(out); + + ir = i_i8(i1,i2,i3,i4,i5,i6,i7,i8); + fprintf(out,"->%d\n",ir); + fflush(out); + ir = 0; clear_traces(); + current_function = (void*) &i_i8; ir = ((int (*) (int,int,int,int,int,int,int,int)) vacall) (i1,i2,i3,i4,i5,i6,i7,i8); + fprintf(out,"->%d\n",ir); + fflush(out); + + ir = i_i16(i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14,i15,i16); + fprintf(out,"->%d\n",ir); + fflush(out); + ir = 0; clear_traces(); + current_function = (void*) &i_i16; ir = ((int (*) (int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int)) vacall) (i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14,i15,i16); + fprintf(out,"->%d\n",ir); + fflush(out); + + ir = i_i32(i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14,i15,i16,i17,i18,i19,i20,i21,i22,i23,i24,i25,i26,i27,i28,i29,i30,i31,i32); + fprintf(out,"->%d\n",ir); + fflush(out); + ir = 0; clear_traces(); + current_function = (void*) &i_i32; ir = ((int (*) (int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int)) vacall) (i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14,i15,i16,i17,i18,i19,i20,i21,i22,i23,i24,i25,i26,i27,i28,i29,i30,i31,i32); + fprintf(out,"->%d\n",ir); + fflush(out); + } + + /* float tests */ + { float fr; + + fr = f_f(f1); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + current_function = (void*) &f_f; fr = ((float (*) (float)) vacall) (f1); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f2(f1,f2); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + current_function = (void*) &f_f2; fr = ((float (*) (float,float)) vacall) (f1,f2); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f4(f1,f2,f3,f4); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + current_function = (void*) &f_f4; fr = ((float (*) (float,float,float,float)) vacall) (f1,f2,f3,f4); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f8(f1,f2,f3,f4,f5,f6,f7,f8); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + current_function = (void*) &f_f8; fr = ((float (*) (float,float,float,float,float,float,float,float)) vacall) (f1,f2,f3,f4,f5,f6,f7,f8); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f16(f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + current_function = (void*) &f_f16; fr = ((float (*) (float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float)) vacall) (f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f24(f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16,f17,f18,f19,f20,f21,f22,f23,f24); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + current_function = (void*) &f_f24; fr = ((float (*) (float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float)) vacall) (f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16,f17,f18,f19,f20,f21,f22,f23,f24); + fprintf(out,"->%g\n",fr); + fflush(out); + } + + /* double tests */ + { double dr; + + dr = d_d(d1); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + current_function = (void*) &d_d; dr = ((double (*) (double)) vacall) (d1); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d2(d1,d2); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + current_function = (void*) &d_d2; dr = ((double (*) (double,double)) vacall) (d1,d2); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d4(d1,d2,d3,d4); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + current_function = (void*) &d_d4; dr = ((double (*) (double,double,double,double)) vacall) (d1,d2,d3,d4); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d8(d1,d2,d3,d4,d5,d6,d7,d8); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + current_function = (void*) &d_d8; dr = ((double (*) (double,double,double,double,double,double,double,double)) vacall) (d1,d2,d3,d4,d5,d6,d7,d8); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d16(d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,d14,d15,d16); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + current_function = (void*) &d_d16; dr = ((double (*) (double,double,double,double,double,double,double,double,double,double,double,double,double,double,double,double)) vacall) (d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,d14,d15,d16); + fprintf(out,"->%g\n",dr); + fflush(out); + } + + /* pointer tests */ + { void* vpr; + + vpr = vp_vpdpcpsp(&uc1,&d2,str3,&I4); + fprintf(out,"->0x%p\n",vpr); + fflush(out); + vpr = 0; clear_traces(); + current_function = (void*) &vp_vpdpcpsp; vpr = ((void* (*) (void*,double*,char*,Int*)) vacall) (&uc1,&d2,str3,&I4); + fprintf(out,"->0x%p\n",vpr); + fflush(out); + } + + /* mixed number tests */ + { uchar ucr; + ushort usr; + float fr; + double dr; + long long llr; + + ucr = uc_ucsil(uc1,us2,ui3,ul4); + fprintf(out,"->%u\n",ucr); + fflush(out); + ucr = 0; clear_traces(); + current_function = (void*) &uc_ucsil; ucr = ((uchar (*) (uchar,ushort,uint,ulong)) vacall) (uc1,us2,ui3,ul4); + fprintf(out,"->%u\n",ucr); + fflush(out); + + dr = d_iidd(i1,i2,d3,d4); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + current_function = (void*) &d_iidd; dr = ((double (*) (int,int,double,double)) vacall) (i1,i2,d3,d4); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_iiidi(i1,i2,i3,d4,i5); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + current_function = (void*) &d_iiidi; dr = ((double (*) (int,int,int,double,int)) vacall) (i1,i2,i3,d4,i5); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_idid(i1,d2,i3,d4); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + current_function = (void*) &d_idid; dr = ((double (*) (int,double,int,double)) vacall) (i1,d2,i3,d4); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_fdi(f1,d2,i3); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + current_function = (void*) &d_fdi; dr = ((double (*) (float,double,int)) vacall) (f1,d2,i3); + fprintf(out,"->%g\n",dr); + fflush(out); + + usr = us_cdcd(c1,d2,c3,d4); + fprintf(out,"->%u\n",usr); + fflush(out); + usr = 0; clear_traces(); + current_function = (void*) &us_cdcd; usr = ((ushort (*) (char,double,char,double)) vacall) (c1,d2,c3,d4); + fprintf(out,"->%u\n",usr); + fflush(out); + + llr = ll_iiilli(i1,i2,i3,ll1,i13); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + llr = 0; clear_traces(); + current_function = (void*) &ll_iiilli; llr = ((long long (*) (int,int,int,long long,int)) vacall) (i1,i2,i3,ll1,i13); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + + llr = ll_flli(f13,ll1,i13); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + llr = 0; clear_traces(); + current_function = (void*) &ll_flli; llr = ((long long (*) (float,long long,int)) vacall) (f13,ll1,i13); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + + fr = f_fi(f1,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + current_function = (void*) &f_fi; fr = ((float (*) (float,int)) vacall) (f1,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f2i(f1,f2,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + current_function = (void*) &f_f2i; fr = ((float (*) (float,float,int)) vacall) (f1,f2,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f3i(f1,f2,f3,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + current_function = (void*) &f_f3i; fr = ((float (*) (float,float,float,int)) vacall) (f1,f2,f3,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f4i(f1,f2,f3,f4,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + current_function = (void*) &f_f4i; fr = ((float (*) (float,float,float,float,int)) vacall) (f1,f2,f3,f4,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f7i(f1,f2,f3,f4,f5,f6,f7,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + current_function = (void*) &f_f7i; fr = ((float (*) (float,float,float,float,float,float,float,int)) vacall) (f1,f2,f3,f4,f5,f6,f7,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f8i(f1,f2,f3,f4,f5,f6,f7,f8,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + current_function = (void*) &f_f8i; fr = ((float (*) (float,float,float,float,float,float,float,float,int)) vacall) (f1,f2,f3,f4,f5,f6,f7,f8,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f12i(f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + current_function = (void*) &f_f12i; fr = ((float (*) (float,float,float,float,float,float,float,float,float,float,float,float,int)) vacall) (f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + + fr = f_f13i(f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + current_function = (void*) &f_f13i; fr = ((float (*) (float,float,float,float,float,float,float,float,float,float,float,float,float,int)) vacall) (f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,i9); + fprintf(out,"->%g\n",fr); + fflush(out); + + dr = d_di(d1,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + current_function = (void*) &d_di; dr = ((double (*) (double,int)) vacall) (d1,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d2i(d1,d2,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + current_function = (void*) &d_d2i; dr = ((double (*) (double,double,int)) vacall) (d1,d2,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d3i(d1,d2,d3,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + current_function = (void*) &d_d3i; dr = ((double (*) (double,double,double,int)) vacall) (d1,d2,d3,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d4i(d1,d2,d3,d4,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + current_function = (void*) &d_d4i; dr = ((double (*) (double,double,double,double,int)) vacall) (d1,d2,d3,d4,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d7i(d1,d2,d3,d4,d5,d6,d7,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + current_function = (void*) &d_d7i; dr = ((double (*) (double,double,double,double,double,double,double,int)) vacall) (d1,d2,d3,d4,d5,d6,d7,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d8i(d1,d2,d3,d4,d5,d6,d7,d8,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + current_function = (void*) &d_d8i; dr = ((double (*) (double,double,double,double,double,double,double,double,int)) vacall) (d1,d2,d3,d4,d5,d6,d7,d8,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d12i(d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + current_function = (void*) &d_d12i; dr = ((double (*) (double,double,double,double,double,double,double,double,double,double,double,double,int)) vacall) (d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_d13i(d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + current_function = (void*) &d_d13i; dr = ((double (*) (double,double,double,double,double,double,double,double,double,double,double,double,double,int)) vacall) (d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,i9); + fprintf(out,"->%g\n",dr); + fflush(out); + } + + /* small structure return tests */ + { + Size1 r = S1_v(); + fprintf(out,"->{%c}\n",r.x1); + fflush(out); + memset(&r,0,sizeof(r)); clear_traces(); + current_function = (void*) &S1_v; r = ((Size1 (*) (void)) vacall) (); + fprintf(out,"->{%c}\n",r.x1); + fflush(out); + } + { + Size2 r = S2_v(); + fprintf(out,"->{%c%c}\n",r.x1,r.x2); + fflush(out); + memset(&r,0,sizeof(r)); clear_traces(); + current_function = (void*) &S2_v; r = ((Size2 (*) (void)) vacall) (); + fprintf(out,"->{%c%c}\n",r.x1,r.x2); + fflush(out); + } + { + Size3 r = S3_v(); + fprintf(out,"->{%c%c%c}\n",r.x1,r.x2,r.x3); + fflush(out); + memset(&r,0,sizeof(r)); clear_traces(); + current_function = (void*) &S3_v; r = ((Size3 (*) (void)) vacall) (); + fprintf(out,"->{%c%c%c}\n",r.x1,r.x2,r.x3); + fflush(out); + } + { + Size4 r = S4_v(); + fprintf(out,"->{%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4); + fflush(out); + memset(&r,0,sizeof(r)); clear_traces(); + current_function = (void*) &S4_v; r = ((Size4 (*) (void)) vacall) (); + fprintf(out,"->{%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4); + fflush(out); + } + { + Size7 r = S7_v(); + fprintf(out,"->{%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7); + fflush(out); + memset(&r,0,sizeof(r)); clear_traces(); + current_function = (void*) &S7_v; r = ((Size7 (*) (void)) vacall) (); + fprintf(out,"->{%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7); + fflush(out); + } + { + Size8 r = S8_v(); + fprintf(out,"->{%c%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7,r.x8); + fflush(out); + memset(&r,0,sizeof(r)); clear_traces(); + current_function = (void*) &S8_v; r = ((Size8 (*) (void)) vacall) (); + fprintf(out,"->{%c%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7,r.x8); + fflush(out); + } + { + Size12 r = S12_v(); + fprintf(out,"->{%c%c%c%c%c%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7,r.x8,r.x9,r.x10,r.x11,r.x12); + fflush(out); + memset(&r,0,sizeof(r)); clear_traces(); + current_function = (void*) &S12_v; r = ((Size12 (*) (void)) vacall) (); + fprintf(out,"->{%c%c%c%c%c%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7,r.x8,r.x9,r.x10,r.x11,r.x12); + fflush(out); + } + { + Size15 r = S15_v(); + fprintf(out,"->{%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7,r.x8,r.x9,r.x10,r.x11,r.x12,r.x13,r.x14,r.x15); + fflush(out); + memset(&r,0,sizeof(r)); clear_traces(); + current_function = (void*) &S15_v; r = ((Size15 (*) (void)) vacall) (); + fprintf(out,"->{%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7,r.x8,r.x9,r.x10,r.x11,r.x12,r.x13,r.x14,r.x15); + fflush(out); + } + { + Size16 r = S16_v(); + fprintf(out,"->{%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7,r.x8,r.x9,r.x10,r.x11,r.x12,r.x13,r.x14,r.x15,r.x16); + fflush(out); + memset(&r,0,sizeof(r)); clear_traces(); + current_function = (void*) &S16_v; r = ((Size16 (*) (void)) vacall) (); + fprintf(out,"->{%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c}\n",r.x1,r.x2,r.x3,r.x4,r.x5,r.x6,r.x7,r.x8,r.x9,r.x10,r.x11,r.x12,r.x13,r.x14,r.x15,r.x16); + fflush(out); + } + + /* structure tests */ + { Int Ir; + Char Cr; + Float Fr; + Double Dr; + J Jr; + T Tr; + X Xr; + + Ir = I_III(I1,I2,I3); + fprintf(out,"->{%d}\n",Ir.x); + fflush(out); + Ir.x = 0; clear_traces(); + current_function = (void*) &I_III; Ir = ((Int (*) (Int,Int,Int)) vacall) (I1,I2,I3); + fprintf(out,"->{%d}\n",Ir.x); + fflush(out); + +#ifndef SKIP_EXTRA_STRUCTS + Cr = C_CdC(C1,d2,C3); + fprintf(out,"->{'%c'}\n",Cr.x); + fflush(out); + Cr.x = '\0'; clear_traces(); + current_function = (void*) &C_CdC; Cr = ((Char (*) (Char,double,Char)) vacall) (C1,d2,C3); + fprintf(out,"->{'%c'}\n",Cr.x); + fflush(out); + + Fr = F_Ffd(F1,f2,d3); + fprintf(out,"->{%g}\n",Fr.x); + fflush(out); + Fr.x = 0.0; clear_traces(); + current_function = (void*) &F_Ffd; Fr = ((Float (*) (Float,float,double)) vacall) (F1,f2,d3); + fprintf(out,"->{%g}\n",Fr.x); + fflush(out); + + Dr = D_fDd(f1,D2,d3); + fprintf(out,"->{%g}\n",Dr.x); + fflush(out); + Dr.x = 0.0; clear_traces(); + current_function = (void*) &D_fDd; Dr = ((Double (*) (float,Double,double)) vacall) (f1,D2,d3); + fprintf(out,"->{%g}\n",Dr.x); + fflush(out); + + Dr = D_Dfd(D1,f2,d3); + fprintf(out,"->{%g}\n",Dr.x); + fflush(out); + Dr.x = 0.0; clear_traces(); + current_function = (void*) &D_Dfd; Dr = ((Double (*) (Double,float,double)) vacall) (D1,f2,d3); + fprintf(out,"->{%g}\n",Dr.x); + fflush(out); +#endif + + Jr = J_JiJ(J1,i2,J2); + fprintf(out,"->{%ld,%ld}\n",Jr.l1,Jr.l2); + fflush(out); + Jr.l1 = Jr.l2 = 0; clear_traces(); + current_function = (void*) &J_JiJ; Jr = ((J (*) (J,int,J)) vacall) (J1,i2,J2); + fprintf(out,"->{%ld,%ld}\n",Jr.l1,Jr.l2); + fflush(out); + +#ifndef SKIP_EXTRA_STRUCTS +#ifndef SKIP_T + Tr = T_TcT(T1,' ',T2); + fprintf(out,"->{\"%c%c%c\"}\n",Tr.c[0],Tr.c[1],Tr.c[2]); + fflush(out); + Tr.c[0] = Tr.c[1] = Tr.c[2] = 0; clear_traces(); + current_function = (void*) &T_TcT; Tr = ((T (*) (T,char,T)) vacall) (T1,' ',T2); + fprintf(out,"->{\"%c%c%c\"}\n",Tr.c[0],Tr.c[1],Tr.c[2]); + fflush(out); +#endif + +#ifndef SKIP_X + Xr = X_BcdB(B1,c2,d3,B2); + fprintf(out,"->{\"%s\",'%c'}\n",Xr.c,Xr.c1); + fflush(out); + Xr.c[0]=Xr.c1='\0'; clear_traces(); + current_function = (void*) &X_BcdB; Xr = ((X (*) (B,char,double,B)) vacall) (B1,c2,d3,B2); + fprintf(out,"->{\"%s\",'%c'}\n",Xr.c,Xr.c1); + fflush(out); +#endif +#endif + } + + /* gpargs boundary tests */ + { long lr; + long long llr; + float fr; + double dr; + + lr = l_l0J(J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + current_function = (void*) &l_l0J; lr = ((long (*) (J,long)) vacall) (J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l1J(l1,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + current_function = (void*) &l_l1J; lr = ((long (*) (long,J,long)) vacall) (l1,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l2J(l1,l2,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + current_function = (void*) &l_l2J; lr = ((long (*) (long,long,J,long)) vacall) (l1,l2,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l3J(l1,l2,l3,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + current_function = (void*) &l_l3J; lr = ((long (*) (long,long,long,J,long)) vacall) (l1,l2,l3,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l4J(l1,l2,l3,l4,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + current_function = (void*) &l_l4J; lr = ((long (*) (long,long,long,long,J,long)) vacall) (l1,l2,l3,l4,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l5J(l1,l2,l3,l4,l5,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + current_function = (void*) &l_l5J; lr = ((long (*) (long,long,long,long,long,J,long)) vacall) (l1,l2,l3,l4,l5,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l6J(l1,l2,l3,l4,l5,l6,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + current_function = (void*) &l_l6J; lr = ((long (*) (long,long,long,long,long,long,J,long)) vacall) (l1,l2,l3,l4,l5,l6,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l7J(l1,l2,l3,l4,l5,l6,l7,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + current_function = (void*) &l_l7J; lr = ((long (*) (long,long,long,long,long,long,long,J,long)) vacall) (l1,l2,l3,l4,l5,l6,l7,J1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l0K(K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + current_function = (void*) &l_l0K; lr = ((long (*) (K,long)) vacall) (K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l1K(l1,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + current_function = (void*) &l_l1K; lr = ((long (*) (long,K,long)) vacall) (l1,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l2K(l1,l2,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + current_function = (void*) &l_l2K; lr = ((long (*) (long,long,K,long)) vacall) (l1,l2,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l3K(l1,l2,l3,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + current_function = (void*) &l_l3K; lr = ((long (*) (long,long,long,K,long)) vacall) (l1,l2,l3,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l4K(l1,l2,l3,l4,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + current_function = (void*) &l_l4K; lr = ((long (*) (long,long,long,long,K,long)) vacall) (l1,l2,l3,l4,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l5K(l1,l2,l3,l4,l5,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + current_function = (void*) &l_l5K; lr = ((long (*) (long,long,long,long,long,K,long)) vacall) (l1,l2,l3,l4,l5,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + lr = l_l6K(l1,l2,l3,l4,l5,l6,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + lr = 0; clear_traces(); + current_function = (void*) &l_l6K; lr = ((long (*) (long,long,long,long,long,long,K,long)) vacall) (l1,l2,l3,l4,l5,l6,K1,l9); + fprintf(out,"->%ld\n",lr); + fflush(out); + + fr = f_f17l3L(f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16,f17,l6,l7,l8,L1); + fprintf(out,"->%g\n",fr); + fflush(out); + fr = 0.0; clear_traces(); + current_function = (void*) &f_f17l3L; fr = ((float (*) (float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,long,long,long,L)) vacall) (f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16,f17,l6,l7,l8,L1); + fprintf(out,"->%g\n",fr); + fflush(out); + + dr = d_d17l3L(d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,d14,d15,d16,d17,l6,l7,l8,L1); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + current_function = (void*) &d_d17l3L; dr = ((double (*) (double,double,double,double,double,double,double,double,double,double,double,double,double,double,double,double,double,long,long,long,L)) vacall) (d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,d14,d15,d16,d17,l6,l7,l8,L1); + fprintf(out,"->%g\n",dr); + fflush(out); + + llr = ll_l2ll(l1,l2,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + llr = 0; clear_traces(); + current_function = (void*) &ll_l2ll; llr = ((long long (*) (long,long,long long,long)) vacall) (l1,l2,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + + llr = ll_l3ll(l1,l2,l3,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + llr = 0; clear_traces(); + current_function = (void*) &ll_l3ll; llr = ((long long (*) (long,long,long,long long,long)) vacall) (l1,l2,l3,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + + llr = ll_l4ll(l1,l2,l3,l4,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + llr = 0; clear_traces(); + current_function = (void*) &ll_l4ll; llr = ((long long (*) (long,long,long,long,long long,long)) vacall) (l1,l2,l3,l4,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + + llr = ll_l5ll(l1,l2,l3,l4,l5,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + llr = 0; clear_traces(); + current_function = (void*) &ll_l5ll; llr = ((long long (*) (long,long,long,long,long,long long,long)) vacall) (l1,l2,l3,l4,l5,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + + llr = ll_l6ll(l1,l2,l3,l4,l5,l6,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + llr = 0; clear_traces(); + current_function = (void*) &ll_l6ll; llr = ((long long (*) (long,long,long,long,long,long,long long,long)) vacall) (l1,l2,l3,l4,l5,l6,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + + llr = ll_l7ll(l1,l2,l3,l4,l5,l6,l7,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + llr = 0; clear_traces(); + current_function = (void*) &ll_l7ll; llr = ((long long (*) (long,long,long,long,long,long,long,long long,long)) vacall) (l1,l2,l3,l4,l5,l6,l7,ll1,l9); + fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff)); + fflush(out); + + dr = d_l2d(l1,l2,ll1,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + current_function = (void*) &d_l2d; dr = ((double (*) (long,long,double,long)) vacall) (l1,l2,ll1,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_l3d(l1,l2,l3,ll1,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + current_function = (void*) &d_l3d; dr = ((double (*) (long,long,long,double,long)) vacall) (l1,l2,l3,ll1,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_l4d(l1,l2,l3,l4,ll1,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + current_function = (void*) &d_l4d; dr = ((double (*) (long,long,long,long,double,long)) vacall) (l1,l2,l3,l4,ll1,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_l5d(l1,l2,l3,l4,l5,ll1,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + current_function = (void*) &d_l5d; dr = ((double (*) (long,long,long,long,long,double,long)) vacall) (l1,l2,l3,l4,l5,ll1,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_l6d(l1,l2,l3,l4,l5,l6,ll1,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + current_function = (void*) &d_l6d; dr = ((double (*) (long,long,long,long,long,long,double,long)) vacall) (l1,l2,l3,l4,l5,l6,ll1,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + + dr = d_l7d(l1,l2,l3,l4,l5,l6,l7,ll1,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + dr = 0.0; clear_traces(); + current_function = (void*) &d_l7d; dr = ((double (*) (long,long,long,long,long,long,long,double,long)) vacall) (l1,l2,l3,l4,l5,l6,l7,ll1,l9); + fprintf(out,"->%g\n",dr); + fflush(out); + } + + /* by-value tests */ + /* This test is trivial, since a copy of k is allocated on the callee's stack. + But anyway... */ + { K k; + + k.l1 = l1; + k.l2 = l2; + k.l3 = l3; + k.l4 = l4; + fprintf(out,"by_value:%ld,%ld,%ld,%ld\n",k.l1,k.l2,k.l3,k.l4); + fflush(out); + clear_traces(); + current_function = (void*) &v_clobber_K; ((void (*) (K)) vacall) (k); + fprintf(out,"by_value:%ld,%ld,%ld,%ld\n",k.l1,k.l2,k.l3,k.l4); + fflush(out); + } + + exit(0); +} diff --git a/vacall/vacall-alpha-linux.s b/vacall/vacall-alpha-linux.s new file mode 100644 index 0000000..85364c8 --- /dev/null +++ b/vacall/vacall-alpha-linux.s @@ -0,0 +1,174 @@ + .set noreorder + .set volatile + .set noat + .set nomacro + .text + .align 2 + .align 4 + .globl vacall_receiver + .ent vacall_receiver +vacall_receiver: + .frame $15,192,$26,48 + .mask 0x4008000,-192 + ldah $29,0($27) !gpdisp!1 + lda $29,0($29) !gpdisp!1 +$vacall_receiver..ng: + lda $30,-192($30) + stq $15,8($30) + mov $30,$15 + lda $3,144($15) + stq $26,0($30) + .prologue 1 + lda $2,88($15) + stq $16,144($15) + subq $2,$3,$2 + ldq $3,vacall_function($29) !literal + stq $2,80($15) + lda $2,192($15) + lda $16,16($15) + stq $2,72($15) + ldq $27,0($3) + lda $2,144($15) + stq $17,152($15) + stq $18,160($15) + stq $19,168($15) + stq $20,176($15) + stq $21,184($15) + stt $f16,88($15) + stt $f17,96($15) + stt $f18,104($15) + stt $f19,112($15) + stt $f20,120($15) + stt $f21,128($15) + stl $31,16($15) + stq $2,40($15) + stq $31,48($15) + stl $31,56($15) + jsr $26,($27),0 + ldah $29,0($26) !gpdisp!2 + lda $29,0($29) !gpdisp!2 + ldl $2,56($15) + beq $2,$L43 + zapnot $2,15,$3 + cmpeq $3,1,$2 + bne $2,$L44 + cmpeq $3,2,$2 + bne $2,$L44 + cmpeq $3,3,$2 + bne $2,$L50 + cmpeq $3,4,$2 + bne $2,$L51 + cmpeq $3,5,$2 + bne $2,$L52 + cmpeq $3,6,$2 + bne $2,$L53 + cmpeq $3,7,$2 + bne $2,$L54 + cmpeq $3,8,$2 + bne $2,$L48 + cmpeq $3,9,$2 + bne $2,$L48 + cmpeq $3,10,$2 + bne $2,$L48 + cmpeq $3,11,$2 + bne $2,$L48 + cmpeq $3,12,$2 + bne $2,$L55 + cmpeq $3,13,$2 + bne $2,$L56 + cmpeq $3,14,$2 + bne $2,$L48 + cmpeq $3,15,$2 + beq $2,$L43 + lda $2,1024($31) + ldl $3,16($15) + and $2,$3,$2 + beq $2,$L43 + ldq $3,64($15) + cmpeq $3,1,$2 + bne $2,$L57 + cmpeq $3,2,$2 + bne $2,$L58 + cmpeq $3,4,$2 + bne $2,$L59 + cmpeq $3,8,$2 + bne $2,$L60 + cmpeq $3,16,$2 + beq $2,$L43 + ldq $2,48($15) + ldq $1,8($2) + ldq $0,0($2) + .align 4 +$L43: + mov $15,$30 + ldq $26,0($30) + ldq $15,8($30) + lda $30,192($30) + ret $31,($26),1 + .align 4 +$L44: + mov $15,$30 + ldl $2,24($15) + ldq $26,0($30) + sll $2,56,$2 + sra $2,56,$0 + ldq $15,8($30) + lda $30,192($30) + ret $31,($26),1 +$L51: + ldl $2,24($15) + sll $2,48,$2 + sra $2,48,$0 + br $31,$L43 +$L50: + ldl $2,24($15) + bis $31,$31,$31 + and $2,0xff,$0 + br $31,$L43 +$L48: + ldq $0,24($15) + br $31,$L43 +$L52: + ldl $2,24($15) + bis $31,$31,$31 + zapnot $2,3,$0 + br $31,$L43 +$L53: + ldl $3,24($15) + bis $31,$31,$31 + mov $3,$0 + br $31,$L43 +$L54: + ldl $2,24($15) + bis $31,$31,$31 + zapnot $2,15,$0 + br $31,$L43 +$L55: + lds $f0,24($15) + br $31,$L43 +$L56: + ldt $f0,24($15) + br $31,$L43 +$L57: + ldq $3,48($15) + ldq_u $2,0($3) + extbl $2,$3,$0 + br $31,$L43 +$L58: + ldq $3,48($15) + ldq_u $2,0($3) + extwl $2,$3,$0 + br $31,$L43 +$L60: + ldq $2,48($15) + bis $31,$31,$31 + ldq $0,0($2) + br $31,$L43 +$L59: + ldq $2,48($15) + ldl $3,0($2) + zapnot $3,15,$0 + br $31,$L43 + .end vacall_receiver + .ident "GCC: (GNU) 4.0.2" + .section .note.GNU-stack,"",@progbits diff --git a/vacall/vacall-alpha-macro.S b/vacall/vacall-alpha-macro.S new file mode 100644 index 0000000..2655035 --- /dev/null +++ b/vacall/vacall-alpha-macro.S @@ -0,0 +1,175 @@ + .set noreorder + .set volatile + .set noat + .set nomacro + .text + .align 2 + .align 4 + .globl vacall_receiver + .ent vacall_receiver +vacall_receiver: + .frame $15,192,$26,48 + .mask 0x4008000,-192 + ldah $29,0($27) !gpdisp!1 + lda $29,0($29) !gpdisp!1 +$vacall_receiver..ng: + lda $30,-192($30) + stq $15,8($30) + mov $30,$15 + lda $3,144($15) + stq $26,0($30) + .prologue 1 + lda $2,88($15) + stq $16,144($15) + subq $2,$3,$2 + ldq $3,vacall_function($29) !literal + stq $2,80($15) + lda $2,192($15) + lda $16,16($15) + stq $2,72($15) + ldq $27,0($3) + lda $2,144($15) + stq $17,152($15) + stq $18,160($15) + stq $19,168($15) + stq $20,176($15) + stq $21,184($15) + stt $f16,88($15) + stt $f17,96($15) + stt $f18,104($15) + stt $f19,112($15) + stt $f20,120($15) + stt $f21,128($15) + stl $31,16($15) + stq $2,40($15) + stq $31,48($15) + stl $31,56($15) + jsr $26,($27),0 + ldah $29,0($26) !gpdisp!2 + lda $29,0($29) !gpdisp!2 + ldl $2,56($15) + beq $2,$L43 + zapnot $2,15,$3 + cmpeq $3,1,$2 + bne $2,$L44 + cmpeq $3,2,$2 + bne $2,$L44 + cmpeq $3,3,$2 + bne $2,$L50 + cmpeq $3,4,$2 + bne $2,$L51 + cmpeq $3,5,$2 + bne $2,$L52 + cmpeq $3,6,$2 + bne $2,$L53 + cmpeq $3,7,$2 + bne $2,$L54 + cmpeq $3,8,$2 + bne $2,$L48 + cmpeq $3,9,$2 + bne $2,$L48 + cmpeq $3,10,$2 + bne $2,$L48 + cmpeq $3,11,$2 + bne $2,$L48 + cmpeq $3,12,$2 + bne $2,$L55 + cmpeq $3,13,$2 + bne $2,$L56 + cmpeq $3,14,$2 + bne $2,$L48 + cmpeq $3,15,$2 + beq $2,$L43 + lda $2,1024($31) + ldl $3,16($15) + and $2,$3,$2 + beq $2,$L43 + ldq $3,64($15) + cmpeq $3,1,$2 + bne $2,$L57 + cmpeq $3,2,$2 + bne $2,$L58 + cmpeq $3,4,$2 + bne $2,$L59 + cmpeq $3,8,$2 + bne $2,$L60 + cmpeq $3,16,$2 + beq $2,$L43 + ldq $2,48($15) + ldq $1,8($2) + ldq $0,0($2) + .align 4 +$L43: + mov $15,$30 + ldq $26,0($30) + ldq $15,8($30) + lda $30,192($30) + ret $31,($26),1 + .align 4 +$L44: + mov $15,$30 + ldl $2,24($15) + ldq $26,0($30) + sll $2,56,$2 + sra $2,56,$0 + ldq $15,8($30) + lda $30,192($30) + ret $31,($26),1 +$L51: + ldl $2,24($15) + sll $2,48,$2 + sra $2,48,$0 + br $31,$L43 +$L50: + ldl $2,24($15) + bis $31,$31,$31 + and $2,0xff,$0 + br $31,$L43 +$L48: + ldq $0,24($15) + br $31,$L43 +$L52: + ldl $2,24($15) + bis $31,$31,$31 + zapnot $2,3,$0 + br $31,$L43 +$L53: + ldl $3,24($15) + bis $31,$31,$31 + mov $3,$0 + br $31,$L43 +$L54: + ldl $2,24($15) + bis $31,$31,$31 + zapnot $2,15,$0 + br $31,$L43 +$L55: + lds $f0,24($15) + br $31,$L43 +$L56: + ldt $f0,24($15) + br $31,$L43 +$L57: + ldq $3,48($15) + ldq_u $2,0($3) + extbl $2,$3,$0 + br $31,$L43 +$L58: + ldq $3,48($15) + ldq_u $2,0($3) + extwl $2,$3,$0 + br $31,$L43 +$L60: + ldq $2,48($15) + bis $31,$31,$31 + ldq $0,0($2) + br $31,$L43 +$L59: + ldq $2,48($15) + ldl $3,0($2) + zapnot $3,15,$0 + br $31,$L43 + .end vacall_receiver +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/vacall/vacall-alpha.c b/vacall/vacall-alpha.c new file mode 100644 index 0000000..cb74c91 --- /dev/null +++ b/vacall/vacall-alpha.c @@ -0,0 +1,161 @@ +/* vacall function for alpha CPU */ + +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +#include "vacall-internal.h" + +#ifdef REENTRANT +#define vacall_receiver callback_receiver +register struct { void (*vacall_function) (void*,va_alist); void* arg; } + * env __asm__("$1"); +#endif +register long arg1 __asm__("$16"); +register long arg2 __asm__("$17"); +register long arg3 __asm__("$18"); +register long arg4 __asm__("$19"); +register long arg5 __asm__("$20"); +register long arg6 __asm__("$21"); +register double farg1 __asm__("$f16"); +register double farg2 __asm__("$f17"); +register double farg3 __asm__("$f18"); +register double farg4 __asm__("$f19"); +register double farg5 __asm__("$f20"); +register double farg6 __asm__("$f21"); +register __vaword iret __asm__("$0"); +register __vaword iret2 __asm__("$1"); +register float fret __asm__("$f0"); +register double dret __asm__("$f0"); + +/* The ABI requires that the first 6 general-purpose argument words are + being passed in registers, even if these words belong to a struct. No room + is allocated for these register words on the stack by the caller, but the + callee allocates room for them - at the right place in the stack frame, + that is, above the usual {fp, retaddr} combo - if and only if they are part + of a larger struct that extends to the stack and the address of this struct + is taken. */ +struct gpargsequence { + __vaword word1; /* $16 */ + __vaword word2; /* $17 */ + __vaword word3; /* $18 */ + __vaword word4; /* $19 */ + __vaword word5; /* $20 */ + __vaword word6; /* $21 */ + __vaword firststackword; +}; + +#ifdef REENTRANT +static +#endif +void /* the return type is variable, not void! */ +vacall_receiver (struct gpargsequence gpargs) +{ + __va_alist list; + /* Move the arguments passed in registers to their stack locations. */ + list.farg[0] = farg1; + list.farg[1] = farg2; + list.farg[2] = farg3; + list.farg[3] = farg4; + list.farg[4] = farg5; + list.farg[5] = farg6; + /* Prepare the va_alist. */ + list.flags = 0; + list.aptr = (long)&gpargs; + list.raddr = (void*)0; + list.rtype = __VAvoid; + list.memargptr = (long)&gpargs.firststackword; + list.farg_offset = (long)&list.farg[0] - list.aptr; + /* Call vacall_function. The macros do all the rest. */ +#ifndef REENTRANT + (*vacall_function) (&list); +#else /* REENTRANT */ + (*env->vacall_function) (env->arg,&list); +#endif + /* Put return value into proper register. */ + if (list.rtype == __VAvoid) { + } else + if (list.rtype == __VAchar) { + iret = list.tmp._char; + } else + if (list.rtype == __VAschar) { + iret = list.tmp._schar; + } else + if (list.rtype == __VAuchar) { + iret = list.tmp._uchar; + } else + if (list.rtype == __VAshort) { + iret = list.tmp._short; + } else + if (list.rtype == __VAushort) { + iret = list.tmp._ushort; + } else + if (list.rtype == __VAint) { + iret = list.tmp._int; + } else + if (list.rtype == __VAuint) { + iret = list.tmp._uint; + } else + if (list.rtype == __VAlong) { + iret = list.tmp._long; + } else + if (list.rtype == __VAulong) { + iret = list.tmp._ulong; + } else + if (list.rtype == __VAlonglong) { + iret = list.tmp._long; + } else + if (list.rtype == __VAulonglong) { + iret = list.tmp._ulong; + } else + if (list.rtype == __VAfloat) { + fret = list.tmp._float; + } else + if (list.rtype == __VAdouble) { + dret = list.tmp._double; + } else + if (list.rtype == __VAvoidp) { + iret = (long)list.tmp._ptr; + } else + if (list.rtype == __VAstruct) { + if (list.flags & __VA_REGISTER_STRUCT_RETURN) { + if (list.rsize == sizeof(char)) { + iret = *(unsigned char *) list.raddr; + } else + if (list.rsize == sizeof(short)) { + iret = *(unsigned short *) list.raddr; + } else + if (list.rsize == sizeof(int)) { + iret = *(unsigned int *) list.raddr; + } else + if (list.rsize == sizeof(long)) { + iret = *(unsigned long *) list.raddr; + } else + if (list.rsize == 2*sizeof(__vaword)) { + iret = ((__vaword *) list.raddr)[0]; + iret2 = ((__vaword *) list.raddr)[1]; + } + } + } +} + +#ifdef REENTRANT +__vacall_r_t +callback_get_receiver (void) +{ + return (__vacall_r_t)(void*)&callback_receiver; +} +#endif diff --git a/vacall/vacall-arm-linux-pic.s b/vacall/vacall-arm-linux-pic.s new file mode 100644 index 0000000..9035020 --- /dev/null +++ b/vacall/vacall-arm-linux-pic.s @@ -0,0 +1,100 @@ + .file "vacall-arm.c" + .text + .align 2 + .global vacall_receiver + .type vacall_receiver,function +vacall_receiver: + @ args = 20, pretend = 16, frame = 32 + @ frame_needed = 1, uses_anonymous_args = 0 + mov ip, sp + sub sp, sp, #16 + stmfd sp!, {sl, fp, ip, lr, pc} + sub fp, ip, #20 + add ip, fp, #4 + ldr sl, .L41 + sub sp, sp, #32 + stmia ip, {r0, r1, r2, r3} + ldr r3, .L41+4 + mov lr, #0 +.L36: + add sl, pc, sl + ldr r2, [sl, r3] + str ip, [fp, #-32] + str lr, [fp, #-24] + str lr, [fp, #-48] + str lr, [fp, #-28] + bic sp, sp, #7 + sub r0, fp, #48 + mov lr, pc + ldr pc, [r2, #0] + ldr r2, [fp, #-24] + cmp r2, #0 + beq .L1 + cmp r2, #1 + beq .L39 + cmp r2, #2 + ldreqsb r0, [fp, #-40] + beq .L1 + cmp r2, #3 + beq .L39 + cmp r2, #4 + ldreqsh r0, [fp, #-40] + beq .L1 + cmp r2, #5 + ldreqh r0, [fp, #-40] + beq .L1 + cmp r2, #6 + beq .L38 + cmp r2, #7 + beq .L38 + cmp r2, #8 + beq .L38 + cmp r2, #9 + beq .L38 + sub r3, r2, #10 + cmp r3, #1 + bls .L37 + cmp r2, #12 + ldreq r0, [fp, #-40] @ float + beq .L1 + cmp r2, #13 + beq .L37 + cmp r2, #14 + beq .L38 + cmp r2, #15 + beq .L40 +.L1: + ldmea fp, {sl, fp, sp, pc} +.L40: + ldr r3, [fp, #-48] + tst r3, #1024 + beq .L1 + ldr r3, [fp, #-20] + cmp r3, #1 + ldreq r3, [fp, #-28] + ldreqb r0, [r3, #0] @ zero_extendqisi2 + beq .L1 + cmp r3, #2 + ldreq r3, [fp, #-28] + ldrne r3, [fp, #-28] + ldreqh r0, [r3, #0] + ldrne r0, [r3, #0] + b .L1 +.L38: + ldr r0, [fp, #-40] + b .L1 +.L37: + sub r0, fp, #40 + ldmia r0, {r0, r1} @ phole ldm + b .L1 +.L39: + ldrb r0, [fp, #-40] @ zero_extendqisi2 + b .L1 +.L42: + .align 2 +.L41: + .word _GLOBAL_OFFSET_TABLE_-(.L36+8) + .word vacall_function(GOT) +.Lfe1: + .size vacall_receiver,.Lfe1-vacall_receiver + .ident "GCC: (GNU) 3.1" diff --git a/vacall/vacall-arm-linux.s b/vacall/vacall-arm-linux.s new file mode 100644 index 0000000..1c9118b --- /dev/null +++ b/vacall/vacall-arm-linux.s @@ -0,0 +1,95 @@ + .file "vacall-arm.c" + .text + .align 2 + .global vacall_receiver + .type vacall_receiver,function +vacall_receiver: + @ args = 20, pretend = 16, frame = 32 + @ frame_needed = 1, uses_anonymous_args = 0 + mov ip, sp + sub sp, sp, #16 + stmfd sp!, {fp, ip, lr, pc} + sub fp, ip, #20 + add lr, fp, #4 + mov ip, #0 + sub sp, sp, #32 + stmia lr, {r0, r1, r2, r3} + bic sp, sp, #7 + str lr, [fp, #-28] + str ip, [fp, #-20] + str ip, [fp, #-44] + str ip, [fp, #-24] + sub r0, fp, #44 + ldr r3, .L40 + mov lr, pc + ldr pc, [r3, #0] + ldr r2, [fp, #-20] + cmp r2, #0 + beq .L1 + cmp r2, #1 + beq .L38 + cmp r2, #2 + ldreqsb r0, [fp, #-36] + beq .L1 + cmp r2, #3 + beq .L38 + cmp r2, #4 + ldreqsh r0, [fp, #-36] + beq .L1 + cmp r2, #5 + ldreqh r0, [fp, #-36] + beq .L1 + cmp r2, #6 + beq .L37 + cmp r2, #7 + beq .L37 + cmp r2, #8 + beq .L37 + cmp r2, #9 + beq .L37 + sub r3, r2, #10 + cmp r3, #1 + bls .L36 + cmp r2, #12 + ldreq r0, [fp, #-36] @ float + beq .L1 + cmp r2, #13 + beq .L36 + cmp r2, #14 + beq .L37 + cmp r2, #15 + beq .L39 +.L1: + ldmea fp, {fp, sp, pc} +.L39: + ldr r3, [fp, #-44] + tst r3, #1024 + beq .L1 + ldr r3, [fp, #-16] + cmp r3, #1 + ldreq r3, [fp, #-24] + ldreqb r0, [r3, #0] @ zero_extendqisi2 + beq .L1 + cmp r3, #2 + ldreq r3, [fp, #-24] + ldrne r3, [fp, #-24] + ldreqh r0, [r3, #0] + ldrne r0, [r3, #0] + b .L1 +.L37: + ldr r0, [fp, #-36] + b .L1 +.L36: + sub r0, fp, #36 + ldmia r0, {r0, r1} @ phole ldm + b .L1 +.L38: + ldrb r0, [fp, #-36] @ zero_extendqisi2 + b .L1 +.L41: + .align 2 +.L40: + .word vacall_function +.Lfe1: + .size vacall_receiver,.Lfe1-vacall_receiver + .ident "GCC: (GNU) 3.1" diff --git a/vacall/vacall-arm-macro.S b/vacall/vacall-arm-macro.S new file mode 100644 index 0000000..3ff455b --- /dev/null +++ b/vacall/vacall-arm-macro.S @@ -0,0 +1,198 @@ +#include "asm-arm.h" +#ifdef __PIC__ + .text + .align 2 + .global C(vacall_receiver) + DECLARE_FUNCTION(vacall_receiver) +FUNBEGIN(vacall_receiver) + // args = 20, pretend = 16, frame = 32 + // frame_needed = 1, uses_anonymous_args = 0 + mov ip, sp + sub sp, sp, $16 + stmfd sp!, {sl, fp, ip, lr, pc} + sub fp, ip, $20 + add ip, fp, $4 + ldr sl, L(41) + sub sp, sp, $32 + stmia ip, {r0, r1, r2, r3} + ldr r3, L(41)+4 + mov lr, $0 +L(36): + add sl, pc, sl + ldr r2, [sl, r3] + str ip, [fp, $-32] + str lr, [fp, $-24] + str lr, [fp, $-48] + str lr, [fp, $-28] + bic sp, sp, $7 + sub r0, fp, $48 + mov lr, pc + ldr pc, [r2, $0] + ldr r2, [fp, $-24] + cmp r2, $0 + beq L(1) + cmp r2, $1 + beq L(39) + cmp r2, $2 + ldreqsb r0, [fp, $-40] + beq L(1) + cmp r2, $3 + beq L(39) + cmp r2, $4 + ldreqsh r0, [fp, $-40] + beq L(1) + cmp r2, $5 + ldreqh r0, [fp, $-40] + beq L(1) + cmp r2, $6 + beq L(38) + cmp r2, $7 + beq L(38) + cmp r2, $8 + beq L(38) + cmp r2, $9 + beq L(38) + sub r3, r2, $10 + cmp r3, $1 + bls L(37) + cmp r2, $12 + ldreq r0, [fp, $-40] // float + beq L(1) + cmp r2, $13 + beq L(37) + cmp r2, $14 + beq L(38) + cmp r2, $15 + beq L(40) +L(1): + ldmea fp, {sl, fp, sp, pc} +L(40): + ldr r3, [fp, $-48] + tst r3, $1024 + beq L(1) + ldr r3, [fp, $-20] + cmp r3, $1 + ldreq r3, [fp, $-28] + ldreqb r0, [r3, $0] // zero_extendqisi2 + beq L(1) + cmp r3, $2 + ldreq r3, [fp, $-28] + ldrne r3, [fp, $-28] + ldreqh r0, [r3, $0] + ldrne r0, [r3, $0] + b L(1) +L(38): + ldr r0, [fp, $-40] + b L(1) +L(37): + sub r0, fp, $40 + ldmia r0, {r0, r1} // phole ldm + b L(1) +L(39): + ldrb r0, [fp, $-40] // zero_extendqisi2 + b L(1) +L(42): + .align 2 +L(41): + .word _GLOBAL_OFFSET_TABLE_-(L(36)+8) + .word C(vacall_function)(GOT) +L(fe1): + FUNEND(vacall_receiver) +#else + .text + .align 2 + .global C(vacall_receiver) + DECLARE_FUNCTION(vacall_receiver) +FUNBEGIN(vacall_receiver) + // args = 20, pretend = 16, frame = 32 + // frame_needed = 1, uses_anonymous_args = 0 + mov ip, sp + sub sp, sp, $16 + stmfd sp!, {fp, ip, lr, pc} + sub fp, ip, $20 + add lr, fp, $4 + mov ip, $0 + sub sp, sp, $32 + stmia lr, {r0, r1, r2, r3} + bic sp, sp, $7 + str lr, [fp, $-28] + str ip, [fp, $-20] + str ip, [fp, $-44] + str ip, [fp, $-24] + sub r0, fp, $44 + ldr r3, L(40) + mov lr, pc + ldr pc, [r3, $0] + ldr r2, [fp, $-20] + cmp r2, $0 + beq L(1) + cmp r2, $1 + beq L(38) + cmp r2, $2 + ldreqsb r0, [fp, $-36] + beq L(1) + cmp r2, $3 + beq L(38) + cmp r2, $4 + ldreqsh r0, [fp, $-36] + beq L(1) + cmp r2, $5 + ldreqh r0, [fp, $-36] + beq L(1) + cmp r2, $6 + beq L(37) + cmp r2, $7 + beq L(37) + cmp r2, $8 + beq L(37) + cmp r2, $9 + beq L(37) + sub r3, r2, $10 + cmp r3, $1 + bls L(36) + cmp r2, $12 + ldreq r0, [fp, $-36] // float + beq L(1) + cmp r2, $13 + beq L(36) + cmp r2, $14 + beq L(37) + cmp r2, $15 + beq L(39) +L(1): + ldmea fp, {fp, sp, pc} +L(39): + ldr r3, [fp, $-44] + tst r3, $1024 + beq L(1) + ldr r3, [fp, $-16] + cmp r3, $1 + ldreq r3, [fp, $-24] + ldreqb r0, [r3, $0] // zero_extendqisi2 + beq L(1) + cmp r3, $2 + ldreq r3, [fp, $-24] + ldrne r3, [fp, $-24] + ldreqh r0, [r3, $0] + ldrne r0, [r3, $0] + b L(1) +L(37): + ldr r0, [fp, $-36] + b L(1) +L(36): + sub r0, fp, $36 + ldmia r0, {r0, r1} // phole ldm + b L(1) +L(38): + ldrb r0, [fp, $-36] // zero_extendqisi2 + b L(1) +L(41): + .align 2 +L(40): + .word C(vacall_function) +L(fe1): + FUNEND(vacall_receiver) +#endif +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",%progbits +#endif diff --git a/vacall/vacall-arm.c b/vacall/vacall-arm.c new file mode 100644 index 0000000..e6b4bd5 --- /dev/null +++ b/vacall/vacall-arm.c @@ -0,0 +1,149 @@ +/* vacall function for arm CPU */ + +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +#include "vacall-internal.h" + +#ifdef REENTRANT +#define vacall_receiver callback_receiver +typedef struct { void (*vacall_function) (void*,va_alist); void* arg; } env_t; +#endif + +/* armel have only softvfp which uses generic registers */ +register __vaword iret __asm__("r0"); +register __vaword iret2 __asm__("r1"); +register float fret __asm__("r0"); +register __vaword dret1 __asm__("r0"); +register __vaword dret2 __asm__("r1"); + +#ifndef REENTRANT +/* The ARM ABI requires that the first 4 general-purpose argument words are + being passed in registers, even if these words belong to a struct. No room + is allocated for these register words on the stack by the caller, but the + callee allocates room for them - at the right place in the stack frame, + that is, above the usual {fp, sp, retaddr, pc} combo - if and only if + they are part of a larger struct that extends to the stack and the address + of this struct is taken. */ +struct gpargsequence { + __vaword word1; /* r0 */ + __vaword word2; /* r1 */ + __vaword word3; /* r2 */ + __vaword word4; /* r3 */ + __vaword firststackword; +}; + +void /* the return type is variable, not void! */ +vacall_receiver (struct gpargsequence gpargs) +#else /* REENTRANT */ +/* The first 4 general-purpose argument words have already been pushed to the + stack by the trampoline. We can ignore them here. */ +static +void /* the return type is variable, not void! */ +vacall_receiver (__vaword ignored1, __vaword ignored2, __vaword ignored3, __vaword ignored4, + env_t* env, __vaword filler, __vaword saved_fp, __vaword saved_sp, __vaword saved_lr, __vaword saved_pc, + __vaword firstword) +#endif +{ + __va_alist list; + + /* Enforce 8-bytes-alignment of the stack pointer. + We need to do it this way because the old GCC that we use to compile + this file does not support the option '-mabi=aapcs'. */ + register unsigned long sp __asm__("r13"); /* C names for registers */ + sp &= -8; + + /* Prepare the va_alist. */ + list.flags = 0; +#ifndef REENTRANT + list.aptr = (long)&gpargs; +#else /* REENTRANT */ + list.aptr = (long)&firstword; +#endif + list.raddr = (void*)0; + list.rtype = __VAvoid; + /* Call vacall_function. The macros do all the rest. */ +#ifndef REENTRANT + (*vacall_function) (&list); +#else /* REENTRANT */ + (*env->vacall_function) (env->arg,&list); +#endif + /* Put return value into proper register. */ + if (list.rtype == __VAvoid) { + } else + if (list.rtype == __VAchar) { + iret = list.tmp._char; + } else + if (list.rtype == __VAschar) { + iret = list.tmp._schar; + } else + if (list.rtype == __VAuchar) { + iret = list.tmp._uchar; + } else + if (list.rtype == __VAshort) { + iret = list.tmp._short; + } else + if (list.rtype == __VAushort) { + iret = list.tmp._ushort; + } else + if (list.rtype == __VAint) { + iret = list.tmp._int; + } else + if (list.rtype == __VAuint) { + iret = list.tmp._uint; + } else + if (list.rtype == __VAlong) { + iret = list.tmp._long; + } else + if (list.rtype == __VAulong) { + iret = list.tmp._ulong; + } else + if (list.rtype == __VAlonglong || list.rtype == __VAulonglong) { + iret = ((__vaword *) &list.tmp._longlong)[0]; + iret2 = ((__vaword *) &list.tmp._longlong)[1]; + } else + if (list.rtype == __VAfloat) { + fret = list.tmp._float; + } else + if (list.rtype == __VAdouble) { + dret1 = ((__vaword *) &list.tmp._double)[0]; + dret2 = ((__vaword *) &list.tmp._double)[1]; + } else + if (list.rtype == __VAvoidp) { + iret = (long)list.tmp._ptr; + } else + if (list.rtype == __VAstruct) { + /* NB: On arm, all structure sizes are divisible by 4. */ + if (list.flags & __VA_REGISTER_STRUCT_RETURN) { + if (list.rsize == sizeof(char)) { /* can't occur */ + iret = *(unsigned char *) list.raddr; + } else + if (list.rsize == sizeof(short)) { /* can't occur */ + iret = *(unsigned short *) list.raddr; + } else + iret = *(unsigned int *) list.raddr; /* struct of size 3 :) */ + } + } +} + +#ifdef REENTRANT +__vacall_r_t +callback_get_receiver (void) +{ + return (__vacall_r_t)(void*)&callback_receiver; +} +#endif diff --git a/vacall/vacall-arm64-macro.S b/vacall/vacall-arm64-macro.S new file mode 100644 index 0000000..63b9cb6 --- /dev/null +++ b/vacall/vacall-arm64-macro.S @@ -0,0 +1,182 @@ +#include "asm-arm.h" + .cpu generic+fp+simd + .text + .align 2 + .p2align 3,,7 + .global C(vacall_receiver) + .type vacall_receiver, %function +FUNBEGIN(vacall_receiver) + stp x29, x30, [sp, -256]! + adrp x9, vacall_function + add x29, sp, 0 + add x10, x29, 256 + stp s0, s1, [x29, 156] + ldr x9, [x9, $:lo12:vacall_function] + stp x0, x1, [x29, 88] + stp s2, s3, [x29, 164] + stp x10, xzr, [x29, 40] + stp s4, s5, [x29, 172] + str x8, [x29, 72] + stp s6, s7, [x29, 180] + stp x2, x3, [x29, 104] + stp d0, d1, [x29, 192] + stp x4, x5, [x29, 120] + stp d2, d3, [x29, 208] + stp x6, x7, [x29, 136] + str wzr, [x29, 16] + add x0, x29, 16 + str wzr, [x29, 56] + str wzr, [x29, 80] + str wzr, [x29, 152] + stp d4, d5, [x29, 224] + stp d6, d7, [x29, 240] + blr x9 + ldr w9, [x29, 56] + cbz w9, L(1) + cmp w9, 1 + beq L(25) + cmp w9, 2 + beq L(29) + cmp w9, 3 + beq L(25) + cmp w9, 4 + beq L(30) + cmp w9, 5 + beq L(31) + cmp w9, 6 + beq L(32) + cmp w9, 7 + beq L(33) + and w10, w9, -3 + cmp w10, 8 + beq L(27) + cmp w10, 9 + beq L(27) + cmp w9, 12 + beq L(34) + cmp w9, 13 + beq L(35) + cmp w9, 14 + beq L(27) + cmp w9, 15 + bne L(1) + ldr w9, [x29, 16] + tbz x9, 10, L(1) + ldr x9, [x29, 64] + sub x10, x9, $1 + cmp x10, 15 + bhi L(1) + ldr x11, [x29, 48] + cmp x9, 8 + and x10, x11, 7 + and x11, x11, -8 + add x9, x9, x10 + bhi L(15) + cmp x9, 8 + lsl w9, w9, 3 + bhi L(16) + mov x12, 2 + sub w9, w9, $1 + lsl x9, x12, x9 + ldr x11, [x11] + sub x9, x9, $1 + lsl w10, w10, 3 + and x9, x9, x11 + asr x0, x9, x10 +L(1): + ldp x29, x30, [sp], 256 + ret + .p2align 3 +L(25): + ldrb w0, [x29, 24] + ldp x29, x30, [sp], 256 + ret + .p2align 3 +L(27): + ldr x0, [x29, 24] + b L(1) + .p2align 3 +L(29): + ldrsb x0, [x29, 24] + b L(1) + .p2align 3 +L(30): + ldrsh x0, [x29, 24] + b L(1) + .p2align 3 +L(31): + ldrh w0, [x29, 24] + b L(1) + .p2align 3 +L(32): + ldrsw x0, [x29, 24] + b L(1) + .p2align 3 +L(33): + ldr w0, [x29, 24] + b L(1) +L(34): + ldr s0, [x29, 24] + b L(1) +L(35): + ldr d0, [x29, 24] + b L(1) +L(15): + cmp x9, 16 + lsl w9, w9, 3 + bls L(36) + mov x13, 2 + sub w9, w9, $129 + ldp x14, x12, [x11, 8] + lsl x9, x13, x9 + lsl w15, w10, 3 + sub x9, x9, $1 + neg w10, w10, lsl 3 + ldr x11, [x11] + add w10, w10, 64 + and x9, x9, x12 + lsl x16, x14, x10 + asr x11, x11, x15 + asr x14, x14, x15 + lsl x10, x9, x10 + orr x0, x11, x16 + orr x1, x10, x14 + b L(1) +L(16): + mov w13, -8 + mov x14, 2 + sub w9, w9, $65 + lsl w15, w10, 3 + ldr x12, [x11, 8] + lsl x9, x14, x9 + mul w10, w13, w10 + sub x9, x9, $1 + ldr x11, [x11] + add w10, w10, 64 + and x9, x9, x12 + asr x11, x11, x15 + lsl x9, x9, x10 + orr x0, x9, x11 + b L(1) +L(36): + mov w13, -4 + mov x14, 2 + sub w9, w9, $65 + lsl w15, w10, 3 + ldr x12, [x11, 8] + lsl x9, x14, x9 + mul w10, w13, w10 + sub x9, x9, $1 + ldr x11, [x11] + add w10, w10, 32 + and x9, x9, x12 + asr x1, x9, x15 + lsl x9, x9, x10 + asr x11, x11, x15 + lsl x9, x9, x10 + orr x0, x11, x9 + b L(1) + FUNEND(vacall_receiver) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",%progbits +#endif diff --git a/vacall/vacall-arm64.c b/vacall/vacall-arm64.c new file mode 100644 index 0000000..e4264f8 --- /dev/null +++ b/vacall/vacall-arm64.c @@ -0,0 +1,229 @@ +/* vacall function for arm64 (a.k.a. aarch64) CPU */ + +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +#include "vacall-internal.h" + +#ifdef REENTRANT +#define vacall_receiver callback_receiver +register struct { void (*vacall_function) (void*,va_alist); void* arg; } + * env __asm__("x18"); +#endif + +register __vaword* sret __asm__("x8"); /* structure return pointer */ + +register __vaword iarg1 __asm__("x0"); +register __vaword iarg2 __asm__("x1"); +register __vaword iarg3 __asm__("x2"); +register __vaword iarg4 __asm__("x3"); +register __vaword iarg5 __asm__("x4"); +register __vaword iarg6 __asm__("x5"); +register __vaword iarg7 __asm__("x6"); +register __vaword iarg8 __asm__("x7"); + +register float farg1 __asm__("s0"); +register float farg2 __asm__("s1"); +register float farg3 __asm__("s2"); +register float farg4 __asm__("s3"); +register float farg5 __asm__("s4"); +register float farg6 __asm__("s5"); +register float farg7 __asm__("s6"); +register float farg8 __asm__("s7"); + +register double darg1 __asm__("d0"); +register double darg2 __asm__("d1"); +register double darg3 __asm__("d2"); +register double darg4 __asm__("d3"); +register double darg5 __asm__("d4"); +register double darg6 __asm__("d5"); +register double darg7 __asm__("d6"); +register double darg8 __asm__("d7"); + +register __vaword iret __asm__("x0"); +register __vaword iret2 __asm__("x1"); +register float fret __asm__("s0"); +register double dret __asm__("d0"); + +#ifdef REENTRANT +static +#endif +void /* the return type is variable, not void! */ +vacall_receiver (__vaword word1, __vaword word2, __vaword word3, __vaword word4, + __vaword word5, __vaword word6, __vaword word7, __vaword word8, + __vaword firstword) +{ + __va_alist list; + /* Move the arguments passed in registers to temp storage. */ + list.iarg[0] = iarg1; + list.iarg[1] = iarg2; + list.iarg[2] = iarg3; + list.iarg[3] = iarg4; + list.iarg[4] = iarg5; + list.iarg[5] = iarg6; + list.iarg[6] = iarg7; + list.iarg[7] = iarg8; + list.farg[0] = farg1; + list.farg[1] = farg2; + list.farg[2] = farg3; + list.farg[3] = farg4; + list.farg[4] = farg5; + list.farg[5] = farg6; + list.farg[6] = farg7; + list.farg[7] = farg8; + list.darg[0] = darg1; + list.darg[1] = darg2; + list.darg[2] = darg3; + list.darg[3] = darg4; + list.darg[4] = darg5; + list.darg[5] = darg6; + list.darg[6] = darg7; + list.darg[7] = darg8; + /* Prepare the va_alist. */ + list.flags = 0; + list.aptr = (long)&firstword; + list.raddr = (void*)0; + list.rtype = __VAvoid; + list.structraddr = sret; + list.ianum = 0; + list.fanum = 0; + /* Call vacall_function. The macros do all the rest. */ +#ifndef REENTRANT + (*vacall_function) (&list); +#else /* REENTRANT */ + (*env->vacall_function) (env->arg,&list); +#endif + /* Put return value into proper register. */ + if (list.rtype == __VAvoid) { + } else + if (list.rtype == __VAchar) { + iret = list.tmp._char; + } else + if (list.rtype == __VAschar) { + iret = list.tmp._schar; + } else + if (list.rtype == __VAuchar) { + iret = list.tmp._uchar; + } else + if (list.rtype == __VAshort) { + iret = list.tmp._short; + } else + if (list.rtype == __VAushort) { + iret = list.tmp._ushort; + } else + if (list.rtype == __VAint) { + iret = list.tmp._int; + } else + if (list.rtype == __VAuint) { + iret = list.tmp._uint; + } else + if (list.rtype == __VAlong || list.rtype == __VAlonglong) { + iret = list.tmp._long; + } else + if (list.rtype == __VAulong || list.rtype == __VAulonglong) { + iret = list.tmp._ulong; + } else + if (list.rtype == __VAfloat) { + fret = list.tmp._float; + } else + if (list.rtype == __VAdouble) { + dret = list.tmp._double; + } else + if (list.rtype == __VAvoidp) { + iret = (long)list.tmp._ptr; + } else + if (list.rtype == __VAstruct) { + /* normal struct return convention */ + if (list.flags & __VA_REGISTER_STRUCT_RETURN) { + /* Return structs of size <= 16 in registers. */ + if (list.rsize > 0 && list.rsize <= 16) { + #if 0 /* Unoptimized */ + iret = (__vaword)((unsigned char *) list.raddr)[0]; + if (list.rsize >= 2) + iret |= (__vaword)((unsigned char *) list.raddr)[1] << 8; + if (list.rsize >= 3) + iret |= (__vaword)((unsigned char *) list.raddr)[2] << 16; + if (list.rsize >= 4) + iret |= (__vaword)((unsigned char *) list.raddr)[3] << 24; + if (list.rsize >= 5) + iret |= (__vaword)((unsigned char *) list.raddr)[4] << 32; + if (list.rsize >= 6) + iret |= (__vaword)((unsigned char *) list.raddr)[5] << 40; + if (list.rsize >= 7) + iret |= (__vaword)((unsigned char *) list.raddr)[6] << 48; + if (list.rsize >= 8) + iret |= (__vaword)((unsigned char *) list.raddr)[7] << 56; + if (list.rsize >= 9) { + iret2 = (__vaword)((unsigned char *) list.raddr)[8]; + if (list.rsize >= 10) + iret2 |= (__vaword)((unsigned char *) list.raddr)[9] << 8; + if (list.rsize >= 11) + iret2 |= (__vaword)((unsigned char *) list.raddr)[10] << 16; + if (list.rsize >= 12) + iret2 |= (__vaword)((unsigned char *) list.raddr)[11] << 24; + if (list.rsize >= 13) + iret2 |= (__vaword)((unsigned char *) list.raddr)[12] << 32; + if (list.rsize >= 14) + iret2 |= (__vaword)((unsigned char *) list.raddr)[13] << 40; + if (list.rsize >= 15) + iret2 |= (__vaword)((unsigned char *) list.raddr)[14] << 48; + if (list.rsize >= 16) + iret2 |= (__vaword)((unsigned char *) list.raddr)[15] << 56; + } + #else /* Optimized: fewer conditional jumps, fewer memory accesses */ + uintptr_t count = list.rsize; /* > 0, ≤ 2*sizeof(__vaword) */ + __vaword* wordaddr = (__vaword*)((uintptr_t)list.raddr & ~(uintptr_t)(sizeof(__vaword)-1)); + uintptr_t start_offset = (uintptr_t)list.raddr & (uintptr_t)(sizeof(__vaword)-1); /* ≥ 0, < sizeof(__vaword) */ + uintptr_t end_offset = start_offset + count; /* > 0, < 3*sizeof(__vaword) */ + if (count <= sizeof(__vaword)) { + /* Assign iret. */ + if (end_offset <= sizeof(__vaword)) { + /* 0 < end_offset ≤ sizeof(__vaword) */ + __vaword mask0 = ((__vaword)2 << (end_offset*8-1)) - 1; + iret = (wordaddr[0] & mask0) >> (start_offset*8); + } else { + /* sizeof(__vaword) < end_offset < 2*sizeof(__vaword), start_offset > 0 */ + __vaword mask1 = ((__vaword)2 << (end_offset*8-sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | ((wordaddr[1] & mask1) << (sizeof(__vaword)*8-start_offset*8)); + } + } else { + /* Assign iret, iret2. */ + if (end_offset <= 2*sizeof(__vaword)) { + /* sizeof(__vaword) < end_offset ≤ 2*sizeof(__vaword) */ + __vaword mask1 = ((__vaword)2 << (end_offset*8-sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | ((wordaddr[1] & mask1) << (sizeof(__vaword)*4-start_offset*4) << (sizeof(__vaword)*4-start_offset*4)); + iret2 = (wordaddr[1] & mask1) >> (start_offset*8); + } else { + /* 2*sizeof(__vaword) < end_offset < 3*sizeof(__vaword), start_offset > 0 */ + __vaword mask2 = ((__vaword)2 << (end_offset*8-2*sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | (wordaddr[1] << (sizeof(__vaword)*8-start_offset*8)); + iret2 = (wordaddr[1] >> (start_offset*8)) | ((wordaddr[2] & mask2) << (sizeof(__vaword)*8-start_offset*8)); + } + } + #endif + } + } + } +} + +#ifdef REENTRANT +__vacall_r_t +callback_get_receiver (void) +{ + return (__vacall_r_t)(void*)&callback_receiver; +} +#endif diff --git a/vacall/vacall-armhf-linux-pic.s b/vacall/vacall-armhf-linux-pic.s new file mode 100644 index 0000000..a591771 --- /dev/null +++ b/vacall/vacall-armhf-linux-pic.s @@ -0,0 +1,155 @@ + .arch armv6 + .eabi_attribute 28, 1 + .eabi_attribute 20, 1 + .eabi_attribute 21, 1 + .eabi_attribute 23, 3 + .eabi_attribute 24, 1 + .eabi_attribute 25, 1 + .eabi_attribute 26, 1 + .eabi_attribute 30, 2 + .eabi_attribute 34, 1 + .eabi_attribute 18, 4 + .file "vacall-armhf.c" + .text + .align 2 + .global vacall_receiver + .syntax unified + .arm + .fpu vfpv3-d16 + .type vacall_receiver, %function +vacall_receiver: + @ args = 20, pretend = 16, frame = 176 + @ frame_needed = 1, uses_anonymous_args = 0 + sub sp, sp, #16 + mov ip, #0 + push {r4, r5, r6, fp, lr} + add fp, sp, #16 + ldr r4, .L32 + ldr r5, .L32+4 + add lr, fp, #4 +.LPIC0: + add r4, pc, r4 + add r6, fp, #20 + sub sp, sp, #180 + stm lr, {r0, r1, r2, r3} + vstr.32 s0, [fp, #-152] + vstr.32 s1, [fp, #-148] + vstr.32 s2, [fp, #-144] + vstr.32 s3, [fp, #-140] + vstr.32 s4, [fp, #-136] + vstr.32 s5, [fp, #-132] + vstr.32 s6, [fp, #-128] + vstr.32 s7, [fp, #-124] + vstr.32 s8, [fp, #-120] + vstr.32 s9, [fp, #-116] + vstr.32 s10, [fp, #-112] + vstr.32 s11, [fp, #-108] + vstr.32 s12, [fp, #-104] + vstr.32 s13, [fp, #-100] + vstr.32 s14, [fp, #-96] + vstr.32 s15, [fp, #-92] + vstr.64 d0, [fp, #-84] + vstr.64 d1, [fp, #-76] + vstr.64 d2, [fp, #-68] + vstr.64 d3, [fp, #-60] + vstr.64 d4, [fp, #-52] + vstr.64 d5, [fp, #-44] + vstr.64 d6, [fp, #-36] + vstr.64 d7, [fp, #-28] + str lr, [fp, #-164] + str ip, [fp, #-196] + str ip, [fp, #-160] + str r6, [fp, #-180] + str ip, [fp, #-156] + str ip, [fp, #-176] + strb ip, [fp, #-172] + ldr r2, [r4, r5] + mov r3, r4 + sub r0, fp, #196 + ldr r3, [r2] + blx r3 + ldrb r3, [fp, #-172] @ zero_extendqisi2 + cmp r3, #0 + beq .L1 + cmp r3, #1 + beq .L25 + cmp r3, #2 + ldrsbeq r0, [fp, #-188] + beq .L1 + cmp r3, #3 + beq .L25 + cmp r3, #4 + ldrsheq r0, [fp, #-188] + beq .L1 + cmp r3, #5 + ldrheq r0, [fp, #-188] + beq .L1 + cmp r3, #6 + beq .L27 + cmp r3, #7 + beq .L27 + cmp r3, #8 + beq .L27 + cmp r3, #9 + beq .L27 + sub r2, r3, #10 + cmp r2, #1 + bls .L29 + cmp r3, #12 + vldreq.32 s0, [fp, #-188] + beq .L1 + cmp r3, #13 + beq .L30 + cmp r3, #14 + beq .L27 + cmp r3, #15 + bne .L1 + ldr r3, [fp, #-196] + tst r3, #1024 + beq .L1 + ldr r3, [fp, #-168] + cmp r3, #1 + beq .L31 + cmp r3, #2 + ldr r3, [fp, #-176] + ldrheq r0, [r3] + ldrne r0, [r3] +.L1: + sub sp, fp, #16 + @ sp needed + pop {r4, r5, r6, fp, lr} + add sp, sp, #16 + bx lr +.L25: + ldrb r0, [fp, #-188] @ zero_extendqisi2 + sub sp, fp, #16 + @ sp needed + pop {r4, r5, r6, fp, lr} + add sp, sp, #16 + bx lr +.L27: + ldr r0, [fp, #-188] + sub sp, fp, #16 + @ sp needed + pop {r4, r5, r6, fp, lr} + add sp, sp, #16 + bx lr +.L30: + vldr.64 d0, [fp, #-188] + b .L1 +.L29: + ldr r0, [fp, #-188] + ldr r1, [fp, #-184] + b .L1 +.L31: + ldr r3, [fp, #-176] + ldrb r0, [r3] @ zero_extendqisi2 + b .L1 +.L33: + .align 2 +.L32: + .word _GLOBAL_OFFSET_TABLE_-(.LPIC0+8) + .word vacall_function(GOT) + .size vacall_receiver, .-vacall_receiver + .ident "GCC: (GNU) 6.3.0" + .section .note.GNU-stack,"",%progbits diff --git a/vacall/vacall-armhf-linux.s b/vacall/vacall-armhf-linux.s new file mode 100644 index 0000000..46ac622 --- /dev/null +++ b/vacall/vacall-armhf-linux.s @@ -0,0 +1,149 @@ + .arch armv6 + .eabi_attribute 28, 1 + .eabi_attribute 20, 1 + .eabi_attribute 21, 1 + .eabi_attribute 23, 3 + .eabi_attribute 24, 1 + .eabi_attribute 25, 1 + .eabi_attribute 26, 1 + .eabi_attribute 30, 2 + .eabi_attribute 34, 1 + .eabi_attribute 18, 4 + .file "vacall-armhf.c" + .text + .align 2 + .global vacall_receiver + .syntax unified + .arm + .fpu vfpv3-d16 + .type vacall_receiver, %function +vacall_receiver: + @ args = 20, pretend = 16, frame = 176 + @ frame_needed = 1, uses_anonymous_args = 0 + sub sp, sp, #16 + mov ip, #0 + push {r4, r5, fp, lr} + add fp, sp, #12 + ldr r4, .L32 + add lr, fp, #4 + add r5, fp, #20 + sub sp, sp, #176 + stm lr, {r0, r1, r2, r3} + vstr.32 s0, [fp, #-144] + vstr.32 s1, [fp, #-140] + vstr.32 s2, [fp, #-136] + vstr.32 s3, [fp, #-132] + vstr.32 s4, [fp, #-128] + vstr.32 s5, [fp, #-124] + vstr.32 s6, [fp, #-120] + vstr.32 s7, [fp, #-116] + vstr.32 s8, [fp, #-112] + vstr.32 s9, [fp, #-108] + vstr.32 s10, [fp, #-104] + vstr.32 s11, [fp, #-100] + vstr.32 s12, [fp, #-96] + vstr.32 s13, [fp, #-92] + vstr.32 s14, [fp, #-88] + vstr.32 s15, [fp, #-84] + vstr.64 d0, [fp, #-76] + vstr.64 d1, [fp, #-68] + vstr.64 d2, [fp, #-60] + vstr.64 d3, [fp, #-52] + vstr.64 d4, [fp, #-44] + vstr.64 d5, [fp, #-36] + vstr.64 d6, [fp, #-28] + vstr.64 d7, [fp, #-20] + str lr, [fp, #-156] + str ip, [fp, #-188] + sub r0, fp, #188 + str ip, [fp, #-152] + ldr r3, [r4] + str r5, [fp, #-172] + str ip, [fp, #-148] + str ip, [fp, #-168] + strb ip, [fp, #-164] + blx r3 + ldrb r3, [fp, #-164] @ zero_extendqisi2 + cmp r3, #0 + beq .L1 + cmp r3, #1 + beq .L25 + cmp r3, #2 + ldrsbeq r0, [fp, #-180] + beq .L1 + cmp r3, #3 + beq .L25 + cmp r3, #4 + ldrsheq r0, [fp, #-180] + beq .L1 + cmp r3, #5 + ldrheq r0, [fp, #-180] + beq .L1 + cmp r3, #6 + beq .L27 + cmp r3, #7 + beq .L27 + cmp r3, #8 + beq .L27 + cmp r3, #9 + beq .L27 + sub r2, r3, #10 + cmp r2, #1 + bls .L29 + cmp r3, #12 + vldreq.32 s0, [fp, #-180] + beq .L1 + cmp r3, #13 + beq .L30 + cmp r3, #14 + beq .L27 + cmp r3, #15 + bne .L1 + ldr r3, [fp, #-188] + tst r3, #1024 + beq .L1 + ldr r3, [fp, #-160] + cmp r3, #1 + beq .L31 + cmp r3, #2 + ldr r3, [fp, #-168] + ldrheq r0, [r3] + ldrne r0, [r3] +.L1: + sub sp, fp, #12 + @ sp needed + pop {r4, r5, fp, lr} + add sp, sp, #16 + bx lr +.L25: + ldrb r0, [fp, #-180] @ zero_extendqisi2 + sub sp, fp, #12 + @ sp needed + pop {r4, r5, fp, lr} + add sp, sp, #16 + bx lr +.L27: + ldr r0, [fp, #-180] + sub sp, fp, #12 + @ sp needed + pop {r4, r5, fp, lr} + add sp, sp, #16 + bx lr +.L30: + vldr.64 d0, [fp, #-180] + b .L1 +.L29: + ldr r0, [fp, #-180] + ldr r1, [fp, #-176] + b .L1 +.L31: + ldr r3, [fp, #-168] + ldrb r0, [r3] @ zero_extendqisi2 + b .L1 +.L33: + .align 2 +.L32: + .word vacall_function + .size vacall_receiver, .-vacall_receiver + .ident "GCC: (GNU) 6.3.0" + .section .note.GNU-stack,"",%progbits diff --git a/vacall/vacall-armhf-macro.S b/vacall/vacall-armhf-macro.S new file mode 100644 index 0000000..b9bbb59 --- /dev/null +++ b/vacall/vacall-armhf-macro.S @@ -0,0 +1,305 @@ +#include "asm-arm.h" +#ifdef __PIC__ + .arch armv6 + .eabi_attribute 28, 1 + .eabi_attribute 20, 1 + .eabi_attribute 21, 1 + .eabi_attribute 23, 3 + .eabi_attribute 24, 1 + .eabi_attribute 25, 1 + .eabi_attribute 26, 1 + .eabi_attribute 30, 2 + .eabi_attribute 34, 1 + .eabi_attribute 18, 4 + .text + .align 2 + .global C(vacall_receiver) + .syntax unified + .arm + .fpu vfpv3-d16 + .type vacall_receiver, %function +FUNBEGIN(vacall_receiver) + // args = 20, pretend = 16, frame = 176 + // frame_needed = 1, uses_anonymous_args = 0 + sub sp, sp, $16 + mov ip, $0 + push {r4, r5, r6, fp, lr} + add fp, sp, $16 + ldr r4, L(32) + ldr r5, L(32)+4 + add lr, fp, $4 +L(PIC0): + add r4, pc, r4 + add r6, fp, $20 + sub sp, sp, $180 + stm lr, {r0, r1, r2, r3} + vstr.32 s0, [fp, $-152] + vstr.32 s1, [fp, $-148] + vstr.32 s2, [fp, $-144] + vstr.32 s3, [fp, $-140] + vstr.32 s4, [fp, $-136] + vstr.32 s5, [fp, $-132] + vstr.32 s6, [fp, $-128] + vstr.32 s7, [fp, $-124] + vstr.32 s8, [fp, $-120] + vstr.32 s9, [fp, $-116] + vstr.32 s10, [fp, $-112] + vstr.32 s11, [fp, $-108] + vstr.32 s12, [fp, $-104] + vstr.32 s13, [fp, $-100] + vstr.32 s14, [fp, $-96] + vstr.32 s15, [fp, $-92] + vstr.64 d0, [fp, $-84] + vstr.64 d1, [fp, $-76] + vstr.64 d2, [fp, $-68] + vstr.64 d3, [fp, $-60] + vstr.64 d4, [fp, $-52] + vstr.64 d5, [fp, $-44] + vstr.64 d6, [fp, $-36] + vstr.64 d7, [fp, $-28] + str lr, [fp, $-164] + str ip, [fp, $-196] + str ip, [fp, $-160] + str r6, [fp, $-180] + str ip, [fp, $-156] + str ip, [fp, $-176] + strb ip, [fp, $-172] + ldr r2, [r4, r5] + mov r3, r4 + sub r0, fp, $196 + ldr r3, [r2] + blx r3 + ldrb r3, [fp, $-172] // zero_extendqisi2 + cmp r3, $0 + beq L(1) + cmp r3, $1 + beq L(25) + cmp r3, $2 + ldrsbeq r0, [fp, $-188] + beq L(1) + cmp r3, $3 + beq L(25) + cmp r3, $4 + ldrsheq r0, [fp, $-188] + beq L(1) + cmp r3, $5 + ldrheq r0, [fp, $-188] + beq L(1) + cmp r3, $6 + beq L(27) + cmp r3, $7 + beq L(27) + cmp r3, $8 + beq L(27) + cmp r3, $9 + beq L(27) + sub r2, r3, $10 + cmp r2, $1 + bls L(29) + cmp r3, $12 + vldreq.32 s0, [fp, $-188] + beq L(1) + cmp r3, $13 + beq L(30) + cmp r3, $14 + beq L(27) + cmp r3, $15 + bne L(1) + ldr r3, [fp, $-196] + tst r3, $1024 + beq L(1) + ldr r3, [fp, $-168] + cmp r3, $1 + beq L(31) + cmp r3, $2 + ldr r3, [fp, $-176] + ldrheq r0, [r3] + ldrne r0, [r3] +L(1): + sub sp, fp, $16 + // sp needed + pop {r4, r5, r6, fp, lr} + add sp, sp, $16 + bx lr +L(25): + ldrb r0, [fp, $-188] // zero_extendqisi2 + sub sp, fp, $16 + // sp needed + pop {r4, r5, r6, fp, lr} + add sp, sp, $16 + bx lr +L(27): + ldr r0, [fp, $-188] + sub sp, fp, $16 + // sp needed + pop {r4, r5, r6, fp, lr} + add sp, sp, $16 + bx lr +L(30): + vldr.64 d0, [fp, $-188] + b L(1) +L(29): + ldr r0, [fp, $-188] + ldr r1, [fp, $-184] + b L(1) +L(31): + ldr r3, [fp, $-176] + ldrb r0, [r3] // zero_extendqisi2 + b L(1) +L(33): + .align 2 +L(32): + .word _GLOBAL_OFFSET_TABLE_-(L(PIC0)+8) + .word C(vacall_function)(GOT) + FUNEND(vacall_receiver) +#else + .arch armv6 + .eabi_attribute 28, 1 + .eabi_attribute 20, 1 + .eabi_attribute 21, 1 + .eabi_attribute 23, 3 + .eabi_attribute 24, 1 + .eabi_attribute 25, 1 + .eabi_attribute 26, 1 + .eabi_attribute 30, 2 + .eabi_attribute 34, 1 + .eabi_attribute 18, 4 + .text + .align 2 + .global C(vacall_receiver) + .syntax unified + .arm + .fpu vfpv3-d16 + .type vacall_receiver, %function +FUNBEGIN(vacall_receiver) + // args = 20, pretend = 16, frame = 176 + // frame_needed = 1, uses_anonymous_args = 0 + sub sp, sp, $16 + mov ip, $0 + push {r4, r5, fp, lr} + add fp, sp, $12 + ldr r4, L(32) + add lr, fp, $4 + add r5, fp, $20 + sub sp, sp, $176 + stm lr, {r0, r1, r2, r3} + vstr.32 s0, [fp, $-144] + vstr.32 s1, [fp, $-140] + vstr.32 s2, [fp, $-136] + vstr.32 s3, [fp, $-132] + vstr.32 s4, [fp, $-128] + vstr.32 s5, [fp, $-124] + vstr.32 s6, [fp, $-120] + vstr.32 s7, [fp, $-116] + vstr.32 s8, [fp, $-112] + vstr.32 s9, [fp, $-108] + vstr.32 s10, [fp, $-104] + vstr.32 s11, [fp, $-100] + vstr.32 s12, [fp, $-96] + vstr.32 s13, [fp, $-92] + vstr.32 s14, [fp, $-88] + vstr.32 s15, [fp, $-84] + vstr.64 d0, [fp, $-76] + vstr.64 d1, [fp, $-68] + vstr.64 d2, [fp, $-60] + vstr.64 d3, [fp, $-52] + vstr.64 d4, [fp, $-44] + vstr.64 d5, [fp, $-36] + vstr.64 d6, [fp, $-28] + vstr.64 d7, [fp, $-20] + str lr, [fp, $-156] + str ip, [fp, $-188] + sub r0, fp, $188 + str ip, [fp, $-152] + ldr r3, [r4] + str r5, [fp, $-172] + str ip, [fp, $-148] + str ip, [fp, $-168] + strb ip, [fp, $-164] + blx r3 + ldrb r3, [fp, $-164] // zero_extendqisi2 + cmp r3, $0 + beq L(1) + cmp r3, $1 + beq L(25) + cmp r3, $2 + ldrsbeq r0, [fp, $-180] + beq L(1) + cmp r3, $3 + beq L(25) + cmp r3, $4 + ldrsheq r0, [fp, $-180] + beq L(1) + cmp r3, $5 + ldrheq r0, [fp, $-180] + beq L(1) + cmp r3, $6 + beq L(27) + cmp r3, $7 + beq L(27) + cmp r3, $8 + beq L(27) + cmp r3, $9 + beq L(27) + sub r2, r3, $10 + cmp r2, $1 + bls L(29) + cmp r3, $12 + vldreq.32 s0, [fp, $-180] + beq L(1) + cmp r3, $13 + beq L(30) + cmp r3, $14 + beq L(27) + cmp r3, $15 + bne L(1) + ldr r3, [fp, $-188] + tst r3, $1024 + beq L(1) + ldr r3, [fp, $-160] + cmp r3, $1 + beq L(31) + cmp r3, $2 + ldr r3, [fp, $-168] + ldrheq r0, [r3] + ldrne r0, [r3] +L(1): + sub sp, fp, $12 + // sp needed + pop {r4, r5, fp, lr} + add sp, sp, $16 + bx lr +L(25): + ldrb r0, [fp, $-180] // zero_extendqisi2 + sub sp, fp, $12 + // sp needed + pop {r4, r5, fp, lr} + add sp, sp, $16 + bx lr +L(27): + ldr r0, [fp, $-180] + sub sp, fp, $12 + // sp needed + pop {r4, r5, fp, lr} + add sp, sp, $16 + bx lr +L(30): + vldr.64 d0, [fp, $-180] + b L(1) +L(29): + ldr r0, [fp, $-180] + ldr r1, [fp, $-176] + b L(1) +L(31): + ldr r3, [fp, $-168] + ldrb r0, [r3] // zero_extendqisi2 + b L(1) +L(33): + .align 2 +L(32): + .word C(vacall_function) + FUNEND(vacall_receiver) +#endif +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",%progbits +#endif diff --git a/vacall/vacall-armhf.c b/vacall/vacall-armhf.c new file mode 100644 index 0000000..3c232b4 --- /dev/null +++ b/vacall/vacall-armhf.c @@ -0,0 +1,195 @@ +/* vacall function for arm CPU with -mfloat-abi=hard */ + +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +#include "vacall-internal.h" + +#ifdef REENTRANT +#define vacall_receiver callback_receiver +typedef struct { void (*vacall_function) (void*,va_alist); void* arg; } env_t; +#endif + +/* armhf passes up to 16 float arguments and up to 8 double arguments + in floating-point registers. */ +register float farg0 __asm__("s0"); +register float farg1 __asm__("s1"); +register float farg2 __asm__("s2"); +register float farg3 __asm__("s3"); +register float farg4 __asm__("s4"); +register float farg5 __asm__("s5"); +register float farg6 __asm__("s6"); +register float farg7 __asm__("s7"); +register float farg8 __asm__("s8"); +register float farg9 __asm__("s9"); +register float farg10 __asm__("s10"); +register float farg11 __asm__("s11"); +register float farg12 __asm__("s12"); +register float farg13 __asm__("s13"); +register float farg14 __asm__("s14"); +register float farg15 __asm__("s15"); +register double darg0 __asm__("d0"); /* overlaps s0,s1 */ +register double darg1 __asm__("d1"); /* overlaps s2,s3 */ +register double darg2 __asm__("d2"); /* overlaps s4,s5 */ +register double darg3 __asm__("d3"); /* overlaps s6,s7 */ +register double darg4 __asm__("d4"); /* overlaps s8,s9 */ +register double darg5 __asm__("d5"); /* overlaps s10,s11 */ +register double darg6 __asm__("d6"); /* overlaps s12,s13 */ +register double darg7 __asm__("d7"); /* overlaps s14,s15 */ +register __vaword iret __asm__("r0"); +register __vaword iret2 __asm__("r1"); +register float fret __asm__("s0"); +register double dret __asm__("d0"); + +#ifndef REENTRANT +/* The ARM ABI requires that the first 4 general-purpose argument words are + being passed in registers, even if these words belong to a struct. No room + is allocated for these register words on the stack by the caller, but the + callee allocates room for them - at the right place in the stack frame, + that is, above the usual {fp, sp, retaddr, pc} combo - if and only if + they are part of a larger struct that extends to the stack and the address + of this struct is taken. */ +struct gpargsequence { + __vaword word1; /* r0 */ + __vaword word2; /* r1 */ + __vaword word3; /* r2 */ + __vaword word4; /* r3 */ + __vaword firststackword; +}; + +#ifdef REENTRANT +static +#endif +void /* the return type is variable, not void! */ +vacall_receiver (struct gpargsequence gpargs) +#else /* REENTRANT */ +/* The first 4 general-purpose argument words have already been pushed to the + stack by the trampoline. We can ignore them here. */ +void /* the return type is variable, not void! */ +vacall_receiver (__vaword ignored1, __vaword ignored2, __vaword ignored3, __vaword ignored4, + env_t* env, __vaword filler, __vaword saved_fp, __vaword saved_sp, __vaword saved_lr, __vaword saved_pc, + __vaword firstword) +#endif +{ + __va_alist list; + /* Save the floating point argument registers. */ + list.farg[0] = farg0; + list.farg[1] = farg1; + list.farg[2] = farg2; + list.farg[3] = farg3; + list.farg[4] = farg4; + list.farg[5] = farg5; + list.farg[6] = farg6; + list.farg[7] = farg7; + list.farg[8] = farg8; + list.farg[9] = farg9; + list.farg[10] = farg10; + list.farg[11] = farg11; + list.farg[12] = farg12; + list.farg[13] = farg13; + list.farg[14] = farg14; + list.farg[15] = farg15; + list.darg[0] = darg0; + list.darg[1] = darg1; + list.darg[2] = darg2; + list.darg[3] = darg3; + list.darg[4] = darg4; + list.darg[5] = darg5; + list.darg[6] = darg6; + list.darg[7] = darg7; + /* Prepare the va_alist. */ + list.flags = 0; +#ifndef REENTRANT + list.iarg = (__vaword*)&gpargs; +#else /* REENTRANT */ + list.iarg = (__vaword*)&firstword; +#endif + list.aptr = (long)(list.iarg + __VA_IARG_NUM); + list.ianum = 0; + list.fanum = 0; + list.raddr = (void*)0; + list.rtype = __VAvoid; + /* Call vacall_function. The macros do all the rest. */ +#ifndef REENTRANT + (*vacall_function) (&list); +#else /* REENTRANT */ + (*env->vacall_function) (env->arg,&list); +#endif + /* Put return value into proper register. */ + if (list.rtype == __VAvoid) { + } else + if (list.rtype == __VAchar) { + iret = list.tmp._char; + } else + if (list.rtype == __VAschar) { + iret = list.tmp._schar; + } else + if (list.rtype == __VAuchar) { + iret = list.tmp._uchar; + } else + if (list.rtype == __VAshort) { + iret = list.tmp._short; + } else + if (list.rtype == __VAushort) { + iret = list.tmp._ushort; + } else + if (list.rtype == __VAint) { + iret = list.tmp._int; + } else + if (list.rtype == __VAuint) { + iret = list.tmp._uint; + } else + if (list.rtype == __VAlong) { + iret = list.tmp._long; + } else + if (list.rtype == __VAulong) { + iret = list.tmp._ulong; + } else + if (list.rtype == __VAlonglong || list.rtype == __VAulonglong) { + iret = ((__vaword *) &list.tmp._longlong)[0]; + iret2 = ((__vaword *) &list.tmp._longlong)[1]; + } else + if (list.rtype == __VAfloat) { + fret = list.tmp._float; + } else + if (list.rtype == __VAdouble) { + dret = list.tmp._double; + } else + if (list.rtype == __VAvoidp) { + iret = (long)list.tmp._ptr; + } else + if (list.rtype == __VAstruct) { + /* NB: On arm, all structure sizes are divisible by 4. */ + if (list.flags & __VA_REGISTER_STRUCT_RETURN) { + if (list.rsize == sizeof(char)) { /* can't occur */ + iret = *(unsigned char *) list.raddr; + } else + if (list.rsize == sizeof(short)) { /* can't occur */ + iret = *(unsigned short *) list.raddr; + } else + iret = *(unsigned int *) list.raddr; /* struct of size 3 :) */ + } + } +} + +#ifdef REENTRANT +__vacall_r_t +callback_get_receiver (void) +{ + return (__vacall_r_t)(void*)&callback_receiver; +} +#endif diff --git a/vacall/vacall-hppa-linux.s b/vacall/vacall-hppa-linux.s new file mode 100644 index 0000000..fb9c5be --- /dev/null +++ b/vacall/vacall-hppa-linux.s @@ -0,0 +1,182 @@ + .LEVEL 1.1 + .text + .align 4 +.globl vacall_receiver + .type vacall_receiver,@function +vacall_receiver: + .PROC + .CALLINFO FRAME=192,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=3 + .ENTRY + copy %r3,%r1 + stw %r2,-20(%r30) + copy %r30,%r3 + stwm %r1,192(%r30) + addil LR'vacall_function-$global$,%r27 + ldo -32(%r3),%r2 + ldo 16(%r3),%r22 + sub %r22,%r2,%r20 + ldo 104(%r3),%r19 + ldo 72(%r3),%r21 + ldo 80(%r20),%r31 + fstds %fr5,-16(%r19) + ldo 64(%r20),%r20 + ldo -48(%r3),%r19 + stw %r26,-36(%r3) + copy %r22,%r26 + stw %r20,56(%r3) + fstws %fr7L,-8(%r21) + stw %r19,52(%r3) + stw %r31,60(%r3) + stw %r25,-40(%r3) + stw %r24,-44(%r3) + stw %r23,-48(%r3) + fstds %fr7,8(%r21) + fstws %fr4L,4(%r21) + fstws %fr5L,0(%r21) + fstws %fr6L,-4(%r21) + stw %r0,16(%r3) + stw %r2,32(%r3) + stw %r0,36(%r3) + stw %r0,40(%r3) + stw %r28,48(%r3) + ldw RR'vacall_function-$global$(%r1),%r22 + .CALL ARGW0=GR + bl $$dyncall,%r31 + copy %r31,%r2 + ldw 40(%r3),%r20 + comib,= 0,%r20,.L48 + ldw -20(%r3),%r2 + comib,= 1,%r20,.L49 + ldb 24(%r3),%r19 + comib,=,n 2,%r20,.L49 + comib,=,n 3,%r20,.L43 + comib,=,n 4,%r20,.L44 + comib,=,n 5,%r20,.L45 + comib,=,n 6,%r20,.L41 + comib,=,n 7,%r20,.L41 + comib,=,n 8,%r20,.L41 + comib,= 9,%r20,.L41 + ldo -10(%r20),%r19 + comib,<<,n 1,%r19,.L22 + ldw 24(%r3),%r28 +.L40: + ldw 28(%r3),%r29 +.L1: + ldw -20(%r3),%r2 +.L48: + ldo 64(%r3),%r30 + bv %r0(%r2) + ldwm -64(%r30),%r3 +.L22: + comib,= 12,%r20,.L46 + ldo 40(%r3),%r19 + comib,=,n 13,%r20,.L47 + comib,=,n 14,%r20,.L1 + ldw 24(%r3),%r28 + comib,<> 15,%r20,.L48 + ldw -20(%r3),%r2 + ldw 16(%r3),%r19 + bb,>= %r19,30,.L1 + ldw 44(%r3),%r2 + ldo -1(%r2),%r19 + comib,<< 7,%r19,.L1 + ldw 36(%r3),%r19 + extru %r19,31,2,%r22 + copy %r19,%r31 + depi 0,31,2,%r31 + comib,<< 4,%r2,.L33 + addl %r22,%r2,%r1 + zdep %r22,28,29,%r22 + mtsar %r22 + zvdepi 2,32,%r19 + comib,<< 4,%r1,.L34 + ldo -1(%r19),%r22 + ldw 0(%r31),%r19 + zdep %r1,28,29,%r20 + ldo -1(%r20),%r20 + and %r19,%r22,%r19 + mtsar %r20 + vextrs %r19,32,%r19 + movb,tr %r19,%r28,.L48 + ldw -20(%r3),%r2 +.L34: + ldw 0(%r31),%r19 + zdep %r1,28,29,%r21 + ldw 4(%r31),%r20 + and %r19,%r22,%r19 + ldo -33(%r21),%r31 + subi 63,%r21,%r21 + mtsar %r21 + zvdep %r19,32,%r19 + mtsar %r31 + vextrs %r20,32,%r20 +.L39: + b .L1 + or %r20,%r19,%r28 +.L33: + zdep %r22,28,29,%r22 + mtsar %r22 + zvdepi 2,32,%r19 + comib,<< 8,%r1,.L37 + ldo -1(%r19),%r2 + ldw 0(%r31),%r21 + zdep %r1,29,30,%r19 + and %r21,%r2,%r21 + ldw 4(%r31),%r22 + subi 47,%r19,%r2 + zdep %r1,28,29,%r19 + mtsar %r2 + ldo -33(%r19),%r19 + zvdep %r21,32,%r20 + zvdep %r20,32,%r20 + mtsar %r19 + vextrs %r22,32,%r22 + vextrs %r21,32,%r21 + movb,tr %r21,%r28,.L1 + or %r20,%r22,%r29 +.L37: + ldw 0(%r31),%r20 + zdep %r1,28,29,%r22 + ldw 8(%r31),%r21 + and %r20,%r2,%r20 + ldo -65(%r22),%r2 + ldw 4(%r31),%r19 + mtsar %r2 + subi 95,%r22,%r31 + vextrs %r21,32,%r21 + mtsar %r31 + zvdep %r19,32,%r22 + zvdep %r20,32,%r20 + or %r22,%r21,%r29 + mtsar %r2 + b .L39 + vextrs %r19,32,%r19 +.L41: + b .L1 + ldw 24(%r3),%r28 +.L47: + ldw 24(%r3),%r28 + b .L40 + fldds -16(%r19),%fr4 +.L46: + ldw 24(%r3),%r28 + b .L1 + fldws -16(%r19),%fr4L +.L45: + b .L1 + ldh 24(%r3),%r28 +.L44: + ldh 24(%r3),%r19 + b .L1 + extrs %r19,31,16,%r28 +.L43: + b .L1 + ldb 24(%r3),%r28 +.L49: + b .L1 + extrs %r19,31,8,%r28 + .EXIT + .PROCEND +.Lfe1: + .size vacall_receiver,.Lfe1-vacall_receiver + .ident "GCC: (GNU) 3.1" diff --git a/vacall/vacall-hppa-macro.S b/vacall/vacall-hppa-macro.S new file mode 100644 index 0000000..da42725 --- /dev/null +++ b/vacall/vacall-hppa-macro.S @@ -0,0 +1,188 @@ +#include "asm-hppa.h" + .LEVEL 1.1 + IMPORT_MILLICODE($$dyncall) + TEXT1() + TEXT2() + .align 4 +GLOBL(vacall_receiver) + DECLARE_FUNCTION(vacall_receiver) +DEF(vacall_receiver) + .PROC + .CALLINFO FRAME=192,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=3 + .ENTRY + copy %r3,%r1 + stw %r2,-20(%r30) + copy %r30,%r3 + stwm %r1,192(%r30) + addil LR!vacall_function-$global$,%r27 + ldo -32(%r3),%r2 + ldo 16(%r3),%r22 + sub %r22,%r2,%r20 + ldo 104(%r3),%r19 + ldo 72(%r3),%r21 + ldo 80(%r20),%r31 + fstds %fr5,-16(%r19) + ldo 64(%r20),%r20 + ldo -48(%r3),%r19 + stw %r26,-36(%r3) + copy %r22,%r26 + stw %r20,56(%r3) + fstws %fr7L,-8(%r21) + stw %r19,52(%r3) + stw %r31,60(%r3) + stw %r25,-40(%r3) + stw %r24,-44(%r3) + stw %r23,-48(%r3) + fstds %fr7,8(%r21) + fstws %fr4L,4(%r21) + fstws %fr5L,0(%r21) + fstws %fr6L,-4(%r21) + stw %r0,16(%r3) + stw %r2,32(%r3) + stw %r0,36(%r3) + stw %r0,40(%r3) + stw %r28,48(%r3) + ldw RR!vacall_function-$global$(%r1),%r22 + .CALL ARGW0=GR + bl $$dyncall,%r31 + copy %r31,%r2 + ldw 40(%r3),%r20 + comib,= 0,%r20,L(48) + ldw -20(%r3),%r2 + comib,= 1,%r20,L(49) + ldb 24(%r3),%r19 + comib,=,n 2,%r20,L(49) + comib,=,n 3,%r20,L(43) + comib,=,n 4,%r20,L(44) + comib,=,n 5,%r20,L(45) + comib,=,n 6,%r20,L(41) + comib,=,n 7,%r20,L(41) + comib,=,n 8,%r20,L(41) + comib,= 9,%r20,L(41) + ldo -10(%r20),%r19 + comib,<<,n 1,%r19,L(22) + ldw 24(%r3),%r28 +DEF(L(40)) + ldw 28(%r3),%r29 +DEF(L(1)) + ldw -20(%r3),%r2 +DEF(L(48)) + ldo 64(%r3),%r30 + bv %r0(%r2) + ldwm -64(%r30),%r3 +DEF(L(22)) + comib,= 12,%r20,L(46) + ldo 40(%r3),%r19 + comib,=,n 13,%r20,L(47) + comib,=,n 14,%r20,L(1) + ldw 24(%r3),%r28 + comib,<> 15,%r20,L(48) + ldw -20(%r3),%r2 + ldw 16(%r3),%r19 + bb,>= %r19,30,L(1) + ldw 44(%r3),%r2 + ldo -1(%r2),%r19 + comib,<< 7,%r19,L(1) + ldw 36(%r3),%r19 + extru %r19,31,2,%r22 + copy %r19,%r31 + depi 0,31,2,%r31 + comib,<< 4,%r2,L(33) + addl %r22,%r2,%r1 + zdep %r22,28,29,%r22 + mtsar %r22 + zvdepi 2,32,%r19 + comib,<< 4,%r1,L(34) + ldo -1(%r19),%r22 + ldw 0(%r31),%r19 + zdep %r1,28,29,%r20 + ldo -1(%r20),%r20 + and %r19,%r22,%r19 + mtsar %r20 + vextrs %r19,32,%r19 + movb,tr %r19,%r28,L(48) + ldw -20(%r3),%r2 +DEF(L(34)) + ldw 0(%r31),%r19 + zdep %r1,28,29,%r21 + ldw 4(%r31),%r20 + and %r19,%r22,%r19 + ldo -33(%r21),%r31 + subi 63,%r21,%r21 + mtsar %r21 + zvdep %r19,32,%r19 + mtsar %r31 + vextrs %r20,32,%r20 +DEF(L(39)) + b L(1) + or %r20,%r19,%r28 +DEF(L(33)) + zdep %r22,28,29,%r22 + mtsar %r22 + zvdepi 2,32,%r19 + comib,<< 8,%r1,L(37) + ldo -1(%r19),%r2 + ldw 0(%r31),%r21 + zdep %r1,29,30,%r19 + and %r21,%r2,%r21 + ldw 4(%r31),%r22 + subi 47,%r19,%r2 + zdep %r1,28,29,%r19 + mtsar %r2 + ldo -33(%r19),%r19 + zvdep %r21,32,%r20 + zvdep %r20,32,%r20 + mtsar %r19 + vextrs %r22,32,%r22 + vextrs %r21,32,%r21 + movb,tr %r21,%r28,L(1) + or %r20,%r22,%r29 +DEF(L(37)) + ldw 0(%r31),%r20 + zdep %r1,28,29,%r22 + ldw 8(%r31),%r21 + and %r20,%r2,%r20 + ldo -65(%r22),%r2 + ldw 4(%r31),%r19 + mtsar %r2 + subi 95,%r22,%r31 + vextrs %r21,32,%r21 + mtsar %r31 + zvdep %r19,32,%r22 + zvdep %r20,32,%r20 + or %r22,%r21,%r29 + mtsar %r2 + b L(39) + vextrs %r19,32,%r19 +DEF(L(41)) + b L(1) + ldw 24(%r3),%r28 +DEF(L(47)) + ldw 24(%r3),%r28 + b L(40) + fldds -16(%r19),%fr4 +DEF(L(46)) + ldw 24(%r3),%r28 + b L(1) + fldws -16(%r19),%fr4L +DEF(L(45)) + b L(1) + ldh 24(%r3),%r28 +DEF(L(44)) + ldh 24(%r3),%r19 + b L(1) + extrs %r19,31,16,%r28 +DEF(L(43)) + b L(1) + ldb 24(%r3),%r28 +DEF(L(49)) + b L(1) + extrs %r19,31,8,%r28 + .EXIT + .PROCEND +DEF(L(fe1)) + FUNEND(vacall_receiver) +IMPORT_DATA(vacall_function) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/vacall/vacall-hppa.c b/vacall/vacall-hppa.c new file mode 100644 index 0000000..50d70b5 --- /dev/null +++ b/vacall/vacall-hppa.c @@ -0,0 +1,256 @@ +/* vacall function for hppa CPU */ + +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +/*--------------------------------------------------------------------------- + HPPA Argument Passing Conventions: + + The calling conventions for anonymous functions and for explicitly named + functions are different. Only the convention for explicitly named functions + matters here. + + All arguments, except the first 4 words, are passed on the stack + - growing down! - with word alignment. Doubles take two words and force + double alignment. Structures args are passed as true structures embedded + in the argument stack. They force double alignment and - if they don't + fit entirely in the 4 register words - are passed in memory. + The first 2 words are passed like this: + %r26 = first integer arg, %r25 = second integer arg, or + %fr4L = first float arg, %fr5L = second float arg, or + %fr5 = double arg. + Similarly for the next 2 words, passed in %r24 and %r23, or + %fr6L and %fr7L, or + %fr7. + + To return a structure, the called function copies the return value to + the address supplied in register "%r28". +---------------------------------------------------------------------------*/ + +#include "vacall-internal.h" + +#ifdef REENTRANT +#define vacall_receiver callback_receiver +register struct { void (*vacall_function) (void*,va_alist); void* arg; } + * env __asm__("%r29"); +#endif +register void* sret __asm__("%r28"); +register long arg1 __asm__("%r26"); +register long arg2 __asm__("%r25"); +register long arg3 __asm__("%r24"); +register long arg4 __asm__("%r23"); +register float farg1 __asm__("%fr4"); /* fr4L */ +register float farg2 __asm__("%fr5"); /* fr5L */ +register float farg3 __asm__("%fr6"); /* fr6L */ +register float farg4 __asm__("%fr7"); /* fr7L */ +register double darg1 __asm__("%fr5"); +register double darg2 __asm__("%fr7"); +register int iret __asm__("%r28"); +register float fret __asm__("%fr4"); /* fr4L */ +register double dret __asm__("%fr4"); +register __vaword iret1 __asm__("%r28"); +register __vaword iret2 __asm__("%r29"); + +#ifdef REENTRANT +static +#endif +void /* the return type is variable, not void! */ +vacall_receiver (__vaword word1, __vaword word2, __vaword word3, __vaword word4, + __vaword firstword) +{ + /* gcc-2.6.3 source says: When a parameter is passed in a register, + * stack space is still allocated for it. + */ + /* Note about stack offsets (see vacall-hppa.s): + * &firstword = %r30 - 244, &word4 = %r30 - 240, ..., &word1 = %r30 - 228, + */ + __va_alist list; + /* Move the arguments passed in registers to their stack locations. */ + (&firstword)[4] = word1; + (&firstword)[3] = word2; + (&firstword)[2] = word3; + (&firstword)[1] = word4; + list.darg[1] = darg1; + list.darg[0] = darg2; + list.farg[3] = farg1; + list.farg[2] = farg2; + list.farg[1] = farg3; + list.farg[0] = farg4; + /* Prepare the va_alist. */ + list.flags = 0; + list.aptr = (long)(&firstword + 5); + list.raddr = (void*)0; + list.rtype = __VAvoid; + list.structraddr = sret; + list.memargptr = (long)(&firstword + 1); + list.farg_offset = (long)&list.farg[4] - list.aptr; + list.darg_offset = (long)&list.darg[2] - list.aptr; + /* Call vacall_function. The macros do all the rest. */ +#ifndef REENTRANT + (*vacall_function) (&list); +#else /* REENTRANT */ + (*env->vacall_function) (env->arg,&list); +#endif + /* Put return value into proper register. */ + if (list.rtype == __VAvoid) { + } else + if (list.rtype == __VAchar) { + iret = list.tmp._char; + } else + if (list.rtype == __VAschar) { + iret = list.tmp._schar; + } else + if (list.rtype == __VAuchar) { + iret = list.tmp._uchar; + } else + if (list.rtype == __VAshort) { + iret = list.tmp._short; + } else + if (list.rtype == __VAushort) { + iret = list.tmp._ushort; + } else + if (list.rtype == __VAint) { + iret = list.tmp._int; + } else + if (list.rtype == __VAuint) { + iret = list.tmp._uint; + } else + if (list.rtype == __VAlong) { + iret = list.tmp._long; + } else + if (list.rtype == __VAulong) { + iret = list.tmp._ulong; + } else + if (list.rtype == __VAlonglong || list.rtype == __VAulonglong) { + iret1 = ((__vaword *) &list.tmp._longlong)[0]; + iret2 = ((__vaword *) &list.tmp._longlong)[1]; + } else + if (list.rtype == __VAfloat) { + fret = list.tmp._float; + iret1 = list.tmp._words[0]; /* HP cc generates a RTNVAL=GR call */ + } else + if (list.rtype == __VAdouble) { + dret = list.tmp._double; + iret1 = list.tmp._words[0]; /* HP cc generates a RTNVAL=GR call */ + iret2 = list.tmp._words[1]; /* i.e. result is expected in r28,r29 */ + } else + if (list.rtype == __VAvoidp) { + iret = (long)list.tmp._ptr; + } else + if (list.rtype == __VAstruct) { + if (list.flags & __VA_SMALL_STRUCT_RETURN) { + /* cc, c89 and gcc >= 2.7 return structs of size <= 8 in registers. */ + /* This is really weird code, unlike all other big-endian platforms. */ + if (list.rsize > 0 && list.rsize <= 8) { + #if 0 /* Unoptimized */ + if (list.rsize == 1) { + iret = ((unsigned char *) list.raddr)[0]; + } else + if (list.rsize == 2) { + iret = (((unsigned char *) list.raddr)[0] << 8) + | ((unsigned char *) list.raddr)[1]; + } else + if (list.rsize == 3) { + iret = (((unsigned char *) list.raddr)[0] << 16) + | (((unsigned char *) list.raddr)[1] << 8) + | ((unsigned char *) list.raddr)[2]; + } else + if (list.rsize == 4) { + iret = (((unsigned char *) list.raddr)[0] << 24) + | (((unsigned char *) list.raddr)[1] << 16) + | (((unsigned char *) list.raddr)[2] << 8) + | ((unsigned char *) list.raddr)[3]; + } else + if (list.rsize == 5) { + iret1 = ((unsigned char *) list.raddr)[0]; + iret2 = (((unsigned char *) list.raddr)[1] << 24) + | (((unsigned char *) list.raddr)[2] << 16) + | (((unsigned char *) list.raddr)[3] << 8) + | ((unsigned char *) list.raddr)[4]; + } else + if (list.rsize == 6) { + iret1 = (((unsigned char *) list.raddr)[0] << 8) + | ((unsigned char *) list.raddr)[1]; + iret2 = (((unsigned char *) list.raddr)[2] << 24) + | (((unsigned char *) list.raddr)[3] << 16) + | (((unsigned char *) list.raddr)[4] << 8) + | ((unsigned char *) list.raddr)[5]; + } else + if (list.rsize == 7) { + iret1 = (((unsigned char *) list.raddr)[0] << 16) + | (((unsigned char *) list.raddr)[1] << 8) + | ((unsigned char *) list.raddr)[2]; + iret2 = (((unsigned char *) list.raddr)[3] << 24) + | (((unsigned char *) list.raddr)[4] << 16) + | (((unsigned char *) list.raddr)[5] << 8) + | ((unsigned char *) list.raddr)[6]; + } else + if (list.rsize == 8) { + iret1 = (((unsigned char *) list.raddr)[0] << 24) + | (((unsigned char *) list.raddr)[1] << 16) + | (((unsigned char *) list.raddr)[2] << 8) + | ((unsigned char *) list.raddr)[3]; + iret2 = (((unsigned char *) list.raddr)[4] << 24) + | (((unsigned char *) list.raddr)[5] << 16) + | (((unsigned char *) list.raddr)[6] << 8) + | ((unsigned char *) list.raddr)[7]; + } + #else /* Optimized: fewer conditional jumps, fewer memory accesses */ + uintptr_t count = list.rsize; /* > 0, ≤ 2*sizeof(__vaword) */ + __vaword* wordaddr = (__vaword*)((uintptr_t)list.raddr & ~(uintptr_t)(sizeof(__vaword)-1)); + uintptr_t start_offset = (uintptr_t)list.raddr & (uintptr_t)(sizeof(__vaword)-1); /* ≥ 0, < sizeof(__vaword) */ + uintptr_t end_offset = start_offset + count; /* > 0, < 3*sizeof(__vaword) */ + if (count <= sizeof(__vaword)) { + /* Assign iret. */ + __vaword mask0 = ((__vaword)2 << (sizeof(__vaword)*8-start_offset*8-1)) - 1; + if (end_offset <= sizeof(__vaword)) { + /* 0 < end_offset ≤ sizeof(__vaword) */ + iret = (wordaddr[0] & mask0) >> (sizeof(__vaword)*8-end_offset*8); + } else { + /* sizeof(__vaword) < end_offset < 2*sizeof(__vaword), start_offset > 0 */ + iret = ((wordaddr[0] & mask0) << (end_offset*8-sizeof(__vaword)*8)) + | (wordaddr[1] >> (2*sizeof(__vaword)*8-end_offset*8)); + } + } else { + /* Assign iret, iret2. */ + __vaword mask0 = ((__vaword)2 << (sizeof(__vaword)*8-start_offset*8-1)) - 1; + if (end_offset <= 2*sizeof(__vaword)) { + /* sizeof(__vaword) < end_offset ≤ 2*sizeof(__vaword) */ + iret = (wordaddr[0] & mask0) >> (2*sizeof(__vaword)*8-end_offset*8); + iret2 = ((wordaddr[0] & mask0) << (end_offset*4-sizeof(__vaword)*4) << (end_offset*4-sizeof(__vaword)*4)) + | (wordaddr[1] >> (2*sizeof(__vaword)*8-end_offset*8)); + } else { + /* 2*sizeof(__vaword) < end_offset < 3*sizeof(__vaword), start_offset > 0 */ + iret = ((wordaddr[0] & mask0) << (end_offset*8-2*sizeof(__vaword)*8)) + | (wordaddr[1] >> (3*sizeof(__vaword)*8-end_offset*8)); + iret2 = (wordaddr[1] << (end_offset*8-2*sizeof(__vaword)*8)) + | (wordaddr[2] >> (3*sizeof(__vaword)*8-end_offset*8)); + } + } + #endif + } + } + } +} + +#ifdef REENTRANT +__vacall_r_t +callback_get_receiver (void) +{ + return (__vacall_r_t)(void*)&callback_receiver; +} +#endif diff --git a/vacall/vacall-hppa64-linux.s b/vacall/vacall-hppa64-linux.s new file mode 100644 index 0000000..8d1317f --- /dev/null +++ b/vacall/vacall-hppa64-linux.s @@ -0,0 +1,225 @@ + .LEVEL 2.0w + .text + .align 8 +.globl vacall_receiver + .type vacall_receiver,@function +vacall_receiver: + .PROC + .CALLINFO FRAME=384,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=8 + .ENTRY + copy %r3,%r1 + std %r2,-16(%r30) + copy %r30,%r3 + std,ma %r1,384(%r30) + std %r4,224(%r3) + copy %r27,%r4 + std %r8,192(%r3) + std %r7,200(%r3) + std %r6,208(%r3) + std %r5,216(%r3) + std %r26,-64(%r29) + std %r19,-8(%r29) + std %r25,-56(%r29) + std %r24,-48(%r29) + std %r23,-40(%r29) + std %r22,-32(%r29) + std %r21,-24(%r29) + std %r20,-16(%r29) +#APP + fstw %fr4R,88(%r3) + fstw %fr5R,92(%r3) + fstw %fr6R,96(%r3) + fstw %fr7R,100(%r3) + fstw %fr8R,104(%r3) + fstw %fr9R,108(%r3) + fstw %fr10R,112(%r3) + fstw %fr11R,116(%r3) +#NO_APP + fstd %fr10,168(%r3) + addil LT'vacall_function,%r27 + ldo -64(%r29),%r31 + ldd RT'vacall_function(%r1),%r1 + ldo 16(%r3),%r26 + std %r31,40(%r3) + std %r29,80(%r3) + ldo -16(%r30),%r29 + ldd 0(%r1),%r31 + fstd %fr11,176(%r3) + fstd %fr4,120(%r3) + fstd %fr5,128(%r3) + fstd %fr6,136(%r3) + fstd %fr7,144(%r3) + fstd %fr8,152(%r3) + fstd %fr9,160(%r3) + stw %r0,16(%r3) + std %r0,48(%r3) + stw %r0,56(%r3) + ldd 16(%r31),%r2 + ldd 24(%r31),%r27 + bve,l (%r2),%r2 + nop + ldw 56(%r3),%r31 + cmpib,= 0,%r31,.L1 + copy %r4,%r27 + cmpib,=,n 1,%r31,.L43 + cmpib,=,n 2,%r31,.L43 + cmpib,=,n 3,%r31,.L44 + cmpib,=,n 4,%r31,.L45 + cmpib,=,n 5,%r31,.L46 + cmpib,=,n 6,%r31,.L47 + cmpib,=,n 7,%r31,.L41 + cmpib,=,n 8,%r31,.L40 + cmpib,=,n 10,%r31,.L40 + cmpib,=,n 9,%r31,.L40 + cmpib,=,n 11,%r31,.L40 + cmpib,=,n 12,%r31,.L48 + cmpib,=,n 13,%r31,.L49 + cmpib,=,n 14,%r31,.L40 + cmpib,= 15,%r31,.L50 + ldw 16(%r3),%r31 +.L1: + ldd -16(%r3),%r2 + ldd 192(%r3),%r8 + ldd 200(%r3),%r7 + ldd 208(%r3),%r6 + ldd 216(%r3),%r5 + ldd 224(%r3),%r4 + ldo 64(%r3),%r30 + bve (%r2) + ldd,mb -64(%r30),%r3 +.L50: + extrd,u %r31,53+1-1,1,%r31 + cmpib,= 0,%r31,.L1 + ldd 48(%r3),%r28 + ldd 48(%r3),%r31 + ldd 64(%r3),%r2 + extrd,u %r31,63,3,%r6 + copy %r31,%r1 + depdi 0,63,3,%r1 + cmpib,*<< 8,%r2,.L32 + add,l %r6,%r2,%r4 + cmpib,*<< 8,%r4,.L33 + depd,z %r4,60,61,%r31 + subi 64,%r31,%r31 + ldd 0(%r1),%r2 + extrd,s %r31,63,32,%r31 + mtsarcm %r31 + depd,z %r6,60,61,%r4 + depdi,z 1,%sar,64,%r31 + mtsarcm %r4 + sub %r0,%r31,%r31 + and %r2,%r31,%r2 + depd,z %r2,%sar,64,%r2 + b .L1 + copy %r2,%r28 +.L33: + subi 128,%r31,%r31 + depd,z %r6,60,61,%r2 + extrd,s %r31,63,32,%r31 + subi 64,%r2,%r5 + mtsarcm %r31 + subi 63,%r2,%r7 + depdi,z 1,%sar,64,%r31 + mtsar %r7 + ldd 8(%r1),%r4 + sub %r0,%r31,%r31 + extrd,s %r5,63,32,%r5 + ldd 0(%r1),%r2 + subi 63,%r5,%r5 + and %r4,%r31,%r4 + depd,z %r2,%sar,64,%r2 + mtsar %r5 + extrd,s %r4,%sar,64,%r4 +.L39: + b .L1 + or %r4,%r2,%r28 +.L32: + ldi 16,%r31 + cmpb,*<< %r31,%r4,.L36 + depd,z %r4,60,61,%r31 + subi 128,%r31,%r31 + depd,z %r6,61,62,%r2 + extrd,s %r31,63,32,%r31 + subi 32,%r2,%r2 + mtsarcm %r31 + extrd,s %r2,63,32,%r2 + depdi,z 1,%sar,64,%r31 + subi 63,%r2,%r7 + ldd 8(%r1),%r4 + sub %r0,%r31,%r31 + mtsar %r7 + ldd 0(%r1),%r5 + and %r4,%r31,%r4 + depd,z %r6,60,61,%r31 + extrd,s %r4,%sar,64,%r2 + subi 63,%r31,%r31 + extrd,s %r2,%sar,64,%r2 + mtsar %r31 + depd,z %r4,%sar,64,%r4 + depd,z %r5,%sar,64,%r5 + copy %r4,%r29 + b .L1 + or %r5,%r2,%r28 +.L36: + subi 192,%r31,%r31 + depd,z %r6,60,61,%r2 + extrd,s %r31,63,32,%r31 + subi 64,%r2,%r6 + mtsarcm %r31 + subi 63,%r2,%r8 + depdi,z 1,%sar,64,%r31 + mtsar %r8 + ldd 8(%r1),%r2 + sub %r0,%r31,%r31 + ldd 16(%r1),%r5 + extrd,s %r6,63,32,%r6 + subi 63,%r6,%r6 + and %r5,%r31,%r5 + ldd 0(%r1),%r4 + depd,z %r2,%sar,64,%r31 + mtsar %r6 + extrd,s %r5,%sar,64,%r5 + mtsar %r8 + depd,z %r4,%sar,64,%r4 + or %r31,%r5,%r29 + mtsar %r6 + b .L39 + extrd,s %r2,%sar,64,%r2 +.L40: + b .L1 + ldd 24(%r3),%r28 +.L49: + b .L40 + fldd 24(%r3),%fr4 +.L48: +#APP + fldw 24(%r3),%fr4R +#NO_APP +.L41: + ldw 24(%r3),%r31 +.L42: + b .L1 + copy %r31,%r28 +.L47: + ldw 24(%r3),%r31 + b .L1 + extrd,s %r31,63,32,%r28 +.L46: + b .L42 + ldh 24(%r3),%r31 +.L45: + ldh 24(%r3),%r31 + b .L1 + extrd,s %r31,63,16,%r28 +.L44: + b .L42 + ldb 24(%r3),%r31 +.L43: + ldb 24(%r3),%r31 + b .L1 + extrd,s %r31,63,8,%r28 + .EXIT + .PROCEND +.Lfe1: + .size vacall_receiver,.Lfe1-vacall_receiver + .ident "GCC: (GNU) 3.1" diff --git a/vacall/vacall-hppa64-macro.S b/vacall/vacall-hppa64-macro.S new file mode 100644 index 0000000..0bf669b --- /dev/null +++ b/vacall/vacall-hppa64-macro.S @@ -0,0 +1,226 @@ +#include "asm-hppa64.h" + .LEVEL 2.0w + TEXT1() + TEXT2() + .align 8 +GLOBL(vacall_receiver) + DECLARE_FUNCTION(vacall_receiver) +DEF(vacall_receiver) + .PROC + .CALLINFO FRAME=384,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=8 + .ENTRY + copy %r3,%r1 + std %r2,-16(%r30) + copy %r30,%r3 + std,ma %r1,384(%r30) + std %r4,224(%r3) + copy %r27,%r4 + std %r8,192(%r3) + std %r7,200(%r3) + std %r6,208(%r3) + std %r5,216(%r3) + std %r26,-64(%r29) + std %r19,-8(%r29) + std %r25,-56(%r29) + std %r24,-48(%r29) + std %r23,-40(%r29) + std %r22,-32(%r29) + std %r21,-24(%r29) + std %r20,-16(%r29) + fstw %fr4R,88(%r3) + fstw %fr5R,92(%r3) + fstw %fr6R,96(%r3) + fstw %fr7R,100(%r3) + fstw %fr8R,104(%r3) + fstw %fr9R,108(%r3) + fstw %fr10R,112(%r3) + fstw %fr11R,116(%r3) + fstd %fr10,168(%r3) + addil LT!vacall_function,%r27 + ldo -64(%r29),%r31 + ldd RT!vacall_function(%r1),%r1 + ldo 16(%r3),%r26 + std %r31,40(%r3) + std %r29,80(%r3) + ldo -16(%r30),%r29 + ldd 0(%r1),%r31 + fstd %fr11,176(%r3) + fstd %fr4,120(%r3) + fstd %fr5,128(%r3) + fstd %fr6,136(%r3) + fstd %fr7,144(%r3) + fstd %fr8,152(%r3) + fstd %fr9,160(%r3) + stw %r0,16(%r3) + std %r0,48(%r3) + stw %r0,56(%r3) + ldd 16(%r31),%r2 + ldd 24(%r31),%r27 + bve,l (%r2),%r2 + nop + ldw 56(%r3),%r31 + cmpib,= 0,%r31,L(1) + copy %r4,%r27 + cmpib,=,n 1,%r31,L(43) + cmpib,=,n 2,%r31,L(43) + cmpib,=,n 3,%r31,L(44) + cmpib,=,n 4,%r31,L(45) + cmpib,=,n 5,%r31,L(46) + cmpib,=,n 6,%r31,L(47) + cmpib,=,n 7,%r31,L(41) + cmpib,=,n 8,%r31,L(40) + cmpib,=,n 10,%r31,L(40) + cmpib,=,n 9,%r31,L(40) + cmpib,=,n 11,%r31,L(40) + cmpib,=,n 12,%r31,L(48) + cmpib,=,n 13,%r31,L(49) + cmpib,=,n 14,%r31,L(40) + cmpib,= 15,%r31,L(50) + ldw 16(%r3),%r31 +DEF(L(1)) + ldd -16(%r3),%r2 + ldd 192(%r3),%r8 + ldd 200(%r3),%r7 + ldd 208(%r3),%r6 + ldd 216(%r3),%r5 + ldd 224(%r3),%r4 + ldo 64(%r3),%r30 + bve (%r2) + ldd,mb -64(%r30),%r3 +DEF(L(50)) + extrd,u %r31,53+1-1,1,%r31 + cmpib,= 0,%r31,L(1) + ldd 48(%r3),%r28 + ldd 48(%r3),%r31 + ldd 64(%r3),%r2 + extrd,u %r31,63,3,%r6 + copy %r31,%r1 + depdi 0,63,3,%r1 + cmpib,*<< 8,%r2,L(32) + add,l %r6,%r2,%r4 + cmpib,*<< 8,%r4,L(33) + depd,z %r4,60,61,%r31 + subi 64,%r31,%r31 + ldd 0(%r1),%r2 + extrd,s %r31,63,32,%r31 + mtsarcm %r31 + depd,z %r6,60,61,%r4 + depdi,z 1,%sar,64,%r31 + mtsarcm %r4 + sub %r0,%r31,%r31 + and %r2,%r31,%r2 + depd,z %r2,%sar,64,%r2 + b L(1) + copy %r2,%r28 +DEF(L(33)) + subi 128,%r31,%r31 + depd,z %r6,60,61,%r2 + extrd,s %r31,63,32,%r31 + subi 64,%r2,%r5 + mtsarcm %r31 + subi 63,%r2,%r7 + depdi,z 1,%sar,64,%r31 + mtsar %r7 + ldd 8(%r1),%r4 + sub %r0,%r31,%r31 + extrd,s %r5,63,32,%r5 + ldd 0(%r1),%r2 + subi 63,%r5,%r5 + and %r4,%r31,%r4 + depd,z %r2,%sar,64,%r2 + mtsar %r5 + extrd,s %r4,%sar,64,%r4 +DEF(L(39)) + b L(1) + or %r4,%r2,%r28 +DEF(L(32)) + ldi 16,%r31 + cmpb,*<< %r31,%r4,L(36) + depd,z %r4,60,61,%r31 + subi 128,%r31,%r31 + depd,z %r6,61,62,%r2 + extrd,s %r31,63,32,%r31 + subi 32,%r2,%r2 + mtsarcm %r31 + extrd,s %r2,63,32,%r2 + depdi,z 1,%sar,64,%r31 + subi 63,%r2,%r7 + ldd 8(%r1),%r4 + sub %r0,%r31,%r31 + mtsar %r7 + ldd 0(%r1),%r5 + and %r4,%r31,%r4 + depd,z %r6,60,61,%r31 + extrd,s %r4,%sar,64,%r2 + subi 63,%r31,%r31 + extrd,s %r2,%sar,64,%r2 + mtsar %r31 + depd,z %r4,%sar,64,%r4 + depd,z %r5,%sar,64,%r5 + copy %r4,%r29 + b L(1) + or %r5,%r2,%r28 +DEF(L(36)) + subi 192,%r31,%r31 + depd,z %r6,60,61,%r2 + extrd,s %r31,63,32,%r31 + subi 64,%r2,%r6 + mtsarcm %r31 + subi 63,%r2,%r8 + depdi,z 1,%sar,64,%r31 + mtsar %r8 + ldd 8(%r1),%r2 + sub %r0,%r31,%r31 + ldd 16(%r1),%r5 + extrd,s %r6,63,32,%r6 + subi 63,%r6,%r6 + and %r5,%r31,%r5 + ldd 0(%r1),%r4 + depd,z %r2,%sar,64,%r31 + mtsar %r6 + extrd,s %r5,%sar,64,%r5 + mtsar %r8 + depd,z %r4,%sar,64,%r4 + or %r31,%r5,%r29 + mtsar %r6 + b L(39) + extrd,s %r2,%sar,64,%r2 +DEF(L(40)) + b L(1) + ldd 24(%r3),%r28 +DEF(L(49)) + b L(40) + fldd 24(%r3),%fr4 +DEF(L(48)) + fldw 24(%r3),%fr4R +DEF(L(41)) + ldw 24(%r3),%r31 +DEF(L(42)) + b L(1) + copy %r31,%r28 +DEF(L(47)) + ldw 24(%r3),%r31 + b L(1) + extrd,s %r31,63,32,%r28 +DEF(L(46)) + b L(42) + ldh 24(%r3),%r31 +DEF(L(45)) + ldh 24(%r3),%r31 + b L(1) + extrd,s %r31,63,16,%r28 +DEF(L(44)) + b L(42) + ldb 24(%r3),%r31 +DEF(L(43)) + ldb 24(%r3),%r31 + b L(1) + extrd,s %r31,63,8,%r28 + .EXIT + .PROCEND +DEF(L(fe1)) + FUNEND(vacall_receiver) +IMPORT_DATA(vacall_function) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/vacall/vacall-hppa64.c b/vacall/vacall-hppa64.c new file mode 100644 index 0000000..7abc8da --- /dev/null +++ b/vacall/vacall-hppa64.c @@ -0,0 +1,294 @@ +/* vacall function for hppa64 CPU */ + +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +#include "vacall-internal.h" + +#ifdef REENTRANT +#define vacall_receiver callback_receiver +register struct { void (*vacall_function) (void*,va_alist); void* arg; } + * env __asm__("%r31"); +#endif + +register __vaword arg1 __asm__("r26"); +register __vaword arg2 __asm__("r25"); +register __vaword arg3 __asm__("r24"); +register __vaword arg4 __asm__("r23"); +register __vaword arg5 __asm__("r22"); +register __vaword arg6 __asm__("r21"); +register __vaword arg7 __asm__("r20"); +register __vaword arg8 __asm__("r19"); + +/*register float farg1 __asm__("fr4R");*/ +/*register float farg2 __asm__("fr5R");*/ +/*register float farg3 __asm__("fr6R");*/ +/*register float farg4 __asm__("fr7R");*/ +/*register float farg5 __asm__("fr8R");*/ +/*register float farg6 __asm__("fr9R");*/ +/*register float farg7 __asm__("fr10R");*/ +/*register float farg8 __asm__("fr11R");*/ + +register double darg1 __asm__("fr4"); +register double darg2 __asm__("fr5"); +register double darg3 __asm__("fr6"); +register double darg4 __asm__("fr7"); +register double darg5 __asm__("fr8"); +register double darg6 __asm__("fr9"); +register double darg7 __asm__("fr10"); +register double darg8 __asm__("fr11"); + +register __vaword iret __asm__("r28"); +register __vaword iret2 __asm__("r29"); + +void /* the return type is variable, not void! */ +vacall_receiver (__vaword word1, __vaword word2, __vaword word3, __vaword word4, + __vaword word5, __vaword word6, __vaword word7, __vaword word8, + __vaword firstword) +{ + __va_alist list; + /* Move the arguments passed in registers to their stack locations. */ + (&firstword)[-8] = word1; + (&firstword)[-7] = word2; + (&firstword)[-6] = word3; + (&firstword)[-5] = word4; + (&firstword)[-4] = word5; + (&firstword)[-3] = word6; + (&firstword)[-2] = word7; + (&firstword)[-1] = word8; + __asm__ __volatile__ ("fstw %%fr4R,%0" : : "m" (list.farg[0])); /* list.farg[0] = farg1; */ + __asm__ __volatile__ ("fstw %%fr5R,%0" : : "m" (list.farg[1])); /* list.farg[1] = farg2; */ + __asm__ __volatile__ ("fstw %%fr6R,%0" : : "m" (list.farg[2])); /* list.farg[2] = farg3; */ + __asm__ __volatile__ ("fstw %%fr7R,%0" : : "m" (list.farg[3])); /* list.farg[3] = farg4; */ + __asm__ __volatile__ ("fstw %%fr8R,%0" : : "m" (list.farg[4])); /* list.farg[4] = farg5; */ + __asm__ __volatile__ ("fstw %%fr9R,%0" : : "m" (list.farg[5])); /* list.farg[5] = farg6; */ + __asm__ __volatile__ ("fstw %%fr10R,%0" : : "m" (list.farg[6])); /* list.farg[6] = farg7; */ + __asm__ __volatile__ ("fstw %%fr11R,%0" : : "m" (list.farg[7])); /* list.farg[7] = farg8; */ + list.darg[0] = darg1; + list.darg[1] = darg2; + list.darg[2] = darg3; + list.darg[3] = darg4; + list.darg[4] = darg5; + list.darg[5] = darg6; + list.darg[6] = darg7; + list.darg[7] = darg8; + /* Prepare the va_alist. */ + list.flags = 0; + list.aptr = (long)(&firstword - 8); + list.raddr = (void*)0; + list.rtype = __VAvoid; + list.memargptr = (long)&firstword; + /* Call vacall_function. The macros do all the rest. */ +#ifndef REENTRANT + (*vacall_function) (&list); +#else /* REENTRANT */ + (*env->vacall_function) (env->arg,&list); +#endif + /* Put return value into proper register. */ + if (list.rtype == __VAvoid) { + } else + if (list.rtype == __VAchar) { + iret = list.tmp._char; + } else + if (list.rtype == __VAschar) { + iret = list.tmp._schar; + } else + if (list.rtype == __VAuchar) { + iret = list.tmp._uchar; + } else + if (list.rtype == __VAshort) { + iret = list.tmp._short; + } else + if (list.rtype == __VAushort) { + iret = list.tmp._ushort; + } else + if (list.rtype == __VAint) { + iret = list.tmp._int; + } else + if (list.rtype == __VAuint) { + iret = list.tmp._uint; + } else + if (list.rtype == __VAlong || list.rtype == __VAlonglong) { + iret = list.tmp._long; + } else + if (list.rtype == __VAulong || list.rtype == __VAulonglong) { + iret = list.tmp._ulong; + } else + if (list.rtype == __VAfloat) { + __asm__ __volatile__ ("fldw %0,%%fr4R" : : "m" (list.tmp._float)); /* farg1 = list.tmp._float; */ + iret = *(unsigned int *)&list.tmp._float; + } else + if (list.rtype == __VAdouble) { + darg1 = list.tmp._double; + iret = *(unsigned long*)&list.tmp._double; + } else + if (list.rtype == __VAvoidp) { + iret = (long)list.tmp._ptr; + } else + if (list.rtype == __VAstruct) { + if (list.flags & __VA_REGISTER_STRUCT_RETURN) { + #if 0 /* Unoptimized */ + if (list.rsize == 1) { + iret = (__vaword)((unsigned char *) list.raddr)[0] << 56; + } else + if (list.rsize == 2) { + iret = ((__vaword)((unsigned char *) list.raddr)[0] << 56) + | ((__vaword)((unsigned char *) list.raddr)[1] << 48); + } else + if (list.rsize == 3) { + iret = ((__vaword)((unsigned char *) list.raddr)[0] << 56) + | ((__vaword)((unsigned char *) list.raddr)[1] << 48) + | ((__vaword)((unsigned char *) list.raddr)[2] << 40); + } else + if (list.rsize == 4) { + iret = ((__vaword)((unsigned char *) list.raddr)[0] << 56) + | ((__vaword)((unsigned char *) list.raddr)[1] << 48) + | ((__vaword)((unsigned char *) list.raddr)[2] << 40) + | ((__vaword)((unsigned char *) list.raddr)[3] << 32); + } else + if (list.rsize == 5) { + iret = ((__vaword)((unsigned char *) list.raddr)[0] << 56) + | ((__vaword)((unsigned char *) list.raddr)[1] << 48) + | ((__vaword)((unsigned char *) list.raddr)[2] << 40) + | ((__vaword)((unsigned char *) list.raddr)[3] << 32) + | ((__vaword)((unsigned char *) list.raddr)[4] << 24); + } else + if (list.rsize == 6) { + iret = ((__vaword)((unsigned char *) list.raddr)[0] << 56) + | ((__vaword)((unsigned char *) list.raddr)[1] << 48) + | ((__vaword)((unsigned char *) list.raddr)[2] << 40) + | ((__vaword)((unsigned char *) list.raddr)[3] << 32) + | ((__vaword)((unsigned char *) list.raddr)[4] << 24) + | ((__vaword)((unsigned char *) list.raddr)[5] << 16); + } else + if (list.rsize == 7) { + iret = ((__vaword)((unsigned char *) list.raddr)[0] << 56) + | ((__vaword)((unsigned char *) list.raddr)[1] << 48) + | ((__vaword)((unsigned char *) list.raddr)[2] << 40) + | ((__vaword)((unsigned char *) list.raddr)[3] << 32) + | ((__vaword)((unsigned char *) list.raddr)[4] << 24) + | ((__vaword)((unsigned char *) list.raddr)[5] << 16) + | ((__vaword)((unsigned char *) list.raddr)[6] << 8); + } else + if (list.rsize >= 8 && list.rsize <= 16) { + iret = ((__vaword)((unsigned char *) list.raddr)[0] << 56) + | ((__vaword)((unsigned char *) list.raddr)[1] << 48) + | ((__vaword)((unsigned char *) list.raddr)[2] << 40) + | ((__vaword)((unsigned char *) list.raddr)[3] << 32) + | ((__vaword)((unsigned char *) list.raddr)[4] << 24) + | ((__vaword)((unsigned char *) list.raddr)[5] << 16) + | ((__vaword)((unsigned char *) list.raddr)[6] << 8) + | (__vaword)((unsigned char *) list.raddr)[7]; + if (list.rsize == 8) { + } else + if (list.rsize == 9) { + iret2 = (__vaword)((unsigned char *) list.raddr)[8] << 56; + } else + if (list.rsize == 10) { + iret2 = ((__vaword)((unsigned char *) list.raddr)[8] << 56) + | ((__vaword)((unsigned char *) list.raddr)[9] << 48); + } else + if (list.rsize == 11) { + iret2 = ((__vaword)((unsigned char *) list.raddr)[8] << 56) + | ((__vaword)((unsigned char *) list.raddr)[9] << 48) + | ((__vaword)((unsigned char *) list.raddr)[10] << 40); + } else + if (list.rsize == 12) { + iret2 = ((__vaword)((unsigned char *) list.raddr)[8] << 56) + | ((__vaword)((unsigned char *) list.raddr)[9] << 48) + | ((__vaword)((unsigned char *) list.raddr)[10] << 40) + | ((__vaword)((unsigned char *) list.raddr)[11] << 32); + } else + if (list.rsize == 13) { + iret2 = ((__vaword)((unsigned char *) list.raddr)[8] << 56) + | ((__vaword)((unsigned char *) list.raddr)[9] << 48) + | ((__vaword)((unsigned char *) list.raddr)[10] << 40) + | ((__vaword)((unsigned char *) list.raddr)[11] << 32) + | ((__vaword)((unsigned char *) list.raddr)[12] << 24); + } else + if (list.rsize == 14) { + iret2 = ((__vaword)((unsigned char *) list.raddr)[8] << 56) + | ((__vaword)((unsigned char *) list.raddr)[9] << 48) + | ((__vaword)((unsigned char *) list.raddr)[10] << 40) + | ((__vaword)((unsigned char *) list.raddr)[11] << 32) + | ((__vaword)((unsigned char *) list.raddr)[12] << 24) + | ((__vaword)((unsigned char *) list.raddr)[13] << 16); + } else + if (list.rsize == 15) { + iret2 = ((__vaword)((unsigned char *) list.raddr)[8] << 56) + | ((__vaword)((unsigned char *) list.raddr)[9] << 48) + | ((__vaword)((unsigned char *) list.raddr)[10] << 40) + | ((__vaword)((unsigned char *) list.raddr)[11] << 32) + | ((__vaword)((unsigned char *) list.raddr)[12] << 24) + | ((__vaword)((unsigned char *) list.raddr)[13] << 16) + | ((__vaword)((unsigned char *) list.raddr)[14] << 8); + } else + if (list.rsize == 16) { + iret2 = ((__vaword)((unsigned char *) list.raddr)[8] << 56) + | ((__vaword)((unsigned char *) list.raddr)[9] << 48) + | ((__vaword)((unsigned char *) list.raddr)[10] << 40) + | ((__vaword)((unsigned char *) list.raddr)[11] << 32) + | ((__vaword)((unsigned char *) list.raddr)[12] << 24) + | ((__vaword)((unsigned char *) list.raddr)[13] << 16) + | ((__vaword)((unsigned char *) list.raddr)[14] << 8) + | (__vaword)((unsigned char *) list.raddr)[15]; + } + } + #else /* Optimized: fewer conditional jumps, fewer memory accesses */ + uintptr_t count = list.rsize; /* > 0, ≤ 2*sizeof(__vaword) */ + __vaword* wordaddr = (__vaword*)((uintptr_t)list.raddr & ~(uintptr_t)(sizeof(__vaword)-1)); + uintptr_t start_offset = (uintptr_t)list.raddr & (uintptr_t)(sizeof(__vaword)-1); /* ≥ 0, < sizeof(__vaword) */ + uintptr_t end_offset = start_offset + count; /* > 0, < 3*sizeof(__vaword) */ + if (count <= sizeof(__vaword)) { + /* Assign iret. */ + if (end_offset <= sizeof(__vaword)) { + /* 0 < end_offset ≤ sizeof(__vaword) */ + __vaword mask0 = - ((__vaword)1 << (sizeof(__vaword)*8-end_offset*8)); + iret = (wordaddr[0] & mask0) << (start_offset*8); + } else { + /* sizeof(__vaword) < end_offset < 2*sizeof(__vaword), start_offset > 0 */ + __vaword mask1 = - ((__vaword)1 << (2*sizeof(__vaword)*8-end_offset*8)); + iret = (wordaddr[0] << (start_offset*8)) | ((wordaddr[1] & mask1) >> (sizeof(__vaword)*8-start_offset*8)); + } + } else { + /* Assign iret, iret2. */ + if (end_offset <= 2*sizeof(__vaword)) { + /* sizeof(__vaword) < end_offset ≤ 2*sizeof(__vaword) */ + __vaword mask1 = - ((__vaword)1 << (2*sizeof(__vaword)*8-end_offset*8)); + iret = (wordaddr[0] << (start_offset*8)) | ((wordaddr[1] & mask1) >> (sizeof(__vaword)*4-start_offset*4) >> (sizeof(__vaword)*4-start_offset*4)); + iret2 = (wordaddr[1] & mask1) << (start_offset*8); + } else { + /* 2*sizeof(__vaword) < end_offset < 3*sizeof(__vaword), start_offset > 0 */ + __vaword mask2 = - ((__vaword)1 << (3*sizeof(__vaword)*8-end_offset*8)); + iret = (wordaddr[0] << (start_offset*8)) | (wordaddr[1] >> (sizeof(__vaword)*8-start_offset*8)); + iret2 = (wordaddr[1] << (start_offset*8)) | ((wordaddr[2] & mask2) >> (sizeof(__vaword)*8-start_offset*8)); + } + } + #endif + } else { + iret = (long)list.raddr; + } + } +} + +#ifdef REENTRANT +__vacall_r_t +callback_get_receiver (void) +{ + return (__vacall_r_t)(void*)&callback_receiver; +} +#endif diff --git a/vacall/vacall-i386-linux-pic.s b/vacall/vacall-i386-linux-pic.s new file mode 100644 index 0000000..65470a8 --- /dev/null +++ b/vacall/vacall-i386-linux-pic.s @@ -0,0 +1,159 @@ + .file "vacall-i386.c" + .text + .align 2 + .p2align 2,,3 +.globl vacall_receiver + .type vacall_receiver,@function +vacall_receiver: + pushl %ebp + movl %esp, %ebp + pushl %esi + pushl %ebx + subl $48, %esp + call .L44 +.L44: + popl %ebx + addl $_GLOBAL_OFFSET_TABLE_+[.-.L44], %ebx + leal 8(%ebp), %edx + movl %edx, -40(%ebp) + subl $12, %esp + leal -56(%ebp), %edx + movl $0, -56(%ebp) + movl $0, -36(%ebp) + movl $0, -32(%ebp) + movl %ebx, -24(%ebp) + pushl %edx + movl vacall_function@GOT(%ebx), %edx + call *(%edx) + movl -32(%ebp), %ecx + addl $16, %esp + testl %ecx, %ecx + je .L43 + cmpl $1, %ecx + je .L45 + cmpl $2, %ecx + je .L45 + cmpl $3, %ecx + je .L50 + cmpl $4, %ecx + je .L51 + cmpl $5, %ecx + je .L52 + cmpl $6, %ecx + je .L49 + cmpl $7, %ecx + je .L49 + cmpl $8, %ecx + je .L49 + cmpl $9, %ecx + je .L49 + leal -10(%ecx), %edx + cmpl $1, %edx + ja .L22 + movl -48(%ebp), %eax +#APP + movl -44(%ebp),%edx +.L33: + .p2align 2,,3 +#NO_APP +.L43: + movl -56(%ebp), %ecx +.L3: + andl $512, %ecx + je .L1 +#APP + movl 0(%ebp),%ecx +#NO_APP + movl -40(%ebp), %esp +#APP + jmp *%ecx +#NO_APP +.L1: + leal -8(%ebp), %esp + popl %ebx + popl %esi + leave + ret +.L22: + cmpl $12, %ecx + je .L53 + cmpl $13, %ecx + je .L54 + cmpl $14, %ecx + je .L49 + cmpl $15, %ecx + jne .L43 + movl -56(%ebp), %ecx + testl $1024, %ecx + movl %ecx, %esi + je .L31 + movl -28(%ebp), %edx + cmpl $1, %edx + je .L55 + cmpl $2, %edx + je .L56 + cmpl $4, %edx + je .L57 + cmpl $8, %edx + je .L58 +.L31: + andl $16, %esi + movl -36(%ebp), %eax + jne .L3 +#APP + leal -4(%ebp), %esp + popl %esi + leave + ret $4 +#NO_APP + jmp .L3 +.L58: + movl -36(%ebp), %edx + movl (%edx), %eax +#APP + movl 4(%edx),%edx +#NO_APP + jmp .L3 +.L57: + movl -36(%ebp), %edx + movl (%edx), %eax + jmp .L3 +.L56: + movl -36(%ebp), %edx + movzwl (%edx), %eax + jmp .L3 +.L55: + movl -36(%ebp), %edx + movzbl (%edx), %eax + jmp .L3 + .p2align 2,,3 +.L49: + movl -48(%ebp), %eax + jmp .L43 +.L54: +#APP + fldl -48(%ebp) +#NO_APP + jmp .L43 +.L53: +#APP + flds -48(%ebp) +#NO_APP + jmp .L43 + .p2align 2,,3 +.L52: + movzwl -48(%ebp), %eax + jmp .L43 +.L51: + movswl -48(%ebp),%eax + jmp .L43 +.L50: + movzbl -48(%ebp), %eax + jmp .L43 + .p2align 2,,3 +.L45: + movsbl -48(%ebp),%eax + jmp .L43 +.Lfe1: + .size vacall_receiver,.Lfe1-vacall_receiver + .ident "GCC: (GNU) 3.1" diff --git a/vacall/vacall-i386-linux.s b/vacall/vacall-i386-linux.s new file mode 100644 index 0000000..d8c714e --- /dev/null +++ b/vacall/vacall-i386-linux.s @@ -0,0 +1,150 @@ + .file "vacall-i386.c" + .text + .align 2 + .p2align 2,,3 +.globl vacall_receiver + .type vacall_receiver,@function +vacall_receiver: + pushl %ebp + movl %esp, %ebp + leal 8(%ebp), %edx + pushl %esi + subl $64, %esp + movl %edx, -40(%ebp) + leal -56(%ebp), %edx + movl $0, -56(%ebp) + movl $0, -36(%ebp) + movl $0, -32(%ebp) + movl %ebx, -24(%ebp) + pushl %edx + call *vacall_function + movl -32(%ebp), %ecx + addl $16, %esp + testl %ecx, %ecx + je .L43 + cmpl $1, %ecx + je .L44 + cmpl $2, %ecx + je .L44 + cmpl $3, %ecx + je .L49 + cmpl $4, %ecx + je .L50 + cmpl $5, %ecx + je .L51 + cmpl $6, %ecx + je .L48 + cmpl $7, %ecx + je .L48 + cmpl $8, %ecx + je .L48 + cmpl $9, %ecx + je .L48 + leal -10(%ecx), %edx + cmpl $1, %edx + ja .L22 + movl -48(%ebp), %eax +#APP + movl -44(%ebp),%edx +.L33: + .p2align 2,,3 +#NO_APP +.L43: + movl -56(%ebp), %ecx +.L3: + andl $512, %ecx + je .L1 +#APP + movl 0(%ebp),%ecx +#NO_APP + movl -40(%ebp), %esp +#APP + jmp *%ecx +#NO_APP +.L1: + movl -4(%ebp), %esi + leave + ret +.L22: + cmpl $12, %ecx + je .L52 + cmpl $13, %ecx + je .L53 + cmpl $14, %ecx + je .L48 + cmpl $15, %ecx + jne .L43 + movl -56(%ebp), %ecx + testl $1024, %ecx + movl %ecx, %esi + je .L31 + movl -28(%ebp), %edx + cmpl $1, %edx + je .L54 + cmpl $2, %edx + je .L55 + cmpl $4, %edx + je .L56 + cmpl $8, %edx + je .L57 +.L31: + andl $16, %esi + movl -36(%ebp), %eax + jne .L3 +#APP + leal -4(%ebp), %esp + popl %esi + leave + ret $4 +#NO_APP + jmp .L3 +.L57: + movl -36(%ebp), %edx + movl (%edx), %eax +#APP + movl 4(%edx),%edx +#NO_APP + jmp .L3 +.L56: + movl -36(%ebp), %edx + movl (%edx), %eax + jmp .L3 +.L55: + movl -36(%ebp), %edx + movzwl (%edx), %eax + jmp .L3 +.L54: + movl -36(%ebp), %edx + movzbl (%edx), %eax + jmp .L3 + .p2align 2,,3 +.L48: + movl -48(%ebp), %eax + jmp .L43 +.L53: +#APP + fldl -48(%ebp) +#NO_APP + jmp .L43 +.L52: +#APP + flds -48(%ebp) +#NO_APP + jmp .L43 + .p2align 2,,3 +.L51: + movzwl -48(%ebp), %eax + jmp .L43 +.L50: + movswl -48(%ebp),%eax + jmp .L43 +.L49: + movzbl -48(%ebp), %eax + jmp .L43 + .p2align 2,,3 +.L44: + movsbl -48(%ebp),%eax + jmp .L43 +.Lfe1: + .size vacall_receiver,.Lfe1-vacall_receiver + .ident "GCC: (GNU) 3.1" diff --git a/vacall/vacall-i386-macro.S b/vacall/vacall-i386-macro.S new file mode 100644 index 0000000..c352c94 --- /dev/null +++ b/vacall/vacall-i386-macro.S @@ -0,0 +1,288 @@ +#include "asm-i386.h" +#ifdef __PIC__ + TEXT() + ALIGN(2) + P2ALIGN(2,3) +GLOBL(C(vacall_receiver)) + DECLARE_FUNCTION(vacall_receiver) +FUNBEGIN(vacall_receiver) + INSN1(push,l ,R(ebp)) + INSN2(mov,l ,R(esp), R(ebp)) + INSN1(push,l ,R(esi)) + INSN1(push,l ,R(ebx)) + INSN2(sub,l ,NUM(48), R(esp)) + INSN1(call,_ ,L(44)) +L(44): + INSN1(pop,l ,R(ebx)) +#ifdef __ELF__ + INSN2(add,l ,NUM()_GLOBAL_OFFSET_TABLE_+[.-L(44)],R(ebx)) +#endif + INSN2(lea,l ,X4 MEM_DISP(ebp,8), R(edx)) + INSN2(mov,l ,R(edx),X4 MEM_DISP(ebp,-40)) + INSN2(sub,l ,NUM(12), R(esp)) + INSN2(lea,l ,X4 MEM_DISP(ebp,-56), R(edx)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(ebp,-56)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(ebp,-36)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(ebp,-32)) + INSN2(mov,l ,R(ebx),X4 MEM_DISP(ebp,-24)) + INSN1(push,l ,R(edx)) + INSN2(mov,l ,C(vacall_function)@MEM_DISP(ebx,GOT), R(edx)) + INSN1(call,_ ,INDIR(X4 MEM(edx))) + INSN2(mov,l ,X4 MEM_DISP(ebp,-32), R(ecx)) + INSN2(add,l ,NUM(16), R(esp)) + INSN2(test,l ,R(ecx), R(ecx)) + INSN1(je,_ ,L(43)) + INSN2(cmp,l ,NUM(1), R(ecx)) + INSN1(je,_ ,L(45)) + INSN2(cmp,l ,NUM(2), R(ecx)) + INSN1(je,_ ,L(45)) + INSN2(cmp,l ,NUM(3), R(ecx)) + INSN1(je,_ ,L(50)) + INSN2(cmp,l ,NUM(4), R(ecx)) + INSN1(je,_ ,L(51)) + INSN2(cmp,l ,NUM(5), R(ecx)) + INSN1(je,_ ,L(52)) + INSN2(cmp,l ,NUM(6), R(ecx)) + INSN1(je,_ ,L(49)) + INSN2(cmp,l ,NUM(7), R(ecx)) + INSN1(je,_ ,L(49)) + INSN2(cmp,l ,NUM(8), R(ecx)) + INSN1(je,_ ,L(49)) + INSN2(cmp,l ,NUM(9), R(ecx)) + INSN1(je,_ ,L(49)) + INSN2(lea,l ,X4 MEM_DISP(ecx,-10), R(edx)) + INSN2(cmp,l ,NUM(1), R(edx)) + INSN1(ja,_ ,L(22)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-48), R(eax)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-44),R(edx)) +L(33): + P2ALIGN(2,3) +L(43): + INSN2(mov,l ,X4 MEM_DISP(ebp,-56), R(ecx)) +L(3): + INSN2(and,l ,NUM(512), R(ecx)) + INSN1(je,_ ,L(1)) + INSN2(mov,l ,X4 MEM_DISP(ebp,0),R(ecx)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-40), R(esp)) + INSN1(jmp,_ ,INDIR(R(ecx))) +L(1): + INSN2(lea,l ,X4 MEM_DISP(ebp,-8), R(esp)) + INSN1(pop,l ,R(ebx)) + INSN1(pop,l ,R(esi)) + leave + ret +L(22): + INSN2(cmp,l ,NUM(12), R(ecx)) + INSN1(je,_ ,L(53)) + INSN2(cmp,l ,NUM(13), R(ecx)) + INSN1(je,_ ,L(54)) + INSN2(cmp,l ,NUM(14), R(ecx)) + INSN1(je,_ ,L(49)) + INSN2(cmp,l ,NUM(15), R(ecx)) + INSN1(jne,_ ,L(43)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-56), R(ecx)) + INSN2(test,l ,NUM(1024), R(ecx)) + INSN2(mov,l ,R(ecx), R(esi)) + INSN1(je,_ ,L(31)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-28), R(edx)) + INSN2(cmp,l ,NUM(1), R(edx)) + INSN1(je,_ ,L(55)) + INSN2(cmp,l ,NUM(2), R(edx)) + INSN1(je,_ ,L(56)) + INSN2(cmp,l ,NUM(4), R(edx)) + INSN1(je,_ ,L(57)) + INSN2(cmp,l ,NUM(8), R(edx)) + INSN1(je,_ ,L(58)) +L(31): + INSN2(and,l ,NUM(16), R(esi)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(eax)) + INSN1(jne,_ ,L(3)) + INSN2(lea,l ,X4 MEM_DISP(ebp,-4), R(esp)) + INSN1(pop,l ,R(esi)) + leave + ret NUM(4) + INSN1(jmp,_ ,L(3)) +L(58): + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(edx)) + INSN2(mov,l ,X4 MEM(edx), R(eax)) + INSN2(mov,l ,X4 MEM_DISP(edx,4),R(edx)) + INSN1(jmp,_ ,L(3)) +L(57): + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(edx)) + INSN2(mov,l ,X4 MEM(edx), R(eax)) + INSN1(jmp,_ ,L(3)) +L(56): + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(edx)) + INSN2MOVXL(movz,w,X2 MEM(edx), R(eax)) + INSN1(jmp,_ ,L(3)) +L(55): + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(edx)) + INSN2MOVXL(movz,b,X1 MEM(edx), R(eax)) + INSN1(jmp,_ ,L(3)) + P2ALIGN(2,3) +L(49): + INSN2(mov,l ,X4 MEM_DISP(ebp,-48), R(eax)) + INSN1(jmp,_ ,L(43)) +L(54): + INSN1(fld,l ,X8 MEM_DISP(ebp,-48)) + INSN1(jmp,_ ,L(43)) +L(53): + INSN1(fld,s ,X4 MEM_DISP(ebp,-48)) + INSN1(jmp,_ ,L(43)) + P2ALIGN(2,3) +L(52): + INSN2MOVXL(movz,w,X2 MEM_DISP(ebp,-48), R(eax)) + INSN1(jmp,_ ,L(43)) +L(51): + INSN2MOVXL(movs,w,X2 MEM_DISP(ebp,-48),R(eax)) + INSN1(jmp,_ ,L(43)) +L(50): + INSN2MOVXL(movz,b,X1 MEM_DISP(ebp,-48), R(eax)) + INSN1(jmp,_ ,L(43)) + P2ALIGN(2,3) +L(45): + INSN2MOVXL(movs,b,X1 MEM_DISP(ebp,-48),R(eax)) + INSN1(jmp,_ ,L(43)) +L(fe1): + FUNEND(vacall_receiver,L(fe1)-vacall_receiver) + +#else + TEXT() + ALIGN(2) + P2ALIGN(2,3) +GLOBL(C(vacall_receiver)) + DECLARE_FUNCTION(vacall_receiver) +FUNBEGIN(vacall_receiver) + INSN1(push,l ,R(ebp)) + INSN2(mov,l ,R(esp), R(ebp)) + INSN2(lea,l ,X4 MEM_DISP(ebp,8), R(edx)) + INSN1(push,l ,R(esi)) + INSN2(sub,l ,NUM(64), R(esp)) + INSN2(mov,l ,R(edx),X4 MEM_DISP(ebp,-40)) + INSN2(lea,l ,X4 MEM_DISP(ebp,-56), R(edx)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(ebp,-56)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(ebp,-36)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(ebp,-32)) + INSN2(mov,l ,R(ebx),X4 MEM_DISP(ebp,-24)) + INSN1(push,l ,R(edx)) + INSN1(call,_ ,INDIR(X4 C(vacall_function))) + INSN2(mov,l ,X4 MEM_DISP(ebp,-32), R(ecx)) + INSN2(add,l ,NUM(16), R(esp)) + INSN2(test,l ,R(ecx), R(ecx)) + INSN1(je,_ ,L(43)) + INSN2(cmp,l ,NUM(1), R(ecx)) + INSN1(je,_ ,L(44)) + INSN2(cmp,l ,NUM(2), R(ecx)) + INSN1(je,_ ,L(44)) + INSN2(cmp,l ,NUM(3), R(ecx)) + INSN1(je,_ ,L(49)) + INSN2(cmp,l ,NUM(4), R(ecx)) + INSN1(je,_ ,L(50)) + INSN2(cmp,l ,NUM(5), R(ecx)) + INSN1(je,_ ,L(51)) + INSN2(cmp,l ,NUM(6), R(ecx)) + INSN1(je,_ ,L(48)) + INSN2(cmp,l ,NUM(7), R(ecx)) + INSN1(je,_ ,L(48)) + INSN2(cmp,l ,NUM(8), R(ecx)) + INSN1(je,_ ,L(48)) + INSN2(cmp,l ,NUM(9), R(ecx)) + INSN1(je,_ ,L(48)) + INSN2(lea,l ,X4 MEM_DISP(ecx,-10), R(edx)) + INSN2(cmp,l ,NUM(1), R(edx)) + INSN1(ja,_ ,L(22)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-48), R(eax)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-44),R(edx)) +L(33): + P2ALIGN(2,3) +L(43): + INSN2(mov,l ,X4 MEM_DISP(ebp,-56), R(ecx)) +L(3): + INSN2(and,l ,NUM(512), R(ecx)) + INSN1(je,_ ,L(1)) + INSN2(mov,l ,X4 MEM_DISP(ebp,0),R(ecx)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-40), R(esp)) + INSN1(jmp,_ ,INDIR(R(ecx))) +L(1): + INSN2(mov,l ,X4 MEM_DISP(ebp,-4), R(esi)) + leave + ret +L(22): + INSN2(cmp,l ,NUM(12), R(ecx)) + INSN1(je,_ ,L(52)) + INSN2(cmp,l ,NUM(13), R(ecx)) + INSN1(je,_ ,L(53)) + INSN2(cmp,l ,NUM(14), R(ecx)) + INSN1(je,_ ,L(48)) + INSN2(cmp,l ,NUM(15), R(ecx)) + INSN1(jne,_ ,L(43)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-56), R(ecx)) + INSN2(test,l ,NUM(1024), R(ecx)) + INSN2(mov,l ,R(ecx), R(esi)) + INSN1(je,_ ,L(31)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-28), R(edx)) + INSN2(cmp,l ,NUM(1), R(edx)) + INSN1(je,_ ,L(54)) + INSN2(cmp,l ,NUM(2), R(edx)) + INSN1(je,_ ,L(55)) + INSN2(cmp,l ,NUM(4), R(edx)) + INSN1(je,_ ,L(56)) + INSN2(cmp,l ,NUM(8), R(edx)) + INSN1(je,_ ,L(57)) +L(31): + INSN2(and,l ,NUM(16), R(esi)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(eax)) + INSN1(jne,_ ,L(3)) + INSN2(lea,l ,X4 MEM_DISP(ebp,-4), R(esp)) + INSN1(pop,l ,R(esi)) + leave + ret NUM(4) + INSN1(jmp,_ ,L(3)) +L(57): + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(edx)) + INSN2(mov,l ,X4 MEM(edx), R(eax)) + INSN2(mov,l ,X4 MEM_DISP(edx,4),R(edx)) + INSN1(jmp,_ ,L(3)) +L(56): + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(edx)) + INSN2(mov,l ,X4 MEM(edx), R(eax)) + INSN1(jmp,_ ,L(3)) +L(55): + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(edx)) + INSN2MOVXL(movz,w,X2 MEM(edx), R(eax)) + INSN1(jmp,_ ,L(3)) +L(54): + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(edx)) + INSN2MOVXL(movz,b,X1 MEM(edx), R(eax)) + INSN1(jmp,_ ,L(3)) + P2ALIGN(2,3) +L(48): + INSN2(mov,l ,X4 MEM_DISP(ebp,-48), R(eax)) + INSN1(jmp,_ ,L(43)) +L(53): + INSN1(fld,l ,X8 MEM_DISP(ebp,-48)) + INSN1(jmp,_ ,L(43)) +L(52): + INSN1(fld,s ,X4 MEM_DISP(ebp,-48)) + INSN1(jmp,_ ,L(43)) + P2ALIGN(2,3) +L(51): + INSN2MOVXL(movz,w,X2 MEM_DISP(ebp,-48), R(eax)) + INSN1(jmp,_ ,L(43)) +L(50): + INSN2MOVXL(movs,w,X2 MEM_DISP(ebp,-48),R(eax)) + INSN1(jmp,_ ,L(43)) +L(49): + INSN2MOVXL(movz,b,X1 MEM_DISP(ebp,-48), R(eax)) + INSN1(jmp,_ ,L(43)) + P2ALIGN(2,3) +L(44): + INSN2MOVXL(movs,b,X1 MEM_DISP(ebp,-48),R(eax)) + INSN1(jmp,_ ,L(43)) +L(fe1): + FUNEND(vacall_receiver,L(fe1)-vacall_receiver) + +#endif +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/vacall/vacall-i386-msvc.c b/vacall/vacall-i386-msvc.c new file mode 100644 index 0000000..170067e --- /dev/null +++ b/vacall/vacall-i386-msvc.c @@ -0,0 +1,291 @@ +#ifdef _MSC_VER +#include "vacall.h" +#endif +#include "asm-i386.h" +#ifdef __PIC__ + TEXT() + ALIGN(2) + P2ALIGN(2,3) +GLOBL(C(vacall_receiver)) + DECLARE_FUNCTION(vacall_receiver) +FUNBEGIN(vacall_receiver) + INSN1(push,l ,R(ebp)) + INSN2(mov,l ,R(esp), R(ebp)) + INSN1(push,l ,R(esi)) + INSN1(push,l ,R(ebx)) + INSN2(sub,l ,NUM(48), R(esp)) + INSN1(call,_ ,L(44)) +L(44): + INSN1(pop,l ,R(ebx)) +#ifdef __ELF__ + INSN2(add,l ,NUM()_GLOBAL_OFFSET_TABLE_+[.-L(44)],R(ebx)) +#endif + INSN2(lea,l ,X4 MEM_DISP(ebp,8), R(edx)) + INSN2(mov,l ,R(edx),X4 MEM_DISP(ebp,-40)) + INSN2(sub,l ,NUM(12), R(esp)) + INSN2(lea,l ,X4 MEM_DISP(ebp,-56), R(edx)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(ebp,-56)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(ebp,-36)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(ebp,-32)) + INSN2(mov,l ,R(ebx),X4 MEM_DISP(ebp,-24)) + INSN1(push,l ,R(edx)) + INSN2(mov,l ,C(vacall_function)@MEM_DISP(ebx,GOT), R(edx)) + INSN1(call,_ ,INDIR(X4 MEM(edx))) + INSN2(mov,l ,X4 MEM_DISP(ebp,-32), R(ecx)) + INSN2(add,l ,NUM(16), R(esp)) + INSN2(test,l ,R(ecx), R(ecx)) + INSN1(je,_ ,L(43)) + INSN2(cmp,l ,NUM(1), R(ecx)) + INSN1(je,_ ,L(45)) + INSN2(cmp,l ,NUM(2), R(ecx)) + INSN1(je,_ ,L(45)) + INSN2(cmp,l ,NUM(3), R(ecx)) + INSN1(je,_ ,L(50)) + INSN2(cmp,l ,NUM(4), R(ecx)) + INSN1(je,_ ,L(51)) + INSN2(cmp,l ,NUM(5), R(ecx)) + INSN1(je,_ ,L(52)) + INSN2(cmp,l ,NUM(6), R(ecx)) + INSN1(je,_ ,L(49)) + INSN2(cmp,l ,NUM(7), R(ecx)) + INSN1(je,_ ,L(49)) + INSN2(cmp,l ,NUM(8), R(ecx)) + INSN1(je,_ ,L(49)) + INSN2(cmp,l ,NUM(9), R(ecx)) + INSN1(je,_ ,L(49)) + INSN2(lea,l ,X4 MEM_DISP(ecx,-10), R(edx)) + INSN2(cmp,l ,NUM(1), R(edx)) + INSN1(ja,_ ,L(22)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-48), R(eax)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-44),R(edx)) +L(33): + P2ALIGN(2,3) +L(43): + INSN2(mov,l ,X4 MEM_DISP(ebp,-56), R(ecx)) +L(3): + INSN2(and,l ,NUM(512), R(ecx)) + INSN1(je,_ ,L(1)) + INSN2(mov,l ,X4 MEM_DISP(ebp,0),R(ecx)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-40), R(esp)) + INSN1(jmp,_ ,INDIR(R(ecx))) +L(1): + INSN2(lea,l ,X4 MEM_DISP(ebp,-8), R(esp)) + INSN1(pop,l ,R(ebx)) + INSN1(pop,l ,R(esi)) + leave + ret +L(22): + INSN2(cmp,l ,NUM(12), R(ecx)) + INSN1(je,_ ,L(53)) + INSN2(cmp,l ,NUM(13), R(ecx)) + INSN1(je,_ ,L(54)) + INSN2(cmp,l ,NUM(14), R(ecx)) + INSN1(je,_ ,L(49)) + INSN2(cmp,l ,NUM(15), R(ecx)) + INSN1(jne,_ ,L(43)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-56), R(ecx)) + INSN2(test,l ,NUM(1024), R(ecx)) + INSN2(mov,l ,R(ecx), R(esi)) + INSN1(je,_ ,L(31)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-28), R(edx)) + INSN2(cmp,l ,NUM(1), R(edx)) + INSN1(je,_ ,L(55)) + INSN2(cmp,l ,NUM(2), R(edx)) + INSN1(je,_ ,L(56)) + INSN2(cmp,l ,NUM(4), R(edx)) + INSN1(je,_ ,L(57)) + INSN2(cmp,l ,NUM(8), R(edx)) + INSN1(je,_ ,L(58)) +L(31): + INSN2(and,l ,NUM(16), R(esi)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(eax)) + INSN1(jne,_ ,L(3)) + INSN2(lea,l ,X4 MEM_DISP(ebp,-4), R(esp)) + INSN1(pop,l ,R(esi)) + leave + ret NUM(4) + INSN1(jmp,_ ,L(3)) +L(58): + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(edx)) + INSN2(mov,l ,X4 MEM(edx), R(eax)) + INSN2(mov,l ,X4 MEM_DISP(edx,4),R(edx)) + INSN1(jmp,_ ,L(3)) +L(57): + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(edx)) + INSN2(mov,l ,X4 MEM(edx), R(eax)) + INSN1(jmp,_ ,L(3)) +L(56): + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(edx)) + INSN2MOVXL(movz,w,X2 MEM(edx), R(eax)) + INSN1(jmp,_ ,L(3)) +L(55): + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(edx)) + INSN2MOVXL(movz,b,X1 MEM(edx), R(eax)) + INSN1(jmp,_ ,L(3)) + P2ALIGN(2,3) +L(49): + INSN2(mov,l ,X4 MEM_DISP(ebp,-48), R(eax)) + INSN1(jmp,_ ,L(43)) +L(54): + INSN1(fld,l ,X8 MEM_DISP(ebp,-48)) + INSN1(jmp,_ ,L(43)) +L(53): + INSN1(fld,s ,X4 MEM_DISP(ebp,-48)) + INSN1(jmp,_ ,L(43)) + P2ALIGN(2,3) +L(52): + INSN2MOVXL(movz,w,X2 MEM_DISP(ebp,-48), R(eax)) + INSN1(jmp,_ ,L(43)) +L(51): + INSN2MOVXL(movs,w,X2 MEM_DISP(ebp,-48),R(eax)) + INSN1(jmp,_ ,L(43)) +L(50): + INSN2MOVXL(movz,b,X1 MEM_DISP(ebp,-48), R(eax)) + INSN1(jmp,_ ,L(43)) + P2ALIGN(2,3) +L(45): + INSN2MOVXL(movs,b,X1 MEM_DISP(ebp,-48),R(eax)) + INSN1(jmp,_ ,L(43)) +L(fe1): + FUNEND(vacall_receiver,L(fe1)-vacall_receiver) + +#else + TEXT() + ALIGN(2) + P2ALIGN(2,3) +GLOBL(C(vacall_receiver)) + DECLARE_FUNCTION(vacall_receiver) +FUNBEGIN(vacall_receiver) + INSN1(push,l ,R(ebp)) + INSN2(mov,l ,R(esp), R(ebp)) + INSN2(lea,l ,X4 MEM_DISP(ebp,8), R(edx)) + INSN1(push,l ,R(esi)) + INSN2(sub,l ,NUM(64), R(esp)) + INSN2(mov,l ,R(edx),X4 MEM_DISP(ebp,-40)) + INSN2(lea,l ,X4 MEM_DISP(ebp,-56), R(edx)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(ebp,-56)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(ebp,-36)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(ebp,-32)) + INSN2(mov,l ,R(ebx),X4 MEM_DISP(ebp,-24)) + INSN1(push,l ,R(edx)) + INSN1(call,_ ,INDIR(X4 C(vacall_function))) + INSN2(mov,l ,X4 MEM_DISP(ebp,-32), R(ecx)) + INSN2(add,l ,NUM(16), R(esp)) + INSN2(test,l ,R(ecx), R(ecx)) + INSN1(je,_ ,L(43)) + INSN2(cmp,l ,NUM(1), R(ecx)) + INSN1(je,_ ,L(44)) + INSN2(cmp,l ,NUM(2), R(ecx)) + INSN1(je,_ ,L(44)) + INSN2(cmp,l ,NUM(3), R(ecx)) + INSN1(je,_ ,L(49)) + INSN2(cmp,l ,NUM(4), R(ecx)) + INSN1(je,_ ,L(50)) + INSN2(cmp,l ,NUM(5), R(ecx)) + INSN1(je,_ ,L(51)) + INSN2(cmp,l ,NUM(6), R(ecx)) + INSN1(je,_ ,L(48)) + INSN2(cmp,l ,NUM(7), R(ecx)) + INSN1(je,_ ,L(48)) + INSN2(cmp,l ,NUM(8), R(ecx)) + INSN1(je,_ ,L(48)) + INSN2(cmp,l ,NUM(9), R(ecx)) + INSN1(je,_ ,L(48)) + INSN2(lea,l ,X4 MEM_DISP(ecx,-10), R(edx)) + INSN2(cmp,l ,NUM(1), R(edx)) + INSN1(ja,_ ,L(22)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-48), R(eax)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-44),R(edx)) +L(33): + P2ALIGN(2,3) +L(43): + INSN2(mov,l ,X4 MEM_DISP(ebp,-56), R(ecx)) +L(3): + INSN2(and,l ,NUM(512), R(ecx)) + INSN1(je,_ ,L(1)) + INSN2(mov,l ,X4 MEM_DISP(ebp,0),R(ecx)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-40), R(esp)) + INSN1(jmp,_ ,INDIR(R(ecx))) +L(1): + INSN2(mov,l ,X4 MEM_DISP(ebp,-4), R(esi)) + leave + ret +L(22): + INSN2(cmp,l ,NUM(12), R(ecx)) + INSN1(je,_ ,L(52)) + INSN2(cmp,l ,NUM(13), R(ecx)) + INSN1(je,_ ,L(53)) + INSN2(cmp,l ,NUM(14), R(ecx)) + INSN1(je,_ ,L(48)) + INSN2(cmp,l ,NUM(15), R(ecx)) + INSN1(jne,_ ,L(43)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-56), R(ecx)) + INSN2(test,l ,NUM(1024), R(ecx)) + INSN2(mov,l ,R(ecx), R(esi)) + INSN1(je,_ ,L(31)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-28), R(edx)) + INSN2(cmp,l ,NUM(1), R(edx)) + INSN1(je,_ ,L(54)) + INSN2(cmp,l ,NUM(2), R(edx)) + INSN1(je,_ ,L(55)) + INSN2(cmp,l ,NUM(4), R(edx)) + INSN1(je,_ ,L(56)) + INSN2(cmp,l ,NUM(8), R(edx)) + INSN1(je,_ ,L(57)) +L(31): + INSN2(and,l ,NUM(16), R(esi)) + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(eax)) + INSN1(jne,_ ,L(3)) + INSN2(lea,l ,X4 MEM_DISP(ebp,-4), R(esp)) + INSN1(pop,l ,R(esi)) + leave + ret NUM(4) + INSN1(jmp,_ ,L(3)) +L(57): + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(edx)) + INSN2(mov,l ,X4 MEM(edx), R(eax)) + INSN2(mov,l ,X4 MEM_DISP(edx,4),R(edx)) + INSN1(jmp,_ ,L(3)) +L(56): + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(edx)) + INSN2(mov,l ,X4 MEM(edx), R(eax)) + INSN1(jmp,_ ,L(3)) +L(55): + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(edx)) + INSN2MOVXL(movz,w,X2 MEM(edx), R(eax)) + INSN1(jmp,_ ,L(3)) +L(54): + INSN2(mov,l ,X4 MEM_DISP(ebp,-36), R(edx)) + INSN2MOVXL(movz,b,X1 MEM(edx), R(eax)) + INSN1(jmp,_ ,L(3)) + P2ALIGN(2,3) +L(48): + INSN2(mov,l ,X4 MEM_DISP(ebp,-48), R(eax)) + INSN1(jmp,_ ,L(43)) +L(53): + INSN1(fld,l ,X8 MEM_DISP(ebp,-48)) + INSN1(jmp,_ ,L(43)) +L(52): + INSN1(fld,s ,X4 MEM_DISP(ebp,-48)) + INSN1(jmp,_ ,L(43)) + P2ALIGN(2,3) +L(51): + INSN2MOVXL(movz,w,X2 MEM_DISP(ebp,-48), R(eax)) + INSN1(jmp,_ ,L(43)) +L(50): + INSN2MOVXL(movs,w,X2 MEM_DISP(ebp,-48),R(eax)) + INSN1(jmp,_ ,L(43)) +L(49): + INSN2MOVXL(movz,b,X1 MEM_DISP(ebp,-48), R(eax)) + INSN1(jmp,_ ,L(43)) + P2ALIGN(2,3) +L(44): + INSN2MOVXL(movs,b,X1 MEM_DISP(ebp,-48),R(eax)) + INSN1(jmp,_ ,L(43)) +L(fe1): + FUNEND(vacall_receiver,L(fe1)-vacall_receiver) + +#endif +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/vacall/vacall-i386.c b/vacall/vacall-i386.c new file mode 100644 index 0000000..5666a27 --- /dev/null +++ b/vacall/vacall-i386.c @@ -0,0 +1,163 @@ +/* vacall function for i386 CPU */ + +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +#include "vacall-internal.h" + +#ifdef REENTRANT +#define vacall_receiver callback_receiver +typedef struct { void (*vacall_function) (void*,va_alist); void* arg; } env_t; +register env_t* env __asm__("%ecx"); +#endif +register void* sp __asm__("%esp"); +register void* sret __asm__("%ebx"); +register int iret __asm__("%eax"); + +#ifdef REENTRANT +static +#endif +void /* the return type is variable, not void! */ +vacall_receiver (__vaword firstword) +{ + __va_alist list; + /* Prepare the va_alist. */ + list.flags = 0; + list.aptr = (long)&firstword; + list.raddr = (void*)0; + list.rtype = __VAvoid; + list.structraddr = sret; + /* Call vacall_function. The macros do all the rest. */ +#ifndef REENTRANT + (*vacall_function) (&list); +#else /* REENTRANT */ + (*env->vacall_function) (env->arg,&list); +#endif + /* Put return value into proper register. */ + if (list.rtype == __VAvoid) { + } else + if (list.rtype == __VAchar) { + iret = list.tmp._char; + } else + if (list.rtype == __VAschar) { + iret = list.tmp._schar; + } else + if (list.rtype == __VAuchar) { + iret = list.tmp._uchar; + } else + if (list.rtype == __VAshort) { + iret = list.tmp._short; + } else + if (list.rtype == __VAushort) { + iret = list.tmp._ushort; + } else + if (list.rtype == __VAint) { + iret = list.tmp._int; + } else + if (list.rtype == __VAuint) { + iret = list.tmp._uint; + } else + if (list.rtype == __VAlong) { + iret = list.tmp._long; + } else + if (list.rtype == __VAulong) { + iret = list.tmp._ulong; + } else + if (list.rtype == __VAlonglong || list.rtype == __VAulonglong) { + /* This code is EXTREMELY fragile!! */ + /* It depends on the register allocation chosen by gcc. */ + iret = ((__vaword *) &list.tmp._longlong)[0]; + asm volatile ("movl %0,%%edx" : : "g"(((__vaword *) &list.tmp._longlong)[1])); + } else + if (list.rtype == __VAfloat) { + asm volatile ("flds %0": : "m"(list.tmp._float)); + } else + if (list.rtype == __VAdouble) { + asm volatile ("fldl %0": : "m"(list.tmp._double)); + } else + if (list.rtype == __VAvoidp) { + iret = (long)list.tmp._ptr; + } else + if (list.rtype == __VAstruct) { + if (list.flags & __VA_REGISTER_STRUCT_RETURN) { + if (list.rsize == sizeof(char)) { + iret = *(unsigned char *) list.raddr; + goto done; + } else + if (list.rsize == sizeof(short)) { + iret = *(unsigned short *) list.raddr; + goto done; + } else + if (list.rsize == sizeof(int)) { + iret = *(unsigned int *) list.raddr; + goto done; + } else + if (list.rsize == 2*sizeof(__vaword)) { + /* This code is EXTREMELY fragile!! */ + /* It depends on the register allocation chosen by gcc. */ + iret = ((__vaword *) list.raddr)[0]; + asm volatile ("movl %0,%%edx" : : "g"(((__vaword *) list.raddr)[1])); + goto done; + } + } + /* On MSVC and on FreeBSD, must put the structure address into %eax. + For the other platforms, it does not matter, but doesn't hurt either. */ + iret = (long) list.raddr; + if (!(list.flags & __VA_MSVC_STRUCT_RETURN)) { + /* We have to pop the struct return address off the stack. */ + /* Callers compiled with -fomit-frame-pointer expect this. */ + /* Return via a "ret $4" instruction. */ + /* NOTE: This is EXTREMELY fragile. We must use the same return sequence + * as the one generated by GCC, except that we use a "ret $4" instruction + * in place of the "ret" instruction. Look at the 'pushl' instructions + * at the beginning of the generated code and at the sequence of + * instructions right before the generated "ret" instruction. */ +#ifdef REENTRANT + asm volatile ("leal -8(%ebp), %esp"); + asm volatile ("popl %esi"); + asm volatile ("popl %edi"); + asm volatile ("leave"); +#else + asm volatile ("leal -4(%ebp), %esp"); + asm volatile ("popl %esi"); + asm volatile ("leave"); +#endif + asm volatile ("ret $4"); + /*NOTREACHED*/ + } + done: ; + } + if (list.flags & __VA_STDCALL_CLEANUP) { + /* Return, and at the same time pop the arguments off the stack. */ + /* Normally done through a "ret $n" instruction. */ + /* Be careful not to clobber %eax and %edx. Only %ecx can be used. */ + /* Use *__builtin_frame_address(0), since __builtin_return_address(0) + * is buggy in gcc-2.7.2. */ + asm volatile ("movl %0,%%ecx" : : "g" (*(void**)__builtin_frame_address(0))); + sp = (void*)list.aptr; + asm volatile ("jmp *%ecx"); + /*NOTREACHED*/ + } +} + +#ifdef REENTRANT +__vacall_r_t +callback_get_receiver (void) +{ + return (__vacall_r_t)(void*)&callback_receiver; +} +#endif diff --git a/vacall/vacall-ia64-linux.s b/vacall/vacall-ia64-linux.s new file mode 100644 index 0000000..864463e --- /dev/null +++ b/vacall/vacall-ia64-linux.s @@ -0,0 +1,842 @@ + .file "vacall-ia64.c" + .pred.safe_across_calls p1-p5,p16-p63 + .text + .align 16 + .global vacall_receiver# + .proc vacall_receiver# +vacall_receiver: + .prologue 14, 41 + .spill 48 + .mmb + .save ar.pfs, r42 + alloc r42 = ar.pfs, 8, 5, 1, 0 + .vframe r43 + mov r43 = r12 + nop 0 + .mmi + adds r12 = -208, r12 + mov r44 = r1 + .save rp, r41 + mov r41 = b0 + .body + ;; + .mmi + adds r14 = -48, r43 + adds r16 = -48, r43 + adds r40 = -152, r43 + .mmb + adds r45 = -192, r43 + st8 [r43] = r38 + nop 0 + ;; + .mmi + nop 0 + st8 [r14] = r32, 8 + adds r32 = -160, r43 + .mmi + st4 [r40] = r0 + ;; + st8 [r14] = r33 + adds r14 = -32, r43 + .mmi + st4 [r45] = r0 + ;; + st8 [r14] = r34 + addl r14 = @ltoffx(vacall_function#), r1 + .mmb + nop 0 + st8 [r32] = r0 + nop 0 + ;; + .mmi + ld8.mov r14 = [r14], vacall_function# + ;; + ld8 r15 = [r14] + nop 0 + .mmi + adds r14 = -24, r43 + ;; + st8 [r14] = r35 + adds r14 = -16, r43 + ;; + .mfi + st8 [r14] = r36 + nop 0 + adds r14 = -8, r43 + .mmi + nop 0 + ;; + st8 [r14] = r37 + nop 0 + .mmi + adds r14 = 8, r43 + ;; + st8 [r14] = r39 + adds r14 = -112, r43 + ;; + .mfi + stfd [r14] = f8 + nop 0 + adds r14 = -104, r43 + .mmi + nop 0 + ;; + stfd [r14] = f9 + nop 0 + .mmi + adds r14 = -96, r43 + ;; + stfd [r14] = f10 + adds r14 = -88, r43 + ;; + .mfi + stfd [r14] = f11 + nop 0 + adds r14 = -80, r43 + .mmi + nop 0 + ;; + stfd [r14] = f12 + nop 0 + .mmi + adds r14 = -72, r43 + ;; + stfd [r14] = f13 + adds r14 = -64, r43 + ;; + .mfi + stfd [r14] = f14 + nop 0 + adds r14 = -56, r43 + .mmi + nop 0 + ;; + stfd [r14] = f15 + nop 0 + .mmi + adds r14 = -168, r43 + ;; + st8 [r14] = r16 + adds r14 = -128, r43 + ;; + .mii + st8 [r14] = r16 + adds r14 = -120, r43 + ;; + nop 0 + .mii + st4 [r14] = r0 + adds r14 = -136, r43 + ;; + nop 0 + .mmb + st8 [r14] = r8 + ld8 r14 = [r15], 8 + nop 0 + ;; + .mib + nop 0 + mov b6 = r14 + nop 0 + .mbb + ld8 r1 = [r15] + nop 0 + br.call.sptk.many b0 = b6 + ;; + .mmb + mov r1 = r44 + ld4 r40 = [r40] + nop 0 + ;; + .mfb + cmp4.eq p6, p7 = 0, r40 + nop 0 + (p6) br.cond.dpnt .L49 + ;; + .mfb + cmp4.ne p6, p7 = 1, r40 + nop 0 + (p7) br.cond.dpnt .L50 + ;; + .mfb + cmp4.ne p6, p7 = 2, r40 + nop 0 + (p7) br.cond.dpnt .L50 + ;; + .mii + nop 0 + cmp4.ne p6, p7 = 3, r40 + ;; + (p7) adds r14 = -184, r43 + ;; + .mfb + (p7) ld1 r8 = [r14] + nop 0 + (p7) br.cond.dpnt .L49 + .mii + nop 0 + cmp4.ne p6, p7 = 4, r40 + ;; + nop 0 + .mmi + (p7) adds r14 = -184, r43 + ;; + (p7) ld2 r14 = [r14] + nop 0 + ;; + .mib + nop 0 + (p7) sxt2 r8 = r14 + (p7) br.cond.dpnt .L49 + .mii + nop 0 + cmp4.ne p6, p7 = 5, r40 + ;; + (p7) adds r14 = -184, r43 + ;; + .mfb + (p7) ld2 r8 = [r14] + nop 0 + (p7) br.cond.dpnt .L49 + .mii + nop 0 + cmp4.ne p6, p7 = 6, r40 + ;; + nop 0 + .mmi + (p7) adds r14 = -184, r43 + ;; + (p7) ld4 r14 = [r14] + nop 0 + ;; + .mib + nop 0 + (p7) sxt4 r8 = r14 + (p7) br.cond.dpnt .L49 + .mii + nop 0 + cmp4.ne p6, p7 = 7, r40 + ;; + (p7) adds r14 = -184, r43 + ;; + .mfb + (p7) ld4 r8 = [r14] + nop 0 + (p7) br.cond.dpnt .L49 + .mfb + cmp4.ne p6, p7 = 8, r40 + nop 0 + (p7) br.cond.dpnt .L54 + ;; + .mfb + cmp4.ne p6, p7 = 9, r40 + nop 0 + (p7) br.cond.dpnt .L54 + ;; + .mfb + cmp4.ne p6, p7 = 10, r40 + nop 0 + (p7) br.cond.dpnt .L54 + ;; + .mfb + cmp4.ne p6, p7 = 11, r40 + nop 0 + (p7) br.cond.dpnt .L54 + ;; + .mii + nop 0 + cmp4.ne p6, p7 = 12, r40 + ;; + (p7) adds r14 = -184, r43 + ;; + .mfb + (p7) ldfs f8 = [r14] + nop 0 + (p7) br.cond.dpnt .L49 + .mii + nop 0 + cmp4.ne p6, p7 = 13, r40 + ;; + (p7) adds r14 = -184, r43 + ;; + .mfb + (p7) ldfd f8 = [r14] + nop 0 + (p7) br.cond.dpnt .L49 + .mfb + cmp4.ne p6, p7 = 14, r40 + nop 0 + (p7) br.cond.dpnt .L54 + ;; + .mib + nop 0 + cmp4.ne p6, p7 = 15, r40 + (p6) br.cond.dptk .L49 + .mii + nop 0 + adds r15 = -192, r43 + ;; + nop 0 + .mmi + ld4 r14 = [r15] + ;; + nop 0 + tbit.z p6, p7 = r14, 10 + .mfb + adds r14 = -144, r43 + nop 0 + (p6) br.cond.dpnt .L49 + ;; + .mmi + ld8 r21 = [r14] + ;; + adds r14 = -1, r21 + nop 0 + ;; + .mib + nop 0 + cmp.ltu p6, p7 = 31, r14 + (p6) br.cond.dpnt .L49 + .mmi + ld8 r14 = [r32] + ;; + and r20 = 7, r14 + and r23 = -8, r14 + .mii + nop 0 + cmp.ltu p6, p7 = 8, r21 + ;; + nop 0 + .mfb + add r14 = r21, r20 + nop 0 + (p6) br.cond.dptk .L35 + ;; + .mib + nop 0 + cmp.ltu p6, p7 = 8, r14 + (p6) br.cond.dptk .L37 + .mfi + shladd r15 = r14, 3, r0 + nop 0 + addl r14 = 2, r0 + .mii + ld8 r16 = [r23] + shladd r17 = r20, 3, r0 + ;; + adds r15 = -1, r15 + ;; + .mii + nop 0 + sxt4 r15 = r15 + ;; + shl r14 = r14, r15 + ;; + .mmi + adds r14 = -1, r14 + ;; + and r14 = r16, r14 + nop 0 + .mmi + nop 0 + ;; + nop 0 + shr r8 = r14, r17 +.L49: + .mii + nop 0 + mov ar.pfs = r42 + mov b0 = r41 + .mib + nop 0 + .label_state 1 + .restore sp + mov r12 = r43 + br.ret.sptk.many b0 +.L50: + .body + .copy_state 1 + .mii + nop 0 + adds r14 = -184, r43 + ;; + nop 0 + .mii + ld1 r14 = [r14] + nop 0 + ;; + sxt1 r8 = r14 + .mii + nop 0 + mov ar.pfs = r42 + mov b0 = r41 + .mib + nop 0 + .label_state 2 + .restore sp + mov r12 = r43 + br.ret.sptk.many b0 +.L54: + .body + .copy_state 2 + .mmb + nop 0 + adds r14 = -184, r43 + nop 0 + ;; + .mii + ld8 r8 = [r14] + mov ar.pfs = r42 + mov b0 = r41 + .mib + nop 0 + .label_state 3 + .restore sp + mov r12 = r43 + br.ret.sptk.many b0 +.L35: + .body + .copy_state 3 + .mib + nop 0 + cmp.ltu p6, p7 = 16, r21 + (p6) br.cond.dptk .L39 + ;; + .mib + nop 0 + cmp.ltu p6, p7 = 16, r14 + (p6) br.cond.dptk .L41 + .mmi + shladd r15 = r14, 3, r0 + adds r14 = 8, r23 + shladd r16 = r20, 2, r0 + .mmb + shladd r18 = r20, 3, r0 + ld8 r17 = [r23] + nop 0 + ;; + .mfi + ld8 r19 = [r14] + nop 0 + addl r14 = 2, r0 + .mii + adds r15 = -65, r15 + sub r16 = 32, r16 + ;; + sxt4 r15 = r15 + .mii + nop 0 + sxt4 r16 = r16 + shr r17 = r17, r18 + ;; + .mii + nop 0 + shl r14 = r14, r15 + ;; + adds r14 = -1, r14 + ;; + .mii + nop 0 + and r14 = r19, r14 + ;; + shl r15 = r14, r16 + .mii + nop 0 + shr r9 = r14, r18 + ;; + shl r15 = r15, r16 + ;; + .mii + or r8 = r15, r17 + mov ar.pfs = r42 + mov b0 = r41 + .mib + nop 0 + .label_state 4 + .restore sp + mov r12 = r43 + br.ret.sptk.many b0 +.L37: + .body + .copy_state 4 + .mfi + shladd r15 = r14, 3, r0 + nop 0 + addl r14 = 2, r0 + .mii + ld8 r17 = [r23], 8 + shladd r18 = r20, 3, r0 + ;; + adds r15 = -65, r15 + .mii + ld8 r19 = [r23] + sub r16 = 64, r18 + ;; + sxt4 r15 = r15 + .mii + nop 0 + sxt4 r16 = r16 + ;; + shl r14 = r14, r15 + .mii + nop 0 + shr r17 = r17, r18 + ;; + adds r14 = -1, r14 + ;; + .mii + nop 0 + and r14 = r19, r14 + ;; + shl r14 = r14, r16 + ;; + .mii + or r8 = r14, r17 + mov ar.pfs = r42 + mov b0 = r41 + .mib + nop 0 + .label_state 5 + .restore sp + mov r12 = r43 + br.ret.sptk.many b0 +.L39: + .body + .copy_state 5 + .mib + nop 0 + cmp.ltu p6, p7 = 24, r21 + (p6) br.cond.dptk .L43 + ;; + .mib + nop 0 + cmp.ltu p6, p7 = 24, r14 + (p6) br.cond.dptk .L45 + .mmi + shladd r15 = r14, 3, r0 + adds r14 = 8, r23 + shladd r16 = r20, 2, r0 + .mmb + shladd r19 = r20, 3, r0 + ld8 r18 = [r23], 16 + nop 0 + ;; + .mmi + ld8 r17 = [r14] + addl r14 = 2, r0 + adds r15 = -65, r15 + .mmb + sub r16 = 32, r16 + ld8 r20 = [r23] + nop 0 + ;; + .mii + nop 0 + sxt4 r15 = r15 + sxt4 r16 = r16 + .mii + nop 0 + shr r18 = r18, r19 + ;; + shl r14 = r14, r15 + .mii + nop 0 + shl r15 = r17, r16 + shr r17 = r17, r19 + ;; + .mii + nop 0 + shl r15 = r15, r16 + adds r14 = -1, r14 + ;; + .mii + and r14 = r20, r14 + or r8 = r15, r18 + ;; + shl r15 = r14, r16 + .mii + nop 0 + shr r10 = r14, r19 + ;; + shl r15 = r15, r16 + ;; + .mii + or r9 = r15, r17 + mov ar.pfs = r42 + mov b0 = r41 + .mib + nop 0 + .label_state 6 + .restore sp + mov r12 = r43 + br.ret.sptk.many b0 +.L41: + .body + .copy_state 6 + .mfi + shladd r16 = r14, 3, r0 + nop 0 + adds r14 = 8, r23 + .mfi + ld8 r18 = [r23], 16 + nop 0 + shladd r15 = r20, 3, r0 + ;; + .mmi + ld8 r17 = [r14] + addl r14 = 2, r0 + adds r16 = -129, r16 + .mmi + ld8 r20 = [r23] + mov r19 = r15 + sub r15 = 64, r15 + ;; + .mii + nop 0 + sxt4 r16 = r16 + sxt4 r15 = r15 + ;; + .mii + nop 0 + shl r14 = r14, r16 + shr r18 = r18, r19 + .mii + nop 0 + shl r16 = r17, r15 + shr r17 = r17, r19 + ;; + .mmi + adds r14 = -1, r14 + ;; + and r14 = r20, r14 + or r8 = r16, r18 + ;; + .mib + nop 0 + shl r14 = r14, r15 + nop 0 + ;; + .mii + or r9 = r14, r17 + mov ar.pfs = r42 + mov b0 = r41 + .mib + nop 0 + .label_state 7 + .restore sp + mov r12 = r43 + br.ret.sptk.many b0 +.L45: + .body + .copy_state 7 + .mmi + shladd r16 = r14, 3, r0 + adds r14 = 24, r23 + shladd r15 = r20, 3, r0 + .mmi + adds r18 = 8, r23 + ld8 r20 = [r23] + adds r19 = 16, r23 + ;; + .mmi + ld8 r22 = [r14] + addl r14 = 2, r0 + adds r16 = -129, r16 + .mmi + mov r17 = r15 + ld8 r18 = [r18] + sub r15 = 64, r15 + ;; + .mib + nop 0 + sxt4 r16 = r16 + nop 0 + .mii + ld8 r19 = [r19] + sxt4 r15 = r15 + ;; + shl r14 = r14, r16 + .mii + nop 0 + shr r21 = r19, r17 + shl r16 = r18, r15 + .mii + nop 0 + shr r20 = r20, r17 + shr r18 = r18, r17 + .mii + nop 0 + shl r19 = r19, r15 + ;; + nop 0 + .mmi + adds r14 = -1, r14 + ;; + and r14 = r22, r14 + or r8 = r16, r20 + .mii + nop 0 + or r9 = r19, r18 + ;; + shl r14 = r14, r15 + ;; + .mii + or r10 = r14, r21 + mov ar.pfs = r42 + mov b0 = r41 + .mib + nop 0 + .label_state 8 + .restore sp + mov r12 = r43 + br.ret.sptk.many b0 +.L43: + .body + .copy_state 8 + .mib + nop 0 + cmp.ltu p6, p7 = 32, r14 + (p6) br.cond.dptk .L47 + .mmi + adds r15 = 24, r23 + shladd r14 = r14, 3, r0 + adds r17 = 8, r23 + .mmi + shladd r16 = r20, 2, r0 + adds r18 = 16, r23 + shladd r20 = r20, 3, r0 + ;; + .mmi + nop 0 + ld8 r22 = [r15] + addl r15 = 2, r0 + .mmi + adds r14 = -65, r14 + ld8 r19 = [r17] + sub r16 = 32, r16 + ;; + .mii + nop 0 + sxt4 r14 = r14 + sxt4 r16 = r16 + .mmb + ld8 r21 = [r18] + ld8 r18 = [r23] + nop 0 + ;; + .mii + nop 0 + shl r15 = r15, r14 + shl r14 = r19, r16 + .mii + nop 0 + shr r18 = r18, r20 + shl r17 = r21, r16 + ;; + .mii + nop 0 + shl r14 = r14, r16 + shr r19 = r19, r20 + .mii + adds r15 = -1, r15 + shl r17 = r17, r16 + shr r21 = r21, r20 + ;; + .mmi + nop 0 + and r15 = r22, r15 + or r8 = r14, r18 + .mmi + or r9 = r17, r19 + ;; + nop 0 + shl r14 = r15, r16 + .mii + nop 0 + shr r11 = r15, r20 + ;; + shl r14 = r14, r16 + ;; + .mii + or r10 = r14, r21 + mov ar.pfs = r42 + mov b0 = r41 + .mib + nop 0 + .label_state 9 + .restore sp + mov r12 = r43 + br.ret.sptk.many b0 +.L47: + .body + .copy_state 9 + .mmb + shladd r16 = r14, 3, r0 + adds r14 = 32, r23 + nop 0 + .mmi + adds r18 = 8, r23 + adds r19 = 16, r23 + shladd r15 = r20, 3, r0 + ;; + .mfi + ld8 r22 = [r14] + nop 0 + adds r14 = 24, r23 + .mmi + ld8 r20 = [r18] + adds r16 = -129, r16 + mov r17 = r15 + .mfi + ld8 r18 = [r19] + nop 0 + sub r15 = 64, r15 + ;; + .mmi + ld8 r19 = [r14] + addl r14 = 2, r0 + sxt4 r16 = r16 + .mii + nop 0 + sxt4 r15 = r15 + ;; + shl r21 = r20, r15 + .mii + nop 0 + shr r20 = r20, r17 + shl r14 = r14, r16 + .mii + ld8 r16 = [r23] + shr r23 = r19, r17 + shl r19 = r19, r15 + ;; + .mii + nop 0 + shr r16 = r16, r17 + shr r17 = r18, r17 + .mii + adds r14 = -1, r14 + shl r18 = r18, r15 + ;; + and r14 = r22, r14 + .mmi + nop 0 + or r8 = r21, r16 + or r10 = r19, r17 + .mii + nop 0 + or r9 = r18, r20 + ;; + shl r14 = r14, r15 + ;; + .mii + or r11 = r14, r23 + mov ar.pfs = r42 + mov b0 = r41 + .mib + nop 0 + .restore sp + mov r12 = r43 + br.ret.sptk.many b0 + .endp vacall_receiver# + .ident "GCC: (GNU) 4.0.1" diff --git a/vacall/vacall-ia64-macro.S b/vacall/vacall-ia64-macro.S new file mode 100644 index 0000000..23fcb30 --- /dev/null +++ b/vacall/vacall-ia64-macro.S @@ -0,0 +1,845 @@ + .file "vacall-ia64.c" + .pred.safe_across_calls p1-p5,p16-p63 + .text + .align 16 + .global vacall_receiver# + .proc vacall_receiver# +vacall_receiver: + .prologue 14, 41 + .spill 48 + .mmb + .save ar.pfs, r42 + alloc r42 = ar.pfs, 8, 5, 1, 0 + .vframe r43 + mov r43 = r12 + nop 0 + .mmi + adds r12 = -208, r12 + mov r44 = r1 + .save rp, r41 + mov r41 = b0 + .body + ;; + .mmi + adds r14 = -48, r43 + adds r16 = -48, r43 + adds r40 = -152, r43 + .mmb + adds r45 = -192, r43 + st8 [r43] = r38 + nop 0 + ;; + .mmi + nop 0 + st8 [r14] = r32, 8 + adds r32 = -160, r43 + .mmi + st4 [r40] = r0 + ;; + st8 [r14] = r33 + adds r14 = -32, r43 + .mmi + st4 [r45] = r0 + ;; + st8 [r14] = r34 + addl r14 = @ltoffx(vacall_function#), r1 + .mmb + nop 0 + st8 [r32] = r0 + nop 0 + ;; + .mmi + ld8.mov r14 = [r14], vacall_function# + ;; + ld8 r15 = [r14] + nop 0 + .mmi + adds r14 = -24, r43 + ;; + st8 [r14] = r35 + adds r14 = -16, r43 + ;; + .mfi + st8 [r14] = r36 + nop 0 + adds r14 = -8, r43 + .mmi + nop 0 + ;; + st8 [r14] = r37 + nop 0 + .mmi + adds r14 = 8, r43 + ;; + st8 [r14] = r39 + adds r14 = -112, r43 + ;; + .mfi + stfd [r14] = f8 + nop 0 + adds r14 = -104, r43 + .mmi + nop 0 + ;; + stfd [r14] = f9 + nop 0 + .mmi + adds r14 = -96, r43 + ;; + stfd [r14] = f10 + adds r14 = -88, r43 + ;; + .mfi + stfd [r14] = f11 + nop 0 + adds r14 = -80, r43 + .mmi + nop 0 + ;; + stfd [r14] = f12 + nop 0 + .mmi + adds r14 = -72, r43 + ;; + stfd [r14] = f13 + adds r14 = -64, r43 + ;; + .mfi + stfd [r14] = f14 + nop 0 + adds r14 = -56, r43 + .mmi + nop 0 + ;; + stfd [r14] = f15 + nop 0 + .mmi + adds r14 = -168, r43 + ;; + st8 [r14] = r16 + adds r14 = -128, r43 + ;; + .mii + st8 [r14] = r16 + adds r14 = -120, r43 + ;; + nop 0 + .mii + st4 [r14] = r0 + adds r14 = -136, r43 + ;; + nop 0 + .mmb + st8 [r14] = r8 + ld8 r14 = [r15], 8 + nop 0 + ;; + .mib + nop 0 + mov b6 = r14 + nop 0 + .mbb + ld8 r1 = [r15] + nop 0 + br.call.sptk.many b0 = b6 + ;; + .mmb + mov r1 = r44 + ld4 r40 = [r40] + nop 0 + ;; + .mfb + cmp4.eq p6, p7 = 0, r40 + nop 0 + (p6) br.cond.dpnt .L49 + ;; + .mfb + cmp4.ne p6, p7 = 1, r40 + nop 0 + (p7) br.cond.dpnt .L50 + ;; + .mfb + cmp4.ne p6, p7 = 2, r40 + nop 0 + (p7) br.cond.dpnt .L50 + ;; + .mii + nop 0 + cmp4.ne p6, p7 = 3, r40 + ;; + (p7) adds r14 = -184, r43 + ;; + .mfb + (p7) ld1 r8 = [r14] + nop 0 + (p7) br.cond.dpnt .L49 + .mii + nop 0 + cmp4.ne p6, p7 = 4, r40 + ;; + nop 0 + .mmi + (p7) adds r14 = -184, r43 + ;; + (p7) ld2 r14 = [r14] + nop 0 + ;; + .mib + nop 0 + (p7) sxt2 r8 = r14 + (p7) br.cond.dpnt .L49 + .mii + nop 0 + cmp4.ne p6, p7 = 5, r40 + ;; + (p7) adds r14 = -184, r43 + ;; + .mfb + (p7) ld2 r8 = [r14] + nop 0 + (p7) br.cond.dpnt .L49 + .mii + nop 0 + cmp4.ne p6, p7 = 6, r40 + ;; + nop 0 + .mmi + (p7) adds r14 = -184, r43 + ;; + (p7) ld4 r14 = [r14] + nop 0 + ;; + .mib + nop 0 + (p7) sxt4 r8 = r14 + (p7) br.cond.dpnt .L49 + .mii + nop 0 + cmp4.ne p6, p7 = 7, r40 + ;; + (p7) adds r14 = -184, r43 + ;; + .mfb + (p7) ld4 r8 = [r14] + nop 0 + (p7) br.cond.dpnt .L49 + .mfb + cmp4.ne p6, p7 = 8, r40 + nop 0 + (p7) br.cond.dpnt .L54 + ;; + .mfb + cmp4.ne p6, p7 = 9, r40 + nop 0 + (p7) br.cond.dpnt .L54 + ;; + .mfb + cmp4.ne p6, p7 = 10, r40 + nop 0 + (p7) br.cond.dpnt .L54 + ;; + .mfb + cmp4.ne p6, p7 = 11, r40 + nop 0 + (p7) br.cond.dpnt .L54 + ;; + .mii + nop 0 + cmp4.ne p6, p7 = 12, r40 + ;; + (p7) adds r14 = -184, r43 + ;; + .mfb + (p7) ldfs f8 = [r14] + nop 0 + (p7) br.cond.dpnt .L49 + .mii + nop 0 + cmp4.ne p6, p7 = 13, r40 + ;; + (p7) adds r14 = -184, r43 + ;; + .mfb + (p7) ldfd f8 = [r14] + nop 0 + (p7) br.cond.dpnt .L49 + .mfb + cmp4.ne p6, p7 = 14, r40 + nop 0 + (p7) br.cond.dpnt .L54 + ;; + .mib + nop 0 + cmp4.ne p6, p7 = 15, r40 + (p6) br.cond.dptk .L49 + .mii + nop 0 + adds r15 = -192, r43 + ;; + nop 0 + .mmi + ld4 r14 = [r15] + ;; + nop 0 + tbit.z p6, p7 = r14, 10 + .mfb + adds r14 = -144, r43 + nop 0 + (p6) br.cond.dpnt .L49 + ;; + .mmi + ld8 r21 = [r14] + ;; + adds r14 = -1, r21 + nop 0 + ;; + .mib + nop 0 + cmp.ltu p6, p7 = 31, r14 + (p6) br.cond.dpnt .L49 + .mmi + ld8 r14 = [r32] + ;; + and r20 = 7, r14 + and r23 = -8, r14 + .mii + nop 0 + cmp.ltu p6, p7 = 8, r21 + ;; + nop 0 + .mfb + add r14 = r21, r20 + nop 0 + (p6) br.cond.dptk .L35 + ;; + .mib + nop 0 + cmp.ltu p6, p7 = 8, r14 + (p6) br.cond.dptk .L37 + .mfi + shladd r15 = r14, 3, r0 + nop 0 + addl r14 = 2, r0 + .mii + ld8 r16 = [r23] + shladd r17 = r20, 3, r0 + ;; + adds r15 = -1, r15 + ;; + .mii + nop 0 + sxt4 r15 = r15 + ;; + shl r14 = r14, r15 + ;; + .mmi + adds r14 = -1, r14 + ;; + and r14 = r16, r14 + nop 0 + .mmi + nop 0 + ;; + nop 0 + shr r8 = r14, r17 +.L49: + .mii + nop 0 + mov ar.pfs = r42 + mov b0 = r41 + .mib + nop 0 + .label_state 1 + .restore sp + mov r12 = r43 + br.ret.sptk.many b0 +.L50: + .body + .copy_state 1 + .mii + nop 0 + adds r14 = -184, r43 + ;; + nop 0 + .mii + ld1 r14 = [r14] + nop 0 + ;; + sxt1 r8 = r14 + .mii + nop 0 + mov ar.pfs = r42 + mov b0 = r41 + .mib + nop 0 + .label_state 2 + .restore sp + mov r12 = r43 + br.ret.sptk.many b0 +.L54: + .body + .copy_state 2 + .mmb + nop 0 + adds r14 = -184, r43 + nop 0 + ;; + .mii + ld8 r8 = [r14] + mov ar.pfs = r42 + mov b0 = r41 + .mib + nop 0 + .label_state 3 + .restore sp + mov r12 = r43 + br.ret.sptk.many b0 +.L35: + .body + .copy_state 3 + .mib + nop 0 + cmp.ltu p6, p7 = 16, r21 + (p6) br.cond.dptk .L39 + ;; + .mib + nop 0 + cmp.ltu p6, p7 = 16, r14 + (p6) br.cond.dptk .L41 + .mmi + shladd r15 = r14, 3, r0 + adds r14 = 8, r23 + shladd r16 = r20, 2, r0 + .mmb + shladd r18 = r20, 3, r0 + ld8 r17 = [r23] + nop 0 + ;; + .mfi + ld8 r19 = [r14] + nop 0 + addl r14 = 2, r0 + .mii + adds r15 = -65, r15 + sub r16 = 32, r16 + ;; + sxt4 r15 = r15 + .mii + nop 0 + sxt4 r16 = r16 + shr r17 = r17, r18 + ;; + .mii + nop 0 + shl r14 = r14, r15 + ;; + adds r14 = -1, r14 + ;; + .mii + nop 0 + and r14 = r19, r14 + ;; + shl r15 = r14, r16 + .mii + nop 0 + shr r9 = r14, r18 + ;; + shl r15 = r15, r16 + ;; + .mii + or r8 = r15, r17 + mov ar.pfs = r42 + mov b0 = r41 + .mib + nop 0 + .label_state 4 + .restore sp + mov r12 = r43 + br.ret.sptk.many b0 +.L37: + .body + .copy_state 4 + .mfi + shladd r15 = r14, 3, r0 + nop 0 + addl r14 = 2, r0 + .mii + ld8 r17 = [r23], 8 + shladd r18 = r20, 3, r0 + ;; + adds r15 = -65, r15 + .mii + ld8 r19 = [r23] + sub r16 = 64, r18 + ;; + sxt4 r15 = r15 + .mii + nop 0 + sxt4 r16 = r16 + ;; + shl r14 = r14, r15 + .mii + nop 0 + shr r17 = r17, r18 + ;; + adds r14 = -1, r14 + ;; + .mii + nop 0 + and r14 = r19, r14 + ;; + shl r14 = r14, r16 + ;; + .mii + or r8 = r14, r17 + mov ar.pfs = r42 + mov b0 = r41 + .mib + nop 0 + .label_state 5 + .restore sp + mov r12 = r43 + br.ret.sptk.many b0 +.L39: + .body + .copy_state 5 + .mib + nop 0 + cmp.ltu p6, p7 = 24, r21 + (p6) br.cond.dptk .L43 + ;; + .mib + nop 0 + cmp.ltu p6, p7 = 24, r14 + (p6) br.cond.dptk .L45 + .mmi + shladd r15 = r14, 3, r0 + adds r14 = 8, r23 + shladd r16 = r20, 2, r0 + .mmb + shladd r19 = r20, 3, r0 + ld8 r18 = [r23], 16 + nop 0 + ;; + .mmi + ld8 r17 = [r14] + addl r14 = 2, r0 + adds r15 = -65, r15 + .mmb + sub r16 = 32, r16 + ld8 r20 = [r23] + nop 0 + ;; + .mii + nop 0 + sxt4 r15 = r15 + sxt4 r16 = r16 + .mii + nop 0 + shr r18 = r18, r19 + ;; + shl r14 = r14, r15 + .mii + nop 0 + shl r15 = r17, r16 + shr r17 = r17, r19 + ;; + .mii + nop 0 + shl r15 = r15, r16 + adds r14 = -1, r14 + ;; + .mii + and r14 = r20, r14 + or r8 = r15, r18 + ;; + shl r15 = r14, r16 + .mii + nop 0 + shr r10 = r14, r19 + ;; + shl r15 = r15, r16 + ;; + .mii + or r9 = r15, r17 + mov ar.pfs = r42 + mov b0 = r41 + .mib + nop 0 + .label_state 6 + .restore sp + mov r12 = r43 + br.ret.sptk.many b0 +.L41: + .body + .copy_state 6 + .mfi + shladd r16 = r14, 3, r0 + nop 0 + adds r14 = 8, r23 + .mfi + ld8 r18 = [r23], 16 + nop 0 + shladd r15 = r20, 3, r0 + ;; + .mmi + ld8 r17 = [r14] + addl r14 = 2, r0 + adds r16 = -129, r16 + .mmi + ld8 r20 = [r23] + mov r19 = r15 + sub r15 = 64, r15 + ;; + .mii + nop 0 + sxt4 r16 = r16 + sxt4 r15 = r15 + ;; + .mii + nop 0 + shl r14 = r14, r16 + shr r18 = r18, r19 + .mii + nop 0 + shl r16 = r17, r15 + shr r17 = r17, r19 + ;; + .mmi + adds r14 = -1, r14 + ;; + and r14 = r20, r14 + or r8 = r16, r18 + ;; + .mib + nop 0 + shl r14 = r14, r15 + nop 0 + ;; + .mii + or r9 = r14, r17 + mov ar.pfs = r42 + mov b0 = r41 + .mib + nop 0 + .label_state 7 + .restore sp + mov r12 = r43 + br.ret.sptk.many b0 +.L45: + .body + .copy_state 7 + .mmi + shladd r16 = r14, 3, r0 + adds r14 = 24, r23 + shladd r15 = r20, 3, r0 + .mmi + adds r18 = 8, r23 + ld8 r20 = [r23] + adds r19 = 16, r23 + ;; + .mmi + ld8 r22 = [r14] + addl r14 = 2, r0 + adds r16 = -129, r16 + .mmi + mov r17 = r15 + ld8 r18 = [r18] + sub r15 = 64, r15 + ;; + .mib + nop 0 + sxt4 r16 = r16 + nop 0 + .mii + ld8 r19 = [r19] + sxt4 r15 = r15 + ;; + shl r14 = r14, r16 + .mii + nop 0 + shr r21 = r19, r17 + shl r16 = r18, r15 + .mii + nop 0 + shr r20 = r20, r17 + shr r18 = r18, r17 + .mii + nop 0 + shl r19 = r19, r15 + ;; + nop 0 + .mmi + adds r14 = -1, r14 + ;; + and r14 = r22, r14 + or r8 = r16, r20 + .mii + nop 0 + or r9 = r19, r18 + ;; + shl r14 = r14, r15 + ;; + .mii + or r10 = r14, r21 + mov ar.pfs = r42 + mov b0 = r41 + .mib + nop 0 + .label_state 8 + .restore sp + mov r12 = r43 + br.ret.sptk.many b0 +.L43: + .body + .copy_state 8 + .mib + nop 0 + cmp.ltu p6, p7 = 32, r14 + (p6) br.cond.dptk .L47 + .mmi + adds r15 = 24, r23 + shladd r14 = r14, 3, r0 + adds r17 = 8, r23 + .mmi + shladd r16 = r20, 2, r0 + adds r18 = 16, r23 + shladd r20 = r20, 3, r0 + ;; + .mmi + nop 0 + ld8 r22 = [r15] + addl r15 = 2, r0 + .mmi + adds r14 = -65, r14 + ld8 r19 = [r17] + sub r16 = 32, r16 + ;; + .mii + nop 0 + sxt4 r14 = r14 + sxt4 r16 = r16 + .mmb + ld8 r21 = [r18] + ld8 r18 = [r23] + nop 0 + ;; + .mii + nop 0 + shl r15 = r15, r14 + shl r14 = r19, r16 + .mii + nop 0 + shr r18 = r18, r20 + shl r17 = r21, r16 + ;; + .mii + nop 0 + shl r14 = r14, r16 + shr r19 = r19, r20 + .mii + adds r15 = -1, r15 + shl r17 = r17, r16 + shr r21 = r21, r20 + ;; + .mmi + nop 0 + and r15 = r22, r15 + or r8 = r14, r18 + .mmi + or r9 = r17, r19 + ;; + nop 0 + shl r14 = r15, r16 + .mii + nop 0 + shr r11 = r15, r20 + ;; + shl r14 = r14, r16 + ;; + .mii + or r10 = r14, r21 + mov ar.pfs = r42 + mov b0 = r41 + .mib + nop 0 + .label_state 9 + .restore sp + mov r12 = r43 + br.ret.sptk.many b0 +.L47: + .body + .copy_state 9 + .mmb + shladd r16 = r14, 3, r0 + adds r14 = 32, r23 + nop 0 + .mmi + adds r18 = 8, r23 + adds r19 = 16, r23 + shladd r15 = r20, 3, r0 + ;; + .mfi + ld8 r22 = [r14] + nop 0 + adds r14 = 24, r23 + .mmi + ld8 r20 = [r18] + adds r16 = -129, r16 + mov r17 = r15 + .mfi + ld8 r18 = [r19] + nop 0 + sub r15 = 64, r15 + ;; + .mmi + ld8 r19 = [r14] + addl r14 = 2, r0 + sxt4 r16 = r16 + .mii + nop 0 + sxt4 r15 = r15 + ;; + shl r21 = r20, r15 + .mii + nop 0 + shr r20 = r20, r17 + shl r14 = r14, r16 + .mii + ld8 r16 = [r23] + shr r23 = r19, r17 + shl r19 = r19, r15 + ;; + .mii + nop 0 + shr r16 = r16, r17 + shr r17 = r18, r17 + .mii + adds r14 = -1, r14 + shl r18 = r18, r15 + ;; + and r14 = r22, r14 + .mmi + nop 0 + or r8 = r21, r16 + or r10 = r19, r17 + .mii + nop 0 + or r9 = r18, r20 + ;; + shl r14 = r14, r15 + ;; + .mii + or r11 = r14, r23 + mov ar.pfs = r42 + mov b0 = r41 + .mib + nop 0 + .restore sp + mov r12 = r43 + br.ret.sptk.many b0 + .endp vacall_receiver# + .ident "GCC: (GNU) 4.0.1" +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/vacall/vacall-ia64.c b/vacall/vacall-ia64.c new file mode 100644 index 0000000..0bdbc7d --- /dev/null +++ b/vacall/vacall-ia64.c @@ -0,0 +1,282 @@ +/* vacall function for ia64 CPU */ + +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +#include "vacall-internal.h" + +#ifdef REENTRANT +#define vacall_receiver callback_receiver +register struct { void (*vacall_function) (void*,va_alist); void* arg; } + * env __asm__("r15"); +#endif +register double farg1 __asm__("f8"); +register double farg2 __asm__("f9"); +register double farg3 __asm__("f10"); +register double farg4 __asm__("f11"); +register double farg5 __asm__("f12"); +register double farg6 __asm__("f13"); +register double farg7 __asm__("f14"); +register double farg8 __asm__("f15"); +register __vaword* sret __asm__("r8"); +register __vaword iret __asm__("r8"); +register __vaword iret2 __asm__("r9"); +register __vaword iret3 __asm__("r10"); +register __vaword iret4 __asm__("r11"); +register float fret __asm__("f8"); +register double dret __asm__("f8"); + +/* The ABI requires that the first 8 general-purpose argument words are + being passed in registers, even if these words belong to a struct. No room + is allocated for these register words on the stack by the caller, but the + callee allocates room for them - at the right place in the stack frame, + that is, above the usual {fp, retaddr} combo - if and only if they are part + of a larger struct that extends to the stack and the address of this struct + is taken. */ +struct gpargsequence { + __vaword word1; /* r32 */ + __vaword word2; /* r33 */ + __vaword word3; /* r34 */ + __vaword word4; /* r35 */ + __vaword word5; /* r36 */ + __vaword word6; /* r37 */ + __vaword word7; /* r38 */ + __vaword word8; /* r39 */ + __vaword firststackword; +}; + +#ifdef REENTRANT +static +#endif +void /* the return type is variable, not void! */ +vacall_receiver (struct gpargsequence gpargs) +{ + __va_alist list; + /* Move the arguments passed in registers to their stack locations. */ + list.farg[0] = farg1; + list.farg[1] = farg2; + list.farg[2] = farg3; + list.farg[3] = farg4; + list.farg[4] = farg5; + list.farg[5] = farg6; + list.farg[6] = farg7; + list.farg[7] = farg8; + /* Prepare the va_alist. */ + list.flags = 0; + list.aptr = (long)&gpargs; + list.saptr = (__vaword*)&gpargs; + list.fanum = 0; + list.raddr = (void*)0; + list.rtype = __VAvoid; + list.structraddr = sret; + /* Call vacall_function. The macros do all the rest. */ +#ifndef REENTRANT + (*vacall_function) (&list); +#else /* REENTRANT */ + (*env->vacall_function) (env->arg,&list); +#endif + /* Put return value into proper register. */ + if (list.rtype == __VAvoid) { + } else + if (list.rtype == __VAchar) { + iret = list.tmp._char; + } else + if (list.rtype == __VAschar) { + iret = list.tmp._schar; + } else + if (list.rtype == __VAuchar) { + iret = list.tmp._uchar; + } else + if (list.rtype == __VAshort) { + iret = list.tmp._short; + } else + if (list.rtype == __VAushort) { + iret = list.tmp._ushort; + } else + if (list.rtype == __VAint) { + iret = list.tmp._int; + } else + if (list.rtype == __VAuint) { + iret = list.tmp._uint; + } else + if (list.rtype == __VAlong) { + iret = list.tmp._long; + } else + if (list.rtype == __VAulong) { + iret = list.tmp._ulong; + } else + if (list.rtype == __VAlonglong) { + iret = list.tmp._long; + } else + if (list.rtype == __VAulonglong) { + iret = list.tmp._ulong; + } else + if (list.rtype == __VAfloat) { + fret = list.tmp._float; + } else + if (list.rtype == __VAdouble) { + dret = list.tmp._double; + } else + if (list.rtype == __VAvoidp) { + iret = (long)list.tmp._ptr; + } else + if (list.rtype == __VAstruct) { + if (list.flags & __VA_REGISTER_STRUCT_RETURN) { + /* Return structs of size <= 32 in registers. */ + if (list.rsize > 0 && list.rsize <= 32) { + #if 0 /* Unoptimized */ + iret = (__vaword)((unsigned char *) list.raddr)[0]; + if (list.rsize >= 2) + iret |= (__vaword)((unsigned char *) list.raddr)[1] << 8; + if (list.rsize >= 3) + iret |= (__vaword)((unsigned char *) list.raddr)[2] << 16; + if (list.rsize >= 4) + iret |= (__vaword)((unsigned char *) list.raddr)[3] << 24; + if (list.rsize >= 5) + iret |= (__vaword)((unsigned char *) list.raddr)[4] << 32; + if (list.rsize >= 6) + iret |= (__vaword)((unsigned char *) list.raddr)[5] << 40; + if (list.rsize >= 7) + iret |= (__vaword)((unsigned char *) list.raddr)[6] << 48; + if (list.rsize >= 8) + iret |= (__vaword)((unsigned char *) list.raddr)[7] << 56; + if (list.rsize >= 9) { + iret2 = (__vaword)((unsigned char *) list.raddr)[8]; + if (list.rsize >= 10) + iret2 |= (__vaword)((unsigned char *) list.raddr)[9] << 8; + if (list.rsize >= 11) + iret2 |= (__vaword)((unsigned char *) list.raddr)[10] << 16; + if (list.rsize >= 12) + iret2 |= (__vaword)((unsigned char *) list.raddr)[11] << 24; + if (list.rsize >= 13) + iret2 |= (__vaword)((unsigned char *) list.raddr)[12] << 32; + if (list.rsize >= 14) + iret2 |= (__vaword)((unsigned char *) list.raddr)[13] << 40; + if (list.rsize >= 15) + iret2 |= (__vaword)((unsigned char *) list.raddr)[14] << 48; + if (list.rsize >= 16) + iret2 |= (__vaword)((unsigned char *) list.raddr)[15] << 56; + if (list.rsize >= 17) { + iret3 = (__vaword)((unsigned char *) list.raddr)[16]; + if (list.rsize >= 18) + iret3 |= (__vaword)((unsigned char *) list.raddr)[17] << 8; + if (list.rsize >= 19) + iret3 |= (__vaword)((unsigned char *) list.raddr)[18] << 16; + if (list.rsize >= 20) + iret3 |= (__vaword)((unsigned char *) list.raddr)[19] << 24; + if (list.rsize >= 21) + iret3 |= (__vaword)((unsigned char *) list.raddr)[20] << 32; + if (list.rsize >= 22) + iret3 |= (__vaword)((unsigned char *) list.raddr)[21] << 40; + if (list.rsize >= 23) + iret3 |= (__vaword)((unsigned char *) list.raddr)[22] << 48; + if (list.rsize >= 24) + iret3 |= (__vaword)((unsigned char *) list.raddr)[23] << 56; + if (list.rsize >= 25) { + iret4 = (__vaword)((unsigned char *) list.raddr)[24]; + if (list.rsize >= 26) + iret4 |= (__vaword)((unsigned char *) list.raddr)[25] << 8; + if (list.rsize >= 27) + iret4 |= (__vaword)((unsigned char *) list.raddr)[26] << 16; + if (list.rsize >= 28) + iret4 |= (__vaword)((unsigned char *) list.raddr)[27] << 24; + if (list.rsize >= 29) + iret4 |= (__vaword)((unsigned char *) list.raddr)[28] << 32; + if (list.rsize >= 30) + iret4 |= (__vaword)((unsigned char *) list.raddr)[29] << 40; + if (list.rsize >= 31) + iret4 |= (__vaword)((unsigned char *) list.raddr)[30] << 48; + if (list.rsize >= 32) + iret4 |= (__vaword)((unsigned char *) list.raddr)[31] << 56; + } + } + } + #else /* Optimized: fewer conditional jumps, fewer memory accesses */ + uintptr_t count = list.rsize; /* > 0, ≤ 4*sizeof(__vaword) */ + __vaword* wordaddr = (__vaword*)((uintptr_t)list.raddr & ~(uintptr_t)(sizeof(__vaword)-1)); + uintptr_t start_offset = (uintptr_t)list.raddr & (uintptr_t)(sizeof(__vaword)-1); /* ≥ 0, < sizeof(__vaword) */ + uintptr_t end_offset = start_offset + count; /* > 0, < 5*sizeof(__vaword) */ + if (count <= sizeof(__vaword)) { + /* Assign iret. */ + if (end_offset <= sizeof(__vaword)) { + /* 0 < end_offset ≤ sizeof(__vaword) */ + __vaword mask0 = ((__vaword)2 << (end_offset*8-1)) - 1; + iret = (wordaddr[0] & mask0) >> (start_offset*8); + } else { + /* sizeof(__vaword) < end_offset < 2*sizeof(__vaword), start_offset > 0 */ + __vaword mask1 = ((__vaword)2 << (end_offset*8-sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | ((wordaddr[1] & mask1) << (sizeof(__vaword)*8-start_offset*8)); + } + } else if (count <= 2*sizeof(__vaword)) { + /* Assign iret, iret2. */ + if (end_offset <= 2*sizeof(__vaword)) { + /* sizeof(__vaword) < end_offset ≤ 2*sizeof(__vaword) */ + __vaword mask1 = ((__vaword)2 << (end_offset*8-sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | ((wordaddr[1] & mask1) << (sizeof(__vaword)*4-start_offset*4) << (sizeof(__vaword)*4-start_offset*4)); + iret2 = (wordaddr[1] & mask1) >> (start_offset*8); + } else { + /* 2*sizeof(__vaword) < end_offset < 3*sizeof(__vaword), start_offset > 0 */ + __vaword mask2 = ((__vaword)2 << (end_offset*8-2*sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | (wordaddr[1] << (sizeof(__vaword)*8-start_offset*8)); + iret2 = (wordaddr[1] >> (start_offset*8)) | ((wordaddr[2] & mask2) << (sizeof(__vaword)*8-start_offset*8)); + } + } else if (count <= 3*sizeof(__vaword)) { + /* Assign iret, iret2, iret3. */ + if (end_offset <= 3*sizeof(__vaword)) { + /* 2*sizeof(__vaword) < end_offset ≤ 3*sizeof(__vaword) */ + __vaword mask2 = ((__vaword)2 << (end_offset*8-sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | (wordaddr[1] << (sizeof(__vaword)*4-start_offset*4) << (sizeof(__vaword)*4-start_offset*4)); + iret2 = (wordaddr[1] >> (start_offset*8)) | ((wordaddr[2] & mask2) << (sizeof(__vaword)*4-start_offset*4) << (sizeof(__vaword)*4-start_offset*4)); + iret3 = (wordaddr[2] & mask2) >> (start_offset*8); + } else { + /* 3*sizeof(__vaword) < end_offset < 4*sizeof(__vaword), start_offset > 0 */ + __vaword mask3 = ((__vaword)2 << (end_offset*8-2*sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | (wordaddr[1] << (sizeof(__vaword)*8-start_offset*8)); + iret2 = (wordaddr[1] >> (start_offset*8)) | (wordaddr[2] << (sizeof(__vaword)*8-start_offset*8)); + iret3 = (wordaddr[2] >> (start_offset*8)) | ((wordaddr[3] & mask3) << (sizeof(__vaword)*8-start_offset*8)); + } + } else { + /* Assign iret, iret2, iret3, iret4. */ + if (end_offset <= 4*sizeof(__vaword)) { + /* 3*sizeof(__vaword) < end_offset ≤ 4*sizeof(__vaword) */ + __vaword mask3 = ((__vaword)2 << (end_offset*8-sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | (wordaddr[1] << (sizeof(__vaword)*4-start_offset*4) << (sizeof(__vaword)*4-start_offset*4)); + iret2 = (wordaddr[1] >> (start_offset*8)) | (wordaddr[2] << (sizeof(__vaword)*4-start_offset*4) << (sizeof(__vaword)*4-start_offset*4)); + iret3 = (wordaddr[2] >> (start_offset*8)) | ((wordaddr[3] & mask3) << (sizeof(__vaword)*4-start_offset*4) << (sizeof(__vaword)*4-start_offset*4)); + iret4 = (wordaddr[3] & mask3) >> (start_offset*8); + } else { + /* 4*sizeof(__vaword) < end_offset < 5*sizeof(__vaword), start_offset > 0 */ + __vaword mask4 = ((__vaword)2 << (end_offset*8-2*sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | (wordaddr[1] << (sizeof(__vaword)*8-start_offset*8)); + iret2 = (wordaddr[1] >> (start_offset*8)) | (wordaddr[2] << (sizeof(__vaword)*8-start_offset*8)); + iret3 = (wordaddr[2] >> (start_offset*8)) | (wordaddr[3] << (sizeof(__vaword)*8-start_offset*8)); + iret4 = (wordaddr[3] >> (start_offset*8)) | ((wordaddr[4] & mask4) << (sizeof(__vaword)*8-start_offset*8)); + } + } + #endif + } + } + } +} + +#ifdef REENTRANT +__vacall_r_t +callback_get_receiver (void) +{ + return (__vacall_r_t)(void*)&callback_receiver; +} +#endif diff --git a/vacall/vacall-internal.h b/vacall/vacall-internal.h new file mode 100644 index 0000000..e29a6d4 --- /dev/null +++ b/vacall/vacall-internal.h @@ -0,0 +1,1204 @@ +/* + * Copyright 1995-2019 Bruno Haible + * + * 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, see . + */ + +#ifndef _VACALL_INTERNAL_H +#define _VACALL_INTERNAL_H + +/* Get intptr_t, uintptr_t. */ +#include "ffcall-stdint.h" + +/* Include the public definitions, */ +#ifndef REENTRANT +#include "vacall.h" +#else +#include "vacall_r.h" +#endif + + +/* The platform indicator symbols (__i386__, etc.) come from + - "config.h" when compiling vacall-libapi.c, + - the GCC command line options when compiling vacall-$(CPU).c. + */ + +/* These two variants of powerpc ABIs are quite different. */ +#if defined(__powerpc__) && !defined(__powerpc64__) +#if defined(_AIX) || (defined(__MACH__) && defined(__APPLE__)) +#define __powerpc_aix__ 1 +#else +#define __powerpc_sysv4__ 1 +#endif +#endif + +/* The Unix and Windows variants of x86_64 ABIs are quite different. */ +#if defined(__x86_64__) +#if defined(_WIN32) || defined(__CYGWIN__) +#define __x86_64_ms__ 1 +#else +#define __x86_64_sysv__ 1 +#endif +#endif + + +/* Max # words in temporary structure storage. + */ +#ifndef __VA_ALIST_WORDS +#define __VA_ALIST_WORDS 256 +#endif + +/* + * Definition of the ‘__va_alist’ type. + */ +/* Note: This struct must not contain members of type 'long' or 'unsigned long', + because in the mingw port we use precompiled code that assumes 'long' is + 64-bit whereas avcall-libapi.c is then compiled by a compiler that has a + 32-bit 'long' type. */ +typedef struct vacall_alist +{ + /* some va_... macros need these flags */ + int flags; + /* temporary storage for return value */ +#if defined(__i386__) || defined(__arm__) || defined(__armhf__) || (defined(__powerpc__) && !defined(__powerpc64__) && defined(__MACH__) && defined(__APPLE__)) + /* Filler word, needed if the numbers of words up to now in this structure */ + /* is odd. */ + /* - On MSVC, alignof(double) = 8, but normally on i386 it is = 4. */ + /* - On ARM, GCC 3.1 produces code for an ABI where alignof(double) = 4 */ + /* and alignof(long long) = 4. But in the newer AAPCS ABI, these */ + /* alignments are 8. */ + /* - On Mac OS X, the Apple compiler has alignof(double) = 8 whereas the */ + /* standard GCC has alignof(double) = 4. */ + __vaword filler1; +#endif + union { + char _char; + signed char _schar; + unsigned char _uchar; + short _short; + unsigned short _ushort; + int _int; + unsigned int _uint; + long _long; + unsigned long _ulong; +#if !(defined(__mips64__) || defined(__sparc64__) || defined(__alpha__) || defined(__hppa64__) || defined(__arm64__) || defined(__powerpc64__) || defined(__ia64__) || defined(__riscv64__)) + long long _longlong; + unsigned long long _ulonglong; +#endif + float _float; + double _double; + void* _ptr; + __vaword _words[2]; + } tmp; + /* current pointer into the argument array */ + uintptr_t aptr; + /* structure return pointer, return type, return type size */ + void* raddr; + enum __VAtype rtype; + uintptr_t rsize; +#if defined(__i386__) || defined(__m68k__) || (defined(__sparc__) && !defined(__sparc64__)) || defined(__hppa__) || defined(__hppa64__) || defined(__arm64__) || defined(__ia64__) + void* structraddr; +#endif +#if (defined(__mips__) && !defined(__mipsn32__) && !defined(__mips64__)) || defined(__alpha__) || defined(__hppa__) || defined(__hppa64__) + uintptr_t memargptr; +#endif +#if defined(__alpha__) + long farg_offset; + double farg[6]; +#endif +#if defined(__hppa__) && !defined(__hppa64__) + long farg_offset; + long darg_offset; + float farg[4]; + double darg[2]; +#endif +#if defined(__mips__) && !defined(__mipsn32__) && !defined(__mips64__) + unsigned int anum; +#define __VA_FARG_NUM 2 + unsigned int fanum; + float farg[__VA_FARG_NUM]; + double darg[__VA_FARG_NUM]; +#endif +#if defined(__mipsn32__) || defined(__mips64__) + int anum; +#define __VA_FARG_NUM 8 + float farg[__VA_FARG_NUM]; + double darg[__VA_FARG_NUM]; +#endif +#if defined(__sparc64__) + int anum; + float farg[16]; + double darg[16]; +#endif +#if defined(__hppa64__) +#define __VA_FARG_NUM 8 + float farg[__VA_FARG_NUM]; + double darg[__VA_FARG_NUM]; +#endif +#if defined(__armhf__) +#define __VA_IARG_NUM 4 + /* The first __AV_IARG_NUM integer arguments are passed in registers, even if + some floating-point arguments have already been allocated on the stack. */ + __vaword* iarg; + unsigned int ianum; + unsigned int fanum; + float farg[16]; + double darg[8]; +#endif +#if defined(__arm64__) +#define __VA_IARG_NUM 8 + unsigned int ianum; + __vaword iarg[__VA_IARG_NUM]; +#define __VA_FARG_NUM 8 + unsigned int fanum; + float farg[__VA_FARG_NUM]; + double darg[__VA_FARG_NUM]; +#endif +#if defined(__powerpc__) || defined(__powerpc64__) +#if defined(__powerpc_sysv4__) +#define __VA_IARG_NUM 8 + unsigned int ianum; + __vaword iarg[__VA_IARG_NUM]; +#define __VA_FARG_NUM 8 +#else +#define __VA_FARG_NUM 13 +#endif + unsigned int fanum; + double farg[__VA_FARG_NUM]; +#endif +#if defined(__ia64__) + __vaword* saptr; +#define __VA_FARG_NUM 8 + unsigned int fanum; + double farg[__VA_FARG_NUM]; +#endif +#if defined(__x86_64_sysv__) +#define __VA_FARG_NUM 8 + unsigned int fanum; + double farg[__VA_FARG_NUM]; +#define __VA_IARG_NUM 6 + unsigned int ianum; + __vaword iarg[__VA_IARG_NUM]; +#endif +#if defined(__x86_64_ms__) + int anum; +#define __VA_FARG_NUM 4 + float farg[__VA_FARG_NUM]; + double darg[__VA_FARG_NUM]; +#endif +#if defined(__s390__) && !defined(__s390x__) +#define __VA_IARG_NUM 5 + unsigned int ianum; + __vaword iarg[5]; +#define __VA_FARG_NUM 2 + unsigned int fanum; + float farg[__VA_FARG_NUM]; + double darg[__VA_FARG_NUM]; +#endif +#if defined(__s390x__) +#define __VA_IARG_NUM 5 + unsigned int ianum; + __vaword iarg[__VA_IARG_NUM]; +#define __VA_FARG_NUM 4 + unsigned int fanum; + float farg[__VA_FARG_NUM]; + double darg[__VA_FARG_NUM]; +#endif +#if defined(__riscv32__) || defined(__riscv64__) +#define __VA_IARG_NUM 8 + unsigned int ianum; + __vaword iarg[__VA_IARG_NUM]; + /* Note: iarg[7] == ((__vaword *) (initial aptr))[-1]. */ +#define __VA_FARG_NUM 8 + unsigned int fanum; + float farg[__VA_FARG_NUM]; + double darg[__VA_FARG_NUM]; +#endif +} __va_alist; + + +/* Avoid macro redefinition warnings on DragonFly BSD. */ +#undef __va_start +#undef __va_arg + + +/* + * Definition of the va_start_xxx macros. + */ + +#define __va_start(LIST,RETTYPE,FLAGS) \ + ((LIST)->flags = (FLAGS), \ + (LIST)->rtype = (RETTYPE) \ + ) + +/* + * va_start_struct: Preparing structure return. + */ +#define __va_start_struct(LIST,TYPE_SIZE,TYPE_ALIGN,TYPE_SPLITTABLE,FLAGS) \ + (__va_start(LIST,__VAstruct,FLAGS), \ + (LIST)->rsize = (TYPE_SIZE), \ + ((LIST)->flags & __VA_SUNPROCC_STRUCT_RETURN \ + ? __va_start_struct2(LIST) \ + : ((LIST)->flags & __VA_SUNCC_STRUCT_RETURN \ + ? ((TYPE_SIZE) <= sizeof(vacall_struct_buffer) || (vacall_error_struct_too_large(TYPE_SIZE), 0), \ + (LIST)->raddr = &vacall_struct_buffer, \ + 0 \ + ) \ + : (((LIST)->flags & __VA_SMALL_STRUCT_RETURN) \ + && __va_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ + ? ((LIST)->raddr = &(LIST)->tmp, \ + __va_start_struct1(LIST,TYPE_SIZE,TYPE_ALIGN,TYPE_SPLITTABLE) \ + ) \ + : __va_start_struct2(LIST) \ + )) ) ) +/* Determines whether a structure is returned in registers, + * depending on its size and its word-splittable flag. + */ +#if (defined(__i386__) && defined(_WIN32)) +#define __va_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ + ((TYPE_SIZE) == 1 || (TYPE_SIZE) == 2 || (TYPE_SIZE) == 4 \ + || ((TYPE_SIZE) == 8 \ + && (((LIST)->flags & __VA_MSVC_STRUCT_RETURN) \ + || ((TYPE_SPLITTABLE) \ + && ((LIST)->flags & __VA_GCC_STRUCT_RETURN) \ + ) ) ) ) +/* Turn on __VA_REGISTER_STRUCT_RETURN if __VA_SMALL_STRUCT_RETURN was set + * and the struct will actually be returned in registers. + */ +#define __va_start_struct1(LIST,TYPE_SIZE,TYPE_ALIGN,TYPE_SPLITTABLE) \ + ((LIST)->flags |= __VA_REGISTER_STRUCT_RETURN, 0) +#endif +#if (defined(__i386__) && !defined(_WIN32)) || defined(__m68k__) || (defined(__powerpc__) && !defined(__powerpc64__)) || (defined(__s390__) && !defined(__s390x__)) +#define __va_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ + ((TYPE_SIZE) == 1 || (TYPE_SIZE) == 2 || (TYPE_SIZE) == 4 \ + || ((TYPE_SIZE) == 8 && (TYPE_SPLITTABLE) \ + && ((LIST)->flags & __VA_GCC_STRUCT_RETURN) \ + ) ) +/* Turn on __VA_REGISTER_STRUCT_RETURN if __VA_SMALL_STRUCT_RETURN was set + * and the struct will actually be returned in registers. + */ +#define __va_start_struct1(LIST,TYPE_SIZE,TYPE_ALIGN,TYPE_SPLITTABLE) \ + ((LIST)->flags |= __VA_REGISTER_STRUCT_RETURN, 0) +#endif +#if defined(__arm__) || defined(__armhf__) +/* structs of size 3 also will be returned in register */ +#define __va_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ + ((TYPE_SIZE) <= 4) +/* Turn on __VA_REGISTER_STRUCT_RETURN if __VA_SMALL_STRUCT_RETURN was set + * and the struct will actually be returned in registers. + */ +#define __va_start_struct1(LIST,TYPE_SIZE,TYPE_ALIGN,TYPE_SPLITTABLE) \ + ((LIST)->flags |= __VA_REGISTER_STRUCT_RETURN, 0) +#endif +#if defined(__alpha__) +#define __va_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ + ((TYPE_SIZE) == 1 || (TYPE_SIZE) == 2 || (TYPE_SIZE) == 4 || (TYPE_SIZE) == 8 \ + || ((TYPE_SIZE) == 16 && (TYPE_SPLITTABLE) \ + && ((LIST)->flags & __VA_GCC_STRUCT_RETURN) \ + ) ) +/* Turn on __VA_REGISTER_STRUCT_RETURN if __VA_SMALL_STRUCT_RETURN was set + * and the struct will actually be returned in registers. + */ +#define __va_start_struct1(LIST,TYPE_SIZE,TYPE_ALIGN,TYPE_SPLITTABLE) \ + ((LIST)->flags |= __VA_REGISTER_STRUCT_RETURN, 0) +#endif +#if (defined(__hppa__) && !defined(__hppa64__)) || defined(__riscv32__) +#define __va_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ + ((TYPE_SIZE) <= 8) +/* Test __VA_SMALL_STRUCT_RETURN at run time. */ +#define __va_start_struct1(LIST,TYPE_SIZE,TYPE_ALIGN,TYPE_SPLITTABLE) \ + 0 +#endif +#if defined(__mips__) && !defined(__mipsn32__) && !defined(__mips64__) || (defined(__sparc__) && !defined(__sparc64__)) +#define __va_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ + ((TYPE_SIZE) == 1 || (TYPE_SIZE) == 2 || (TYPE_SIZE) == 4) +/* Test __VA_SMALL_STRUCT_RETURN instead of __VA_REGISTER_STRUCT_RETURN. */ +#if defined(__mips__) && !defined(__mipsn32__) && !defined(__mips64__) +#define __va_start_struct1(LIST,TYPE_SIZE,TYPE_ALIGN,TYPE_SPLITTABLE) \ + ((LIST)->anum++, \ + 0 \ + ) +#else +#define __va_start_struct1(LIST,TYPE_SIZE,TYPE_ALIGN,TYPE_SPLITTABLE) \ + 0 +#endif +#endif +#if defined(__mipsn32__) || defined(__mips64__) +#define __va_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ + ((LIST)->flags & __VA_GCC_STRUCT_RETURN \ + ? ((TYPE_SIZE) == 1 || (TYPE_SIZE) == 2 || (TYPE_SIZE) == 4 || (TYPE_SIZE) == 8) \ + : ((TYPE_SIZE) <= 16) \ + ) +/* Turn on __VA_REGISTER_STRUCT_RETURN if __VA_SMALL_STRUCT_RETURN was set + * and the struct will actually be returned in registers. Also turn on + * __VA_REGISTER_FLOATSTRUCT_RETURN or __VA_REGISTER_DOUBLESTRUCT_RETURN if + * the struct will be returned in floating-point registers. + */ +#define __va_start_struct1(LIST,TYPE_SIZE,TYPE_ALIGN,TYPE_SPLITTABLE) \ + ((LIST)->flags |= __VA_REGISTER_STRUCT_RETURN, \ + (TYPE_ALIGN) == sizeof(float) && (TYPE_SPLITTABLE) \ + && ((TYPE_SIZE) == sizeof(float) || (TYPE_SIZE) == 2*sizeof(float)) \ + && ((LIST)->flags |= __VA_REGISTER_FLOATSTRUCT_RETURN), \ + (TYPE_ALIGN) == sizeof(double) && (TYPE_SPLITTABLE) \ + && ((TYPE_SIZE) == sizeof(double) || (TYPE_SIZE) == 2*sizeof(double)) \ + && ((LIST)->flags |= __VA_REGISTER_DOUBLESTRUCT_RETURN), \ + 0) +#endif +#if (defined(__powerpc64__) && !defined(__powerpc64_elfv2__)) || defined(__s390x__) +#define __va_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ + 0 +#define __va_start_struct1(LIST,TYPE_SIZE,TYPE_ALIGN,TYPE_SPLITTABLE) \ + 0 +#endif +#if defined(__sparc64__) || defined(__ia64__) +#define __va_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ + ((TYPE_SIZE) <= 32) +/* Turn on __VA_REGISTER_STRUCT_RETURN if __VA_SMALL_STRUCT_RETURN was set + * and the struct will actually be returned in registers. + */ +#define __va_start_struct1(LIST,TYPE_SIZE,TYPE_ALIGN,TYPE_SPLITTABLE) \ + ((LIST)->flags |= __VA_REGISTER_STRUCT_RETURN, \ + 0) +#endif +#if defined(__hppa64__) || defined(__arm64__) || (defined(__powerpc64__) && defined(__powerpc64_elfv2__)) || defined(__x86_64_sysv__) || defined(__riscv64__) +#define __va_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ + ((TYPE_SIZE) <= 16) +/* Turn on __VA_REGISTER_STRUCT_RETURN if __VA_SMALL_STRUCT_RETURN was set + * and the struct will actually be returned in registers. + */ +#define __va_start_struct1(LIST,TYPE_SIZE,TYPE_ALIGN,TYPE_SPLITTABLE) \ + ((LIST)->flags |= __VA_REGISTER_STRUCT_RETURN, \ + 0) +#endif +#if defined(__x86_64_ms__) +#define __va_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ + ((TYPE_SIZE) == 1 || (TYPE_SIZE) == 2 || (TYPE_SIZE) == 4 || (TYPE_SIZE) == 8) +/* Turn on __VA_REGISTER_STRUCT_RETURN if __VA_SMALL_STRUCT_RETURN was set + * and the struct will actually be returned in registers. + */ +#define __va_start_struct1(LIST,TYPE_SIZE,TYPE_ALIGN,TYPE_SPLITTABLE) \ + ((LIST)->flags |= __VA_REGISTER_STRUCT_RETURN, \ + 0) +#endif +/* + * Preparing structure return in memory. + */ +#if defined(__i386__) || defined(__alpha__) || (defined(__arm__) && !defined(__armhf__)) || defined(__powerpc_aix__) || defined(__powerpc64__) +/* Return structure pointer is passed as first arg. */ +#define __va_start_struct2(LIST) \ + ((LIST)->raddr = *(void* *)((LIST)->aptr), \ + (LIST)->aptr += sizeof(void*), \ + 0 \ + ) +#endif +#if defined(__mips__) || defined(__mipsn32__) || defined(__mips64__) || defined(__sparc64__) || defined(__x86_64_ms__) +/* Return structure pointer is passed as first arg. */ +#define __va_start_struct2(LIST) \ + ((LIST)->raddr = *(void* *)((LIST)->aptr), \ + (LIST)->aptr += sizeof(void*), \ + (LIST)->anum++, \ + 0 \ + ) +#endif +#if defined(__armhf__) +/* Return structure pointer is passed as first arg. */ +#define __va_start_struct2(LIST) \ + ((LIST)->raddr = (void*)(LIST)->iarg[(LIST)->ianum], \ + (LIST)->ianum++, \ + 0 \ + ) +#endif +#if defined(__powerpc_sysv4__) || defined(__x86_64_sysv__) || defined(__s390__) || defined(__s390x__) || defined(__riscv32__) || defined(__riscv64__) +/* Return structure pointer is passed as first arg. */ +#define __va_start_struct2(LIST) \ + ((LIST)->raddr = (void*)((LIST)->iarg[(LIST)->ianum++]), \ + 0 \ + ) +#endif +#if defined(__m68k__) || (defined(__sparc__) && !defined(__sparc64__)) || defined(__hppa__) || defined(__hppa64__) || defined(__arm64__) || defined(__ia64__) +/* Return structure pointer is passed in a special register. */ +#define __va_start_struct2(LIST) \ + ((LIST)->raddr = (LIST)->structraddr, 0) +#endif + + +/* + * Definition of the va_arg_xxx macros. + */ + +/* Padding of non-struct arguments. */ +#define __va_argsize(TYPE_SIZE) \ + (((TYPE_SIZE) + sizeof(__vaword)-1) & -(intptr_t)sizeof(__vaword)) +#if defined(__i386__) || defined(__m68k__) || (defined(__mips__) && !defined(__mipsn32__) && !defined(__mips64__)) || (defined(__sparc__) && !defined(__sparc64__)) || defined(__alpha__) || (defined(__arm__) && !defined(__armhf__)) || defined(__arm64__) || defined(__powerpc_aix__) || defined(__powerpc64__) || defined(__ia64__) || defined(__x86_64_sysv__) || defined(__s390__) || defined(__s390x__) || defined(__riscv32__) || defined(__riscv64__) +/* args grow up */ +/* small structures < 1 word are adjusted depending on compiler */ +#define __va_arg_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + ((LIST)->aptr += __va_argsize(TYPE_SIZE), \ + (LIST)->aptr - __va_argsize(TYPE_SIZE) \ + ) +#define __va_arg_rightadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + ((LIST)->aptr += __va_argsize(TYPE_SIZE), \ + (LIST)->aptr - ((TYPE_SIZE) < sizeof(__vaword) \ + ? (TYPE_SIZE) \ + : __va_argsize(TYPE_SIZE) \ + ) \ + ) +#endif +#if defined(__armhf__) +/* args grow up */ +/* small structures < 1 word are adjusted depending on compiler */ +/* the first __VA_IARG_NUM argument words are passed in registers */ +#define __va_arg_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + (((LIST)->ianum + ((TYPE_SIZE) + sizeof(__vaword)-1) / sizeof(__vaword) <= __VA_IARG_NUM \ + ? ((LIST)->ianum += __va_argsize(TYPE_SIZE) / sizeof(__vaword), \ + (char*)&(LIST)->iarg[(LIST)->ianum] \ + ) \ + : (((LIST)->aptr == (uintptr_t)&(LIST)->iarg[__VA_IARG_NUM] \ + ? /* split case */ \ + ((LIST)->aptr = (uintptr_t)&(LIST)->iarg[(LIST)->ianum] + __va_argsize(TYPE_SIZE), \ + 0) \ + : ((LIST)->aptr += __va_argsize(TYPE_SIZE), \ + 0)), \ + (LIST)->ianum = __VA_IARG_NUM, \ + (char*)(LIST)->aptr \ + ) ) \ + - __va_argsize(TYPE_SIZE) \ + ) +#define __va_arg_rightadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + (((LIST)->ianum + ((TYPE_SIZE) + sizeof(__vaword)-1) / sizeof(__vaword) <= __VA_IARG_NUM \ + ? ((LIST)->ianum += __va_argsize(TYPE_SIZE) / sizeof(__vaword), \ + (char*)&(LIST)->iarg[(LIST)->ianum] \ + ) \ + : (((LIST)->aptr == (uintptr_t)&(LIST)->iarg[__VA_IARG_NUM] \ + ? /* split case */ \ + ((LIST)->aptr = (uintptr_t)&(LIST)->iarg[(LIST)->ianum] + __va_argsize(TYPE_SIZE), \ + 0) \ + : ((LIST)->aptr += __va_argsize(TYPE_SIZE), \ + 0)), \ + (LIST)->ianum = __VA_IARG_NUM, \ + (char*)(LIST)->aptr \ + ) ) \ + - ((TYPE_SIZE) < sizeof(__vaword) \ + ? (TYPE_SIZE) \ + : __va_argsize(TYPE_SIZE) \ + ) \ + ) +#endif +#if defined(__powerpc_sysv4__) +/* args grow up */ +/* small structures < 1 word are adjusted depending on compiler */ +/* the first __VA_IARG_NUM argument words are passed in registers */ +#define __va_arg_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + (((LIST)->ianum + ((TYPE_SIZE) + sizeof(__vaword)-1) / sizeof(__vaword) <= __VA_IARG_NUM \ + ? ((LIST)->ianum += __va_argsize(TYPE_SIZE) / sizeof(__vaword), \ + (char*)&(LIST)->iarg[(LIST)->ianum] \ + ) \ + : ((LIST)->aptr += __va_argsize(TYPE_SIZE), \ + (char*)(LIST)->aptr \ + ) ) \ + - __va_argsize(TYPE_SIZE) \ + ) +#define __va_arg_rightadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + (((LIST)->ianum + ((TYPE_SIZE) + sizeof(__vaword)-1) / sizeof(__vaword) <= __VA_IARG_NUM \ + ? ((LIST)->ianum += __va_argsize(TYPE_SIZE) / sizeof(__vaword), \ + (char*)&(LIST)->iarg[(LIST)->ianum] \ + ) \ + : ((LIST)->aptr += __va_argsize(TYPE_SIZE), \ + (char*)(LIST)->aptr \ + ) ) \ + - ((TYPE_SIZE) < sizeof(__vaword) \ + ? (TYPE_SIZE) \ + : __va_argsize(TYPE_SIZE) \ + ) \ + ) +#endif +#if defined(__mipsn32__) || defined(__mips64__) || defined(__sparc64__) || defined(__x86_64_ms__) +/* args grow up */ +/* small structures < 1 word are adjusted depending on compiler */ +#define __va_arg_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + ((LIST)->anum += __va_argsize(TYPE_SIZE)/sizeof(__vaword), \ + (LIST)->aptr += __va_argsize(TYPE_SIZE), \ + (LIST)->aptr - __va_argsize(TYPE_SIZE) \ + ) +#define __va_arg_rightadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + ((LIST)->anum += __va_argsize(TYPE_SIZE)/sizeof(__vaword), \ + (LIST)->aptr += __va_argsize(TYPE_SIZE), \ + (LIST)->aptr - ((TYPE_SIZE) < sizeof(__vaword) \ + ? (TYPE_SIZE) \ + : __va_argsize(TYPE_SIZE) \ + ) \ + ) +#endif +#if defined(__hppa__) && !defined(__hppa64__) +/* args grow down */ +#define __va_arg_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + ((LIST)->aptr = (LIST)->aptr - __va_argsize(TYPE_SIZE), \ + ((TYPE_SIZE) > 4 && ((LIST)->aptr &= -8)), \ + (LIST)->aptr \ + ) +#define __va_arg_rightadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + ((LIST)->aptr = (LIST)->aptr - __va_argsize(TYPE_SIZE), \ + ((TYPE_SIZE) > 4 && ((LIST)->aptr &= -8)), \ + (LIST)->aptr + ((-(TYPE_SIZE)) & 3) \ + ) +#endif +#if defined(__hppa64__) +/* args grow up */ +#define __va_arg_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + (((TYPE_SIZE) > 8 && ((LIST)->aptr = (((LIST)->aptr +15) & -16))), \ + (LIST)->aptr += __va_argsize(TYPE_SIZE), \ + (LIST)->aptr - __va_argsize(TYPE_SIZE) \ + ) +#define __va_arg_rightadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + (((TYPE_SIZE) > 8 && ((LIST)->aptr = (((LIST)->aptr +15) & -16))), \ + (LIST)->aptr += __va_argsize(TYPE_SIZE), \ + (LIST)->aptr - ((TYPE_SIZE) < sizeof(__vaword) \ + ? (TYPE_SIZE) \ + : __va_argsize(TYPE_SIZE) \ + ) \ + ) +#endif +#if defined(__i386__) || ((defined(__mipsn32__) || defined(__mips64__)) && defined(_MIPSEL)) || defined(__alpha__) || ((defined(__arm__) || defined(__armhf__)) && defined(__ARMEL__)) || defined(__ia64__) || (defined(__powerpc64__) && defined(_LITTLE_ENDIAN)) || defined(__x86_64_ms__) +/* little endian -> small args < 1 word are adjusted to the left */ +#define __va_arg_adjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + (void*)__va_arg_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) +#endif +#if defined(__m68k__) || ((defined(__mipsn32__) || defined(__mips64__)) && defined(_MIPSEB)) || defined(__sparc__) || defined(__sparc64__) || defined(__hppa__) || defined(__hppa64__) || ((defined(__arm__) || defined(__armhf__)) && !defined(__ARMEL__)) || (defined(__powerpc__) && !defined(__powerpc64__)) || (defined(__powerpc64__) && defined(_BIG_ENDIAN)) +/* big endian -> small args < 1 word are adjusted to the right */ +#define __va_arg_adjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + (void*)__va_arg_rightadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) +#endif +#if defined(__mips__) && !defined(__mipsn32__) && !defined(__mips64__) +#ifdef _MIPSEB +/* big endian -> small args < 1 word are adjusted to the right */ +#define __va_arg_adjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + ((LIST)->anum++, \ + (void*)__va_arg_rightadjusted(LIST,TYPE_SIZE,TYPE_ALIGN)) +#else /* _MIPSEL */ +/* little endian -> small args < 1 word are adjusted to the left */ +#define __va_arg_adjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + ((LIST)->anum++, \ + (void*)__va_arg_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN)) +#endif +#endif +#if defined(__arm64__) +/* the first __VA_IARG_NUM argument words are passed in registers */ +#define __va_arg_adjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + ((LIST)->ianum + ((TYPE_SIZE) + sizeof(__vaword)-1) / sizeof(__vaword) <= __VA_IARG_NUM \ + ? ((LIST)->ianum += ((TYPE_SIZE) + sizeof(__vaword)-1) / sizeof(__vaword), \ + &(LIST)->iarg[(LIST)->ianum - ((TYPE_SIZE) + sizeof(__vaword)-1) / sizeof(__vaword)] \ + ) \ + : ((LIST)->ianum = __VA_IARG_NUM, \ + (void*)__va_arg_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + ) ) +#endif +#if defined(__x86_64_sysv__) +/* the first __VA_IARG_NUM argument words are passed in registers */ +#define __va_arg_adjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + (((TYPE_SIZE) <= 2*sizeof(__vaword) \ + && (LIST)->ianum + ((TYPE_SIZE) + sizeof(__vaword)-1) / sizeof(__vaword) <= __VA_IARG_NUM) \ + ? ((LIST)->ianum += ((TYPE_SIZE) + sizeof(__vaword)-1) / sizeof(__vaword), \ + &(LIST)->iarg[(LIST)->ianum - ((TYPE_SIZE) + sizeof(__vaword)-1) / sizeof(__vaword)] \ + ) \ + : (void*)__va_arg_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + ) +#endif +#if defined(__s390__) || defined(__s390x__) +/* the first __VA_IARG_NUM argument words are passed in registers */ +#define __va_arg_adjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + ((LIST)->ianum + ((TYPE_SIZE) + sizeof(__vaword)-1) / sizeof(__vaword) <= __VA_IARG_NUM \ + ? ((LIST)->ianum += ((TYPE_SIZE) + sizeof(__vaword)-1) / sizeof(__vaword), \ + (void*)((uintptr_t)&(LIST)->iarg[(LIST)->ianum] - (TYPE_SIZE)) \ + ) \ + : ((LIST)->ianum = __VA_IARG_NUM, \ + (void*)__va_arg_rightadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + ) ) +#endif +#if defined(__riscv32__) || defined(__riscv64__) +/* the first __VA_IARG_NUM argument words are passed in registers */ +#define __va_arg_adjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + ((LIST)->ianum + ((TYPE_SIZE) + sizeof(__vaword)-1) / sizeof(__vaword) <= __VA_IARG_NUM \ + ? ((LIST)->ianum += ((TYPE_SIZE) + sizeof(__vaword)-1) / sizeof(__vaword), \ + &(LIST)->iarg[(LIST)->ianum - ((TYPE_SIZE) + sizeof(__vaword)-1) / sizeof(__vaword)] \ + ) \ + : (((LIST)->ianum < __VA_IARG_NUM \ + ? ((LIST)->aptr -= (__VA_IARG_NUM - (LIST)->ianum) * sizeof(__vaword), \ + (LIST)->ianum = __VA_IARG_NUM, \ + 0) \ + : 0), \ + (void*)__va_arg_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + ) ) +#endif +#define __va_arg(LIST,TYPE) \ + *(TYPE*)__va_arg_adjusted(LIST,sizeof(TYPE),__VA_alignof(TYPE)) + +/* Integer arguments. */ + +#define _va_arg_char(LIST) __va_arg(LIST,char) +#define _va_arg_schar(LIST) __va_arg(LIST,signed char) +#define _va_arg_uchar(LIST) __va_arg(LIST,unsigned char) +#define _va_arg_short(LIST) __va_arg(LIST,short) +#define _va_arg_ushort(LIST) __va_arg(LIST,unsigned short) +#define _va_arg_int(LIST) __va_arg(LIST,int) +#define _va_arg_uint(LIST) __va_arg(LIST,unsigned int) +#define _va_arg_long(LIST) __va_arg(LIST,long) +#define _va_arg_ulong(LIST) __va_arg(LIST,unsigned long) + +#if defined(__mips64__) || defined(__sparc64__) || defined(__alpha__) || defined(__hppa64__) || defined(__arm64__) || defined(__powerpc64__) || defined(__ia64__) || (defined(__x86_64__) && !defined(__x86_64_x32__) && !defined(__VA_LLP64)) || defined(__s390x__) || defined(__riscv64__) +/* ‘long long’ and ‘long’ are identical. */ +#define _va_arg_longlong _va_arg_long +#define _va_arg_ulonglong _va_arg_ulong +#elif defined(__mipsn32__) || defined(__x86_64_x32__) || (defined(__x86_64__) && defined(__VA_LLP64)) +/* ‘long long’ fits in __vaword. */ +#define _va_arg_longlong(LIST) __va_arg(LIST,long long) +#define _va_arg_ulonglong(LIST) __va_arg(LIST,unsigned long long) +#elif defined(__i386__) || defined(__m68k__) || defined(__mips__) || (defined(__sparc__) && !defined(__sparc64__)) || (defined(__hppa__) && !defined(__hppa64__)) || defined(__arm__) || defined(__armhf__) || defined(__powerpc__) || (defined(__s390__) && !defined(__s390x__)) || defined(__riscv32__) +/* ‘long long’s are passed embedded on the arg stack. */ +#define _va_arg_longlong(LIST) __va_arg_longlong(LIST,long long) +#define _va_arg_ulonglong(LIST) __va_arg_longlong(LIST,unsigned long long) +#if defined(__i386__) || defined(__m68k__) || defined(__powerpc_aix__) +/* ‘long long’s are (at most) word-aligned. */ +#define __va_arg_longlong(LIST,TYPE) __va_arg(LIST,TYPE) +#endif +#if defined(__mips__) || defined(__arm__) +/* ‘long long’s have alignment 8. */ +#define __va_arg_longlong(LIST,TYPE) \ + ((LIST)->aptr = (((LIST)->aptr+__VA_alignof(TYPE)-1) & -(intptr_t)__VA_alignof(TYPE)), \ + __va_arg(LIST,TYPE)) +#endif +#if defined(__armhf__) || defined(__powerpc_sysv4__) +/* ‘long long’s have alignment 8. */ +#define __va_arg_longlong(LIST,TYPE) \ + (((LIST)->ianum < __VA_IARG_NUM \ + ? ((LIST)->ianum = (((LIST)->ianum+__VA_alignof(TYPE)/sizeof(__vaword)-1) & -(intptr_t)(__VA_alignof(TYPE)/sizeof(__vaword))), 0) \ + : ((LIST)->aptr = (((LIST)->aptr+__VA_alignof(TYPE)-1) & -(intptr_t)__VA_alignof(TYPE)), 0) \ + ), \ + __va_arg(LIST,TYPE)) +#endif +#if (defined(__s390__) && !defined(__s390x__)) || defined(__riscv32__) +/* Within the arg stack, the alignment is only 4, not 8. */ +#define __va_arg_longlong(LIST,TYPE) __va_arg(LIST,TYPE) +#endif +#if (defined(__sparc__) && !defined(__sparc64__)) +/* Within the arg stack, the alignment is only 4, not 8. */ +/* Beware against unaligned accesses! */ +#define __va_arg_longlong(LIST,TYPE) \ + ((LIST)->tmp._words[0] = ((__vaword*)((LIST)->aptr))[0], \ + (LIST)->tmp._words[1] = ((__vaword*)((LIST)->aptr))[1], \ + (LIST)->aptr += sizeof(TYPE), \ + (TYPE)((LIST)->tmp._longlong) \ + ) +#endif +#if defined(__hppa__) && !defined(__hppa64__) +/* ‘long long’s have alignment 8. */ +#define __va_arg_longlong(LIST,TYPE) \ + ((LIST)->aptr = ((LIST)->aptr & -(intptr_t)__VA_alignof(TYPE)), \ + __va_arg(LIST,TYPE)) +#endif +#endif + +/* Floating point arguments. */ + +#if defined(__i386__) || defined(__m68k__) || defined(__mipsn32__) || defined(__mips64__) || defined(__sparc__) || defined(__sparc64__) || defined(__alpha__) || defined(__hppa64__) || defined(__arm64__) || defined(__powerpc__) || defined(__powerpc64__) || defined(__ia64__) || defined(__x86_64__) || defined(__s390__) || defined(__s390x__) || defined(__riscv32__) || defined(__riscv64__) +#define __va_align_double(LIST) +#endif +#if defined(__mips__) && !defined(__mipsn32__) && !defined(__mips64__) || defined(__arm__) || defined(__armhf__) +/* __VA_alignof(double) > sizeof(__vaword) */ +#define __va_align_double(LIST) \ + (LIST)->aptr = ((LIST)->aptr + sizeof(double)-1) & -(intptr_t)sizeof(double), +#endif +#if defined(__hppa__) && !defined(__hppa64__) +#define __va_align_double(LIST) \ + (LIST)->aptr = (LIST)->aptr & -(intptr_t)sizeof(double), +#endif + +#if defined(__sparc__) && !defined(__sparc64__) +/* Beware against unaligned ‘double’ accesses! */ +#define _va_arg_double(LIST) \ + (__va_align_double(LIST) \ + (LIST)->tmp._words[0] = ((__vaword*)((LIST)->aptr))[0], \ + (LIST)->tmp._words[1] = ((__vaword*)((LIST)->aptr))[1], \ + (LIST)->aptr += sizeof(double), \ + (LIST)->tmp._double \ + ) +#endif +#if defined(__alpha__) +/* The first 6 floating point registers have been stored in another place. */ +#define _va_arg_double(LIST) \ + (((LIST)->aptr += sizeof(double)) <= (LIST)->memargptr \ + ? *(double*)((LIST)->aptr - sizeof(double) + (LIST)->farg_offset) \ + : *(double*)((LIST)->aptr - sizeof(double)) \ + ) +#define _va_arg_float(LIST) \ + (((LIST)->aptr += sizeof(double)) <= (LIST)->memargptr \ + ? /* The first 6 args have been put into memory by "stt" instructions */\ + /* (see vacall-alpha.s!). Therefore load them as doubles. */ \ + /* When viewed as floats, the value will be the correct one. */ \ + (float)*(double*)((LIST)->aptr - sizeof(double) + (LIST)->farg_offset) \ + : /* These args have been put into memory by "sts" instructions, */ \ + /* therefore load them as floats. */ \ + *(float*)((LIST)->aptr - sizeof(double)) \ + ) +#endif +#if defined(__hppa__) && !defined(__hppa64__) +/* The floats and doubles among the first 4 argument words are passed + * - in both general registers and floating-point registers when the + * function call is a variadic one, which means: + * - for HP cc: the call is done through a function pointer or + * directly to a function declared with a varargs prototype, + * - for GCC: the function's type is a varargs function. + * - in floating-point registers otherwise. + * Since the code in tests.c uses a function pointer, casted to a non-varargs + * function type, we are in the first case for HP cc, but in the second case + * for GCC. + * Therefore we need to take the values from the floating-point registers. + */ +#define _va_arg_float(LIST) \ + (((LIST)->aptr -= sizeof(float)) >= (LIST)->memargptr \ + ? /* The first 4 float args are stored separately. */ \ + *(float*)((LIST)->aptr + (LIST)->farg_offset) \ + : *(float*)((LIST)->aptr) \ + ) +#define _va_arg_double(LIST) \ + (__va_align_double(LIST) \ + (((LIST)->aptr -= sizeof(double)) >= (LIST)->memargptr \ + ? /* The first 2 double args are stored separately. */ \ + *(double*)((LIST)->aptr + (LIST)->darg_offset) \ + : *(double*)((LIST)->aptr) \ + )) +#endif +#if defined(__mips__) && !defined(__mipsn32__) && !defined(__mips64__) +/* The first 0,1,2 registers are stored elsewhere if they are floating-point + * parameters. + */ +#define _va_arg_float(LIST) \ + ((LIST)->aptr += sizeof(float), \ + (LIST)->anum++, \ + (LIST)->fanum++, \ + ((LIST)->anum == (LIST)->fanum && (LIST)->fanum <= __VA_FARG_NUM \ + ? /* only floating-point arguments so far */ \ + (LIST)->farg[(LIST)->fanum - 1] \ + : *(float*)((LIST)->aptr - sizeof(float)) \ + )) +#define _va_arg_double(LIST) \ + (__va_align_double(LIST) \ + (LIST)->aptr += sizeof(double), \ + (LIST)->anum++, \ + (LIST)->fanum++, \ + ((LIST)->anum == (LIST)->fanum && (LIST)->fanum <= __VA_FARG_NUM \ + ? /* only floating-point arguments so far */ \ + (LIST)->darg[(LIST)->fanum - 1] \ + : *(double*)((LIST)->aptr - sizeof(double)) \ + )) +#endif +#if defined(__mipsn32__) || defined(__mips64__) || defined(__x86_64_ms__) +/* The first 0,..,8 registers are stored elsewhere if they are floating-point + * parameters. + */ +#define _va_arg_float(LIST) \ + (__va_align_double(LIST) \ + (LIST)->aptr += sizeof(double), \ + (++(LIST)->anum <= __VA_FARG_NUM \ + ? (LIST)->farg[(LIST)->anum - 1] \ + : *(float*)((LIST)->aptr - sizeof(double)) \ + )) +#define _va_arg_double(LIST) \ + (__va_align_double(LIST) \ + (LIST)->aptr += sizeof(double), \ + (++(LIST)->anum <= __VA_FARG_NUM \ + ? (LIST)->darg[(LIST)->anum - 1] \ + : *(double*)((LIST)->aptr - sizeof(double)) \ + )) +#endif +#if defined(__sparc64__) +/* The first 0,..,16 registers are stored elsewhere if they are floating-point + * parameters. + */ +#define _va_arg_float(LIST) \ + (__va_align_double(LIST) \ + (LIST)->aptr += sizeof(double), \ + (++(LIST)->anum <= 16 \ + ? (LIST)->farg[(LIST)->anum - 1] \ + : *(float*)((LIST)->aptr - sizeof(float)) \ + )) +#define _va_arg_double(LIST) \ + (__va_align_double(LIST) \ + (LIST)->aptr += sizeof(double), \ + (++(LIST)->anum <= 16 \ + ? (LIST)->darg[(LIST)->anum - 1] \ + : *(double*)((LIST)->aptr - sizeof(double)) \ + )) +#endif +#if defined(__hppa64__) +/* The floating-point arguments among the first 8 argument words have been + stored elsewhere. */ +#define _va_arg_float(LIST) \ + ((LIST)->aptr += sizeof(double), \ + ((LIST)->aptr <= (LIST)->memargptr \ + ? (LIST)->farg[__VA_FARG_NUM-1-((LIST)->memargptr - (LIST)->aptr)/sizeof(__vaword)] \ + : ((float*)(LIST)->aptr)[-1] \ + )) +#define _va_arg_double(LIST) \ + ((LIST)->aptr += sizeof(double), \ + ((LIST)->aptr <= (LIST)->memargptr \ + ? (LIST)->darg[__VA_FARG_NUM-1-((LIST)->memargptr - (LIST)->aptr)/sizeof(__vaword)] \ + : ((double*)(LIST)->aptr)[-1] \ + )) +#endif +#if defined(__armhf__) +#define _va_arg_float(LIST) \ + ((LIST)->fanum <= 15 \ + ? (LIST)->farg[(LIST)->fanum++] \ + : ((LIST)->aptr += sizeof(float), \ + *(float*)((LIST)->aptr - sizeof(float)) \ + ) ) +#define _va_arg_double(LIST) \ + (((LIST)->fanum % 2 ? (LIST)->fanum++ : 0), \ + ((LIST)->fanum <= 14 \ + ? ((LIST)->fanum += 2, (LIST)->darg[(LIST)->fanum / 2 - 1]) \ + : ((LIST)->aptr += sizeof(double), \ + *(double*)((LIST)->aptr - sizeof(double)) \ + )) ) +#endif +#if defined(__arm64__) +/* The first __VA_FARG_NUM floating-point args have been stored elsewhere. */ +#define _va_arg_float(LIST) \ + ((LIST)->fanum < __VA_FARG_NUM \ + ? (LIST)->farg[(LIST)->fanum++] \ + : ((LIST)->aptr += sizeof(__vaword), \ + *(float*)((LIST)->aptr - sizeof(__vaword)) \ + ) ) +#define _va_arg_double(LIST) \ + ((LIST)->fanum < __VA_FARG_NUM \ + ? (LIST)->darg[(LIST)->fanum++] \ + : ((LIST)->aptr += sizeof(__vaword), \ + *(double*)((LIST)->aptr - sizeof(__vaword)) \ + ) ) +#endif +#if defined(__powerpc_aix__) +/* The first __VA_FARG_NUM floating-point args have been stored elsewhere. */ +#define _va_arg_float(LIST) \ + ((LIST)->aptr += sizeof(float), \ + ((LIST)->fanum < __VA_FARG_NUM \ + ? (float) (LIST)->farg[(LIST)->fanum++] \ + : *(float*)((LIST)->aptr - sizeof(float)) \ + )) +#define _va_arg_double(LIST) \ + (__va_align_double(LIST) \ + (LIST)->aptr += sizeof(double), \ + ((LIST)->fanum < __VA_FARG_NUM \ + ? (LIST)->farg[(LIST)->fanum++] \ + : *(double*)((LIST)->aptr - sizeof(double)) \ + )) +#endif +#if defined(__powerpc_sysv4__) +/* The first __VA_FARG_NUM floating-point args have been stored elsewhere. */ +#define _va_arg_float(LIST) \ + ((LIST)->fanum < __VA_FARG_NUM \ + ? (float) (LIST)->farg[(LIST)->fanum++] \ + : ((LIST)->aptr += sizeof(float), \ + *(float*)((LIST)->aptr - sizeof(float)) \ + ) ) +#define _va_arg_double(LIST) \ + ((LIST)->fanum < __VA_FARG_NUM \ + ? (LIST)->farg[(LIST)->fanum++] \ + : (__va_align_double(LIST) \ + (LIST)->aptr += sizeof(double), \ + *(double*)((LIST)->aptr - sizeof(double)) \ + ) ) +#endif +#if defined(__powerpc64__) +/* The first __VA_FARG_NUM floating-point args have been stored elsewhere. */ +#if defined(_AIX) +#define _va_arg_float(LIST) \ + ((LIST)->aptr += sizeof(__vaword), \ + ((LIST)->fanum < __VA_FARG_NUM \ + ? (float) (LIST)->farg[(LIST)->fanum++] \ + : ((float*)(LIST)->aptr)[(LIST)->flags & __VA_AIXCC_FLOAT_ARGS ? -2 : -1] \ + )) +#elif defined(_LITTLE_ENDIAN) +#define _va_arg_float(LIST) \ + ((LIST)->aptr += sizeof(__vaword), \ + ((LIST)->fanum < __VA_FARG_NUM \ + ? (float) (LIST)->farg[(LIST)->fanum++] \ + : ((float*)(LIST)->aptr)[-2] \ + )) +#else /* _BIG_ENDIAN */ +#define _va_arg_float(LIST) \ + ((LIST)->aptr += sizeof(__vaword), \ + ((LIST)->fanum < __VA_FARG_NUM \ + ? (float) (LIST)->farg[(LIST)->fanum++] \ + : ((float*)(LIST)->aptr)[-1] \ + )) +#endif +#define _va_arg_double(LIST) \ + (__va_align_double(LIST) \ + (LIST)->aptr += sizeof(double), \ + ((LIST)->fanum < __VA_FARG_NUM \ + ? (LIST)->farg[(LIST)->fanum++] \ + : *(double*)((LIST)->aptr - sizeof(double)) \ + )) +#endif +#if defined(__ia64__) +/* The first 8 floating-point args have been stored elsewhere. */ +#define _va_arg_float(LIST) \ + ((LIST)->aptr += sizeof(__vaword), \ + ((LIST)->fanum < __VA_FARG_NUM \ + ? (float) (LIST)->farg[(LIST)->fanum++] \ + : *(float*)((LIST)->aptr - sizeof(__vaword)) \ + )) +#define _va_arg_double(LIST) \ + (__va_align_double(LIST) \ + (LIST)->aptr += sizeof(double), \ + ((LIST)->fanum < __VA_FARG_NUM \ + ? (LIST)->farg[(LIST)->fanum++] \ + : *(double*)((LIST)->aptr - sizeof(double)) \ + )) +#endif +#if defined(__x86_64_sysv__) +/* The first 8 floating-point args have been stored elsewhere. */ +#define _va_arg_float(LIST) \ + ((LIST)->fanum < __VA_FARG_NUM \ + ? *(float*)&(LIST)->farg[(LIST)->fanum++] \ + : ((LIST)->aptr += sizeof(__vaword), \ + *(float*)((LIST)->aptr - sizeof(__vaword)) \ + ) ) +#define _va_arg_double(LIST) \ + ((LIST)->fanum < __VA_FARG_NUM \ + ? (LIST)->farg[(LIST)->fanum++] \ + : ((LIST)->aptr += sizeof(__vaword), \ + *(double*)((LIST)->aptr - sizeof(__vaword)) \ + ) ) +#endif +#if defined(__s390__) || defined(__s390x__) +/* The first __VA_FARG_NUM floating-point args have been stored elsewhere. */ +#define _va_arg_float(LIST) \ + ((LIST)->fanum < __VA_FARG_NUM \ + ? (LIST)->farg[(LIST)->fanum++] \ + : ((LIST)->aptr += sizeof(__vaword), \ + ((float*)(LIST)->aptr)[-1] \ + ) ) +#define _va_arg_double(LIST) \ + ((LIST)->fanum < __VA_FARG_NUM \ + ? (LIST)->darg[(LIST)->fanum++] \ + : ((LIST)->aptr += sizeof(double), \ + *(double*)((LIST)->aptr - sizeof(double)) \ + ) ) +#endif +#if defined(__riscv32__) || defined(__riscv64__) +/* The first __VA_FARG_NUM floating-point args have been stored elsewhere. */ +#define _va_arg_float(LIST) \ + ((LIST)->fanum < __VA_FARG_NUM \ + ? (LIST)->farg[(LIST)->fanum++] \ + : __va_arg((LIST),float) \ + ) +#define _va_arg_double(LIST) \ + ((LIST)->fanum < __VA_FARG_NUM \ + ? (LIST)->darg[(LIST)->fanum++] \ + : __va_arg((LIST),double) \ + ) +#endif +#ifndef _va_arg_float +#define _va_arg_float(LIST) __va_arg(LIST,float) +#endif +#ifndef _va_arg_double +#define _va_arg_double(LIST) \ + (__va_align_double(LIST) __va_arg(LIST,double)) +#endif + +/* Pointer arguments. */ +#define _va_arg_ptr(LIST) __va_arg(LIST,void*) + +/* Structure arguments. */ +/* Structure argument alignment. */ +#if defined(__i386__) && defined(_MSC_VER) +/* In MSVC, doubles inside structures have alignment 8, i.e. + * __VA_alignof(double) = 8, but doubles (and also structures containing + * doubles) are passed on the stack with alignment 4. Looks really weird. + */ +#define __va_struct_alignment(TYPE_ALIGN) \ + ((TYPE_ALIGN) <= 4 ? (TYPE_ALIGN) : 4) +#else +#define __va_struct_alignment(TYPE_ALIGN) \ + (TYPE_ALIGN) +#endif +#define __va_align_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ + (LIST)->aptr = ((LIST)->aptr + __va_struct_alignment(TYPE_ALIGN)-1) & -(intptr_t)__va_struct_alignment(TYPE_ALIGN), +#if defined(__i386__) || defined(__m68k__) || defined(__alpha__) || defined(__arm__) || defined(__armhf__) || (defined(__powerpc64__) && !defined(_AIX)) || defined(__x86_64_sysv__) +#define __va_arg_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ + (__va_align_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ + __va_arg_adjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + ) +#endif +#if defined(__mips__) && !defined(__mipsn32__) && !defined(__mips64__) +/* small structures < 1 word are adjusted depending on compiler */ +#define __va_arg_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ + (__va_align_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ + ((LIST)->flags & __VA_SGICC_STRUCT_ARGS \ + ? /* SGI MIPS cc passes small structures left-adjusted, although big-endian! */\ + (void*)__va_arg_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + : /* SGI MIPS gcc passes small structures within the first four words left- \ + * adjusted, for compatibility with cc. But structures in memory are passed \ + * right-adjusted!! See gcc-2.6.3/config/mips/mips.c:function_arg(). \ + */ \ + ((LIST)->aptr < (LIST)->memargptr \ + ? (void*)__va_arg_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + : (void*)__va_arg_rightadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + )) ) +#endif +#if defined(__mipsn32__) || defined(__mips64__) +/* small structures < 1 word are adjusted depending on compiler */ +#define __va_arg_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ + (__va_align_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ + ((LIST)->flags & __VA_SGICC_STRUCT_ARGS \ + ? /* SGI MIPS cc and gcc >= 3.4 passes small structures left-adjusted, although big-endian! */\ + (void*)__va_arg_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + : /* SGI MIPS gcc < 3.4 passes small structures right-adjusted. */ \ + (void*)__va_arg_rightadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + )) +#endif +#if defined(__powerpc_aix__) || (defined(__powerpc64__) && defined(_AIX)) +/* small structures < 1 word are adjusted depending on compiler */ +#define __va_arg_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ + (__va_align_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ + ((LIST)->flags & __VA_AIXCC_STRUCT_ARGS \ + ? /* AIX cc and xlc pass small structures left-adjusted, although big-endian! */\ + (void*)__va_arg_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + : /* gcc passes small structures right-adjusted. */ \ + (void*)__va_arg_rightadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + )) +#endif +#if defined(__powerpc_sysv4__) +/* Structures are passed as pointers to caller-made local copies. */ +#define __va_arg_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ + va_arg_ptr(LIST,void*) +#endif +#if defined(__sparc__) && !defined(__sparc64__) +/* Structures are passed as pointers to caller-made local copies. */ +#define __va_arg_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ + va_arg_ptr(LIST,void*) +#endif +#if defined(__sparc64__) +/* Small structures are passed left-adjusted, although big-endian! */ +/* Big structures are passed as pointers to caller-made local copies. */ +#define __va_arg_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ + ((TYPE_SIZE) <= 16 \ + ? (__va_align_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ + (void*)__va_arg_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN)) \ + : va_arg_ptr(LIST,void*) \ + ) +#endif +#if defined(__hppa64__) +/* Structures are passed left-adjusted (although big-endian!). */ +#define __va_arg_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ + (__va_align_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ + (void*)__va_arg_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + ) +#endif +#if defined(__arm64__) || defined(__riscv32__) || defined(__riscv64__) +/* Small structures are passed in registers or on the stack. */ +/* Big structures are passed as pointers to caller-made local copies. */ +#define __va_arg_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ + ((TYPE_SIZE) <= 2*sizeof(__vaword) \ + ? (void*)__va_arg_adjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + : va_arg_ptr(LIST,void*) \ + ) +#endif +#if defined(__x86_64_ms__) || defined(__s390__) || defined(__s390x__) +/* Structures of 1, 2, 4, 8 bytes are passed as embedded copies on the arg stack. + * Big structures are passed as pointers to caller-made local copies. + */ +#define __va_arg_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ + ((TYPE_SIZE) == 1 || (TYPE_SIZE) == 2 || (TYPE_SIZE) == 4 || (TYPE_SIZE) == 8 \ + ? (void*)__va_arg_adjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + : va_arg_ptr(LIST,void*) \ + ) +#endif +#if defined(__hppa__) && !defined(__hppa64__) +/* Structures <= 8 bytes are passed as embedded copies on the arg stack. + * Big structures are passed as pointers (to caller-made local copies + * with GCC >= 8, without copy otherwise). + */ +#define __va_arg_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ + ((TYPE_SIZE) > 8 \ + ? va_arg_ptr(LIST,void*) \ + : /* FIXME: gcc-2.6.3 passes structures <= 4 bytes in memory left-adjusted! ?? */\ + (void*)__va_arg_rightadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + ) +#endif +#if defined(__ia64__) +/* With GCC < 3, types larger than a word have 2-word alignment. */ +#define __va_arg_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ + (__va_align_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ + (((LIST)->flags & __VA_OLDGCC_STRUCT_ARGS) && (TYPE_SIZE) > sizeof(__vaword) && (((__vaword*)(LIST)->aptr - (LIST)->saptr) & 1) ? (LIST)->aptr += sizeof(__vaword) : 0), \ + __va_arg_adjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + ) +#endif + + +/* + * Definition of the va_return_xxx macros. + */ +#define __va_return(LIST,RETTYPE) \ + (((LIST)->rtype == (RETTYPE)) || (vacall_error_type_mismatch((LIST)->rtype,RETTYPE), 0)) +#define _va_return_void(LIST) \ + __va_return(LIST,__VAvoid) +#define _va_return_char(LIST,VAL) \ + (__va_return(LIST,__VAchar), (LIST)->tmp._char = (VAL)) +#define _va_return_schar(LIST,VAL) \ + (__va_return(LIST,__VAschar), (LIST)->tmp._schar = (VAL)) +#define _va_return_uchar(LIST,VAL) \ + (__va_return(LIST,__VAuchar), (LIST)->tmp._uchar = (VAL)) +#define _va_return_short(LIST,VAL) \ + (__va_return(LIST,__VAshort), (LIST)->tmp._short = (VAL)) +#define _va_return_ushort(LIST,VAL) \ + (__va_return(LIST,__VAushort), (LIST)->tmp._ushort = (VAL)) +#define _va_return_int(LIST,VAL) \ + (__va_return(LIST,__VAint), (LIST)->tmp._int = (VAL)) +#define _va_return_uint(LIST,VAL) \ + (__va_return(LIST,__VAuint), (LIST)->tmp._uint = (VAL)) +#define _va_return_long(LIST,VAL) \ + (__va_return(LIST,__VAlong), (LIST)->tmp._long = (VAL)) +#define _va_return_ulong(LIST,VAL) \ + (__va_return(LIST,__VAulong), (LIST)->tmp._ulong = (VAL)) +#if defined(__mips64__) || defined(__sparc64__) || defined(__alpha__) || defined(__hppa64__) || defined(__arm64__) || defined(__powerpc64__) || defined(__ia64__) || (defined(__x86_64__) && !defined(__x86_64_x32__) && !defined(__VA_LLP64)) || defined(__riscv64__) +#define _va_return_longlong(LIST,VAL) \ + (__va_return(LIST,__VAlonglong), (LIST)->tmp._long = (VAL)) +#define _va_return_ulonglong(LIST,VAL) \ + (__va_return(LIST,__VAulonglong), (LIST)->tmp._ulong = (VAL)) +#else +#define _va_return_longlong(LIST,VAL) \ + (__va_return(LIST,__VAlonglong), (LIST)->tmp._longlong = (VAL)) +#define _va_return_ulonglong(LIST,VAL) \ + (__va_return(LIST,__VAulonglong), (LIST)->tmp._ulonglong = (VAL)) +#endif +#define _va_return_float(LIST,VAL) \ + (__va_return(LIST,__VAfloat), (LIST)->tmp._float = (VAL)) +#define _va_return_double(LIST,VAL) \ + (__va_return(LIST,__VAdouble), (LIST)->tmp._double = (VAL)) +#define _va_return_ptr(LIST,VAL) \ + (__va_return(LIST,__VAvoidp), (LIST)->tmp._ptr = (VAL)) +#define __va_return_struct(LIST,TYPE_SIZE,TYPE_ALIGN,VAL_ADDR) \ + (__va_return(LIST,__VAstruct), \ + vacall_structcpy((void*)((LIST)->raddr),VAL_ADDR,TYPE_SIZE,TYPE_ALIGN) \ + ) + + +/* + * Miscellaneous declarations. + */ +extern void vacall_structcpy (void* dest, const void* src, unsigned long size, unsigned long alignment); + + +#endif /* _VACALL_INTERNAL_H */ diff --git a/vacall/vacall-libapi.c b/vacall/vacall-libapi.c new file mode 100644 index 0000000..385e7be --- /dev/null +++ b/vacall/vacall-libapi.c @@ -0,0 +1,232 @@ +/* + * Copyright 1995-2018 Bruno Haible + * + * 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, see . + */ + +#include "config.h" +#include +#include +#include + +#include "vacall-internal.h" + +/* This is the implementation of the library API. + The symbols that the linker sees are all prefixed with 'vacall', + to avoid potential collisions with other libraries. */ + +#ifndef REENTRANT + +/* This is the function pointer vacall(). A function pointer indirection is + needed because gcc-3.4 generates invalid code when the address of a symbol + is casted to a function pointer with different return type. + (https://gcc.gnu.org/ml/gcc-patches/2003-12/msg01767.html) */ +#ifdef __cplusplus +extern "C" void vacall_receiver (); /* the return type is variable, not void! */ +#else +extern void vacall_receiver (); /* the return type is variable, not void! */ +#endif +void (*vacall) () = vacall_receiver; + +/* This is the function called by vacall(). */ +void (* vacall_function) (va_alist); + +#endif + +/* Room for returning structs according to the Sun C non-reentrant struct return convention. */ +typedef union { __vaword room[__VA_ALIST_WORDS]; double align; } __va_struct_buffer_t; +static __va_struct_buffer_t vacall_struct_buffer; + +static _Noreturn void +vacall_error_type_mismatch (enum __VAtype start_type, enum __VAtype return_type) +{ + /* If you see this, fix your code. */ + fprintf (stderr, "vacall: va_start type %d and va_return type %d disagree.\n", + (int)start_type, (int)return_type); + abort(); +} + +static _Noreturn void +vacall_error_struct_too_large (unsigned int size) +{ + /* If you see this, increase __VA_ALIST_WORDS: */ + fprintf (stderr, "vacall: struct of size %u too large for Sun C struct return.\n", + size); + abort(); +} + +void vacall_start (va_alist list, int rettype, int flags) +{ + __va_start(list,rettype,flags); +} + +void vacall_start_struct (va_alist list, size_t type_size, size_t type_align, int type_splittable, int flags) +{ + __va_start_struct(list,type_size,type_align,type_splittable,flags); +} + +char vacall_arg_char (va_alist list) +{ + return _va_arg_char(list); +} + +signed char vacall_arg_schar (va_alist list) +{ + return _va_arg_schar(list); +} + +unsigned char vacall_arg_uchar (va_alist list) +{ + return _va_arg_uchar(list); +} + +short vacall_arg_short (va_alist list) +{ + return _va_arg_short(list); +} + +unsigned short vacall_arg_ushort (va_alist list) +{ + return _va_arg_ushort(list); +} + +int vacall_arg_int (va_alist list) +{ + return _va_arg_int(list); +} + +unsigned int vacall_arg_uint (va_alist list) +{ + return _va_arg_uint(list); +} + +long vacall_arg_long (va_alist list) +{ + return _va_arg_long(list); +} + +unsigned long vacall_arg_ulong (va_alist list) +{ + return _va_arg_ulong(list); +} + +long long vacall_arg_longlong (va_alist list) +{ + return _va_arg_longlong(list); +} + +unsigned long long vacall_arg_ulonglong (va_alist list) +{ + return _va_arg_ulonglong(list); +} + +float vacall_arg_float (va_alist list) +{ + return _va_arg_float(list); +} + +double vacall_arg_double (va_alist list) +{ + return _va_arg_double(list); +} + +void* vacall_arg_ptr (va_alist list) +{ + return _va_arg_ptr(list); +} + +void* vacall_arg_struct (va_alist list, size_t type_size, size_t type_align) +{ + return __va_arg_struct(list,type_size,type_align); +} + +void vacall_return_void (va_alist list) +{ + _va_return_void(list); +} + +void vacall_return_char (va_alist list, char val) +{ + _va_return_char(list,val); +} + +void vacall_return_schar (va_alist list, signed char val) +{ + _va_return_schar(list,val); +} + +void vacall_return_uchar (va_alist list, unsigned char val) +{ + _va_return_uchar(list,val); +} + +void vacall_return_short (va_alist list, short val) +{ + _va_return_short(list,val); +} + +void vacall_return_ushort (va_alist list, unsigned short val) +{ + _va_return_ushort(list,val); +} + +void vacall_return_int (va_alist list, int val) +{ + _va_return_int(list,val); +} + +void vacall_return_uint (va_alist list, unsigned int val) +{ + _va_return_uint(list,val); +} + +void vacall_return_long (va_alist list, long val) +{ + _va_return_long(list,val); +} + +void vacall_return_ulong (va_alist list, unsigned long val) +{ + _va_return_ulong(list,val); +} + +void vacall_return_longlong (va_alist list, long long val) +{ + _va_return_longlong(list,val); +} + +void vacall_return_ulonglong (va_alist list, unsigned long long val) +{ + _va_return_ulonglong(list,val); +} + +void vacall_return_float (va_alist list, float val) +{ + _va_return_float(list,val); +} + +void vacall_return_double (va_alist list, double val) +{ + _va_return_double(list,val); +} + +void vacall_return_ptr (va_alist list, void* val) +{ + _va_return_ptr(list,val); +} + +void vacall_return_struct (va_alist list, size_t type_size, size_t type_align, const void* val_addr) +{ + __va_return_struct(list,type_size,type_align,val_addr); +} diff --git a/vacall/vacall-m68k-linux.s b/vacall/vacall-m68k-linux.s new file mode 100644 index 0000000..808fd79 --- /dev/null +++ b/vacall/vacall-m68k-linux.s @@ -0,0 +1,171 @@ + .file "vacall-m68k.c" + .text + .align 2 + .globl vacall_receiver + .type vacall_receiver,@function +vacall_receiver: + link.w %a6,#-32 + movm.l #0x3030,-(%sp) + clr.l -32(%a6) + lea (8,%a6),%a2 + move.l %a2,-20(%a6) + clr.l -16(%a6) + clr.l -12(%a6) + move.l %a1,-4(%a6) + pea -32(%a6) + move.l vacall_function,%a2 + jbsr (%a2) + addq.l #4,%sp + move.l -12(%a6),%a3 + tst.l %a3 + jbeq .L1 + moveq.l #1,%d2 + cmp.l %a3,%d2 + jbeq .L46 + moveq.l #2,%d3 + cmp.l %a3,%d3 + jbeq .L46 + moveq.l #3,%d2 + cmp.l %a3,%d2 + jbeq .L47 + moveq.l #4,%d3 + cmp.l %a3,%d3 + jbeq .L48 + moveq.l #5,%d2 + cmp.l %a3,%d2 + jbeq .L49 + moveq.l #6,%d3 + cmp.l %a3,%d3 + jbeq .L45 + moveq.l #7,%d2 + cmp.l %a3,%d2 + jbeq .L45 + moveq.l #8,%d3 + cmp.l %a3,%d3 + jbeq .L45 + moveq.l #9,%d2 + cmp.l %a3,%d2 + jbeq .L45 + lea (-10,%a3),%a2 + moveq.l #1,%d3 + cmp.l %a2,%d3 + jbcs .L22 + move.l -28(%a6),%d0 + move.l -24(%a6),%d1 + jbra .L1 + .align 2 +.L22: + moveq.l #12,%d2 + cmp.l %a3,%d2 + jbeq .L50 + moveq.l #13,%d2 + cmp.l %a3,%d2 + jbeq .L51 + moveq.l #14,%d3 + cmp.l %a3,%d3 + jbeq .L52 + moveq.l #15,%d2 + cmp.l %a3,%d2 + jbne .L1 + btst #2,-30(%a6) + jbeq .L1 + move.l -8(%a6),%d2 + moveq.l #1,%d3 + cmp.l %d2,%d3 + jbeq .L53 + moveq.l #2,%d3 + cmp.l %d2,%d3 + jbeq .L54 + moveq.l #4,%d3 + cmp.l %d2,%d3 + jbeq .L55 + moveq.l #8,%d3 + cmp.l %d2,%d3 + jbne .L1 + move.l -16(%a6),%a2 + move.l (%a2),%d0 + move.l 4(%a2),%d1 + jbra .L1 + .align 2 +.L55: + move.l -16(%a6),%a2 + move.l (%a2),%d0 + jbra .L1 + .align 2 +.L54: + move.l -16(%a6),%a2 + clr.l %d0 + move.w (%a2),%d0 + jbra .L1 + .align 2 +.L53: + move.l -16(%a6),%a2 + clr.l %d0 + move.b (%a2),%d0 + jbra .L1 + .align 2 +.L52: + move.l -28(%a6),%d0 + move.l %d0,%a0 + jbra .L1 + .align 2 +.L51: + btst #6,-29(%a6) + jbeq .L31 + fmove.d -28(%a6),%fp0 + jbra .L1 + .align 2 +.L31: + move.l -28(%a6),%d0 + move.l -24(%a6),%d1 + jbra .L1 + .align 2 +.L50: + move.l -32(%a6),%d2 + btst #6,%d2 + jbeq .L25 + fmove.s -28(%a6),%fp0 + jbra .L1 + .align 2 +.L25: + btst #5,%d2 + jbeq .L27 + fmove.s -28(%a6),%fp1 + fmove.d %fp1,-(%sp) + move.l (%sp)+,%d0 + move.l (%sp)+,%d1 + jbra .L1 + .align 2 +.L27: + move.l -28(%a6),%d0 + jbra .L1 + .align 2 +.L45: + move.l -28(%a6),%d0 + jbra .L1 + .align 2 +.L49: + clr.l %d0 + move.w -28(%a6),%d0 + jbra .L1 + .align 2 +.L48: + move.w -28(%a6),%d0 + ext.l %d0 + jbra .L1 + .align 2 +.L47: + clr.l %d0 + move.b -28(%a6),%d0 + jbra .L1 + .align 2 +.L46: + move.b -28(%a6),%d0 + extb.l %d0 +.L1: + movm.l -48(%a6),#0xc0c + unlk %a6 + rts +.Lfe1: + .size vacall_receiver,.Lfe1-vacall_receiver + .ident "GCC: (GNU) 3.1" diff --git a/vacall/vacall-m68k-sun.s b/vacall/vacall-m68k-sun.s new file mode 100644 index 0000000..07fae31 --- /dev/null +++ b/vacall/vacall-m68k-sun.s @@ -0,0 +1,167 @@ +#NO_APP + .text + .even + .globl _vacall_receiver +_vacall_receiver: + link a6,#-32 + moveml #0x3030,sp@- + clrl a6@(-32) + lea a6@(8),a2 + movel a2,a6@(-20) + clrl a6@(-16) + clrl a6@(-12) + movel a1,a6@(-4) + pea a6@(-32) + movel _vacall_function,a2 + jbsr a2@ + addql #4,sp + movel a6@(-12),a3 + tstl a3 + jeq L1 + moveq #1,d2 + cmpl a3,d2 + jeq L46 + moveq #2,d3 + cmpl a3,d3 + jeq L46 + moveq #3,d2 + cmpl a3,d2 + jeq L47 + moveq #4,d3 + cmpl a3,d3 + jeq L48 + moveq #5,d2 + cmpl a3,d2 + jeq L49 + moveq #6,d3 + cmpl a3,d3 + jeq L45 + moveq #7,d2 + cmpl a3,d2 + jeq L45 + moveq #8,d3 + cmpl a3,d3 + jeq L45 + moveq #9,d2 + cmpl a3,d2 + jeq L45 + lea a3@(-10),a2 + moveq #1,d3 + cmpl a2,d3 + jcs L22 + movel a6@(-28),d0 + movel a6@(-24),d1 + jra L1 + .even +L22: + moveq #12,d2 + cmpl a3,d2 + jeq L50 + moveq #13,d2 + cmpl a3,d2 + jeq L51 + moveq #14,d3 + cmpl a3,d3 + jeq L52 + moveq #15,d2 + cmpl a3,d2 + jne L1 + btst #2,a6@(-30) + jeq L1 + movel a6@(-8),d2 + moveq #1,d3 + cmpl d2,d3 + jeq L53 + moveq #2,d3 + cmpl d2,d3 + jeq L54 + moveq #4,d3 + cmpl d2,d3 + jeq L55 + moveq #8,d3 + cmpl d2,d3 + jne L1 + movel a6@(-16),a2 + movel a2@,d0 + movel a2@(4),d1 + jra L1 + .even +L55: + movel a6@(-16),a2 + movel a2@,d0 + jra L1 + .even +L54: + movel a6@(-16),a2 + clrl d0 + movew a2@,d0 + jra L1 + .even +L53: + movel a6@(-16),a2 + clrl d0 + moveb a2@,d0 + jra L1 + .even +L52: + movel a6@(-28),d0 + movel d0,a0 + jra L1 + .even +L51: + btst #6,a6@(-29) + jeq L31 + fmoved a6@(-28),fp0 + jra L1 + .even +L31: + movel a6@(-28),d0 + movel a6@(-24),d1 + jra L1 + .even +L50: + movel a6@(-32),d2 + btst #6,d2 + jeq L25 + fmoves a6@(-28),fp0 + jra L1 + .even +L25: + btst #5,d2 + jeq L27 + fmoves a6@(-28),fp1 + fmoved fp1,sp@- + movel sp@+,d0 + movel sp@+,d1 + jra L1 + .even +L27: + movel a6@(-28),d0 + jra L1 + .even +L45: + movel a6@(-28),d0 + jra L1 + .even +L49: + clrl d0 + movew a6@(-28),d0 + jra L1 + .even +L48: + movew a6@(-28),d0 + extl d0 + jra L1 + .even +L47: + clrl d0 + moveb a6@(-28),d0 + jra L1 + .even +L46: + moveb a6@(-28),d0 + extbl d0 +L1: + moveml a6@(-48),#0xc0c + unlk a6 + rts diff --git a/vacall/vacall-m68k.c b/vacall/vacall-m68k.c new file mode 100644 index 0000000..e6394df --- /dev/null +++ b/vacall/vacall-m68k.c @@ -0,0 +1,136 @@ +/* vacall function for m68k CPU */ + +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +#include "vacall-internal.h" + +#ifdef REENTRANT +#define vacall_receiver callback_receiver +register struct { void (*vacall_function) (void*,va_alist); void* arg; } + * env __asm__("a0"); +#endif +register void* sret __asm__("a1"); +register int iret __asm__("d0"); +register int iret2 __asm__("d1"); +register int pret __asm__("a0"); /* some compilers return pointers in a0 */ +register float fret __asm__("d0"); /* d0 */ +register double dret __asm__("d0"); /* d0,d1 */ +register float fp_fret __asm__("fp0"); +register double fp_dret __asm__("fp0"); + +#ifdef REENTRANT +static +#endif +void /* the return type is variable, not void! */ +vacall_receiver (__vaword firstword) +{ + __va_alist list; + /* Prepare the va_alist. */ + list.flags = 0; + list.aptr = (long)&firstword; + list.raddr = (void*)0; + list.rtype = __VAvoid; + list.structraddr = sret; + /* Call vacall_function. The macros do all the rest. */ +#ifndef REENTRANT + (*vacall_function) (&list); +#else /* REENTRANT */ + (*env->vacall_function) (env->arg,&list); +#endif + /* Put return value into proper register. */ + if (list.rtype == __VAvoid) { + } else + if (list.rtype == __VAchar) { + iret = list.tmp._char; + } else + if (list.rtype == __VAschar) { + iret = list.tmp._schar; + } else + if (list.rtype == __VAuchar) { + iret = list.tmp._uchar; + } else + if (list.rtype == __VAshort) { + iret = list.tmp._short; + } else + if (list.rtype == __VAushort) { + iret = list.tmp._ushort; + } else + if (list.rtype == __VAint) { + iret = list.tmp._int; + } else + if (list.rtype == __VAuint) { + iret = list.tmp._uint; + } else + if (list.rtype == __VAlong) { + iret = list.tmp._long; + } else + if (list.rtype == __VAulong) { + iret = list.tmp._ulong; + } else + if (list.rtype == __VAlonglong || list.rtype == __VAulonglong) { + iret = ((__vaword *) &list.tmp._longlong)[0]; + iret2 = ((__vaword *) &list.tmp._longlong)[1]; + } else + if (list.rtype == __VAfloat) { + if (list.flags & __VA_FREG_FLOAT_RETURN) { + fp_fret = list.tmp._float; + } else { + if (list.flags & __VA_SUNCC_FLOAT_RETURN) { + dret = (double)list.tmp._float; + } else { + fret = list.tmp._float; + } + } + } else + if (list.rtype == __VAdouble) { + if (list.flags & __VA_FREG_FLOAT_RETURN) { + fp_dret = list.tmp._double; + } else { + dret = list.tmp._double; + } + } else + if (list.rtype == __VAvoidp) { + pret = iret = (long)list.tmp._ptr; + } else + if (list.rtype == __VAstruct) { + /* NB: On m68k, all structure sizes are divisible by 2. */ + if (list.flags & __VA_REGISTER_STRUCT_RETURN) { + if (list.rsize == sizeof(char)) { /* can't occur */ + iret = *(unsigned char *) list.raddr; + } else + if (list.rsize == sizeof(short)) { + iret = *(unsigned short *) list.raddr; + } else + if (list.rsize == sizeof(int)) { + iret = *(unsigned int *) list.raddr; + } else + if (list.rsize == 2*sizeof(__vaword)) { + iret = ((__vaword *) list.raddr)[0]; + iret2 = ((__vaword *) list.raddr)[1]; + } + } + } +} + +#ifdef REENTRANT +__vacall_r_t +callback_get_receiver (void) +{ + return (__vacall_r_t)(void*)&callback_receiver; +} +#endif diff --git a/vacall/vacall-m68k.mit.S b/vacall/vacall-m68k.mit.S new file mode 100644 index 0000000..d617c3f --- /dev/null +++ b/vacall/vacall-m68k.mit.S @@ -0,0 +1,172 @@ +#include "asm-m68k.h" + .text + .even + .globl C(vacall_receiver) + DECLARE_FUNCTION(vacall_receiver) +FUNBEGIN(vacall_receiver) + link $a6,#-32 + moveml #0x3030,$sp@- + clrl $a6@(-32) + lea $a6@(8),$a2 + movel $a2,$a6@(-20) + clrl $a6@(-16) + clrl $a6@(-12) + movel $a1,$a6@(-4) + pea $a6@(-32) + movel C(vacall_function),$a2 + jbsr $a2@ + addql #4,$sp + movel $a6@(-12),$a3 + tstl $a3 + jeq L(1) + moveq #1,$d2 + cmpl $a3,$d2 + jeq L(46) + moveq #2,$d3 + cmpl $a3,$d3 + jeq L(46) + moveq #3,$d2 + cmpl $a3,$d2 + jeq L(47) + moveq #4,$d3 + cmpl $a3,$d3 + jeq L(48) + moveq #5,$d2 + cmpl $a3,$d2 + jeq L(49) + moveq #6,$d3 + cmpl $a3,$d3 + jeq L(45) + moveq #7,$d2 + cmpl $a3,$d2 + jeq L(45) + moveq #8,$d3 + cmpl $a3,$d3 + jeq L(45) + moveq #9,$d2 + cmpl $a3,$d2 + jeq L(45) + lea $a3@(-10),$a2 + moveq #1,$d3 + cmpl $a2,$d3 + jcs L(22) + movel $a6@(-28),$d0 + movel $a6@(-24),$d1 + jra L(1) + .even +L(22): + moveq #12,$d2 + cmpl $a3,$d2 + jeq L(50) + moveq #13,$d2 + cmpl $a3,$d2 + jeq L(51) + moveq #14,$d3 + cmpl $a3,$d3 + jeq L(52) + moveq #15,$d2 + cmpl $a3,$d2 + jne L(1) + btst #2,$a6@(-30) + jeq L(1) + movel $a6@(-8),$d2 + moveq #1,$d3 + cmpl $d2,$d3 + jeq L(53) + moveq #2,$d3 + cmpl $d2,$d3 + jeq L(54) + moveq #4,$d3 + cmpl $d2,$d3 + jeq L(55) + moveq #8,$d3 + cmpl $d2,$d3 + jne L(1) + movel $a6@(-16),$a2 + movel $a2@,$d0 + movel $a2@(4),$d1 + jra L(1) + .even +L(55): + movel $a6@(-16),$a2 + movel $a2@,$d0 + jra L(1) + .even +L(54): + movel $a6@(-16),$a2 + clrl $d0 + movew $a2@,$d0 + jra L(1) + .even +L(53): + movel $a6@(-16),$a2 + clrl $d0 + moveb $a2@,$d0 + jra L(1) + .even +L(52): + movel $a6@(-28),$d0 + movel $d0,$a0 + jra L(1) + .even +L(51): + btst #6,$a6@(-29) + jeq L(31) + fmoved $a6@(-28),$fp0 + jra L(1) + .even +L(31): + movel $a6@(-28),$d0 + movel $a6@(-24),$d1 + jra L(1) + .even +L(50): + movel $a6@(-32),$d2 + btst #6,$d2 + jeq L(25) + fmoves $a6@(-28),$fp0 + jra L(1) + .even +L(25): + btst #5,$d2 + jeq L(27) + fmoves $a6@(-28),$fp1 + fmoved $fp1,$sp@- + movel $sp@+,$d0 + movel $sp@+,$d1 + jra L(1) + .even +L(27): + movel $a6@(-28),$d0 + jra L(1) + .even +L(45): + movel $a6@(-28),$d0 + jra L(1) + .even +L(49): + clrl $d0 + movew $a6@(-28),$d0 + jra L(1) + .even +L(48): + movew $a6@(-28),$d0 + extl $d0 + jra L(1) + .even +L(47): + clrl $d0 + moveb $a6@(-28),$d0 + jra L(1) + .even +L(46): + moveb $a6@(-28),$d0 + extbl $d0 +L(1): + moveml $a6@(-48),#0xc0c + unlk $a6 + rts +FUNEND(vacall_receiver) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/vacall/vacall-m68k.motorola.S b/vacall/vacall-m68k.motorola.S new file mode 100644 index 0000000..e4beb5b --- /dev/null +++ b/vacall/vacall-m68k.motorola.S @@ -0,0 +1,173 @@ +#include "asm-m68k.h" + .text + .align 2 + .globl C(vacall_receiver) + DECLARE_FUNCTION(vacall_receiver) +FUNBEGIN(vacall_receiver) + link.w %a6,#-32 + movm.l #0x3030,-(%sp) + clr.l -32(%a6) + lea (8,%a6),%a2 + move.l %a2,-20(%a6) + clr.l -16(%a6) + clr.l -12(%a6) + move.l %a1,-4(%a6) + pea -32(%a6) + move.l C(vacall_function),%a2 + jbsr (%a2) + addq.l #4,%sp + move.l -12(%a6),%a3 + tst.l %a3 + jbeq L(1) + moveq.l #1,%d2 + cmp.l %a3,%d2 + jbeq L(46) + moveq.l #2,%d3 + cmp.l %a3,%d3 + jbeq L(46) + moveq.l #3,%d2 + cmp.l %a3,%d2 + jbeq L(47) + moveq.l #4,%d3 + cmp.l %a3,%d3 + jbeq L(48) + moveq.l #5,%d2 + cmp.l %a3,%d2 + jbeq L(49) + moveq.l #6,%d3 + cmp.l %a3,%d3 + jbeq L(45) + moveq.l #7,%d2 + cmp.l %a3,%d2 + jbeq L(45) + moveq.l #8,%d3 + cmp.l %a3,%d3 + jbeq L(45) + moveq.l #9,%d2 + cmp.l %a3,%d2 + jbeq L(45) + lea (-10,%a3),%a2 + moveq.l #1,%d3 + cmp.l %a2,%d3 + jbcs L(22) + move.l -28(%a6),%d0 + move.l -24(%a6),%d1 + jbra L(1) + .align 2 +L(22): + moveq.l #12,%d2 + cmp.l %a3,%d2 + jbeq L(50) + moveq.l #13,%d2 + cmp.l %a3,%d2 + jbeq L(51) + moveq.l #14,%d3 + cmp.l %a3,%d3 + jbeq L(52) + moveq.l #15,%d2 + cmp.l %a3,%d2 + jbne L(1) + btst #2,-30(%a6) + jbeq L(1) + move.l -8(%a6),%d2 + moveq.l #1,%d3 + cmp.l %d2,%d3 + jbeq L(53) + moveq.l #2,%d3 + cmp.l %d2,%d3 + jbeq L(54) + moveq.l #4,%d3 + cmp.l %d2,%d3 + jbeq L(55) + moveq.l #8,%d3 + cmp.l %d2,%d3 + jbne L(1) + move.l -16(%a6),%a2 + move.l (%a2),%d0 + move.l 4(%a2),%d1 + jbra L(1) + .align 2 +L(55): + move.l -16(%a6),%a2 + move.l (%a2),%d0 + jbra L(1) + .align 2 +L(54): + move.l -16(%a6),%a2 + clr.l %d0 + move.w (%a2),%d0 + jbra L(1) + .align 2 +L(53): + move.l -16(%a6),%a2 + clr.l %d0 + move.b (%a2),%d0 + jbra L(1) + .align 2 +L(52): + move.l -28(%a6),%d0 + move.l %d0,%a0 + jbra L(1) + .align 2 +L(51): + btst #6,-29(%a6) + jbeq L(31) + fmove.d -28(%a6),%fp0 + jbra L(1) + .align 2 +L(31): + move.l -28(%a6),%d0 + move.l -24(%a6),%d1 + jbra L(1) + .align 2 +L(50): + move.l -32(%a6),%d2 + btst #6,%d2 + jbeq L(25) + fmove.s -28(%a6),%fp0 + jbra L(1) + .align 2 +L(25): + btst #5,%d2 + jbeq L(27) + fmove.s -28(%a6),%fp1 + fmove.d %fp1,-(%sp) + move.l (%sp)+,%d0 + move.l (%sp)+,%d1 + jbra L(1) + .align 2 +L(27): + move.l -28(%a6),%d0 + jbra L(1) + .align 2 +L(45): + move.l -28(%a6),%d0 + jbra L(1) + .align 2 +L(49): + clr.l %d0 + move.w -28(%a6),%d0 + jbra L(1) + .align 2 +L(48): + move.w -28(%a6),%d0 + ext.l %d0 + jbra L(1) + .align 2 +L(47): + clr.l %d0 + move.b -28(%a6),%d0 + jbra L(1) + .align 2 +L(46): + move.b -28(%a6),%d0 + extb.l %d0 +L(1): + movm.l -48(%a6),#0xc0c + unlk %a6 + rts +L(fe1): + FUNEND(vacall_receiver) +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/vacall/vacall-mips.c b/vacall/vacall-mips.c new file mode 100644 index 0000000..dad244c --- /dev/null +++ b/vacall/vacall-mips.c @@ -0,0 +1,139 @@ +/* vacall function for mips CPU */ + +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +#include "vacall-internal.h" + +#ifndef REENTRANT +typedef void (*func_pointer)(va_alist); +#else /* REENTRANT */ +#define vacall_receiver callback_receiver +typedef void (*func_pointer)(void*,va_alist); +register struct { func_pointer vacall_function; void* arg; } + * env __asm__("$2"); +#endif +register float farg1 __asm__("$f12"); +register float farg2 __asm__("$f14"); +register double darg1 __asm__("$f12"); +register double darg2 __asm__("$f14"); +register int iret __asm__("$2"); +register int iret2 __asm__("$3"); +register float fret __asm__("$f0"); +register double dret __asm__("$f0"); + +#ifdef REENTRANT +static +#endif +void /* the return type is variable, not void! */ +vacall_receiver (__vaword word1, __vaword word2, __vaword word3, __vaword word4, + __vaword firstword) +{ + __va_alist list; + /* gcc-2.6.3 source says: When a parameter is passed in a register, + * stack space is still allocated for it. + */ + /* Move the arguments passed in registers to their stack locations. */ + (&firstword)[-4] = word1; + (&firstword)[-3] = word2; + (&firstword)[-2] = word3; + (&firstword)[-1] = word4; + list.darg[0] = darg1; + list.darg[1] = darg2; + list.farg[0] = farg1; + list.farg[1] = farg2; + /* Prepare the va_alist. */ + list.flags = 0; + list.aptr = (long)(&firstword - 4); + list.raddr = (void*)0; + list.rtype = __VAvoid; + list.memargptr = (long)&firstword; + list.anum = 0; + list.fanum = 0; + /* Call vacall_function. The macros do all the rest. */ +#ifndef REENTRANT + (*vacall_function) (&list); +#else /* REENTRANT */ + (*env->vacall_function) (env->arg,&list); +#endif + /* Put return value into proper register. */ + if (list.rtype == __VAvoid) { + } else + if (list.rtype == __VAchar) { + iret = list.tmp._char; + } else + if (list.rtype == __VAschar) { + iret = list.tmp._schar; + } else + if (list.rtype == __VAuchar) { + iret = list.tmp._uchar; + } else + if (list.rtype == __VAshort) { + iret = list.tmp._short; + } else + if (list.rtype == __VAushort) { + iret = list.tmp._ushort; + } else + if (list.rtype == __VAint) { + iret = list.tmp._int; + } else + if (list.rtype == __VAuint) { + iret = list.tmp._uint; + } else + if (list.rtype == __VAlong) { + iret = list.tmp._long; + } else + if (list.rtype == __VAulong) { + iret = list.tmp._ulong; + } else + if (list.rtype == __VAlonglong || list.rtype == __VAulonglong) { + iret = ((__vaword *) &list.tmp._longlong)[0]; + iret2 = ((__vaword *) &list.tmp._longlong)[1]; + } else + if (list.rtype == __VAfloat) { + fret = list.tmp._float; + } else + if (list.rtype == __VAdouble) { + dret = list.tmp._double; + } else + if (list.rtype == __VAvoidp) { + iret = (long)list.tmp._ptr; + } else + if (list.rtype == __VAstruct) { + if (list.flags & __VA_SMALL_STRUCT_RETURN) { + if (list.rsize == sizeof(char)) { + iret = *(unsigned char *) list.raddr; + } else + if (list.rsize == sizeof(short)) { + iret = *(unsigned short *) list.raddr; + } else + if (list.rsize == sizeof(int)) { + iret = *(unsigned int *) list.raddr; + } + } else { + iret = (long)list.raddr; + } + } +} + +#ifdef REENTRANT +__vacall_r_t +callback_get_receiver (void) +{ + return (__vacall_r_t)(void*)&callback_receiver; +} +#endif diff --git a/vacall/vacall-mips64.c b/vacall/vacall-mips64.c new file mode 100644 index 0000000..9b5aeac --- /dev/null +++ b/vacall/vacall-mips64.c @@ -0,0 +1,508 @@ +/* vacall function for mips CPU */ + +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +#include "vacall-internal.h" + +#ifndef REENTRANT +typedef void (*func_pointer)(va_alist); +#else /* REENTRANT */ +#define vacall_receiver callback_receiver +typedef void (*func_pointer)(void*,va_alist); +register struct { func_pointer vacall_function; void* arg; } + * env __asm__("$2"); +#endif +register void* sp __asm__("$sp"); +register long iarg0 __asm__("$4"); +register long iarg1 __asm__("$5"); +register long iarg2 __asm__("$6"); +register long iarg3 __asm__("$7"); +register long iarg4 __asm__("$8"); +register long iarg5 __asm__("$9"); +register long iarg6 __asm__("$10"); +register long iarg7 __asm__("$11"); +register float farg0 __asm__("$f12"); +register float farg1 __asm__("$f13"); +register float farg2 __asm__("$f14"); +register float farg3 __asm__("$f15"); +register float farg4 __asm__("$f16"); +register float farg5 __asm__("$f17"); +register float farg6 __asm__("$f18"); +register float farg7 __asm__("$f19"); +register double darg0 __asm__("$f12"); +register double darg1 __asm__("$f13"); +register double darg2 __asm__("$f14"); +register double darg3 __asm__("$f15"); +register double darg4 __asm__("$f16"); +register double darg5 __asm__("$f17"); +register double darg6 __asm__("$f18"); +register double darg7 __asm__("$f19"); +register long iret __asm__("$2"); +register long iret2 __asm__("$3"); +register float fret __asm__("$f0"); +register float fret2 __asm__("$f2"); +register double dret __asm__("$f0"); +register double dret2 __asm__("$f2"); + +/* The ABI requires that the first 8 general-purpose argument words are + being passed in registers, even if these words belong to a struct. No room + is allocated for these register words on the stack by the caller, but the + callee allocates room for them - at the right place in the stack frame, + that is, above the usual {fp, retaddr} combo - if and only if they are part + of a larger struct that extends to the stack and the address of this struct + is taken. */ +struct gpargsequence { + __vaword word1; /* r4 */ + __vaword word2; /* r5 */ + __vaword word3; /* r6 */ + __vaword word4; /* r7 */ + __vaword word5; /* r8 */ + __vaword word6; /* r9 */ + __vaword word7; /* r10 */ + __vaword word8; /* r11 */ + __vaword firststackword; +}; + +#ifdef REENTRANT +static +#endif +void /* the return type is variable, not void! */ +vacall_receiver (struct gpargsequence gpargs) +{ + __va_alist list; + list.darg[0] = darg0; + list.darg[1] = darg1; + list.darg[2] = darg2; + list.darg[3] = darg3; + list.darg[4] = darg4; + list.darg[5] = darg5; + list.darg[6] = darg6; + list.darg[7] = darg7; + list.farg[0] = farg0; + list.farg[1] = farg1; + list.farg[2] = farg2; + list.farg[3] = farg3; + list.farg[4] = farg4; + list.farg[5] = farg5; + list.farg[6] = farg6; + list.farg[7] = farg7; + /* Prepare the va_alist. */ + list.flags = 0; + list.aptr = (long)&gpargs; + list.raddr = (void*)0; + list.rtype = __VAvoid; + list.anum = 0; + /* Call vacall_function. The macros do all the rest. */ +#ifndef REENTRANT + (*vacall_function) (&list); +#else /* REENTRANT */ + (*env->vacall_function) (env->arg,&list); +#endif + /* Put return value into proper register. */ + if (list.rtype == __VAvoid) { + } else + if (list.rtype == __VAchar) { + iret = list.tmp._char; + } else + if (list.rtype == __VAschar) { + iret = list.tmp._schar; + } else + if (list.rtype == __VAuchar) { + iret = list.tmp._uchar; + } else + if (list.rtype == __VAshort) { + iret = list.tmp._short; + } else + if (list.rtype == __VAushort) { + iret = list.tmp._ushort; + } else + if (list.rtype == __VAint) { + iret = list.tmp._int; + } else + if (list.rtype == __VAuint) { + iret = list.tmp._uint; + } else + if (list.rtype == __VAlong) { + iret = list.tmp._long; + } else + if (list.rtype == __VAulong) { + iret = list.tmp._ulong; + } else + if (list.rtype == __VAlonglong) { + iret = list.tmp._long; + } else + if (list.rtype == __VAulonglong) { + iret = list.tmp._ulong; + } else + if (list.rtype == __VAfloat) { + fret = list.tmp._float; + } else + if (list.rtype == __VAdouble) { + dret = list.tmp._double; + } else + if (list.rtype == __VAvoidp) { + iret = (long)list.tmp._ptr; + } else + if (list.rtype == __VAstruct) { + if (list.flags & __VA_REGISTER_STRUCT_RETURN) { + if (list.flags & __VA_GCC_STRUCT_RETURN) { + /* gcc returns structs of size 1,2,4,8 in registers. */ + if (list.rsize == sizeof(char)) { + iret = *(unsigned char *) list.raddr; + } else + if (list.rsize == sizeof(short)) { + iret = *(unsigned short *) list.raddr; + } else + if (list.rsize == sizeof(int)) { + iret = *(unsigned int *) list.raddr; + } else + if (list.rsize == sizeof(long)) { + iret = *(unsigned long *) list.raddr; + } + } else { + /* cc returns structs of size <= 16 in registers. */ + /* Maybe this big if cascade could be replaced with + * if (list.rsize > 0 && list.rsize <= 16) + * __asm__ ("ldl $2,%0 ; ldr $2,%1" + * : : "m" (((unsigned char *) list.raddr)[0]), + * "m" (((unsigned char *) list.raddr)[7])); + */ + if (list.rsize > 0 && list.rsize <= 16) { + #if 0 /* Unoptimized */ + if (list.rsize == 1) { + #if defined(_MIPSEL) + iret = (__vaword)((unsigned char *) list.raddr)[0]; + #else + iret = (__vaword)((unsigned char *) list.raddr)[0] << 56; + #endif + } else + if (list.rsize == 2) { + #if defined(_MIPSEL) + iret = ((__vaword)((unsigned char *) list.raddr)[0]) + | ((__vaword)((unsigned char *) list.raddr)[1] << 8); + #else + iret = ((__vaword)((unsigned char *) list.raddr)[0] << 56) + | ((__vaword)((unsigned char *) list.raddr)[1] << 48); + #endif + } else + if (list.rsize == 3) { + #if defined(_MIPSEL) + iret = ((__vaword)((unsigned char *) list.raddr)[0]) + | ((__vaword)((unsigned char *) list.raddr)[1] << 8) + | ((__vaword)((unsigned char *) list.raddr)[2] << 16); + #else + iret = ((__vaword)((unsigned char *) list.raddr)[0] << 56) + | ((__vaword)((unsigned char *) list.raddr)[1] << 48) + | ((__vaword)((unsigned char *) list.raddr)[2] << 40); + #endif + } else + if (list.rsize == 4) { + #if defined(_MIPSEL) + iret = ((__vaword)((unsigned char *) list.raddr)[0]) + | ((__vaword)((unsigned char *) list.raddr)[1] << 8) + | ((__vaword)((unsigned char *) list.raddr)[2] << 16) + | ((__vaword)((unsigned char *) list.raddr)[3] << 24); + #else + iret = ((__vaword)((unsigned char *) list.raddr)[0] << 56) + | ((__vaword)((unsigned char *) list.raddr)[1] << 48) + | ((__vaword)((unsigned char *) list.raddr)[2] << 40) + | ((__vaword)((unsigned char *) list.raddr)[3] << 32); + #endif + } else + if (list.rsize == 5) { + #if defined(_MIPSEL) + iret = ((__vaword)((unsigned char *) list.raddr)[0]) + | ((__vaword)((unsigned char *) list.raddr)[1] << 8) + | ((__vaword)((unsigned char *) list.raddr)[2] << 16) + | ((__vaword)((unsigned char *) list.raddr)[3] << 24) + | ((__vaword)((unsigned char *) list.raddr)[4] << 32); + #else + iret = ((__vaword)((unsigned char *) list.raddr)[0] << 56) + | ((__vaword)((unsigned char *) list.raddr)[1] << 48) + | ((__vaword)((unsigned char *) list.raddr)[2] << 40) + | ((__vaword)((unsigned char *) list.raddr)[3] << 32) + | ((__vaword)((unsigned char *) list.raddr)[4] << 24); + #endif + } else + if (list.rsize == 6) { + #if defined(_MIPSEL) + iret = ((__vaword)((unsigned char *) list.raddr)[0]) + | ((__vaword)((unsigned char *) list.raddr)[1] << 8) + | ((__vaword)((unsigned char *) list.raddr)[2] << 16) + | ((__vaword)((unsigned char *) list.raddr)[3] << 24) + | ((__vaword)((unsigned char *) list.raddr)[4] << 32) + | ((__vaword)((unsigned char *) list.raddr)[5] << 40); + #else + iret = ((__vaword)((unsigned char *) list.raddr)[0] << 56) + | ((__vaword)((unsigned char *) list.raddr)[1] << 48) + | ((__vaword)((unsigned char *) list.raddr)[2] << 40) + | ((__vaword)((unsigned char *) list.raddr)[3] << 32) + | ((__vaword)((unsigned char *) list.raddr)[4] << 24) + | ((__vaword)((unsigned char *) list.raddr)[5] << 16); + #endif + } else + if (list.rsize == 7) { + #if defined(_MIPSEL) + iret = ((__vaword)((unsigned char *) list.raddr)[0]) + | ((__vaword)((unsigned char *) list.raddr)[1] << 8) + | ((__vaword)((unsigned char *) list.raddr)[2] << 16) + | ((__vaword)((unsigned char *) list.raddr)[3] << 24) + | ((__vaword)((unsigned char *) list.raddr)[4] << 32) + | ((__vaword)((unsigned char *) list.raddr)[5] << 40) + | ((__vaword)((unsigned char *) list.raddr)[6] << 48); + #else + iret = ((__vaword)((unsigned char *) list.raddr)[0] << 56) + | ((__vaword)((unsigned char *) list.raddr)[1] << 48) + | ((__vaword)((unsigned char *) list.raddr)[2] << 40) + | ((__vaword)((unsigned char *) list.raddr)[3] << 32) + | ((__vaword)((unsigned char *) list.raddr)[4] << 24) + | ((__vaword)((unsigned char *) list.raddr)[5] << 16) + | ((__vaword)((unsigned char *) list.raddr)[6] << 8); + #endif + } else + if (list.rsize >= 8 && list.rsize <= 16) { + #if defined(_MIPSEL) + iret = ((__vaword)((unsigned char *) list.raddr)[0]) + | ((__vaword)((unsigned char *) list.raddr)[1] << 8) + | ((__vaword)((unsigned char *) list.raddr)[2] << 16) + | ((__vaword)((unsigned char *) list.raddr)[3] << 24) + | ((__vaword)((unsigned char *) list.raddr)[4] << 32) + | ((__vaword)((unsigned char *) list.raddr)[5] << 40) + | ((__vaword)((unsigned char *) list.raddr)[6] << 48) + | ((__vaword)((unsigned char *) list.raddr)[7] << 56); + #else + iret = ((__vaword)((unsigned char *) list.raddr)[0] << 56) + | ((__vaword)((unsigned char *) list.raddr)[1] << 48) + | ((__vaword)((unsigned char *) list.raddr)[2] << 40) + | ((__vaword)((unsigned char *) list.raddr)[3] << 32) + | ((__vaword)((unsigned char *) list.raddr)[4] << 24) + | ((__vaword)((unsigned char *) list.raddr)[5] << 16) + | ((__vaword)((unsigned char *) list.raddr)[6] << 8) + | (__vaword)((unsigned char *) list.raddr)[7]; + #endif + /* Maybe this big if cascade could be replaced with + * if (list.rsize > 8 && list.rsize <= 16) + * __asm__ ("ldl $3,%0 ; ldr $3,%1" + * : : "m" (((unsigned char *) list.raddr)[8]), + * "m" (((unsigned char *) list.raddr)[15])); + */ + if (list.rsize == 8) { + } else + if (list.rsize == 9) { + #if defined(_MIPSEL) + iret2 = (__vaword)((unsigned char *) list.raddr)[8]; + #else + iret2 = (__vaword)((unsigned char *) list.raddr)[8] << 56; + #endif + } else + if (list.rsize == 10) { + #if defined(_MIPSEL) + iret2 = ((__vaword)((unsigned char *) list.raddr)[8]) + | ((__vaword)((unsigned char *) list.raddr)[9] << 8); + #else + iret2 = ((__vaword)((unsigned char *) list.raddr)[8] << 56) + | ((__vaword)((unsigned char *) list.raddr)[9] << 48); + #endif + } else + if (list.rsize == 11) { + #if defined(_MIPSEL) + iret2 = ((__vaword)((unsigned char *) list.raddr)[8]) + | ((__vaword)((unsigned char *) list.raddr)[9] << 8) + | ((__vaword)((unsigned char *) list.raddr)[10] << 16); + #else + iret2 = ((__vaword)((unsigned char *) list.raddr)[8] << 56) + | ((__vaword)((unsigned char *) list.raddr)[9] << 48) + | ((__vaword)((unsigned char *) list.raddr)[10] << 40); + #endif + } else + if (list.rsize == 12) { + #if defined(_MIPSEL) + iret2 = ((__vaword)((unsigned char *) list.raddr)[8]) + | ((__vaword)((unsigned char *) list.raddr)[9] << 8) + | ((__vaword)((unsigned char *) list.raddr)[10] << 16) + | ((__vaword)((unsigned char *) list.raddr)[11] << 24); + #else + iret2 = ((__vaword)((unsigned char *) list.raddr)[8] << 56) + | ((__vaword)((unsigned char *) list.raddr)[9] << 48) + | ((__vaword)((unsigned char *) list.raddr)[10] << 40) + | ((__vaword)((unsigned char *) list.raddr)[11] << 32); + #endif + } else + if (list.rsize == 13) { + #if defined(_MIPSEL) + iret2 = ((__vaword)((unsigned char *) list.raddr)[8]) + | ((__vaword)((unsigned char *) list.raddr)[9] << 8) + | ((__vaword)((unsigned char *) list.raddr)[10] << 16) + | ((__vaword)((unsigned char *) list.raddr)[11] << 24) + | ((__vaword)((unsigned char *) list.raddr)[12] << 32); + #else + iret2 = ((__vaword)((unsigned char *) list.raddr)[8] << 56) + | ((__vaword)((unsigned char *) list.raddr)[9] << 48) + | ((__vaword)((unsigned char *) list.raddr)[10] << 40) + | ((__vaword)((unsigned char *) list.raddr)[11] << 32) + | ((__vaword)((unsigned char *) list.raddr)[12] << 24); + #endif + } else + if (list.rsize == 14) { + #if defined(_MIPSEL) + iret2 = ((__vaword)((unsigned char *) list.raddr)[8]) + | ((__vaword)((unsigned char *) list.raddr)[9] << 8) + | ((__vaword)((unsigned char *) list.raddr)[10] << 16) + | ((__vaword)((unsigned char *) list.raddr)[11] << 24) + | ((__vaword)((unsigned char *) list.raddr)[12] << 32) + | ((__vaword)((unsigned char *) list.raddr)[13] << 40); + #else + iret2 = ((__vaword)((unsigned char *) list.raddr)[8] << 56) + | ((__vaword)((unsigned char *) list.raddr)[9] << 48) + | ((__vaword)((unsigned char *) list.raddr)[10] << 40) + | ((__vaword)((unsigned char *) list.raddr)[11] << 32) + | ((__vaword)((unsigned char *) list.raddr)[12] << 24) + | ((__vaword)((unsigned char *) list.raddr)[13] << 16); + #endif + } else + if (list.rsize == 15) { + #if defined(_MIPSEL) + iret2 = ((__vaword)((unsigned char *) list.raddr)[8]) + | ((__vaword)((unsigned char *) list.raddr)[9] << 8) + | ((__vaword)((unsigned char *) list.raddr)[10] << 16) + | ((__vaword)((unsigned char *) list.raddr)[11] << 24) + | ((__vaword)((unsigned char *) list.raddr)[12] << 32) + | ((__vaword)((unsigned char *) list.raddr)[13] << 40) + | ((__vaword)((unsigned char *) list.raddr)[14] << 48); + #else + iret2 = ((__vaword)((unsigned char *) list.raddr)[8] << 56) + | ((__vaword)((unsigned char *) list.raddr)[9] << 48) + | ((__vaword)((unsigned char *) list.raddr)[10] << 40) + | ((__vaword)((unsigned char *) list.raddr)[11] << 32) + | ((__vaword)((unsigned char *) list.raddr)[12] << 24) + | ((__vaword)((unsigned char *) list.raddr)[13] << 16) + | ((__vaword)((unsigned char *) list.raddr)[14] << 8); + #endif + } else + if (list.rsize == 16) { + #if defined(_MIPSEL) + iret2 = ((__vaword)((unsigned char *) list.raddr)[8]) + | ((__vaword)((unsigned char *) list.raddr)[9] << 8) + | ((__vaword)((unsigned char *) list.raddr)[10] << 16) + | ((__vaword)((unsigned char *) list.raddr)[11] << 24) + | ((__vaword)((unsigned char *) list.raddr)[12] << 32) + | ((__vaword)((unsigned char *) list.raddr)[13] << 40) + | ((__vaword)((unsigned char *) list.raddr)[14] << 48) + | ((__vaword)((unsigned char *) list.raddr)[15] << 56); + #else + iret2 = ((__vaword)((unsigned char *) list.raddr)[8] << 56) + | ((__vaword)((unsigned char *) list.raddr)[9] << 48) + | ((__vaword)((unsigned char *) list.raddr)[10] << 40) + | ((__vaword)((unsigned char *) list.raddr)[11] << 32) + | ((__vaword)((unsigned char *) list.raddr)[12] << 24) + | ((__vaword)((unsigned char *) list.raddr)[13] << 16) + | ((__vaword)((unsigned char *) list.raddr)[14] << 8) + | (__vaword)((unsigned char *) list.raddr)[15]; + #endif + } + } + #else /* Optimized: fewer conditional jumps, fewer memory accesses */ + uintptr_t count = list.rsize; /* > 0, ≤ 2*sizeof(__vaword) */ + __vaword* wordaddr = (__vaword*)((uintptr_t)list.raddr & ~(uintptr_t)(sizeof(__vaword)-1)); + uintptr_t start_offset = (uintptr_t)list.raddr & (uintptr_t)(sizeof(__vaword)-1); /* ≥ 0, < sizeof(__vaword) */ + uintptr_t end_offset = start_offset + count; /* > 0, < 3*sizeof(__vaword) */ + #if defined(_MIPSEL) + if (count <= sizeof(__vaword)) { + /* Assign iret. */ + if (end_offset <= sizeof(__vaword)) { + /* 0 < end_offset ≤ sizeof(__vaword) */ + __vaword mask0 = ((__vaword)2 << (end_offset*8-1)) - 1; + iret = (wordaddr[0] & mask0) >> (start_offset*8); + } else { + /* sizeof(__vaword) < end_offset < 2*sizeof(__vaword), start_offset > 0 */ + __vaword mask1 = ((__vaword)2 << (end_offset*8-sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | ((wordaddr[1] & mask1) << (sizeof(__vaword)*8-start_offset*8)); + } + } else { + /* Assign iret, iret2. */ + if (end_offset <= 2*sizeof(__vaword)) { + /* sizeof(__vaword) < end_offset ≤ 2*sizeof(__vaword) */ + __vaword mask1 = ((__vaword)2 << (end_offset*8-sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | ((wordaddr[1] & mask1) << (sizeof(__vaword)*4-start_offset*4) << (sizeof(__vaword)*4-start_offset*4)); + iret2 = (wordaddr[1] & mask1) >> (start_offset*8); + } else { + /* 2*sizeof(__vaword) < end_offset < 3*sizeof(__vaword), start_offset > 0 */ + __vaword mask2 = ((__vaword)2 << (end_offset*8-2*sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | (wordaddr[1] << (sizeof(__vaword)*8-start_offset*8)); + iret2 = (wordaddr[1] >> (start_offset*8)) | ((wordaddr[2] & mask2) << (sizeof(__vaword)*8-start_offset*8)); + } + } + #else + if (count <= sizeof(__vaword)) { + /* Assign iret. */ + if (end_offset <= sizeof(__vaword)) { + /* 0 < end_offset ≤ sizeof(__vaword) */ + __vaword mask0 = - ((__vaword)1 << (sizeof(__vaword)*8-end_offset*8)); + iret = (wordaddr[0] & mask0) << (start_offset*8); + } else { + /* sizeof(__vaword) < end_offset < 2*sizeof(__vaword), start_offset > 0 */ + __vaword mask1 = - ((__vaword)1 << (2*sizeof(__vaword)*8-end_offset*8)); + iret = (wordaddr[0] << (start_offset*8)) | ((wordaddr[1] & mask1) >> (sizeof(__vaword)*8-start_offset*8)); + } + } else { + /* Assign iret, iret2. */ + if (end_offset <= 2*sizeof(__vaword)) { + /* sizeof(__vaword) < end_offset ≤ 2*sizeof(__vaword) */ + __vaword mask1 = - ((__vaword)1 << (2*sizeof(__vaword)*8-end_offset*8)); + iret = (wordaddr[0] << (start_offset*8)) | ((wordaddr[1] & mask1) >> (sizeof(__vaword)*4-start_offset*4) >> (sizeof(__vaword)*4-start_offset*4)); + iret2 = (wordaddr[1] & mask1) << (start_offset*8); + } else { + /* 2*sizeof(__vaword) < end_offset < 3*sizeof(__vaword), start_offset > 0 */ + __vaword mask2 = - ((__vaword)1 << (3*sizeof(__vaword)*8-end_offset*8)); + iret = (wordaddr[0] << (start_offset*8)) | (wordaddr[1] >> (sizeof(__vaword)*8-start_offset*8)); + iret2 = (wordaddr[1] << (start_offset*8)) | ((wordaddr[2] & mask2) >> (sizeof(__vaword)*8-start_offset*8)); + } + } + #endif + #endif + } + if (list.flags & __VA_REGISTER_FLOATSTRUCT_RETURN) { + if (list.rsize == sizeof(float)) { + fret = *(float*)list.raddr; + } else + if (list.rsize == 2*sizeof(float)) { + fret = *(float*)list.raddr; + fret2 = *(float*)((char*)list.raddr + 4); + } + } + if (list.flags & __VA_REGISTER_DOUBLESTRUCT_RETURN) { + if (list.rsize == sizeof(double)) { + dret = *(double*)list.raddr; + } else + if (list.rsize == 2*sizeof(double)) { + dret = *(double*)list.raddr; + dret2 = *(double*)((char*)list.raddr + 8); + } + } + } + } + } +} + +#ifdef REENTRANT +__vacall_r_t +callback_get_receiver (void) +{ + return (__vacall_r_t)(void*)&callback_receiver; +} +#endif diff --git a/vacall/vacall-mips64eb-linux.s b/vacall/vacall-mips64eb-linux.s new file mode 100644 index 0000000..caeec7b --- /dev/null +++ b/vacall/vacall-mips64eb-linux.s @@ -0,0 +1,362 @@ + .file 1 "vacall-mips64.c" + .section .mdebug.abi64 + .previous + .nan legacy + .module fp=64 + .module oddspreg + .abicalls + .text + .align 2 + .align 3 + .globl vacall_receiver + .set nomips16 + .set nomicromips + .ent vacall_receiver + .type vacall_receiver, @function +vacall_receiver: + .frame $fp,272,$31 # vars= 160, regs= 6/0, args= 0, gp= 0 + .mask 0xd0070000,-72 + .fmask 0x00000000,0 + .set noreorder + .set nomacro + daddiu $sp,$sp,-272 + sd $28,184($sp) + lui $28,%hi(%neg(%gp_rel(vacall_receiver))) + daddu $28,$28,$25 + daddiu $28,$28,%lo(%neg(%gp_rel(vacall_receiver))) + ld $12,%got_disp(vacall_function)($28) + sd $fp,192($sp) + move $fp,$sp + ld $25,0($12) + daddiu $12,$fp,208 + sd $31,200($sp) + sd $18,176($sp) + sd $17,168($sp) + sd $16,160($sp) + sd $4,208($fp) + sd $5,216($fp) + sd $6,224($fp) + sd $7,232($fp) + sd $8,240($fp) + sd $9,248($fp) + sd $10,256($fp) + sd $11,264($fp) + sdc1 $f12,96($fp) + sdc1 $f13,104($fp) + sdc1 $f14,112($fp) + sdc1 $f15,120($fp) + sdc1 $f16,128($fp) + sdc1 $f17,136($fp) + sdc1 $f18,144($fp) + sdc1 $f19,152($fp) + swc1 $f12,60($fp) + swc1 $f13,64($fp) + swc1 $f14,68($fp) + swc1 $f15,72($fp) + swc1 $f16,76($fp) + swc1 $f17,80($fp) + swc1 $f18,84($fp) + swc1 $f19,88($fp) + move $4,$fp + sw $0,0($fp) + sd $12,24($fp) + sd $0,32($fp) + sw $0,40($fp) + jalr $25 + sw $0,56($fp) + + lw $12,40($fp) + beq $12,$0,.L1 + li $13,1 # 0x1 + + beq $12,$13,.L43 + li $13,2 # 0x2 + + beq $12,$13,.L43 + li $13,3 # 0x3 + + beq $12,$13,.L46 + li $13,4 # 0x4 + + beq $12,$13,.L47 + li $13,5 # 0x5 + + beq $12,$13,.L48 + li $13,6 # 0x6 + + beq $12,$13,.L49 + li $13,7 # 0x7 + + beq $12,$13,.L50 + li $13,8 # 0x8 + + beq $12,$13,.L44 + li $13,9 # 0x9 + + beq $12,$13,.L44 + li $13,10 # 0xa + + beq $12,$13,.L44 + li $13,11 # 0xb + + beq $12,$13,.L44 + li $13,12 # 0xc + + beq $12,$13,.L51 + li $13,13 # 0xd + + beq $12,$13,.L52 + li $13,14 # 0xe + + beq $12,$13,.L44 + li $13,15 # 0xf + + bnel $12,$13,.L58 + move $sp,$fp + + lw $12,0($fp) + andi $13,$12,0x400 + beq $13,$0,.L1 + andi $13,$12,0x4 + + beq $13,$0,.L19 + ld $14,48($fp) + + ld $12,48($fp) + li $13,1 # 0x1 + beq $12,$13,.L53 + li $13,2 # 0x2 + + beq $12,$13,.L54 + li $13,4 # 0x4 + + beq $12,$13,.L55 + li $13,8 # 0x8 + + bnel $12,$13,.L58 + move $sp,$fp + + ld $12,32($fp) + ld $2,0($12) +.L1: + move $sp,$fp +.L58: + ld $31,200($sp) + ld $fp,192($sp) + ld $28,184($sp) + ld $18,176($sp) + ld $17,168($sp) + ld $16,160($sp) + j $31 + daddiu $sp,$sp,272 + + .align 3 +.L43: + move $sp,$fp + ld $31,200($sp) + ld $28,184($sp) + ld $18,176($sp) + ld $17,168($sp) + ld $16,160($sp) + lb $2,8($fp) + ld $fp,192($sp) + j $31 + daddiu $sp,$sp,272 + + .align 3 +.L44: + b .L1 + ld $2,8($fp) + + .align 3 +.L46: + b .L1 + lbu $2,8($fp) + + .align 3 +.L47: + b .L1 + lh $2,8($fp) + + .align 3 +.L48: + b .L1 + lhu $2,8($fp) + + .align 3 +.L49: + b .L1 + lw $2,8($fp) + + .align 3 +.L51: + b .L1 + lwc1 $f0,8($fp) + + .align 3 +.L50: + b .L1 + lwu $2,8($fp) + +.L52: + b .L1 + ldc1 $f0,8($fp) + +.L19: + daddiu $13,$14,-1 + sltu $13,$13,16 + beql $13,$0,.L59 + andi $13,$12,0x800 + + ld $13,32($fp) + li $24,-8 # 0xfffffffffffffff8 + sltu $25,$14,9 + andi $15,$13,0x7 + and $24,$13,$24 + beq $25,$0,.L24 + daddu $13,$14,$15 + + sltu $25,$13,9 + sll $13,$13,0 + beq $25,$0,.L25 + subu $13,$0,$13 + + ld $25,0($24) + sll $13,$13,3 + li $24,-1 # 0xffffffffffffffff + dsll $13,$24,$13 + and $13,$13,$25 + sll $15,$15,3 + dsll $2,$13,$15 +.L23: + andi $13,$12,0x800 +.L59: + beql $13,$0,.L27 + andi $12,$12,0x1000 + + li $13,4 # 0x4 + beq $14,$13,.L56 + li $13,8 # 0x8 + + beql $14,$13,.L57 + ld $13,32($fp) + + andi $12,$12,0x1000 + beql $12,$0,.L58 + move $sp,$fp + + li $12,16 # 0x10 +.L60: + bnel $14,$12,.L58 + move $sp,$fp + + ld $12,32($fp) + ldc1 $f0,0($12) + b .L1 + ldc1 $f2,8($12) + +.L27: + beq $12,$0,.L1 + li $12,8 # 0x8 + + bne $14,$12,.L60 + li $12,16 # 0x10 + + ld $13,32($fp) + b .L1 + ldc1 $f0,0($13) + +.L24: + sltu $25,$13,17 + beq $25,$0,.L26 + sll $13,$13,0 + + ld $18,8($24) + subu $13,$0,$13 + move $16,$15 + li $25,-1 # 0xffffffffffffffff + subu $15,$0,$15 + sll $13,$13,3 + dsll $13,$25,$13 + ld $17,0($24) + sll $25,$15,2 + addiu $24,$25,32 + and $13,$13,$18 + sll $15,$16,3 + dsra $25,$13,$24 + dsll $16,$17,$15 + dsra $24,$25,$24 + or $2,$16,$24 + b .L23 + dsll $3,$13,$15 + +.L53: + ld $12,32($fp) + b .L1 + lbu $2,0($12) + +.L54: + ld $12,32($fp) + b .L1 + lhu $2,0($12) + +.L26: + ld $18,16($24) + subu $13,$0,$13 + ld $16,8($24) + ld $17,0($24) + subu $25,$0,$15 + sll $13,$13,3 + li $24,-1 # 0xffffffffffffffff + dsll $24,$24,$13 + sll $25,$25,3 + sll $15,$15,3 + addiu $25,$25,64 + and $13,$24,$18 + dsra $13,$13,$25 + dsll $24,$17,$15 + dsra $17,$16,$25 + dsll $15,$16,$15 + or $2,$24,$17 + b .L23 + or $3,$13,$15 + +.L56: + ld $12,32($fp) + b .L1 + lwc1 $f0,0($12) + +.L55: + ld $12,32($fp) + b .L1 + lwu $2,0($12) + +.L25: + ld $16,8($24) + ld $25,0($24) + sll $13,$13,3 + li $24,-1 # 0xffffffffffffffff + dsll $13,$24,$13 + subu $24,$0,$15 + and $13,$13,$16 + sll $24,$24,3 + sll $15,$15,3 + dsra $13,$13,$24 + dsll $15,$25,$15 + b .L23 + or $2,$13,$15 + +.L57: + andi $12,$12,0x1000 + lwc1 $f0,0($13) + beq $12,$0,.L1 + lwc1 $f2,4($13) + + b .L1 + ldc1 $f0,0($13) + + .set macro + .set reorder + .end vacall_receiver + .size vacall_receiver, .-vacall_receiver + .ident "GCC: (GNU) 5.4.0" diff --git a/vacall/vacall-mips64eb-macro.S b/vacall/vacall-mips64eb-macro.S new file mode 100644 index 0000000..87b6667 --- /dev/null +++ b/vacall/vacall-mips64eb-macro.S @@ -0,0 +1,356 @@ +#include "asm-mips.h" + .file 1 "vacall-mips64.c" + .text + .align 2 + .align 3 + .globl vacall_receiver + .set nomips16 + .set nomicromips + .ent vacall_receiver + DECLARE_FUNCTION(vacall_receiver) +vacall_receiver: + .frame $fp,272,$31 + .mask 0xd0070000,-72 + .fmask 0x00000000,0 + .set noreorder + .set nomacro + daddiu $sp,$sp,-272 + sd $28,184($sp) + lui $28,%hi(%neg(%gp_rel(vacall_receiver))) + daddu $28,$28,$25 + daddiu $28,$28,%lo(%neg(%gp_rel(vacall_receiver))) + ld $12,%got_disp(vacall_function)($28) + sd $fp,192($sp) + move $fp,$sp + ld $25,0($12) + daddiu $12,$fp,208 + sd $31,200($sp) + sd $18,176($sp) + sd $17,168($sp) + sd $16,160($sp) + sd $4,208($fp) + sd $5,216($fp) + sd $6,224($fp) + sd $7,232($fp) + sd $8,240($fp) + sd $9,248($fp) + sd $10,256($fp) + sd $11,264($fp) + sdc1 $f12,96($fp) + sdc1 $f13,104($fp) + sdc1 $f14,112($fp) + sdc1 $f15,120($fp) + sdc1 $f16,128($fp) + sdc1 $f17,136($fp) + sdc1 $f18,144($fp) + sdc1 $f19,152($fp) + swc1 $f12,60($fp) + swc1 $f13,64($fp) + swc1 $f14,68($fp) + swc1 $f15,72($fp) + swc1 $f16,76($fp) + swc1 $f17,80($fp) + swc1 $f18,84($fp) + swc1 $f19,88($fp) + move $4,$fp + sw $0,0($fp) + sd $12,24($fp) + sd $0,32($fp) + sw $0,40($fp) + jalr $25 + sw $0,56($fp) + + lw $12,40($fp) + beq $12,$0,.L1 + li $13,1 + + beq $12,$13,.L43 + li $13,2 + + beq $12,$13,.L43 + li $13,3 + + beq $12,$13,.L46 + li $13,4 + + beq $12,$13,.L47 + li $13,5 + + beq $12,$13,.L48 + li $13,6 + + beq $12,$13,.L49 + li $13,7 + + beq $12,$13,.L50 + li $13,8 + + beq $12,$13,.L44 + li $13,9 + + beq $12,$13,.L44 + li $13,10 + + beq $12,$13,.L44 + li $13,11 + + beq $12,$13,.L44 + li $13,12 + + beq $12,$13,.L51 + li $13,13 + + beq $12,$13,.L52 + li $13,14 + + beq $12,$13,.L44 + li $13,15 + + bnel $12,$13,.L58 + move $sp,$fp + + lw $12,0($fp) + andi $13,$12,0x400 + beq $13,$0,.L1 + andi $13,$12,0x4 + + beq $13,$0,.L19 + ld $14,48($fp) + + ld $12,48($fp) + li $13,1 + beq $12,$13,.L53 + li $13,2 + + beq $12,$13,.L54 + li $13,4 + + beq $12,$13,.L55 + li $13,8 + + bnel $12,$13,.L58 + move $sp,$fp + + ld $12,32($fp) + ld $2,0($12) +.L1: + move $sp,$fp +.L58: + ld $31,200($sp) + ld $fp,192($sp) + ld $28,184($sp) + ld $18,176($sp) + ld $17,168($sp) + ld $16,160($sp) + j $31 + daddiu $sp,$sp,272 + + .align 3 +.L43: + move $sp,$fp + ld $31,200($sp) + ld $28,184($sp) + ld $18,176($sp) + ld $17,168($sp) + ld $16,160($sp) + lb $2,8($fp) + ld $fp,192($sp) + j $31 + daddiu $sp,$sp,272 + + .align 3 +.L44: + b .L1 + ld $2,8($fp) + + .align 3 +.L46: + b .L1 + lbu $2,8($fp) + + .align 3 +.L47: + b .L1 + lh $2,8($fp) + + .align 3 +.L48: + b .L1 + lhu $2,8($fp) + + .align 3 +.L49: + b .L1 + lw $2,8($fp) + + .align 3 +.L51: + b .L1 + lwc1 $f0,8($fp) + + .align 3 +.L50: + b .L1 + lwu $2,8($fp) + +.L52: + b .L1 + ldc1 $f0,8($fp) + +.L19: + daddiu $13,$14,-1 + sltu $13,$13,16 + beql $13,$0,.L59 + andi $13,$12,0x800 + + ld $13,32($fp) + li $24,-8 + sltu $25,$14,9 + andi $15,$13,0x7 + and $24,$13,$24 + beq $25,$0,.L24 + daddu $13,$14,$15 + + sltu $25,$13,9 + sll $13,$13,0 + beq $25,$0,.L25 + subu $13,$0,$13 + + ld $25,0($24) + sll $13,$13,3 + li $24,-1 + dsll $13,$24,$13 + and $13,$13,$25 + sll $15,$15,3 + dsll $2,$13,$15 +.L23: + andi $13,$12,0x800 +.L59: + beql $13,$0,.L27 + andi $12,$12,0x1000 + + li $13,4 + beq $14,$13,.L56 + li $13,8 + + beql $14,$13,.L57 + ld $13,32($fp) + + andi $12,$12,0x1000 + beql $12,$0,.L58 + move $sp,$fp + + li $12,16 +.L60: + bnel $14,$12,.L58 + move $sp,$fp + + ld $12,32($fp) + ldc1 $f0,0($12) + b .L1 + ldc1 $f2,8($12) + +.L27: + beq $12,$0,.L1 + li $12,8 + + bne $14,$12,.L60 + li $12,16 + + ld $13,32($fp) + b .L1 + ldc1 $f0,0($13) + +.L24: + sltu $25,$13,17 + beq $25,$0,.L26 + sll $13,$13,0 + + ld $18,8($24) + subu $13,$0,$13 + move $16,$15 + li $25,-1 + subu $15,$0,$15 + sll $13,$13,3 + dsll $13,$25,$13 + ld $17,0($24) + sll $25,$15,2 + addiu $24,$25,32 + and $13,$13,$18 + sll $15,$16,3 + dsra $25,$13,$24 + dsll $16,$17,$15 + dsra $24,$25,$24 + or $2,$16,$24 + b .L23 + dsll $3,$13,$15 + +.L53: + ld $12,32($fp) + b .L1 + lbu $2,0($12) + +.L54: + ld $12,32($fp) + b .L1 + lhu $2,0($12) + +.L26: + ld $18,16($24) + subu $13,$0,$13 + ld $16,8($24) + ld $17,0($24) + subu $25,$0,$15 + sll $13,$13,3 + li $24,-1 + dsll $24,$24,$13 + sll $25,$25,3 + sll $15,$15,3 + addiu $25,$25,64 + and $13,$24,$18 + dsra $13,$13,$25 + dsll $24,$17,$15 + dsra $17,$16,$25 + dsll $15,$16,$15 + or $2,$24,$17 + b .L23 + or $3,$13,$15 + +.L56: + ld $12,32($fp) + b .L1 + lwc1 $f0,0($12) + +.L55: + ld $12,32($fp) + b .L1 + lwu $2,0($12) + +.L25: + ld $16,8($24) + ld $25,0($24) + sll $13,$13,3 + li $24,-1 + dsll $13,$24,$13 + subu $24,$0,$15 + and $13,$13,$16 + sll $24,$24,3 + sll $15,$15,3 + dsra $13,$13,$24 + dsll $15,$25,$15 + b .L23 + or $2,$13,$15 + +.L57: + andi $12,$12,0x1000 + lwc1 $f0,0($13) + beq $12,$0,.L1 + lwc1 $f2,4($13) + + b .L1 + ldc1 $f0,0($13) + + .set macro + .set reorder + .end vacall_receiver + .size vacall_receiver, .-vacall_receiver diff --git a/vacall/vacall-mips64el-linux.s b/vacall/vacall-mips64el-linux.s new file mode 100644 index 0000000..a2ea9ad --- /dev/null +++ b/vacall/vacall-mips64el-linux.s @@ -0,0 +1,366 @@ + .file 1 "vacall-mips64.c" + .section .mdebug.abi64 + .previous + .nan legacy + .module fp=64 + .module oddspreg + .abicalls + .text + .align 2 + .align 3 + .globl vacall_receiver + .set nomips16 + .set nomicromips + .ent vacall_receiver + .type vacall_receiver, @function +vacall_receiver: + .frame $fp,272,$31 # vars= 160, regs= 6/0, args= 0, gp= 0 + .mask 0xd0070000,-72 + .fmask 0x00000000,0 + .set noreorder + .set nomacro + daddiu $sp,$sp,-272 + sd $28,184($sp) + lui $28,%hi(%neg(%gp_rel(vacall_receiver))) + daddu $28,$28,$25 + daddiu $28,$28,%lo(%neg(%gp_rel(vacall_receiver))) + ld $12,%got_disp(vacall_function)($28) + sd $fp,192($sp) + move $fp,$sp + ld $25,0($12) + daddiu $12,$fp,208 + sd $31,200($sp) + sd $18,176($sp) + sd $17,168($sp) + sd $16,160($sp) + sd $4,208($fp) + sd $5,216($fp) + sd $6,224($fp) + sd $7,232($fp) + sd $8,240($fp) + sd $9,248($fp) + sd $10,256($fp) + sd $11,264($fp) + sdc1 $f12,96($fp) + sdc1 $f13,104($fp) + sdc1 $f14,112($fp) + sdc1 $f15,120($fp) + sdc1 $f16,128($fp) + sdc1 $f17,136($fp) + sdc1 $f18,144($fp) + sdc1 $f19,152($fp) + swc1 $f12,60($fp) + swc1 $f13,64($fp) + swc1 $f14,68($fp) + swc1 $f15,72($fp) + swc1 $f16,76($fp) + swc1 $f17,80($fp) + swc1 $f18,84($fp) + swc1 $f19,88($fp) + move $4,$fp + sw $0,0($fp) + sd $12,24($fp) + sd $0,32($fp) + sw $0,40($fp) + jalr $25 + sw $0,56($fp) + + lw $12,40($fp) + beq $12,$0,.L1 + li $13,1 # 0x1 + + beq $12,$13,.L43 + li $13,2 # 0x2 + + beq $12,$13,.L43 + li $13,3 # 0x3 + + beq $12,$13,.L46 + li $13,4 # 0x4 + + beq $12,$13,.L47 + li $13,5 # 0x5 + + beq $12,$13,.L48 + li $13,6 # 0x6 + + beq $12,$13,.L49 + li $13,7 # 0x7 + + beq $12,$13,.L50 + li $13,8 # 0x8 + + beq $12,$13,.L44 + li $13,9 # 0x9 + + beq $12,$13,.L44 + li $13,10 # 0xa + + beq $12,$13,.L44 + li $13,11 # 0xb + + beq $12,$13,.L44 + li $13,12 # 0xc + + beq $12,$13,.L51 + li $13,13 # 0xd + + beq $12,$13,.L52 + li $13,14 # 0xe + + beq $12,$13,.L44 + li $13,15 # 0xf + + bnel $12,$13,.L58 + move $sp,$fp + + lw $12,0($fp) + andi $13,$12,0x400 + beq $13,$0,.L1 + andi $13,$12,0x4 + + beq $13,$0,.L19 + ld $14,48($fp) + + ld $12,48($fp) + li $13,1 # 0x1 + beq $12,$13,.L53 + li $13,2 # 0x2 + + beq $12,$13,.L54 + li $13,4 # 0x4 + + beq $12,$13,.L55 + li $13,8 # 0x8 + + bnel $12,$13,.L58 + move $sp,$fp + + ld $12,32($fp) + ld $2,0($12) +.L1: + move $sp,$fp +.L58: + ld $31,200($sp) + ld $fp,192($sp) + ld $28,184($sp) + ld $18,176($sp) + ld $17,168($sp) + ld $16,160($sp) + j $31 + daddiu $sp,$sp,272 + + .align 3 +.L43: + move $sp,$fp + ld $31,200($sp) + ld $28,184($sp) + ld $18,176($sp) + ld $17,168($sp) + ld $16,160($sp) + lb $2,8($fp) + ld $fp,192($sp) + j $31 + daddiu $sp,$sp,272 + + .align 3 +.L44: + b .L1 + ld $2,8($fp) + + .align 3 +.L46: + b .L1 + lbu $2,8($fp) + + .align 3 +.L47: + b .L1 + lh $2,8($fp) + + .align 3 +.L48: + b .L1 + lhu $2,8($fp) + + .align 3 +.L49: + b .L1 + lw $2,8($fp) + + .align 3 +.L51: + b .L1 + lwc1 $f0,8($fp) + + .align 3 +.L50: + b .L1 + lwu $2,8($fp) + +.L52: + b .L1 + ldc1 $f0,8($fp) + +.L19: + daddiu $13,$14,-1 + sltu $13,$13,16 + beql $13,$0,.L59 + andi $13,$12,0x800 + + ld $13,32($fp) + li $15,-8 # 0xfffffffffffffff8 + sltu $25,$14,9 + andi $24,$13,0x7 + and $15,$13,$15 + beq $25,$0,.L24 + daddu $13,$14,$24 + + sltu $25,$13,9 + beq $25,$0,.L25 + dsll $13,$13,3 + + daddiu $13,$13,-1 + ld $25,0($15) + sll $13,$13,0 + li $15,2 # 0x2 + dsll $13,$15,$13 + daddiu $13,$13,-1 + and $13,$13,$25 + sll $24,$24,3 + dsra $2,$13,$24 +.L23: + andi $13,$12,0x800 +.L59: + beql $13,$0,.L27 + andi $12,$12,0x1000 + + li $13,4 # 0x4 + beq $14,$13,.L56 + li $13,8 # 0x8 + + beql $14,$13,.L57 + ld $13,32($fp) + + andi $12,$12,0x1000 + beql $12,$0,.L58 + move $sp,$fp + + li $12,16 # 0x10 +.L60: + bnel $14,$12,.L58 + move $sp,$fp + + ld $12,32($fp) + ldc1 $f0,0($12) + b .L1 + ldc1 $f2,8($12) + +.L27: + beq $12,$0,.L1 + li $12,8 # 0x8 + + bne $14,$12,.L60 + li $12,16 # 0x10 + + ld $13,32($fp) + b .L1 + ldc1 $f0,0($13) + +.L24: + sltu $25,$13,17 + beq $25,$0,.L26 + dsll $13,$13,3 + + daddiu $13,$13,-65 + ld $17,8($15) + li $25,2 # 0x2 + sll $13,$13,0 + dsll $13,$25,$13 + subu $25,$0,$24 + sll $25,$25,2 + ld $16,0($15) + daddiu $13,$13,-1 + addiu $15,$25,32 + and $13,$13,$17 + sll $24,$24,3 + dsll $25,$13,$15 + dsra $16,$16,$24 + dsll $15,$25,$15 + or $2,$16,$15 + b .L23 + dsra $3,$13,$24 + +.L53: + ld $12,32($fp) + b .L1 + lbu $2,0($12) + +.L54: + ld $12,32($fp) + b .L1 + lhu $2,0($12) + +.L26: + daddiu $13,$13,-129 + ld $16,8($15) + ld $17,0($15) + sll $13,$13,0 + ld $18,16($15) + li $15,2 # 0x2 + subu $25,$0,$24 + dsll $15,$15,$13 + daddiu $15,$15,-1 + sll $25,$25,3 + sll $24,$24,3 + addiu $25,$25,64 + and $13,$15,$18 + dsll $13,$13,$25 + dsra $15,$17,$24 + dsll $17,$16,$25 + dsra $24,$16,$24 + or $2,$15,$17 + b .L23 + or $3,$13,$24 + +.L56: + ld $12,32($fp) + b .L1 + lwc1 $f0,0($12) + +.L55: + ld $12,32($fp) + b .L1 + lwu $2,0($12) + +.L25: + daddiu $13,$13,-65 + li $25,2 # 0x2 + sll $13,$13,0 + ld $17,8($15) + dsll $13,$25,$13 + ld $25,0($15) + daddiu $13,$13,-1 + subu $16,$0,$24 + and $15,$13,$17 + sll $24,$24,3 + sll $13,$16,3 + dsll $13,$15,$13 + dsra $24,$25,$24 + b .L23 + or $2,$13,$24 + +.L57: + andi $12,$12,0x1000 + lwc1 $f0,0($13) + beq $12,$0,.L1 + lwc1 $f2,4($13) + + b .L1 + ldc1 $f0,0($13) + + .set macro + .set reorder + .end vacall_receiver + .size vacall_receiver, .-vacall_receiver + .ident "GCC: (GNU) 5.4.0" diff --git a/vacall/vacall-mips64el-macro.S b/vacall/vacall-mips64el-macro.S new file mode 100644 index 0000000..63b81f5 --- /dev/null +++ b/vacall/vacall-mips64el-macro.S @@ -0,0 +1,360 @@ +#include "asm-mips.h" + .file 1 "vacall-mips64.c" + .text + .align 2 + .align 3 + .globl vacall_receiver + .set nomips16 + .set nomicromips + .ent vacall_receiver + DECLARE_FUNCTION(vacall_receiver) +vacall_receiver: + .frame $fp,272,$31 + .mask 0xd0070000,-72 + .fmask 0x00000000,0 + .set noreorder + .set nomacro + daddiu $sp,$sp,-272 + sd $28,184($sp) + lui $28,%hi(%neg(%gp_rel(vacall_receiver))) + daddu $28,$28,$25 + daddiu $28,$28,%lo(%neg(%gp_rel(vacall_receiver))) + ld $12,%got_disp(vacall_function)($28) + sd $fp,192($sp) + move $fp,$sp + ld $25,0($12) + daddiu $12,$fp,208 + sd $31,200($sp) + sd $18,176($sp) + sd $17,168($sp) + sd $16,160($sp) + sd $4,208($fp) + sd $5,216($fp) + sd $6,224($fp) + sd $7,232($fp) + sd $8,240($fp) + sd $9,248($fp) + sd $10,256($fp) + sd $11,264($fp) + sdc1 $f12,96($fp) + sdc1 $f13,104($fp) + sdc1 $f14,112($fp) + sdc1 $f15,120($fp) + sdc1 $f16,128($fp) + sdc1 $f17,136($fp) + sdc1 $f18,144($fp) + sdc1 $f19,152($fp) + swc1 $f12,60($fp) + swc1 $f13,64($fp) + swc1 $f14,68($fp) + swc1 $f15,72($fp) + swc1 $f16,76($fp) + swc1 $f17,80($fp) + swc1 $f18,84($fp) + swc1 $f19,88($fp) + move $4,$fp + sw $0,0($fp) + sd $12,24($fp) + sd $0,32($fp) + sw $0,40($fp) + jalr $25 + sw $0,56($fp) + + lw $12,40($fp) + beq $12,$0,.L1 + li $13,1 + + beq $12,$13,.L43 + li $13,2 + + beq $12,$13,.L43 + li $13,3 + + beq $12,$13,.L46 + li $13,4 + + beq $12,$13,.L47 + li $13,5 + + beq $12,$13,.L48 + li $13,6 + + beq $12,$13,.L49 + li $13,7 + + beq $12,$13,.L50 + li $13,8 + + beq $12,$13,.L44 + li $13,9 + + beq $12,$13,.L44 + li $13,10 + + beq $12,$13,.L44 + li $13,11 + + beq $12,$13,.L44 + li $13,12 + + beq $12,$13,.L51 + li $13,13 + + beq $12,$13,.L52 + li $13,14 + + beq $12,$13,.L44 + li $13,15 + + bnel $12,$13,.L58 + move $sp,$fp + + lw $12,0($fp) + andi $13,$12,0x400 + beq $13,$0,.L1 + andi $13,$12,0x4 + + beq $13,$0,.L19 + ld $14,48($fp) + + ld $12,48($fp) + li $13,1 + beq $12,$13,.L53 + li $13,2 + + beq $12,$13,.L54 + li $13,4 + + beq $12,$13,.L55 + li $13,8 + + bnel $12,$13,.L58 + move $sp,$fp + + ld $12,32($fp) + ld $2,0($12) +.L1: + move $sp,$fp +.L58: + ld $31,200($sp) + ld $fp,192($sp) + ld $28,184($sp) + ld $18,176($sp) + ld $17,168($sp) + ld $16,160($sp) + j $31 + daddiu $sp,$sp,272 + + .align 3 +.L43: + move $sp,$fp + ld $31,200($sp) + ld $28,184($sp) + ld $18,176($sp) + ld $17,168($sp) + ld $16,160($sp) + lb $2,8($fp) + ld $fp,192($sp) + j $31 + daddiu $sp,$sp,272 + + .align 3 +.L44: + b .L1 + ld $2,8($fp) + + .align 3 +.L46: + b .L1 + lbu $2,8($fp) + + .align 3 +.L47: + b .L1 + lh $2,8($fp) + + .align 3 +.L48: + b .L1 + lhu $2,8($fp) + + .align 3 +.L49: + b .L1 + lw $2,8($fp) + + .align 3 +.L51: + b .L1 + lwc1 $f0,8($fp) + + .align 3 +.L50: + b .L1 + lwu $2,8($fp) + +.L52: + b .L1 + ldc1 $f0,8($fp) + +.L19: + daddiu $13,$14,-1 + sltu $13,$13,16 + beql $13,$0,.L59 + andi $13,$12,0x800 + + ld $13,32($fp) + li $15,-8 + sltu $25,$14,9 + andi $24,$13,0x7 + and $15,$13,$15 + beq $25,$0,.L24 + daddu $13,$14,$24 + + sltu $25,$13,9 + beq $25,$0,.L25 + dsll $13,$13,3 + + daddiu $13,$13,-1 + ld $25,0($15) + sll $13,$13,0 + li $15,2 + dsll $13,$15,$13 + daddiu $13,$13,-1 + and $13,$13,$25 + sll $24,$24,3 + dsra $2,$13,$24 +.L23: + andi $13,$12,0x800 +.L59: + beql $13,$0,.L27 + andi $12,$12,0x1000 + + li $13,4 + beq $14,$13,.L56 + li $13,8 + + beql $14,$13,.L57 + ld $13,32($fp) + + andi $12,$12,0x1000 + beql $12,$0,.L58 + move $sp,$fp + + li $12,16 +.L60: + bnel $14,$12,.L58 + move $sp,$fp + + ld $12,32($fp) + ldc1 $f0,0($12) + b .L1 + ldc1 $f2,8($12) + +.L27: + beq $12,$0,.L1 + li $12,8 + + bne $14,$12,.L60 + li $12,16 + + ld $13,32($fp) + b .L1 + ldc1 $f0,0($13) + +.L24: + sltu $25,$13,17 + beq $25,$0,.L26 + dsll $13,$13,3 + + daddiu $13,$13,-65 + ld $17,8($15) + li $25,2 + sll $13,$13,0 + dsll $13,$25,$13 + subu $25,$0,$24 + sll $25,$25,2 + ld $16,0($15) + daddiu $13,$13,-1 + addiu $15,$25,32 + and $13,$13,$17 + sll $24,$24,3 + dsll $25,$13,$15 + dsra $16,$16,$24 + dsll $15,$25,$15 + or $2,$16,$15 + b .L23 + dsra $3,$13,$24 + +.L53: + ld $12,32($fp) + b .L1 + lbu $2,0($12) + +.L54: + ld $12,32($fp) + b .L1 + lhu $2,0($12) + +.L26: + daddiu $13,$13,-129 + ld $16,8($15) + ld $17,0($15) + sll $13,$13,0 + ld $18,16($15) + li $15,2 + subu $25,$0,$24 + dsll $15,$15,$13 + daddiu $15,$15,-1 + sll $25,$25,3 + sll $24,$24,3 + addiu $25,$25,64 + and $13,$15,$18 + dsll $13,$13,$25 + dsra $15,$17,$24 + dsll $17,$16,$25 + dsra $24,$16,$24 + or $2,$15,$17 + b .L23 + or $3,$13,$24 + +.L56: + ld $12,32($fp) + b .L1 + lwc1 $f0,0($12) + +.L55: + ld $12,32($fp) + b .L1 + lwu $2,0($12) + +.L25: + daddiu $13,$13,-65 + li $25,2 + sll $13,$13,0 + ld $17,8($15) + dsll $13,$25,$13 + ld $25,0($15) + daddiu $13,$13,-1 + subu $16,$0,$24 + and $15,$13,$17 + sll $24,$24,3 + sll $13,$16,3 + dsll $13,$15,$13 + dsra $24,$25,$24 + b .L23 + or $2,$13,$24 + +.L57: + andi $12,$12,0x1000 + lwc1 $f0,0($13) + beq $12,$0,.L1 + lwc1 $f2,4($13) + + b .L1 + ldc1 $f0,0($13) + + .set macro + .set reorder + .end vacall_receiver + .size vacall_receiver, .-vacall_receiver diff --git a/vacall/vacall-mipseb-linux.s b/vacall/vacall-mipseb-linux.s new file mode 100644 index 0000000..7cc4184 --- /dev/null +++ b/vacall/vacall-mipseb-linux.s @@ -0,0 +1,295 @@ + .file 1 "vacall-mips.c" + .section .mdebug.abi32 + .previous + .nan legacy + .module fp=xx + .module nooddspreg + .abicalls + .text + .align 2 + .globl vacall_receiver + .set nomips16 + .set nomicromips + .ent vacall_receiver + .type vacall_receiver, @function +vacall_receiver: + .frame $fp,104,$31 # vars= 72, regs= 2/0, args= 16, gp= 8 + .mask 0xc0000000,-4 + .fmask 0x00000000,0 + .set noreorder + .cpload $25 + .set reorder + addiu $sp,$sp,-104 + sw $fp,96($sp) + move $fp,$sp + sw $31,100($sp) + la $8,vacall_function + sw $4,104($fp) + lw $25,0($8) + addiu $4,$fp,104 + sw $4,40($fp) + addiu $4,$fp,120 + sw $4,56($fp) + .cprestore 16 + addiu $4,$fp,24 + sw $5,108($fp) + sw $6,112($fp) + sw $7,116($fp) + sdc1 $f12,80($fp) + sdc1 $f14,88($fp) + swc1 $f12,68($fp) + swc1 $f14,72($fp) + sw $0,24($fp) + sw $0,44($fp) + sw $0,48($fp) + sw $0,60($fp) + sw $0,64($fp) + jal $25 + lw $4,48($fp) + .set noreorder + .set nomacro + beq $4,$0,$L1 + li $5,1 # 0x1 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L23 + li $5,2 # 0x2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L23 + li $5,3 # 0x3 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L29 + li $5,4 # 0x4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L30 + li $5,5 # 0x5 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L31 + li $5,6 # 0x6 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,7 # 0x7 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,8 # 0x8 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,9 # 0x9 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + addiu $5,$4,-10 + .set macro + .set reorder + + sltu $5,$5,2 + .set noreorder + .set nomacro + bne $5,$0,$L32 + li $5,12 # 0xc + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L33 + li $5,13 # 0xd + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L34 + li $5,14 # 0xe + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,15 # 0xf + .set macro + .set reorder + + .set noreorder + .set nomacro + bnel $4,$5,$L37 + move $sp,$fp + .set macro + .set reorder + + lw $4,24($fp) + andi $4,$4,0x2 + .set noreorder + .set nomacro + beql $4,$0,$L38 + lw $2,44($fp) + .set macro + .set reorder + + lw $4,52($fp) + li $5,1 # 0x1 + .set noreorder + .set nomacro + beql $4,$5,$L35 + lw $4,44($fp) + .set macro + .set reorder + + li $5,2 # 0x2 + .set noreorder + .set nomacro + beq $4,$5,$L36 + li $5,4 # 0x4 + .set macro + .set reorder + + .set noreorder + .set nomacro + bnel $4,$5,$L37 + move $sp,$fp + .set macro + .set reorder + + lw $4,44($fp) + lw $2,0($4) +$L1: +$L38: + move $sp,$fp +$L37: + lw $31,100($sp) + lw $fp,96($sp) + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,104 + .set macro + .set reorder + +$L23: + move $sp,$fp + lw $31,100($sp) + lb $2,32($fp) + lw $fp,96($sp) + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,104 + .set macro + .set reorder + +$L27: + move $sp,$fp + lw $31,100($sp) + lw $2,32($fp) + lw $fp,96($sp) + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,104 + .set macro + .set reorder + +$L29: + .set noreorder + .set nomacro + b $L1 + lbu $2,32($fp) + .set macro + .set reorder + +$L30: + .set noreorder + .set nomacro + b $L1 + lh $2,32($fp) + .set macro + .set reorder + +$L31: + .set noreorder + .set nomacro + b $L1 + lhu $2,32($fp) + .set macro + .set reorder + +$L34: + .set noreorder + .set nomacro + b $L1 + ldc1 $f0,32($fp) + .set macro + .set reorder + +$L32: + lw $2,32($fp) + .set noreorder + .set nomacro + b $L1 + lw $3,36($fp) + .set macro + .set reorder + +$L33: + .set noreorder + .set nomacro + b $L1 + lwc1 $f0,32($fp) + .set macro + .set reorder + +$L35: + .set noreorder + .set nomacro + b $L1 + lbu $2,0($4) + .set macro + .set reorder + +$L36: + lw $4,44($fp) + .set noreorder + .set nomacro + b $L1 + lhu $2,0($4) + .set macro + .set reorder + + .end vacall_receiver + .size vacall_receiver, .-vacall_receiver + .ident "GCC: (GNU) 5.4.0" diff --git a/vacall/vacall-mipseb-macro.S b/vacall/vacall-mipseb-macro.S new file mode 100644 index 0000000..9255dce --- /dev/null +++ b/vacall/vacall-mipseb-macro.S @@ -0,0 +1,289 @@ +#include "asm-mips.h" + .file 1 "vacall-mips.c" + .text + .align 2 + .globl vacall_receiver + .set nomips16 + .set nomicromips + .ent vacall_receiver + DECLARE_FUNCTION(vacall_receiver) +vacall_receiver: + .frame $fp,104,$31 + .mask 0xc0000000,-4 + .fmask 0x00000000,0 + .set noreorder + .cpload $25 + .set reorder + addiu $sp,$sp,-104 + sw $fp,96($sp) + move $fp,$sp + sw $31,100($sp) + la $8,vacall_function + sw $4,104($fp) + lw $25,0($8) + addiu $4,$fp,104 + sw $4,40($fp) + addiu $4,$fp,120 + sw $4,56($fp) + .cprestore 16 + addiu $4,$fp,24 + sw $5,108($fp) + sw $6,112($fp) + sw $7,116($fp) + sdc1 $f12,80($fp) + sdc1 $f14,88($fp) + swc1 $f12,68($fp) + swc1 $f14,72($fp) + sw $0,24($fp) + sw $0,44($fp) + sw $0,48($fp) + sw $0,60($fp) + sw $0,64($fp) + jal $25 + lw $4,48($fp) + .set noreorder + .set nomacro + beq $4,$0,$L1 + li $5,1 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L23 + li $5,2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L23 + li $5,3 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L29 + li $5,4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L30 + li $5,5 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L31 + li $5,6 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,7 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,8 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,9 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + addiu $5,$4,-10 + .set macro + .set reorder + + sltu $5,$5,2 + .set noreorder + .set nomacro + bne $5,$0,$L32 + li $5,12 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L33 + li $5,13 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L34 + li $5,14 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,15 + .set macro + .set reorder + + .set noreorder + .set nomacro + bnel $4,$5,$L37 + move $sp,$fp + .set macro + .set reorder + + lw $4,24($fp) + andi $4,$4,0x2 + .set noreorder + .set nomacro + beql $4,$0,$L38 + lw $2,44($fp) + .set macro + .set reorder + + lw $4,52($fp) + li $5,1 + .set noreorder + .set nomacro + beql $4,$5,$L35 + lw $4,44($fp) + .set macro + .set reorder + + li $5,2 + .set noreorder + .set nomacro + beq $4,$5,$L36 + li $5,4 + .set macro + .set reorder + + .set noreorder + .set nomacro + bnel $4,$5,$L37 + move $sp,$fp + .set macro + .set reorder + + lw $4,44($fp) + lw $2,0($4) +$L1: +$L38: + move $sp,$fp +$L37: + lw $31,100($sp) + lw $fp,96($sp) + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,104 + .set macro + .set reorder + +$L23: + move $sp,$fp + lw $31,100($sp) + lb $2,32($fp) + lw $fp,96($sp) + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,104 + .set macro + .set reorder + +$L27: + move $sp,$fp + lw $31,100($sp) + lw $2,32($fp) + lw $fp,96($sp) + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,104 + .set macro + .set reorder + +$L29: + .set noreorder + .set nomacro + b $L1 + lbu $2,32($fp) + .set macro + .set reorder + +$L30: + .set noreorder + .set nomacro + b $L1 + lh $2,32($fp) + .set macro + .set reorder + +$L31: + .set noreorder + .set nomacro + b $L1 + lhu $2,32($fp) + .set macro + .set reorder + +$L34: + .set noreorder + .set nomacro + b $L1 + ldc1 $f0,32($fp) + .set macro + .set reorder + +$L32: + lw $2,32($fp) + .set noreorder + .set nomacro + b $L1 + lw $3,36($fp) + .set macro + .set reorder + +$L33: + .set noreorder + .set nomacro + b $L1 + lwc1 $f0,32($fp) + .set macro + .set reorder + +$L35: + .set noreorder + .set nomacro + b $L1 + lbu $2,0($4) + .set macro + .set reorder + +$L36: + lw $4,44($fp) + .set noreorder + .set nomacro + b $L1 + lhu $2,0($4) + .set macro + .set reorder + + .end vacall_receiver + .size vacall_receiver, .-vacall_receiver diff --git a/vacall/vacall-mipsel-linux.s b/vacall/vacall-mipsel-linux.s new file mode 100644 index 0000000..7cc4184 --- /dev/null +++ b/vacall/vacall-mipsel-linux.s @@ -0,0 +1,295 @@ + .file 1 "vacall-mips.c" + .section .mdebug.abi32 + .previous + .nan legacy + .module fp=xx + .module nooddspreg + .abicalls + .text + .align 2 + .globl vacall_receiver + .set nomips16 + .set nomicromips + .ent vacall_receiver + .type vacall_receiver, @function +vacall_receiver: + .frame $fp,104,$31 # vars= 72, regs= 2/0, args= 16, gp= 8 + .mask 0xc0000000,-4 + .fmask 0x00000000,0 + .set noreorder + .cpload $25 + .set reorder + addiu $sp,$sp,-104 + sw $fp,96($sp) + move $fp,$sp + sw $31,100($sp) + la $8,vacall_function + sw $4,104($fp) + lw $25,0($8) + addiu $4,$fp,104 + sw $4,40($fp) + addiu $4,$fp,120 + sw $4,56($fp) + .cprestore 16 + addiu $4,$fp,24 + sw $5,108($fp) + sw $6,112($fp) + sw $7,116($fp) + sdc1 $f12,80($fp) + sdc1 $f14,88($fp) + swc1 $f12,68($fp) + swc1 $f14,72($fp) + sw $0,24($fp) + sw $0,44($fp) + sw $0,48($fp) + sw $0,60($fp) + sw $0,64($fp) + jal $25 + lw $4,48($fp) + .set noreorder + .set nomacro + beq $4,$0,$L1 + li $5,1 # 0x1 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L23 + li $5,2 # 0x2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L23 + li $5,3 # 0x3 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L29 + li $5,4 # 0x4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L30 + li $5,5 # 0x5 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L31 + li $5,6 # 0x6 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,7 # 0x7 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,8 # 0x8 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,9 # 0x9 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + addiu $5,$4,-10 + .set macro + .set reorder + + sltu $5,$5,2 + .set noreorder + .set nomacro + bne $5,$0,$L32 + li $5,12 # 0xc + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L33 + li $5,13 # 0xd + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L34 + li $5,14 # 0xe + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,15 # 0xf + .set macro + .set reorder + + .set noreorder + .set nomacro + bnel $4,$5,$L37 + move $sp,$fp + .set macro + .set reorder + + lw $4,24($fp) + andi $4,$4,0x2 + .set noreorder + .set nomacro + beql $4,$0,$L38 + lw $2,44($fp) + .set macro + .set reorder + + lw $4,52($fp) + li $5,1 # 0x1 + .set noreorder + .set nomacro + beql $4,$5,$L35 + lw $4,44($fp) + .set macro + .set reorder + + li $5,2 # 0x2 + .set noreorder + .set nomacro + beq $4,$5,$L36 + li $5,4 # 0x4 + .set macro + .set reorder + + .set noreorder + .set nomacro + bnel $4,$5,$L37 + move $sp,$fp + .set macro + .set reorder + + lw $4,44($fp) + lw $2,0($4) +$L1: +$L38: + move $sp,$fp +$L37: + lw $31,100($sp) + lw $fp,96($sp) + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,104 + .set macro + .set reorder + +$L23: + move $sp,$fp + lw $31,100($sp) + lb $2,32($fp) + lw $fp,96($sp) + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,104 + .set macro + .set reorder + +$L27: + move $sp,$fp + lw $31,100($sp) + lw $2,32($fp) + lw $fp,96($sp) + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,104 + .set macro + .set reorder + +$L29: + .set noreorder + .set nomacro + b $L1 + lbu $2,32($fp) + .set macro + .set reorder + +$L30: + .set noreorder + .set nomacro + b $L1 + lh $2,32($fp) + .set macro + .set reorder + +$L31: + .set noreorder + .set nomacro + b $L1 + lhu $2,32($fp) + .set macro + .set reorder + +$L34: + .set noreorder + .set nomacro + b $L1 + ldc1 $f0,32($fp) + .set macro + .set reorder + +$L32: + lw $2,32($fp) + .set noreorder + .set nomacro + b $L1 + lw $3,36($fp) + .set macro + .set reorder + +$L33: + .set noreorder + .set nomacro + b $L1 + lwc1 $f0,32($fp) + .set macro + .set reorder + +$L35: + .set noreorder + .set nomacro + b $L1 + lbu $2,0($4) + .set macro + .set reorder + +$L36: + lw $4,44($fp) + .set noreorder + .set nomacro + b $L1 + lhu $2,0($4) + .set macro + .set reorder + + .end vacall_receiver + .size vacall_receiver, .-vacall_receiver + .ident "GCC: (GNU) 5.4.0" diff --git a/vacall/vacall-mipsel-macro.S b/vacall/vacall-mipsel-macro.S new file mode 100644 index 0000000..9255dce --- /dev/null +++ b/vacall/vacall-mipsel-macro.S @@ -0,0 +1,289 @@ +#include "asm-mips.h" + .file 1 "vacall-mips.c" + .text + .align 2 + .globl vacall_receiver + .set nomips16 + .set nomicromips + .ent vacall_receiver + DECLARE_FUNCTION(vacall_receiver) +vacall_receiver: + .frame $fp,104,$31 + .mask 0xc0000000,-4 + .fmask 0x00000000,0 + .set noreorder + .cpload $25 + .set reorder + addiu $sp,$sp,-104 + sw $fp,96($sp) + move $fp,$sp + sw $31,100($sp) + la $8,vacall_function + sw $4,104($fp) + lw $25,0($8) + addiu $4,$fp,104 + sw $4,40($fp) + addiu $4,$fp,120 + sw $4,56($fp) + .cprestore 16 + addiu $4,$fp,24 + sw $5,108($fp) + sw $6,112($fp) + sw $7,116($fp) + sdc1 $f12,80($fp) + sdc1 $f14,88($fp) + swc1 $f12,68($fp) + swc1 $f14,72($fp) + sw $0,24($fp) + sw $0,44($fp) + sw $0,48($fp) + sw $0,60($fp) + sw $0,64($fp) + jal $25 + lw $4,48($fp) + .set noreorder + .set nomacro + beq $4,$0,$L1 + li $5,1 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L23 + li $5,2 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L23 + li $5,3 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L29 + li $5,4 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L30 + li $5,5 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L31 + li $5,6 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,7 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,8 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,9 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + addiu $5,$4,-10 + .set macro + .set reorder + + sltu $5,$5,2 + .set noreorder + .set nomacro + bne $5,$0,$L32 + li $5,12 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L33 + li $5,13 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L34 + li $5,14 + .set macro + .set reorder + + .set noreorder + .set nomacro + beq $4,$5,$L27 + li $5,15 + .set macro + .set reorder + + .set noreorder + .set nomacro + bnel $4,$5,$L37 + move $sp,$fp + .set macro + .set reorder + + lw $4,24($fp) + andi $4,$4,0x2 + .set noreorder + .set nomacro + beql $4,$0,$L38 + lw $2,44($fp) + .set macro + .set reorder + + lw $4,52($fp) + li $5,1 + .set noreorder + .set nomacro + beql $4,$5,$L35 + lw $4,44($fp) + .set macro + .set reorder + + li $5,2 + .set noreorder + .set nomacro + beq $4,$5,$L36 + li $5,4 + .set macro + .set reorder + + .set noreorder + .set nomacro + bnel $4,$5,$L37 + move $sp,$fp + .set macro + .set reorder + + lw $4,44($fp) + lw $2,0($4) +$L1: +$L38: + move $sp,$fp +$L37: + lw $31,100($sp) + lw $fp,96($sp) + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,104 + .set macro + .set reorder + +$L23: + move $sp,$fp + lw $31,100($sp) + lb $2,32($fp) + lw $fp,96($sp) + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,104 + .set macro + .set reorder + +$L27: + move $sp,$fp + lw $31,100($sp) + lw $2,32($fp) + lw $fp,96($sp) + .set noreorder + .set nomacro + j $31 + addiu $sp,$sp,104 + .set macro + .set reorder + +$L29: + .set noreorder + .set nomacro + b $L1 + lbu $2,32($fp) + .set macro + .set reorder + +$L30: + .set noreorder + .set nomacro + b $L1 + lh $2,32($fp) + .set macro + .set reorder + +$L31: + .set noreorder + .set nomacro + b $L1 + lhu $2,32($fp) + .set macro + .set reorder + +$L34: + .set noreorder + .set nomacro + b $L1 + ldc1 $f0,32($fp) + .set macro + .set reorder + +$L32: + lw $2,32($fp) + .set noreorder + .set nomacro + b $L1 + lw $3,36($fp) + .set macro + .set reorder + +$L33: + .set noreorder + .set nomacro + b $L1 + lwc1 $f0,32($fp) + .set macro + .set reorder + +$L35: + .set noreorder + .set nomacro + b $L1 + lbu $2,0($4) + .set macro + .set reorder + +$L36: + lw $4,44($fp) + .set noreorder + .set nomacro + b $L1 + lhu $2,0($4) + .set macro + .set reorder + + .end vacall_receiver + .size vacall_receiver, .-vacall_receiver diff --git a/vacall/vacall-mipsn32.c b/vacall/vacall-mipsn32.c new file mode 100644 index 0000000..32599ce --- /dev/null +++ b/vacall/vacall-mipsn32.c @@ -0,0 +1,508 @@ +/* vacall function for mips CPU */ + +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +#include "vacall-internal.h" + +#ifndef REENTRANT +typedef void (*func_pointer)(va_alist); +#else /* REENTRANT */ +#define vacall_receiver callback_receiver +typedef void (*func_pointer)(void*,va_alist); +register struct { func_pointer vacall_function; void* arg; } + * env __asm__("$2"); +#endif +register void* sp __asm__("$sp"); +register __vaword iarg0 __asm__("$4"); +register __vaword iarg1 __asm__("$5"); +register __vaword iarg2 __asm__("$6"); +register __vaword iarg3 __asm__("$7"); +register __vaword iarg4 __asm__("$8"); +register __vaword iarg5 __asm__("$9"); +register __vaword iarg6 __asm__("$10"); +register __vaword iarg7 __asm__("$11"); +register float farg0 __asm__("$f12"); +register float farg1 __asm__("$f13"); +register float farg2 __asm__("$f14"); +register float farg3 __asm__("$f15"); +register float farg4 __asm__("$f16"); +register float farg5 __asm__("$f17"); +register float farg6 __asm__("$f18"); +register float farg7 __asm__("$f19"); +register double darg0 __asm__("$f12"); +register double darg1 __asm__("$f13"); +register double darg2 __asm__("$f14"); +register double darg3 __asm__("$f15"); +register double darg4 __asm__("$f16"); +register double darg5 __asm__("$f17"); +register double darg6 __asm__("$f18"); +register double darg7 __asm__("$f19"); +register __vaword iret __asm__("$2"); +register __vaword iret2 __asm__("$3"); +register float fret __asm__("$f0"); +register float fret2 __asm__("$f2"); +register double dret __asm__("$f0"); +register double dret2 __asm__("$f2"); + +/* The ABI requires that the first 8 general-purpose argument words are + being passed in registers, even if these words belong to a struct. No room + is allocated for these register words on the stack by the caller, but the + callee allocates room for them - at the right place in the stack frame, + that is, above the usual {fp, retaddr} combo - if and only if they are part + of a larger struct that extends to the stack and the address of this struct + is taken. */ +struct gpargsequence { + __vaword word1; /* r4 */ + __vaword word2; /* r5 */ + __vaword word3; /* r6 */ + __vaword word4; /* r7 */ + __vaword word5; /* r8 */ + __vaword word6; /* r9 */ + __vaword word7; /* r10 */ + __vaword word8; /* r11 */ + __vaword firststackword; +}; + +#ifdef REENTRANT +static +#endif +void /* the return type is variable, not void! */ +vacall_receiver (struct gpargsequence gpargs) +{ + __va_alist list; + list.darg[0] = darg0; + list.darg[1] = darg1; + list.darg[2] = darg2; + list.darg[3] = darg3; + list.darg[4] = darg4; + list.darg[5] = darg5; + list.darg[6] = darg6; + list.darg[7] = darg7; + list.farg[0] = farg0; + list.farg[1] = farg1; + list.farg[2] = farg2; + list.farg[3] = farg3; + list.farg[4] = farg4; + list.farg[5] = farg5; + list.farg[6] = farg6; + list.farg[7] = farg7; + /* Prepare the va_alist. */ + list.flags = 0; + list.aptr = (long)&gpargs; + list.raddr = (void*)0; + list.rtype = __VAvoid; + list.anum = 0; + /* Call vacall_function. The macros do all the rest. */ +#ifndef REENTRANT + (*vacall_function) (&list); +#else /* REENTRANT */ + (*env->vacall_function) (env->arg,&list); +#endif + /* Put return value into proper register. */ + if (list.rtype == __VAvoid) { + } else + if (list.rtype == __VAchar) { + iret = list.tmp._char; + } else + if (list.rtype == __VAschar) { + iret = list.tmp._schar; + } else + if (list.rtype == __VAuchar) { + iret = list.tmp._uchar; + } else + if (list.rtype == __VAshort) { + iret = list.tmp._short; + } else + if (list.rtype == __VAushort) { + iret = list.tmp._ushort; + } else + if (list.rtype == __VAint) { + iret = list.tmp._int; + } else + if (list.rtype == __VAuint) { + iret = list.tmp._uint; + } else + if (list.rtype == __VAlong) { + iret = list.tmp._long; + } else + if (list.rtype == __VAulong) { + iret = list.tmp._ulong; + } else + if (list.rtype == __VAlonglong) { + iret = list.tmp._longlong; + } else + if (list.rtype == __VAulonglong) { + iret = list.tmp._ulonglong; + } else + if (list.rtype == __VAfloat) { + fret = list.tmp._float; + } else + if (list.rtype == __VAdouble) { + dret = list.tmp._double; + } else + if (list.rtype == __VAvoidp) { + iret = (long)list.tmp._ptr; + } else + if (list.rtype == __VAstruct) { + if (list.flags & __VA_REGISTER_STRUCT_RETURN) { + if (list.flags & __VA_GCC_STRUCT_RETURN) { + /* gcc returns structs of size 1,2,4,8 in registers. */ + if (list.rsize == sizeof(char)) { + iret = *(unsigned char *) list.raddr; + } else + if (list.rsize == sizeof(short)) { + iret = *(unsigned short *) list.raddr; + } else + if (list.rsize == sizeof(int)) { + iret = *(unsigned int *) list.raddr; + } else + if (list.rsize == sizeof(long long)) { + iret = *(unsigned long long *) list.raddr; + } + } else { + /* cc returns structs of size <= 16 in registers. */ + /* Maybe this big if cascade could be replaced with + * if (list.rsize > 0 && list.rsize <= 16) + * __asm__ ("ldl $2,%0 ; ldr $2,%1" + * : : "m" (((unsigned char *) list.raddr)[0]), + * "m" (((unsigned char *) list.raddr)[7])); + */ + if (list.rsize > 0 && list.rsize <= 16) { + #if 0 /* Unoptimized */ + if (list.rsize == 1) { + #if defined(_MIPSEL) + iret = (__vaword)((unsigned char *) list.raddr)[0]; + #else + iret = (__vaword)((unsigned char *) list.raddr)[0] << 56; + #endif + } else + if (list.rsize == 2) { + #if defined(_MIPSEL) + iret = ((__vaword)((unsigned char *) list.raddr)[0]) + | ((__vaword)((unsigned char *) list.raddr)[1] << 8); + #else + iret = ((__vaword)((unsigned char *) list.raddr)[0] << 56) + | ((__vaword)((unsigned char *) list.raddr)[1] << 48); + #endif + } else + if (list.rsize == 3) { + #if defined(_MIPSEL) + iret = ((__vaword)((unsigned char *) list.raddr)[0]) + | ((__vaword)((unsigned char *) list.raddr)[1] << 8) + | ((__vaword)((unsigned char *) list.raddr)[2] << 16); + #else + iret = ((__vaword)((unsigned char *) list.raddr)[0] << 56) + | ((__vaword)((unsigned char *) list.raddr)[1] << 48) + | ((__vaword)((unsigned char *) list.raddr)[2] << 40); + #endif + } else + if (list.rsize == 4) { + #if defined(_MIPSEL) + iret = ((__vaword)((unsigned char *) list.raddr)[0]) + | ((__vaword)((unsigned char *) list.raddr)[1] << 8) + | ((__vaword)((unsigned char *) list.raddr)[2] << 16) + | ((__vaword)((unsigned char *) list.raddr)[3] << 24); + #else + iret = ((__vaword)((unsigned char *) list.raddr)[0] << 56) + | ((__vaword)((unsigned char *) list.raddr)[1] << 48) + | ((__vaword)((unsigned char *) list.raddr)[2] << 40) + | ((__vaword)((unsigned char *) list.raddr)[3] << 32); + #endif + } else + if (list.rsize == 5) { + #if defined(_MIPSEL) + iret = ((__vaword)((unsigned char *) list.raddr)[0]) + | ((__vaword)((unsigned char *) list.raddr)[1] << 8) + | ((__vaword)((unsigned char *) list.raddr)[2] << 16) + | ((__vaword)((unsigned char *) list.raddr)[3] << 24) + | ((__vaword)((unsigned char *) list.raddr)[4] << 32); + #else + iret = ((__vaword)((unsigned char *) list.raddr)[0] << 56) + | ((__vaword)((unsigned char *) list.raddr)[1] << 48) + | ((__vaword)((unsigned char *) list.raddr)[2] << 40) + | ((__vaword)((unsigned char *) list.raddr)[3] << 32) + | ((__vaword)((unsigned char *) list.raddr)[4] << 24); + #endif + } else + if (list.rsize == 6) { + #if defined(_MIPSEL) + iret = ((__vaword)((unsigned char *) list.raddr)[0]) + | ((__vaword)((unsigned char *) list.raddr)[1] << 8) + | ((__vaword)((unsigned char *) list.raddr)[2] << 16) + | ((__vaword)((unsigned char *) list.raddr)[3] << 24) + | ((__vaword)((unsigned char *) list.raddr)[4] << 32) + | ((__vaword)((unsigned char *) list.raddr)[5] << 40); + #else + iret = ((__vaword)((unsigned char *) list.raddr)[0] << 56) + | ((__vaword)((unsigned char *) list.raddr)[1] << 48) + | ((__vaword)((unsigned char *) list.raddr)[2] << 40) + | ((__vaword)((unsigned char *) list.raddr)[3] << 32) + | ((__vaword)((unsigned char *) list.raddr)[4] << 24) + | ((__vaword)((unsigned char *) list.raddr)[5] << 16); + #endif + } else + if (list.rsize == 7) { + #if defined(_MIPSEL) + iret = ((__vaword)((unsigned char *) list.raddr)[0]) + | ((__vaword)((unsigned char *) list.raddr)[1] << 8) + | ((__vaword)((unsigned char *) list.raddr)[2] << 16) + | ((__vaword)((unsigned char *) list.raddr)[3] << 24) + | ((__vaword)((unsigned char *) list.raddr)[4] << 32) + | ((__vaword)((unsigned char *) list.raddr)[5] << 40) + | ((__vaword)((unsigned char *) list.raddr)[6] << 48); + #else + iret = ((__vaword)((unsigned char *) list.raddr)[0] << 56) + | ((__vaword)((unsigned char *) list.raddr)[1] << 48) + | ((__vaword)((unsigned char *) list.raddr)[2] << 40) + | ((__vaword)((unsigned char *) list.raddr)[3] << 32) + | ((__vaword)((unsigned char *) list.raddr)[4] << 24) + | ((__vaword)((unsigned char *) list.raddr)[5] << 16) + | ((__vaword)((unsigned char *) list.raddr)[6] << 8); + #endif + } else + if (list.rsize >= 8 && list.rsize <= 16) { + #if defined(_MIPSEL) + iret = ((__vaword)((unsigned char *) list.raddr)[0]) + | ((__vaword)((unsigned char *) list.raddr)[1] << 8) + | ((__vaword)((unsigned char *) list.raddr)[2] << 16) + | ((__vaword)((unsigned char *) list.raddr)[3] << 24) + | ((__vaword)((unsigned char *) list.raddr)[4] << 32) + | ((__vaword)((unsigned char *) list.raddr)[5] << 40) + | ((__vaword)((unsigned char *) list.raddr)[6] << 48) + | ((__vaword)((unsigned char *) list.raddr)[7] << 56); + #else + iret = ((__vaword)((unsigned char *) list.raddr)[0] << 56) + | ((__vaword)((unsigned char *) list.raddr)[1] << 48) + | ((__vaword)((unsigned char *) list.raddr)[2] << 40) + | ((__vaword)((unsigned char *) list.raddr)[3] << 32) + | ((__vaword)((unsigned char *) list.raddr)[4] << 24) + | ((__vaword)((unsigned char *) list.raddr)[5] << 16) + | ((__vaword)((unsigned char *) list.raddr)[6] << 8) + | (__vaword)((unsigned char *) list.raddr)[7]; + #endif + /* Maybe this big if cascade could be replaced with + * if (list.rsize > 8 && list.rsize <= 16) + * __asm__ ("ldl $3,%0 ; ldr $3,%1" + * : : "m" (((unsigned char *) list.raddr)[8]), + * "m" (((unsigned char *) list.raddr)[15])); + */ + if (list.rsize == 8) { + } else + if (list.rsize == 9) { + #if defined(_MIPSEL) + iret2 = (__vaword)((unsigned char *) list.raddr)[8]; + #else + iret2 = (__vaword)((unsigned char *) list.raddr)[8] << 56; + #endif + } else + if (list.rsize == 10) { + #if defined(_MIPSEL) + iret2 = ((__vaword)((unsigned char *) list.raddr)[8]) + | ((__vaword)((unsigned char *) list.raddr)[9] << 8); + #else + iret2 = ((__vaword)((unsigned char *) list.raddr)[8] << 56) + | ((__vaword)((unsigned char *) list.raddr)[9] << 48); + #endif + } else + if (list.rsize == 11) { + #if defined(_MIPSEL) + iret2 = ((__vaword)((unsigned char *) list.raddr)[8]) + | ((__vaword)((unsigned char *) list.raddr)[9] << 8) + | ((__vaword)((unsigned char *) list.raddr)[10] << 16); + #else + iret2 = ((__vaword)((unsigned char *) list.raddr)[8] << 56) + | ((__vaword)((unsigned char *) list.raddr)[9] << 48) + | ((__vaword)((unsigned char *) list.raddr)[10] << 40); + #endif + } else + if (list.rsize == 12) { + #if defined(_MIPSEL) + iret2 = ((__vaword)((unsigned char *) list.raddr)[8]) + | ((__vaword)((unsigned char *) list.raddr)[9] << 8) + | ((__vaword)((unsigned char *) list.raddr)[10] << 16) + | ((__vaword)((unsigned char *) list.raddr)[11] << 24); + #else + iret2 = ((__vaword)((unsigned char *) list.raddr)[8] << 56) + | ((__vaword)((unsigned char *) list.raddr)[9] << 48) + | ((__vaword)((unsigned char *) list.raddr)[10] << 40) + | ((__vaword)((unsigned char *) list.raddr)[11] << 32); + #endif + } else + if (list.rsize == 13) { + #if defined(_MIPSEL) + iret2 = ((__vaword)((unsigned char *) list.raddr)[8]) + | ((__vaword)((unsigned char *) list.raddr)[9] << 8) + | ((__vaword)((unsigned char *) list.raddr)[10] << 16) + | ((__vaword)((unsigned char *) list.raddr)[11] << 24) + | ((__vaword)((unsigned char *) list.raddr)[12] << 32); + #else + iret2 = ((__vaword)((unsigned char *) list.raddr)[8] << 56) + | ((__vaword)((unsigned char *) list.raddr)[9] << 48) + | ((__vaword)((unsigned char *) list.raddr)[10] << 40) + | ((__vaword)((unsigned char *) list.raddr)[11] << 32) + | ((__vaword)((unsigned char *) list.raddr)[12] << 24); + #endif + } else + if (list.rsize == 14) { + #if defined(_MIPSEL) + iret2 = ((__vaword)((unsigned char *) list.raddr)[8]) + | ((__vaword)((unsigned char *) list.raddr)[9] << 8) + | ((__vaword)((unsigned char *) list.raddr)[10] << 16) + | ((__vaword)((unsigned char *) list.raddr)[11] << 24) + | ((__vaword)((unsigned char *) list.raddr)[12] << 32) + | ((__vaword)((unsigned char *) list.raddr)[13] << 40); + #else + iret2 = ((__vaword)((unsigned char *) list.raddr)[8] << 56) + | ((__vaword)((unsigned char *) list.raddr)[9] << 48) + | ((__vaword)((unsigned char *) list.raddr)[10] << 40) + | ((__vaword)((unsigned char *) list.raddr)[11] << 32) + | ((__vaword)((unsigned char *) list.raddr)[12] << 24) + | ((__vaword)((unsigned char *) list.raddr)[13] << 16); + #endif + } else + if (list.rsize == 15) { + #if defined(_MIPSEL) + iret2 = ((__vaword)((unsigned char *) list.raddr)[8]) + | ((__vaword)((unsigned char *) list.raddr)[9] << 8) + | ((__vaword)((unsigned char *) list.raddr)[10] << 16) + | ((__vaword)((unsigned char *) list.raddr)[11] << 24) + | ((__vaword)((unsigned char *) list.raddr)[12] << 32) + | ((__vaword)((unsigned char *) list.raddr)[13] << 40) + | ((__vaword)((unsigned char *) list.raddr)[14] << 48); + #else + iret2 = ((__vaword)((unsigned char *) list.raddr)[8] << 56) + | ((__vaword)((unsigned char *) list.raddr)[9] << 48) + | ((__vaword)((unsigned char *) list.raddr)[10] << 40) + | ((__vaword)((unsigned char *) list.raddr)[11] << 32) + | ((__vaword)((unsigned char *) list.raddr)[12] << 24) + | ((__vaword)((unsigned char *) list.raddr)[13] << 16) + | ((__vaword)((unsigned char *) list.raddr)[14] << 8); + #endif + } else + if (list.rsize == 16) { + #if defined(_MIPSEL) + iret2 = ((__vaword)((unsigned char *) list.raddr)[8]) + | ((__vaword)((unsigned char *) list.raddr)[9] << 8) + | ((__vaword)((unsigned char *) list.raddr)[10] << 16) + | ((__vaword)((unsigned char *) list.raddr)[11] << 24) + | ((__vaword)((unsigned char *) list.raddr)[12] << 32) + | ((__vaword)((unsigned char *) list.raddr)[13] << 40) + | ((__vaword)((unsigned char *) list.raddr)[14] << 48) + | ((__vaword)((unsigned char *) list.raddr)[15] << 56); + #else + iret2 = ((__vaword)((unsigned char *) list.raddr)[8] << 56) + | ((__vaword)((unsigned char *) list.raddr)[9] << 48) + | ((__vaword)((unsigned char *) list.raddr)[10] << 40) + | ((__vaword)((unsigned char *) list.raddr)[11] << 32) + | ((__vaword)((unsigned char *) list.raddr)[12] << 24) + | ((__vaword)((unsigned char *) list.raddr)[13] << 16) + | ((__vaword)((unsigned char *) list.raddr)[14] << 8) + | (__vaword)((unsigned char *) list.raddr)[15]; + #endif + } + } + #else /* Optimized: fewer conditional jumps, fewer memory accesses */ + uintptr_t count = list.rsize; /* > 0, ≤ 2*sizeof(__vaword) */ + __vaword* wordaddr = (__vaword*)((uintptr_t)list.raddr & ~(uintptr_t)(sizeof(__vaword)-1)); + uintptr_t start_offset = (uintptr_t)list.raddr & (uintptr_t)(sizeof(__vaword)-1); /* ≥ 0, < sizeof(__vaword) */ + uintptr_t end_offset = start_offset + count; /* > 0, < 3*sizeof(__vaword) */ + #if defined(_MIPSEL) + if (count <= sizeof(__vaword)) { + /* Assign iret. */ + if (end_offset <= sizeof(__vaword)) { + /* 0 < end_offset ≤ sizeof(__vaword) */ + __vaword mask0 = ((__vaword)2 << (end_offset*8-1)) - 1; + iret = (wordaddr[0] & mask0) >> (start_offset*8); + } else { + /* sizeof(__vaword) < end_offset < 2*sizeof(__vaword), start_offset > 0 */ + __vaword mask1 = ((__vaword)2 << (end_offset*8-sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | ((wordaddr[1] & mask1) << (sizeof(__vaword)*8-start_offset*8)); + } + } else { + /* Assign iret, iret2. */ + if (end_offset <= 2*sizeof(__vaword)) { + /* sizeof(__vaword) < end_offset ≤ 2*sizeof(__vaword) */ + __vaword mask1 = ((__vaword)2 << (end_offset*8-sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | ((wordaddr[1] & mask1) << (sizeof(__vaword)*4-start_offset*4) << (sizeof(__vaword)*4-start_offset*4)); + iret2 = (wordaddr[1] & mask1) >> (start_offset*8); + } else { + /* 2*sizeof(__vaword) < end_offset < 3*sizeof(__vaword), start_offset > 0 */ + __vaword mask2 = ((__vaword)2 << (end_offset*8-2*sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | (wordaddr[1] << (sizeof(__vaword)*8-start_offset*8)); + iret2 = (wordaddr[1] >> (start_offset*8)) | ((wordaddr[2] & mask2) << (sizeof(__vaword)*8-start_offset*8)); + } + } + #else + if (count <= sizeof(__vaword)) { + /* Assign iret. */ + if (end_offset <= sizeof(__vaword)) { + /* 0 < end_offset ≤ sizeof(__vaword) */ + __vaword mask0 = - ((__vaword)1 << (sizeof(__vaword)*8-end_offset*8)); + iret = (wordaddr[0] & mask0) << (start_offset*8); + } else { + /* sizeof(__vaword) < end_offset < 2*sizeof(__vaword), start_offset > 0 */ + __vaword mask1 = - ((__vaword)1 << (2*sizeof(__vaword)*8-end_offset*8)); + iret = (wordaddr[0] << (start_offset*8)) | ((wordaddr[1] & mask1) >> (sizeof(__vaword)*8-start_offset*8)); + } + } else { + /* Assign iret, iret2. */ + if (end_offset <= 2*sizeof(__vaword)) { + /* sizeof(__vaword) < end_offset ≤ 2*sizeof(__vaword) */ + __vaword mask1 = - ((__vaword)1 << (2*sizeof(__vaword)*8-end_offset*8)); + iret = (wordaddr[0] << (start_offset*8)) | ((wordaddr[1] & mask1) >> (sizeof(__vaword)*4-start_offset*4) >> (sizeof(__vaword)*4-start_offset*4)); + iret2 = (wordaddr[1] & mask1) << (start_offset*8); + } else { + /* 2*sizeof(__vaword) < end_offset < 3*sizeof(__vaword), start_offset > 0 */ + __vaword mask2 = - ((__vaword)1 << (3*sizeof(__vaword)*8-end_offset*8)); + iret = (wordaddr[0] << (start_offset*8)) | (wordaddr[1] >> (sizeof(__vaword)*8-start_offset*8)); + iret2 = (wordaddr[1] << (start_offset*8)) | ((wordaddr[2] & mask2) >> (sizeof(__vaword)*8-start_offset*8)); + } + } + #endif + #endif + } + if (list.flags & __VA_REGISTER_FLOATSTRUCT_RETURN) { + if (list.rsize == sizeof(float)) { + fret = *(float*)list.raddr; + } else + if (list.rsize == 2*sizeof(float)) { + fret = *(float*)list.raddr; + fret2 = *(float*)((char*)list.raddr + 4); + } + } + if (list.flags & __VA_REGISTER_DOUBLESTRUCT_RETURN) { + if (list.rsize == sizeof(double)) { + dret = *(double*)list.raddr; + } else + if (list.rsize == 2*sizeof(double)) { + dret = *(double*)list.raddr; + dret2 = *(double*)((char*)list.raddr + 8); + } + } + } + } + } +} + +#ifdef REENTRANT +__vacall_r_t +callback_get_receiver (void) +{ + return (__vacall_r_t)(void*)&callback_receiver; +} +#endif diff --git a/vacall/vacall-mipsn32eb-linux.s b/vacall/vacall-mipsn32eb-linux.s new file mode 100644 index 0000000..9feb329 --- /dev/null +++ b/vacall/vacall-mipsn32eb-linux.s @@ -0,0 +1,357 @@ + .file 1 "vacall-mipsn32.c" + .section .mdebug.abiN32 + .previous + .nan legacy + .module fp=64 + .module oddspreg + .abicalls + .text + .align 2 + .align 3 + .globl vacall_receiver + .set nomips16 + .set nomicromips + .ent vacall_receiver + .type vacall_receiver, @function +vacall_receiver: + .frame $fp,256,$31 # vars= 144, regs= 6/0, args= 0, gp= 0 + .mask 0xd0070000,-72 + .fmask 0x00000000,0 + .set noreorder + .set nomacro + addiu $sp,$sp,-256 + sd $28,168($sp) + lui $28,%hi(__gnu_local_gp) + addiu $28,$28,%lo(__gnu_local_gp) + lw $12,%got_disp(vacall_function)($28) + sd $fp,176($sp) + move $fp,$sp + lw $25,0($12) + addiu $12,$fp,192 + sd $31,184($sp) + sd $18,160($sp) + sd $17,152($sp) + sd $16,144($sp) + sd $4,192($fp) + sd $5,200($fp) + sd $6,208($fp) + sd $7,216($fp) + sd $8,224($fp) + sd $9,232($fp) + sd $10,240($fp) + sd $11,248($fp) + sdc1 $f12,80($fp) + sdc1 $f13,88($fp) + sdc1 $f14,96($fp) + sdc1 $f15,104($fp) + sdc1 $f16,112($fp) + sdc1 $f17,120($fp) + sdc1 $f18,128($fp) + sdc1 $f19,136($fp) + swc1 $f12,44($fp) + swc1 $f13,48($fp) + swc1 $f14,52($fp) + swc1 $f15,56($fp) + swc1 $f16,60($fp) + swc1 $f17,64($fp) + swc1 $f18,68($fp) + swc1 $f19,72($fp) + move $4,$fp + sw $0,0($fp) + sw $12,24($fp) + sw $0,28($fp) + sw $0,32($fp) + jalr $25 + sw $0,40($fp) + + lw $12,32($fp) + beq $12,$0,.L1 + li $13,1 # 0x1 + + beq $12,$13,.L43 + li $13,2 # 0x2 + + beq $12,$13,.L43 + li $13,3 # 0x3 + + beq $12,$13,.L49 + li $13,4 # 0x4 + + beq $12,$13,.L50 + li $13,5 # 0x5 + + beq $12,$13,.L51 + li $13,6 # 0x6 + + beq $12,$13,.L46 + li $13,7 # 0x7 + + beq $12,$13,.L45 + li $13,8 # 0x8 + + beq $12,$13,.L46 + li $13,9 # 0x9 + + beq $12,$13,.L45 + li $13,10 # 0xa + + beq $12,$13,.L47 + li $13,11 # 0xb + + beq $12,$13,.L47 + li $13,12 # 0xc + + beq $12,$13,.L52 + li $13,13 # 0xd + + beq $12,$13,.L53 + li $13,14 # 0xe + + beq $12,$13,.L46 + li $13,15 # 0xf + + bnel $12,$13,.L59 + move $sp,$fp + + lw $12,0($fp) + andi $13,$12,0x400 + beq $13,$0,.L1 + andi $13,$12,0x4 + + beq $13,$0,.L19 + lw $24,36($fp) + + lw $12,36($fp) + li $13,1 # 0x1 + beq $12,$13,.L54 + li $13,2 # 0x2 + + beq $12,$13,.L55 + li $13,4 # 0x4 + + beq $12,$13,.L56 + li $13,8 # 0x8 + + bnel $12,$13,.L59 + move $sp,$fp + + lw $12,28($fp) + ld $2,0($12) +.L1: + move $sp,$fp +.L59: + ld $31,184($sp) + ld $fp,176($sp) + ld $28,168($sp) + ld $18,160($sp) + ld $17,152($sp) + ld $16,144($sp) + j $31 + addiu $sp,$sp,256 + + .align 3 +.L43: + move $sp,$fp + ld $31,184($sp) + ld $28,168($sp) + ld $18,160($sp) + ld $17,152($sp) + ld $16,144($sp) + lb $2,8($fp) + ld $fp,176($sp) + j $31 + addiu $sp,$sp,256 + + .align 3 +.L46: + b .L1 + lw $2,8($fp) + + .align 3 +.L49: + b .L1 + lbu $2,8($fp) + + .align 3 +.L50: + b .L1 + lh $2,8($fp) + + .align 3 +.L45: + b .L1 + lwu $2,8($fp) + + .align 3 +.L51: + b .L1 + lhu $2,8($fp) + + .align 3 +.L52: + b .L1 + lwc1 $f0,8($fp) + + .align 3 +.L47: + b .L1 + ld $2,8($fp) + +.L53: + b .L1 + ldc1 $f0,8($fp) + +.L19: + addiu $13,$24,-1 + sltu $13,$13,16 + beql $13,$0,.L60 + andi $13,$12,0x800 + + lw $13,28($fp) + li $15,-8 # 0xfffffffffffffff8 + sltu $25,$24,9 + andi $14,$13,0x7 + and $15,$13,$15 + beq $25,$0,.L24 + addu $13,$24,$14 + + sltu $25,$13,9 + beq $25,$0,.L25 + subu $13,$0,$13 + + ld $25,0($15) + sll $13,$13,3 + li $15,-1 # 0xffffffffffffffff + dsll $13,$15,$13 + and $13,$13,$25 + sll $14,$14,3 + dsll $2,$13,$14 +.L23: + andi $13,$12,0x800 +.L60: + beql $13,$0,.L27 + andi $12,$12,0x1000 + + li $13,4 # 0x4 + beq $24,$13,.L57 + li $13,8 # 0x8 + + beql $24,$13,.L58 + lw $13,28($fp) + + andi $12,$12,0x1000 + beql $12,$0,.L59 + move $sp,$fp + + li $12,16 # 0x10 +.L61: + bnel $24,$12,.L59 + move $sp,$fp + + lw $12,28($fp) + ldc1 $f0,0($12) + b .L1 + ldc1 $f2,8($12) + +.L27: + beq $12,$0,.L1 + li $12,8 # 0x8 + + bne $24,$12,.L61 + li $12,16 # 0x10 + + lw $13,28($fp) + b .L1 + ldc1 $f0,0($13) + +.L24: + sltu $25,$13,17 + beq $25,$0,.L26 + subu $13,$0,$13 + + ld $17,8($15) + subu $16,$0,$14 + li $25,-1 # 0xffffffffffffffff + sll $13,$13,3 + dsll $13,$25,$13 + sll $25,$16,2 + ld $16,0($15) + and $13,$13,$17 + addiu $15,$25,32 + sll $14,$14,3 + dsra $25,$13,$15 + dsll $16,$16,$14 + dsra $15,$25,$15 + or $2,$16,$15 + b .L23 + dsll $3,$13,$14 + +.L54: + lw $12,28($fp) + b .L1 + lbu $2,0($12) + +.L55: + lw $12,28($fp) + b .L1 + lhu $2,0($12) + +.L26: + ld $18,16($15) + ld $16,8($15) + ld $17,0($15) + subu $25,$0,$14 + li $15,-1 # 0xffffffffffffffff + sll $13,$13,3 + sll $25,$25,3 + dsll $13,$15,$13 + sll $14,$14,3 + addiu $15,$25,64 + and $13,$13,$18 + dsll $25,$17,$14 + dsra $13,$13,$15 + dsra $17,$16,$15 + dsll $14,$16,$14 + or $2,$25,$17 + b .L23 + or $3,$13,$14 + +.L57: + lw $12,28($fp) + b .L1 + lwc1 $f0,0($12) + +.L56: + lw $12,28($fp) + b .L1 + lwu $2,0($12) + +.L25: + ld $16,8($15) + ld $25,0($15) + sll $13,$13,3 + li $15,-1 # 0xffffffffffffffff + dsll $13,$15,$13 + subu $15,$0,$14 + and $13,$13,$16 + sll $15,$15,3 + sll $14,$14,3 + dsra $13,$13,$15 + dsll $14,$25,$14 + b .L23 + or $2,$13,$14 + +.L58: + andi $12,$12,0x1000 + lwc1 $f0,0($13) + beq $12,$0,.L1 + lwc1 $f2,4($13) + + b .L1 + ldc1 $f0,0($13) + + .set macro + .set reorder + .end vacall_receiver + .size vacall_receiver, .-vacall_receiver + .ident "GCC: (GNU) 5.4.0" diff --git a/vacall/vacall-mipsn32eb-macro.S b/vacall/vacall-mipsn32eb-macro.S new file mode 100644 index 0000000..f19511d --- /dev/null +++ b/vacall/vacall-mipsn32eb-macro.S @@ -0,0 +1,351 @@ +#include "asm-mips.h" + .file 1 "vacall-mipsn32.c" + .text + .align 2 + .align 3 + .globl vacall_receiver + .set nomips16 + .set nomicromips + .ent vacall_receiver + DECLARE_FUNCTION(vacall_receiver) +vacall_receiver: + .frame $fp,256,$31 + .mask 0xd0070000,-72 + .fmask 0x00000000,0 + .set noreorder + .set nomacro + addiu $sp,$sp,-256 + sd $28,168($sp) + lui $28,%hi(__gnu_local_gp) + addiu $28,$28,%lo(__gnu_local_gp) + lw $12,%got_disp(vacall_function)($28) + sd $fp,176($sp) + move $fp,$sp + lw $25,0($12) + addiu $12,$fp,192 + sd $31,184($sp) + sd $18,160($sp) + sd $17,152($sp) + sd $16,144($sp) + sd $4,192($fp) + sd $5,200($fp) + sd $6,208($fp) + sd $7,216($fp) + sd $8,224($fp) + sd $9,232($fp) + sd $10,240($fp) + sd $11,248($fp) + sdc1 $f12,80($fp) + sdc1 $f13,88($fp) + sdc1 $f14,96($fp) + sdc1 $f15,104($fp) + sdc1 $f16,112($fp) + sdc1 $f17,120($fp) + sdc1 $f18,128($fp) + sdc1 $f19,136($fp) + swc1 $f12,44($fp) + swc1 $f13,48($fp) + swc1 $f14,52($fp) + swc1 $f15,56($fp) + swc1 $f16,60($fp) + swc1 $f17,64($fp) + swc1 $f18,68($fp) + swc1 $f19,72($fp) + move $4,$fp + sw $0,0($fp) + sw $12,24($fp) + sw $0,28($fp) + sw $0,32($fp) + jalr $25 + sw $0,40($fp) + + lw $12,32($fp) + beq $12,$0,.L1 + li $13,1 + + beq $12,$13,.L43 + li $13,2 + + beq $12,$13,.L43 + li $13,3 + + beq $12,$13,.L49 + li $13,4 + + beq $12,$13,.L50 + li $13,5 + + beq $12,$13,.L51 + li $13,6 + + beq $12,$13,.L46 + li $13,7 + + beq $12,$13,.L45 + li $13,8 + + beq $12,$13,.L46 + li $13,9 + + beq $12,$13,.L45 + li $13,10 + + beq $12,$13,.L47 + li $13,11 + + beq $12,$13,.L47 + li $13,12 + + beq $12,$13,.L52 + li $13,13 + + beq $12,$13,.L53 + li $13,14 + + beq $12,$13,.L46 + li $13,15 + + bnel $12,$13,.L59 + move $sp,$fp + + lw $12,0($fp) + andi $13,$12,0x400 + beq $13,$0,.L1 + andi $13,$12,0x4 + + beq $13,$0,.L19 + lw $24,36($fp) + + lw $12,36($fp) + li $13,1 + beq $12,$13,.L54 + li $13,2 + + beq $12,$13,.L55 + li $13,4 + + beq $12,$13,.L56 + li $13,8 + + bnel $12,$13,.L59 + move $sp,$fp + + lw $12,28($fp) + ld $2,0($12) +.L1: + move $sp,$fp +.L59: + ld $31,184($sp) + ld $fp,176($sp) + ld $28,168($sp) + ld $18,160($sp) + ld $17,152($sp) + ld $16,144($sp) + j $31 + addiu $sp,$sp,256 + + .align 3 +.L43: + move $sp,$fp + ld $31,184($sp) + ld $28,168($sp) + ld $18,160($sp) + ld $17,152($sp) + ld $16,144($sp) + lb $2,8($fp) + ld $fp,176($sp) + j $31 + addiu $sp,$sp,256 + + .align 3 +.L46: + b .L1 + lw $2,8($fp) + + .align 3 +.L49: + b .L1 + lbu $2,8($fp) + + .align 3 +.L50: + b .L1 + lh $2,8($fp) + + .align 3 +.L45: + b .L1 + lwu $2,8($fp) + + .align 3 +.L51: + b .L1 + lhu $2,8($fp) + + .align 3 +.L52: + b .L1 + lwc1 $f0,8($fp) + + .align 3 +.L47: + b .L1 + ld $2,8($fp) + +.L53: + b .L1 + ldc1 $f0,8($fp) + +.L19: + addiu $13,$24,-1 + sltu $13,$13,16 + beql $13,$0,.L60 + andi $13,$12,0x800 + + lw $13,28($fp) + li $15,-8 + sltu $25,$24,9 + andi $14,$13,0x7 + and $15,$13,$15 + beq $25,$0,.L24 + addu $13,$24,$14 + + sltu $25,$13,9 + beq $25,$0,.L25 + subu $13,$0,$13 + + ld $25,0($15) + sll $13,$13,3 + li $15,-1 + dsll $13,$15,$13 + and $13,$13,$25 + sll $14,$14,3 + dsll $2,$13,$14 +.L23: + andi $13,$12,0x800 +.L60: + beql $13,$0,.L27 + andi $12,$12,0x1000 + + li $13,4 + beq $24,$13,.L57 + li $13,8 + + beql $24,$13,.L58 + lw $13,28($fp) + + andi $12,$12,0x1000 + beql $12,$0,.L59 + move $sp,$fp + + li $12,16 +.L61: + bnel $24,$12,.L59 + move $sp,$fp + + lw $12,28($fp) + ldc1 $f0,0($12) + b .L1 + ldc1 $f2,8($12) + +.L27: + beq $12,$0,.L1 + li $12,8 + + bne $24,$12,.L61 + li $12,16 + + lw $13,28($fp) + b .L1 + ldc1 $f0,0($13) + +.L24: + sltu $25,$13,17 + beq $25,$0,.L26 + subu $13,$0,$13 + + ld $17,8($15) + subu $16,$0,$14 + li $25,-1 + sll $13,$13,3 + dsll $13,$25,$13 + sll $25,$16,2 + ld $16,0($15) + and $13,$13,$17 + addiu $15,$25,32 + sll $14,$14,3 + dsra $25,$13,$15 + dsll $16,$16,$14 + dsra $15,$25,$15 + or $2,$16,$15 + b .L23 + dsll $3,$13,$14 + +.L54: + lw $12,28($fp) + b .L1 + lbu $2,0($12) + +.L55: + lw $12,28($fp) + b .L1 + lhu $2,0($12) + +.L26: + ld $18,16($15) + ld $16,8($15) + ld $17,0($15) + subu $25,$0,$14 + li $15,-1 + sll $13,$13,3 + sll $25,$25,3 + dsll $13,$15,$13 + sll $14,$14,3 + addiu $15,$25,64 + and $13,$13,$18 + dsll $25,$17,$14 + dsra $13,$13,$15 + dsra $17,$16,$15 + dsll $14,$16,$14 + or $2,$25,$17 + b .L23 + or $3,$13,$14 + +.L57: + lw $12,28($fp) + b .L1 + lwc1 $f0,0($12) + +.L56: + lw $12,28($fp) + b .L1 + lwu $2,0($12) + +.L25: + ld $16,8($15) + ld $25,0($15) + sll $13,$13,3 + li $15,-1 + dsll $13,$15,$13 + subu $15,$0,$14 + and $13,$13,$16 + sll $15,$15,3 + sll $14,$14,3 + dsra $13,$13,$15 + dsll $14,$25,$14 + b .L23 + or $2,$13,$14 + +.L58: + andi $12,$12,0x1000 + lwc1 $f0,0($13) + beq $12,$0,.L1 + lwc1 $f2,4($13) + + b .L1 + ldc1 $f0,0($13) + + .set macro + .set reorder + .end vacall_receiver + .size vacall_receiver, .-vacall_receiver diff --git a/vacall/vacall-mipsn32el-linux.s b/vacall/vacall-mipsn32el-linux.s new file mode 100644 index 0000000..54a7cdc --- /dev/null +++ b/vacall/vacall-mipsn32el-linux.s @@ -0,0 +1,361 @@ + .file 1 "vacall-mipsn32.c" + .section .mdebug.abiN32 + .previous + .nan legacy + .module fp=64 + .module oddspreg + .abicalls + .text + .align 2 + .align 3 + .globl vacall_receiver + .set nomips16 + .set nomicromips + .ent vacall_receiver + .type vacall_receiver, @function +vacall_receiver: + .frame $fp,256,$31 # vars= 144, regs= 6/0, args= 0, gp= 0 + .mask 0xd0070000,-72 + .fmask 0x00000000,0 + .set noreorder + .set nomacro + addiu $sp,$sp,-256 + sd $28,168($sp) + lui $28,%hi(__gnu_local_gp) + addiu $28,$28,%lo(__gnu_local_gp) + lw $12,%got_disp(vacall_function)($28) + sd $fp,176($sp) + move $fp,$sp + lw $25,0($12) + addiu $12,$fp,192 + sd $31,184($sp) + sd $18,160($sp) + sd $17,152($sp) + sd $16,144($sp) + sd $4,192($fp) + sd $5,200($fp) + sd $6,208($fp) + sd $7,216($fp) + sd $8,224($fp) + sd $9,232($fp) + sd $10,240($fp) + sd $11,248($fp) + sdc1 $f12,80($fp) + sdc1 $f13,88($fp) + sdc1 $f14,96($fp) + sdc1 $f15,104($fp) + sdc1 $f16,112($fp) + sdc1 $f17,120($fp) + sdc1 $f18,128($fp) + sdc1 $f19,136($fp) + swc1 $f12,44($fp) + swc1 $f13,48($fp) + swc1 $f14,52($fp) + swc1 $f15,56($fp) + swc1 $f16,60($fp) + swc1 $f17,64($fp) + swc1 $f18,68($fp) + swc1 $f19,72($fp) + move $4,$fp + sw $0,0($fp) + sw $12,24($fp) + sw $0,28($fp) + sw $0,32($fp) + jalr $25 + sw $0,40($fp) + + lw $12,32($fp) + beq $12,$0,.L1 + li $13,1 # 0x1 + + beq $12,$13,.L43 + li $13,2 # 0x2 + + beq $12,$13,.L43 + li $13,3 # 0x3 + + beq $12,$13,.L49 + li $13,4 # 0x4 + + beq $12,$13,.L50 + li $13,5 # 0x5 + + beq $12,$13,.L51 + li $13,6 # 0x6 + + beq $12,$13,.L46 + li $13,7 # 0x7 + + beq $12,$13,.L45 + li $13,8 # 0x8 + + beq $12,$13,.L46 + li $13,9 # 0x9 + + beq $12,$13,.L45 + li $13,10 # 0xa + + beq $12,$13,.L47 + li $13,11 # 0xb + + beq $12,$13,.L47 + li $13,12 # 0xc + + beq $12,$13,.L52 + li $13,13 # 0xd + + beq $12,$13,.L53 + li $13,14 # 0xe + + beq $12,$13,.L46 + li $13,15 # 0xf + + bnel $12,$13,.L59 + move $sp,$fp + + lw $12,0($fp) + andi $13,$12,0x400 + beq $13,$0,.L1 + andi $13,$12,0x4 + + beq $13,$0,.L19 + lw $24,36($fp) + + lw $12,36($fp) + li $13,1 # 0x1 + beq $12,$13,.L54 + li $13,2 # 0x2 + + beq $12,$13,.L55 + li $13,4 # 0x4 + + beq $12,$13,.L56 + li $13,8 # 0x8 + + bnel $12,$13,.L59 + move $sp,$fp + + lw $12,28($fp) + ld $2,0($12) +.L1: + move $sp,$fp +.L59: + ld $31,184($sp) + ld $fp,176($sp) + ld $28,168($sp) + ld $18,160($sp) + ld $17,152($sp) + ld $16,144($sp) + j $31 + addiu $sp,$sp,256 + + .align 3 +.L43: + move $sp,$fp + ld $31,184($sp) + ld $28,168($sp) + ld $18,160($sp) + ld $17,152($sp) + ld $16,144($sp) + lb $2,8($fp) + ld $fp,176($sp) + j $31 + addiu $sp,$sp,256 + + .align 3 +.L46: + b .L1 + lw $2,8($fp) + + .align 3 +.L49: + b .L1 + lbu $2,8($fp) + + .align 3 +.L50: + b .L1 + lh $2,8($fp) + + .align 3 +.L45: + b .L1 + lwu $2,8($fp) + + .align 3 +.L51: + b .L1 + lhu $2,8($fp) + + .align 3 +.L52: + b .L1 + lwc1 $f0,8($fp) + + .align 3 +.L47: + b .L1 + ld $2,8($fp) + +.L53: + b .L1 + ldc1 $f0,8($fp) + +.L19: + addiu $13,$24,-1 + sltu $13,$13,16 + beql $13,$0,.L60 + andi $13,$12,0x800 + + lw $13,28($fp) + li $15,-8 # 0xfffffffffffffff8 + sltu $25,$24,9 + andi $14,$13,0x7 + and $15,$13,$15 + beq $25,$0,.L24 + addu $13,$24,$14 + + sltu $25,$13,9 + beq $25,$0,.L25 + sll $13,$13,3 + + ld $25,0($15) + addiu $13,$13,-1 + li $15,2 # 0x2 + dsll $13,$15,$13 + daddiu $13,$13,-1 + and $13,$13,$25 + sll $14,$14,3 + dsra $2,$13,$14 +.L23: + andi $13,$12,0x800 +.L60: + beql $13,$0,.L27 + andi $12,$12,0x1000 + + li $13,4 # 0x4 + beq $24,$13,.L57 + li $13,8 # 0x8 + + beql $24,$13,.L58 + lw $13,28($fp) + + andi $12,$12,0x1000 + beql $12,$0,.L59 + move $sp,$fp + + li $12,16 # 0x10 +.L61: + bnel $24,$12,.L59 + move $sp,$fp + + lw $12,28($fp) + ldc1 $f0,0($12) + b .L1 + ldc1 $f2,8($12) + +.L27: + beq $12,$0,.L1 + li $12,8 # 0x8 + + bne $24,$12,.L61 + li $12,16 # 0x10 + + lw $13,28($fp) + b .L1 + ldc1 $f0,0($13) + +.L24: + sltu $25,$13,17 + beq $25,$0,.L26 + sll $13,$13,3 + + ld $17,8($15) + li $25,2 # 0x2 + addiu $13,$13,-65 + dsll $13,$25,$13 + subu $25,$0,$14 + sll $25,$25,2 + ld $16,0($15) + daddiu $13,$13,-1 + addiu $15,$25,32 + and $13,$13,$17 + sll $14,$14,3 + dsll $25,$13,$15 + dsra $16,$16,$14 + dsll $15,$25,$15 + or $2,$16,$15 + b .L23 + dsra $3,$13,$14 + +.L54: + lw $12,28($fp) + b .L1 + lbu $2,0($12) + +.L55: + lw $12,28($fp) + b .L1 + lhu $2,0($12) + +.L26: + ld $16,8($15) + ld $17,0($15) + addiu $13,$13,-129 + ld $18,16($15) + li $15,2 # 0x2 + subu $25,$0,$14 + dsll $15,$15,$13 + daddiu $15,$15,-1 + sll $25,$25,3 + sll $14,$14,3 + addiu $25,$25,64 + and $13,$15,$18 + dsll $13,$13,$25 + dsra $15,$17,$14 + dsll $17,$16,$25 + dsra $14,$16,$14 + or $2,$15,$17 + b .L23 + or $3,$13,$14 + +.L57: + lw $12,28($fp) + b .L1 + lwc1 $f0,0($12) + +.L56: + lw $12,28($fp) + b .L1 + lwu $2,0($12) + +.L25: + li $25,2 # 0x2 + addiu $13,$13,-65 + ld $17,8($15) + dsll $13,$25,$13 + ld $25,0($15) + daddiu $13,$13,-1 + subu $16,$0,$14 + and $15,$13,$17 + sll $14,$14,3 + sll $13,$16,3 + dsll $13,$15,$13 + dsra $14,$25,$14 + b .L23 + or $2,$13,$14 + +.L58: + andi $12,$12,0x1000 + lwc1 $f0,0($13) + beq $12,$0,.L1 + lwc1 $f2,4($13) + + b .L1 + ldc1 $f0,0($13) + + .set macro + .set reorder + .end vacall_receiver + .size vacall_receiver, .-vacall_receiver + .ident "GCC: (GNU) 5.4.0" diff --git a/vacall/vacall-mipsn32el-macro.S b/vacall/vacall-mipsn32el-macro.S new file mode 100644 index 0000000..0aa74c5 --- /dev/null +++ b/vacall/vacall-mipsn32el-macro.S @@ -0,0 +1,355 @@ +#include "asm-mips.h" + .file 1 "vacall-mipsn32.c" + .text + .align 2 + .align 3 + .globl vacall_receiver + .set nomips16 + .set nomicromips + .ent vacall_receiver + DECLARE_FUNCTION(vacall_receiver) +vacall_receiver: + .frame $fp,256,$31 + .mask 0xd0070000,-72 + .fmask 0x00000000,0 + .set noreorder + .set nomacro + addiu $sp,$sp,-256 + sd $28,168($sp) + lui $28,%hi(__gnu_local_gp) + addiu $28,$28,%lo(__gnu_local_gp) + lw $12,%got_disp(vacall_function)($28) + sd $fp,176($sp) + move $fp,$sp + lw $25,0($12) + addiu $12,$fp,192 + sd $31,184($sp) + sd $18,160($sp) + sd $17,152($sp) + sd $16,144($sp) + sd $4,192($fp) + sd $5,200($fp) + sd $6,208($fp) + sd $7,216($fp) + sd $8,224($fp) + sd $9,232($fp) + sd $10,240($fp) + sd $11,248($fp) + sdc1 $f12,80($fp) + sdc1 $f13,88($fp) + sdc1 $f14,96($fp) + sdc1 $f15,104($fp) + sdc1 $f16,112($fp) + sdc1 $f17,120($fp) + sdc1 $f18,128($fp) + sdc1 $f19,136($fp) + swc1 $f12,44($fp) + swc1 $f13,48($fp) + swc1 $f14,52($fp) + swc1 $f15,56($fp) + swc1 $f16,60($fp) + swc1 $f17,64($fp) + swc1 $f18,68($fp) + swc1 $f19,72($fp) + move $4,$fp + sw $0,0($fp) + sw $12,24($fp) + sw $0,28($fp) + sw $0,32($fp) + jalr $25 + sw $0,40($fp) + + lw $12,32($fp) + beq $12,$0,.L1 + li $13,1 + + beq $12,$13,.L43 + li $13,2 + + beq $12,$13,.L43 + li $13,3 + + beq $12,$13,.L49 + li $13,4 + + beq $12,$13,.L50 + li $13,5 + + beq $12,$13,.L51 + li $13,6 + + beq $12,$13,.L46 + li $13,7 + + beq $12,$13,.L45 + li $13,8 + + beq $12,$13,.L46 + li $13,9 + + beq $12,$13,.L45 + li $13,10 + + beq $12,$13,.L47 + li $13,11 + + beq $12,$13,.L47 + li $13,12 + + beq $12,$13,.L52 + li $13,13 + + beq $12,$13,.L53 + li $13,14 + + beq $12,$13,.L46 + li $13,15 + + bnel $12,$13,.L59 + move $sp,$fp + + lw $12,0($fp) + andi $13,$12,0x400 + beq $13,$0,.L1 + andi $13,$12,0x4 + + beq $13,$0,.L19 + lw $24,36($fp) + + lw $12,36($fp) + li $13,1 + beq $12,$13,.L54 + li $13,2 + + beq $12,$13,.L55 + li $13,4 + + beq $12,$13,.L56 + li $13,8 + + bnel $12,$13,.L59 + move $sp,$fp + + lw $12,28($fp) + ld $2,0($12) +.L1: + move $sp,$fp +.L59: + ld $31,184($sp) + ld $fp,176($sp) + ld $28,168($sp) + ld $18,160($sp) + ld $17,152($sp) + ld $16,144($sp) + j $31 + addiu $sp,$sp,256 + + .align 3 +.L43: + move $sp,$fp + ld $31,184($sp) + ld $28,168($sp) + ld $18,160($sp) + ld $17,152($sp) + ld $16,144($sp) + lb $2,8($fp) + ld $fp,176($sp) + j $31 + addiu $sp,$sp,256 + + .align 3 +.L46: + b .L1 + lw $2,8($fp) + + .align 3 +.L49: + b .L1 + lbu $2,8($fp) + + .align 3 +.L50: + b .L1 + lh $2,8($fp) + + .align 3 +.L45: + b .L1 + lwu $2,8($fp) + + .align 3 +.L51: + b .L1 + lhu $2,8($fp) + + .align 3 +.L52: + b .L1 + lwc1 $f0,8($fp) + + .align 3 +.L47: + b .L1 + ld $2,8($fp) + +.L53: + b .L1 + ldc1 $f0,8($fp) + +.L19: + addiu $13,$24,-1 + sltu $13,$13,16 + beql $13,$0,.L60 + andi $13,$12,0x800 + + lw $13,28($fp) + li $15,-8 + sltu $25,$24,9 + andi $14,$13,0x7 + and $15,$13,$15 + beq $25,$0,.L24 + addu $13,$24,$14 + + sltu $25,$13,9 + beq $25,$0,.L25 + sll $13,$13,3 + + ld $25,0($15) + addiu $13,$13,-1 + li $15,2 + dsll $13,$15,$13 + daddiu $13,$13,-1 + and $13,$13,$25 + sll $14,$14,3 + dsra $2,$13,$14 +.L23: + andi $13,$12,0x800 +.L60: + beql $13,$0,.L27 + andi $12,$12,0x1000 + + li $13,4 + beq $24,$13,.L57 + li $13,8 + + beql $24,$13,.L58 + lw $13,28($fp) + + andi $12,$12,0x1000 + beql $12,$0,.L59 + move $sp,$fp + + li $12,16 +.L61: + bnel $24,$12,.L59 + move $sp,$fp + + lw $12,28($fp) + ldc1 $f0,0($12) + b .L1 + ldc1 $f2,8($12) + +.L27: + beq $12,$0,.L1 + li $12,8 + + bne $24,$12,.L61 + li $12,16 + + lw $13,28($fp) + b .L1 + ldc1 $f0,0($13) + +.L24: + sltu $25,$13,17 + beq $25,$0,.L26 + sll $13,$13,3 + + ld $17,8($15) + li $25,2 + addiu $13,$13,-65 + dsll $13,$25,$13 + subu $25,$0,$14 + sll $25,$25,2 + ld $16,0($15) + daddiu $13,$13,-1 + addiu $15,$25,32 + and $13,$13,$17 + sll $14,$14,3 + dsll $25,$13,$15 + dsra $16,$16,$14 + dsll $15,$25,$15 + or $2,$16,$15 + b .L23 + dsra $3,$13,$14 + +.L54: + lw $12,28($fp) + b .L1 + lbu $2,0($12) + +.L55: + lw $12,28($fp) + b .L1 + lhu $2,0($12) + +.L26: + ld $16,8($15) + ld $17,0($15) + addiu $13,$13,-129 + ld $18,16($15) + li $15,2 + subu $25,$0,$14 + dsll $15,$15,$13 + daddiu $15,$15,-1 + sll $25,$25,3 + sll $14,$14,3 + addiu $25,$25,64 + and $13,$15,$18 + dsll $13,$13,$25 + dsra $15,$17,$14 + dsll $17,$16,$25 + dsra $14,$16,$14 + or $2,$15,$17 + b .L23 + or $3,$13,$14 + +.L57: + lw $12,28($fp) + b .L1 + lwc1 $f0,0($12) + +.L56: + lw $12,28($fp) + b .L1 + lwu $2,0($12) + +.L25: + li $25,2 + addiu $13,$13,-65 + ld $17,8($15) + dsll $13,$25,$13 + ld $25,0($15) + daddiu $13,$13,-1 + subu $16,$0,$14 + and $15,$13,$17 + sll $14,$14,3 + sll $13,$16,3 + dsll $13,$15,$13 + dsra $14,$25,$14 + b .L23 + or $2,$13,$14 + +.L58: + andi $12,$12,0x1000 + lwc1 $f0,0($13) + beq $12,$0,.L1 + lwc1 $f2,4($13) + + b .L1 + ldc1 $f0,0($13) + + .set macro + .set reorder + .end vacall_receiver + .size vacall_receiver, .-vacall_receiver diff --git a/vacall/vacall-powerpc-aix.s b/vacall/vacall-powerpc-aix.s new file mode 100644 index 0000000..b4e3505 --- /dev/null +++ b/vacall/vacall-powerpc-aix.s @@ -0,0 +1,171 @@ + .file "vacall-powerpc.c" + .toc + .csect .text[PR] + .toc +LC..0: + .tc vacall_function[TC],vacall_function[RW] + .csect .text[PR] + .align 2 + .globl vacall_receiver + .globl .vacall_receiver + .csect vacall_receiver[DS] +vacall_receiver: + .long .vacall_receiver, TOC[tc0], 0 + .csect .text[PR] +.vacall_receiver: + .extern __mulh + .extern __mull + .extern __divss + .extern __divus + .extern __quoss + .extern __quous + mflr 0 + stw 0,8(1) + stw 29,-12(1) + stw 31,-4(1) + lwz 11,LC..0(2) + stwu 1,-216(1) + mr 31,1 + lwz 29,0(11) + addi 0,31,240 + li 11,0 + stw 9,264(31) + stw 3,240(31) + stw 5,248(31) + stw 6,252(31) + stw 7,256(31) + stw 8,260(31) + stw 10,268(31) + stw 11,88(31) + stw 4,244(31) + stfd 1,92(31) + stfd 2,100(31) + stfd 3,108(31) + stfd 4,116(31) + stfd 5,124(31) + stfd 6,132(31) + stfd 7,140(31) + stfd 8,148(31) + stfd 9,156(31) + stfd 10,164(31) + stfd 11,172(31) + stfd 12,180(31) + stfd 13,188(31) + stw 11,56(31) + stw 11,76(31) + stw 11,80(31) + stw 0,72(31) + lwz 0,0(29) + addi 3,31,56 + stw 2,20(1) + mtctr 0 + lwz 11,8(29) + lwz 2,4(29) + bctrl + lwz 2,20(1) + lwz 9,80(31) + cmpwi 0,9,0 + beq- 0,L..1 + cmpwi 0,9,1 + beq- 0,L..41 + cmpwi 0,9,2 + beq- 0,L..42 + cmpwi 0,9,3 + beq- 0,L..41 + cmpwi 0,9,4 + beq- 0,L..43 + cmpwi 0,9,5 + beq- 0,L..44 + cmpwi 0,9,6 + beq- 0,L..40 + cmpwi 0,9,7 + beq- 0,L..40 + cmpwi 0,9,8 + beq- 0,L..40 + cmpwi 0,9,9 + beq- 0,L..40 + addi 0,9,-10 + cmplwi 0,0,1 + bgt- 0,L..22 + lwz 3,64(31) + lwz 4,68(31) +L..1: + lwz 1,0(1) + lwz 0,8(1) + lwz 29,-12(1) + mtlr 0 + lwz 31,-4(1) + blr +L..22: + cmpwi 0,9,12 + beq- 0,L..45 + cmpwi 0,9,13 + beq- 0,L..46 + cmpwi 0,9,14 + beq- 0,L..40 + cmpwi 0,9,15 + bne+ 0,L..1 + lwz 0,56(31) + andi. 9,0,1024 + beq- 0,L..1 + lwz 0,84(31) + cmpwi 0,0,1 + beq- 0,L..47 + cmpwi 0,0,2 + beq- 0,L..48 + cmpwi 0,0,4 + beq- 0,L..49 + cmpwi 0,0,8 + bne+ 0,L..1 + lwz 9,76(31) + lwz 4,4(9) +L..39: + lwz 3,0(9) + b L..1 +L..49: + lwz 9,76(31) + b L..39 +L..48: + lwz 9,76(31) + lhz 3,0(9) + b L..1 +L..47: + lwz 9,76(31) + lbz 3,0(9) + b L..1 +L..40: + lwz 3,64(31) + b L..1 +L..46: + lfd 1,64(31) + b L..1 +L..45: + lfs 1,64(31) + b L..1 +L..44: + lhz 3,64(31) + b L..1 +L..43: + lha 3,64(31) + b L..1 +L..41: + lbz 3,64(31) + b L..1 +L..42: + lbz 0,64(31) + slwi 0,0,24 + srawi 3,0,24 + b L..1 +LT..vacall_receiver: + .long 0 + .byte 0,0,32,97,128,3,8,0 + .long 0 + .long LT..vacall_receiver-.vacall_receiver + .short 15 + .byte "vacall_receiver" + .byte 31 + .align 2 +_section_.text: + .csect .data[RW],3 + .long _section_.text + .extern vacall_function[RW] diff --git a/vacall/vacall-powerpc-linux-macro.S b/vacall/vacall-powerpc-linux-macro.S new file mode 100644 index 0000000..3d56e0f --- /dev/null +++ b/vacall/vacall-powerpc-linux-macro.S @@ -0,0 +1,143 @@ + .file "vacall-powerpc.c" + .section ".text" + .align 2 + .globl vacall_receiver + .type vacall_receiver, @function +vacall_receiver: + .extern __mulh + .extern __mull + .extern __divss + .extern __divus + .extern __quoss + .extern __quous + stwu 1,-176(1) + mflr 0 + li 11,0 + stw 0,180(1) + stw 31,172(1) + mr 31,1 + stw 9,76(31) + addi 0,31,184 + lis 9,vacall_function@ha + stw 3,52(31) + lwz 9,vacall_function@l(9) + addi 3,31,16 + stw 5,60(31) + mtctr 9 + stw 6,64(31) + stw 7,68(31) + stw 8,72(31) + stw 10,80(31) + stw 0,32(31) + stw 11,84(31) + stw 4,56(31) + stfd 1,88(31) + stfd 2,96(31) + stfd 3,104(31) + stfd 4,112(31) + stfd 5,120(31) + stfd 6,128(31) + stfd 7,136(31) + stfd 8,144(31) + stw 11,16(31) + stw 11,48(31) + stw 11,36(31) + stw 11,40(31) + bctrl + lwz 9,40(31) + cmpwi 0,9,0 + beq- 0,.L1 + cmpwi 0,9,1 + beq- 0,.L41 + cmpwi 0,9,2 + beq- 0,.L42 + cmpwi 0,9,3 + beq- 0,.L41 + cmpwi 0,9,4 + beq- 0,.L43 + cmpwi 0,9,5 + beq- 0,.L44 + cmpwi 0,9,6 + beq- 0,.L40 + cmpwi 0,9,7 + beq- 0,.L40 + cmpwi 0,9,8 + beq- 0,.L40 + cmpwi 0,9,9 + beq- 0,.L40 + addi 0,9,-10 + cmplwi 0,0,1 + bgt- 0,.L22 + lwz 3,24(31) + lwz 4,28(31) +.L1: + lwz 11,0(1) + lwz 0,4(11) + lwz 31,-4(11) + mtlr 0 + mr 1,11 + blr +.L22: + cmpwi 0,9,12 + beq- 0,.L45 + cmpwi 0,9,13 + beq- 0,.L46 + cmpwi 0,9,14 + beq- 0,.L40 + cmpwi 0,9,15 + bne+ 0,.L1 + lwz 0,16(31) + andi. 9,0,1024 + beq- 0,.L1 + lwz 0,44(31) + cmpwi 0,0,1 + beq- 0,.L47 + cmpwi 0,0,2 + beq- 0,.L48 + cmpwi 0,0,4 + beq- 0,.L49 + cmpwi 0,0,8 + bne+ 0,.L1 + lwz 9,36(31) + lwz 4,4(9) +.L39: + lwz 3,0(9) + b .L1 +.L49: + lwz 9,36(31) + b .L39 +.L48: + lwz 9,36(31) + lhz 3,0(9) + b .L1 +.L47: + lwz 9,36(31) + lbz 3,0(9) + b .L1 +.L40: + lwz 3,24(31) + b .L1 +.L46: + lfd 1,24(31) + b .L1 +.L45: + lfs 1,24(31) + b .L1 +.L44: + lhz 3,24(31) + b .L1 +.L43: + lha 3,24(31) + b .L1 +.L41: + lbz 3,24(31) + b .L1 +.L42: + lbz 0,24(31) + slwi 0,0,24 + srawi 3,0,24 + b .L1 + .size vacall_receiver, .-vacall_receiver +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/vacall/vacall-powerpc-linux.s b/vacall/vacall-powerpc-linux.s new file mode 100644 index 0000000..b40c8aa --- /dev/null +++ b/vacall/vacall-powerpc-linux.s @@ -0,0 +1,142 @@ + .file "vacall-powerpc.c" + .section ".text" + .align 2 + .globl vacall_receiver + .type vacall_receiver, @function +vacall_receiver: + .extern __mulh + .extern __mull + .extern __divss + .extern __divus + .extern __quoss + .extern __quous + stwu 1,-176(1) + mflr 0 + li 11,0 + stw 0,180(1) + stw 31,172(1) + mr 31,1 + stw 9,76(31) + addi 0,31,184 + lis 9,vacall_function@ha + stw 3,52(31) + lwz 9,vacall_function@l(9) + addi 3,31,16 + stw 5,60(31) + mtctr 9 + stw 6,64(31) + stw 7,68(31) + stw 8,72(31) + stw 10,80(31) + stw 0,32(31) + stw 11,84(31) + stw 4,56(31) + stfd 1,88(31) + stfd 2,96(31) + stfd 3,104(31) + stfd 4,112(31) + stfd 5,120(31) + stfd 6,128(31) + stfd 7,136(31) + stfd 8,144(31) + stw 11,16(31) + stw 11,48(31) + stw 11,36(31) + stw 11,40(31) + bctrl + lwz 9,40(31) + cmpwi 0,9,0 + beq- 0,.L1 + cmpwi 0,9,1 + beq- 0,.L41 + cmpwi 0,9,2 + beq- 0,.L42 + cmpwi 0,9,3 + beq- 0,.L41 + cmpwi 0,9,4 + beq- 0,.L43 + cmpwi 0,9,5 + beq- 0,.L44 + cmpwi 0,9,6 + beq- 0,.L40 + cmpwi 0,9,7 + beq- 0,.L40 + cmpwi 0,9,8 + beq- 0,.L40 + cmpwi 0,9,9 + beq- 0,.L40 + addi 0,9,-10 + cmplwi 0,0,1 + bgt- 0,.L22 + lwz 3,24(31) + lwz 4,28(31) +.L1: + lwz 11,0(1) + lwz 0,4(11) + lwz 31,-4(11) + mtlr 0 + mr 1,11 + blr +.L22: + cmpwi 0,9,12 + beq- 0,.L45 + cmpwi 0,9,13 + beq- 0,.L46 + cmpwi 0,9,14 + beq- 0,.L40 + cmpwi 0,9,15 + bne+ 0,.L1 + lwz 0,16(31) + andi. 9,0,1024 + beq- 0,.L1 + lwz 0,44(31) + cmpwi 0,0,1 + beq- 0,.L47 + cmpwi 0,0,2 + beq- 0,.L48 + cmpwi 0,0,4 + beq- 0,.L49 + cmpwi 0,0,8 + bne+ 0,.L1 + lwz 9,36(31) + lwz 4,4(9) +.L39: + lwz 3,0(9) + b .L1 +.L49: + lwz 9,36(31) + b .L39 +.L48: + lwz 9,36(31) + lhz 3,0(9) + b .L1 +.L47: + lwz 9,36(31) + lbz 3,0(9) + b .L1 +.L40: + lwz 3,24(31) + b .L1 +.L46: + lfd 1,24(31) + b .L1 +.L45: + lfs 1,24(31) + b .L1 +.L44: + lhz 3,24(31) + b .L1 +.L43: + lha 3,24(31) + b .L1 +.L41: + lbz 3,24(31) + b .L1 +.L42: + lbz 0,24(31) + slwi 0,0,24 + srawi 3,0,24 + b .L1 + .size vacall_receiver, .-vacall_receiver + .section .note.GNU-stack,"",@progbits + .ident "GCC: (GNU) 3.3.6" diff --git a/vacall/vacall-powerpc-macos.s b/vacall/vacall-powerpc-macos.s new file mode 100644 index 0000000..a508e75 --- /dev/null +++ b/vacall/vacall-powerpc-macos.s @@ -0,0 +1,142 @@ +.text + .align 2 + .globl _vacall_receiver +_vacall_receiver: + mflr r0 + stmw r29,-12(r1) + bcl 20,31,L1$pb +L1$pb: + stw r0,8(r1) + mflr r31 + stwu r1,-224(r1) + addis r29,r31,ha16(L_vacall_function$non_lazy_ptr-L1$pb) + li r11,0 + lwz r29,lo16(L_vacall_function$non_lazy_ptr-L1$pb)(r29) + mr r30,r1 + addi r0,r30,248 + stw r3,248(r30) + lwz r29,0(r29) + addi r3,r30,64 + stw r9,272(r30) + stw r5,256(r30) + mtctr r29 + stw r6,260(r30) + stw r7,264(r30) + stw r8,268(r30) + stw r10,276(r30) + stw r0,80(r30) + stw r11,96(r30) + stw r4,252(r30) + stfd f1,100(r30) + stfd f2,108(r30) + stfd f3,116(r30) + stfd f4,124(r30) + stfd f5,132(r30) + stfd f6,140(r30) + stfd f7,148(r30) + stfd f8,156(r30) + stfd f9,164(r30) + stfd f10,172(r30) + stfd f11,180(r30) + stfd f12,188(r30) + stfd f13,196(r30) + stw r11,64(r30) + stw r11,84(r30) + stw r11,88(r30) + bctrl + lwz r9,88(r30) + cmpwi cr0,r9,0 + beq- cr0,L1 + cmpwi cr0,r9,1 + beq- cr0,L41 + cmpwi cr0,r9,2 + beq- cr0,L41 + cmpwi cr0,r9,3 + beq- cr0,L42 + cmpwi cr0,r9,4 + beq- cr0,L43 + cmpwi cr0,r9,5 + beq- cr0,L44 + cmpwi cr0,r9,6 + beq- cr0,L40 + cmpwi cr0,r9,7 + beq- cr0,L40 + cmpwi cr0,r9,8 + beq- cr0,L40 + cmpwi cr0,r9,9 + beq- cr0,L40 + addi r0,r9,-10 + cmplwi cr0,r0,1 + bgt- cr0,L22 + lwz r3,72(r30) + lwz r4,76(r30) +L1: + lwz r1,0(r1) + lwz r0,8(r1) + lmw r29,-12(r1) + mtlr r0 + blr +L22: + cmpwi cr0,r9,12 + beq- cr0,L45 + cmpwi cr0,r9,13 + beq- cr0,L46 + cmpwi cr0,r9,14 + beq- cr0,L40 + cmpwi cr0,r9,15 + bne+ cr0,L1 + lwz r0,64(r30) + andi. r9,r0,1024 + beq- cr0,L1 + lwz r0,92(r30) + cmpwi cr0,r0,1 + beq- cr0,L47 + cmpwi cr0,r0,2 + beq- cr0,L48 + cmpwi cr0,r0,4 + beq- cr0,L49 + cmpwi cr0,r0,8 + bne+ cr0,L1 + lwz r9,84(r30) + lwz r4,4(r9) +L39: + lwz r3,0(r9) + b L1 +L49: + lwz r9,84(r30) + b L39 +L48: + lwz r9,84(r30) + lhz r3,0(r9) + b L1 +L47: + lwz r9,84(r30) + lbz r3,0(r9) + b L1 +L40: + lwz r3,72(r30) + b L1 +L46: + lfd f1,72(r30) + b L1 +L45: + lfs f1,72(r30) + b L1 +L44: + lhz r3,72(r30) + b L1 +L43: + lha r3,72(r30) + b L1 +L42: + lbz r3,72(r30) + b L1 +L41: + lbz r0,72(r30) + extsb r3,r0 + b L1 +.data +.non_lazy_symbol_pointer +L_vacall_function$non_lazy_ptr: + .indirect_symbol _vacall_function + .long 0 diff --git a/vacall/vacall-powerpc-sysv4-macro.S b/vacall/vacall-powerpc-sysv4-macro.S new file mode 100644 index 0000000..3d56e0f --- /dev/null +++ b/vacall/vacall-powerpc-sysv4-macro.S @@ -0,0 +1,143 @@ + .file "vacall-powerpc.c" + .section ".text" + .align 2 + .globl vacall_receiver + .type vacall_receiver, @function +vacall_receiver: + .extern __mulh + .extern __mull + .extern __divss + .extern __divus + .extern __quoss + .extern __quous + stwu 1,-176(1) + mflr 0 + li 11,0 + stw 0,180(1) + stw 31,172(1) + mr 31,1 + stw 9,76(31) + addi 0,31,184 + lis 9,vacall_function@ha + stw 3,52(31) + lwz 9,vacall_function@l(9) + addi 3,31,16 + stw 5,60(31) + mtctr 9 + stw 6,64(31) + stw 7,68(31) + stw 8,72(31) + stw 10,80(31) + stw 0,32(31) + stw 11,84(31) + stw 4,56(31) + stfd 1,88(31) + stfd 2,96(31) + stfd 3,104(31) + stfd 4,112(31) + stfd 5,120(31) + stfd 6,128(31) + stfd 7,136(31) + stfd 8,144(31) + stw 11,16(31) + stw 11,48(31) + stw 11,36(31) + stw 11,40(31) + bctrl + lwz 9,40(31) + cmpwi 0,9,0 + beq- 0,.L1 + cmpwi 0,9,1 + beq- 0,.L41 + cmpwi 0,9,2 + beq- 0,.L42 + cmpwi 0,9,3 + beq- 0,.L41 + cmpwi 0,9,4 + beq- 0,.L43 + cmpwi 0,9,5 + beq- 0,.L44 + cmpwi 0,9,6 + beq- 0,.L40 + cmpwi 0,9,7 + beq- 0,.L40 + cmpwi 0,9,8 + beq- 0,.L40 + cmpwi 0,9,9 + beq- 0,.L40 + addi 0,9,-10 + cmplwi 0,0,1 + bgt- 0,.L22 + lwz 3,24(31) + lwz 4,28(31) +.L1: + lwz 11,0(1) + lwz 0,4(11) + lwz 31,-4(11) + mtlr 0 + mr 1,11 + blr +.L22: + cmpwi 0,9,12 + beq- 0,.L45 + cmpwi 0,9,13 + beq- 0,.L46 + cmpwi 0,9,14 + beq- 0,.L40 + cmpwi 0,9,15 + bne+ 0,.L1 + lwz 0,16(31) + andi. 9,0,1024 + beq- 0,.L1 + lwz 0,44(31) + cmpwi 0,0,1 + beq- 0,.L47 + cmpwi 0,0,2 + beq- 0,.L48 + cmpwi 0,0,4 + beq- 0,.L49 + cmpwi 0,0,8 + bne+ 0,.L1 + lwz 9,36(31) + lwz 4,4(9) +.L39: + lwz 3,0(9) + b .L1 +.L49: + lwz 9,36(31) + b .L39 +.L48: + lwz 9,36(31) + lhz 3,0(9) + b .L1 +.L47: + lwz 9,36(31) + lbz 3,0(9) + b .L1 +.L40: + lwz 3,24(31) + b .L1 +.L46: + lfd 1,24(31) + b .L1 +.L45: + lfs 1,24(31) + b .L1 +.L44: + lhz 3,24(31) + b .L1 +.L43: + lha 3,24(31) + b .L1 +.L41: + lbz 3,24(31) + b .L1 +.L42: + lbz 0,24(31) + slwi 0,0,24 + srawi 3,0,24 + b .L1 + .size vacall_receiver, .-vacall_receiver +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/vacall/vacall-powerpc.c b/vacall/vacall-powerpc.c new file mode 100644 index 0000000..ea3e208 --- /dev/null +++ b/vacall/vacall-powerpc.c @@ -0,0 +1,181 @@ +/* vacall function for powerpc CPU */ + +/* + * Copyright 1995-2017 Bruno Haible + * Copyright 2000 Adam Fedor + * Copyright 2004 Paul Guyot + * + * 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, see . + */ + +#include "vacall-internal.h" + +#ifdef REENTRANT +#define vacall_receiver callback_receiver +register struct { void (*vacall_function) (void*,va_alist); void* arg; } + * env __asm__("r11"); +#endif +register double farg1 __asm__("fr1"); +register double farg2 __asm__("fr2"); +register double farg3 __asm__("fr3"); +register double farg4 __asm__("fr4"); +register double farg5 __asm__("fr5"); +register double farg6 __asm__("fr6"); +register double farg7 __asm__("fr7"); +register double farg8 __asm__("fr8"); +register double farg9 __asm__("fr9"); +register double farg10 __asm__("fr10"); +register double farg11 __asm__("fr11"); +register double farg12 __asm__("fr12"); +register double farg13 __asm__("fr13"); +register __vaword iret __asm__("r3"); +register __vaword iret2 __asm__("r4"); +register float fret __asm__("fr1"); +register double dret __asm__("fr1"); + +#ifdef REENTRANT +static +#endif +void /* the return type is variable, not void! */ +vacall_receiver (__vaword word1, __vaword word2, __vaword word3, __vaword word4, + __vaword word5, __vaword word6, __vaword word7, __vaword word8, + __vaword firstword) +{ + __va_alist list; +#if defined(_AIX) || (defined(__MACH__) && defined(__APPLE__)) /* __powerpc_aix__ */ + /* gcc-2.6.3 source says: When a parameter is passed in a register, + * stack space is still allocated for it. + */ + /* Move the arguments passed in registers to their stack locations. */ + (&firstword)[-8] = word1; + (&firstword)[-7] = word2; + (&firstword)[-6] = word3; + (&firstword)[-5] = word4; + (&firstword)[-4] = word5; + (&firstword)[-3] = word6; + (&firstword)[-2] = word7; + (&firstword)[-1] = word8; +#else /* __powerpc_sysv4__ */ + /* Move the arguments passed in registers to temp storage, since + moving them to the stack would mess up the stack */ + list.iarg[0] = word1; + list.iarg[1] = word2; + list.iarg[2] = word3; + list.iarg[3] = word4; + list.iarg[4] = word5; + list.iarg[5] = word6; + list.iarg[6] = word7; + list.iarg[7] = word8; +#endif + list.farg[0] = farg1; + list.farg[1] = farg2; + list.farg[2] = farg3; + list.farg[3] = farg4; + list.farg[4] = farg5; + list.farg[5] = farg6; + list.farg[6] = farg7; + list.farg[7] = farg8; +#if defined(_AIX) || (defined(__MACH__) && defined(__APPLE__)) /* __powerpc_aix__ */ + list.farg[8] = farg9; + list.farg[9] = farg10; + list.farg[10] = farg11; + list.farg[11] = farg12; + list.farg[12] = farg13; +#endif + /* Prepare the va_alist. */ + list.flags = 0; +#if defined(_AIX) || (defined(__MACH__) && defined(__APPLE__)) /* __powerpc_aix__ */ + list.aptr = (long)(&firstword - 8); +#else /* __powerpc_sysv4__ */ + list.aptr = (long)(&firstword); + list.ianum = 0; +#endif + list.raddr = (void*)0; + list.rtype = __VAvoid; + list.fanum = 0; + /* Call vacall_function. The macros do all the rest. */ +#ifndef REENTRANT + (*vacall_function) (&list); +#else /* REENTRANT */ + (*env->vacall_function) (env->arg,&list); +#endif + /* Put return value into proper register. */ + if (list.rtype == __VAvoid) { + } else + if (list.rtype == __VAchar) { + iret = list.tmp._char; + } else + if (list.rtype == __VAschar) { + iret = list.tmp._schar; + } else + if (list.rtype == __VAuchar) { + iret = list.tmp._uchar; + } else + if (list.rtype == __VAshort) { + iret = list.tmp._short; + } else + if (list.rtype == __VAushort) { + iret = list.tmp._ushort; + } else + if (list.rtype == __VAint) { + iret = list.tmp._int; + } else + if (list.rtype == __VAuint) { + iret = list.tmp._uint; + } else + if (list.rtype == __VAlong) { + iret = list.tmp._long; + } else + if (list.rtype == __VAulong) { + iret = list.tmp._ulong; + } else + if (list.rtype == __VAlonglong || list.rtype == __VAulonglong) { + iret = ((__vaword *) &list.tmp._longlong)[0]; + iret2 = ((__vaword *) &list.tmp._longlong)[1]; + } else + if (list.rtype == __VAfloat) { + fret = list.tmp._float; + } else + if (list.rtype == __VAdouble) { + dret = list.tmp._double; + } else + if (list.rtype == __VAvoidp) { + iret = (long)list.tmp._ptr; + } else + if (list.rtype == __VAstruct) { + if (list.flags & __VA_REGISTER_STRUCT_RETURN) { + if (list.rsize == sizeof(char)) { + iret = *(unsigned char *) list.raddr; + } else + if (list.rsize == sizeof(short)) { + iret = *(unsigned short *) list.raddr; + } else + if (list.rsize == sizeof(int)) { + iret = *(unsigned int *) list.raddr; + } else + if (list.rsize == 2*sizeof(__vaword)) { + iret = ((__vaword *) list.raddr)[0]; + iret2 = ((__vaword *) list.raddr)[1]; + } + } + } +} + +#ifdef REENTRANT +__vacall_r_t +callback_get_receiver (void) +{ + return (__vacall_r_t)(void*)&callback_receiver; +} +#endif diff --git a/vacall/vacall-powerpc64-aix.s b/vacall/vacall-powerpc64-aix.s new file mode 100644 index 0000000..bb888b7 --- /dev/null +++ b/vacall/vacall-powerpc64-aix.s @@ -0,0 +1,151 @@ + .file "vacall-powerpc64.c" + .csect .text[PR] + .toc + .csect .text[PR] + .toc +LC..0: + .tc vacall_function[TC],vacall_function[UA] + .csect .text[PR] + .align 2 + .align 4 + .globl vacall_receiver + .globl .vacall_receiver + .csect vacall_receiver[DS],3 +vacall_receiver: + .llong .vacall_receiver, TOC[tc0], 0 + .csect .text[PR] +.vacall_receiver: + mflr 0 + std 31,-8(1) + li 11,0 + std 0,16(1) + li 0,0 + stdu 1,-304(1) + mr 31,1 + std 2,40(1) + stw 0,112(31) + stw 11,152(31) + stw 11,168(31) + std 9,400(31) + addi 9,31,352 + std 3,352(31) + stfd 1,172(31) + std 4,360(31) + std 5,368(31) + std 6,376(31) + std 7,384(31) + std 8,392(31) + stfd 2,180(31) + addi 3,31,112 + stfd 3,188(31) + stfd 4,196(31) + stfd 5,204(31) + stfd 6,212(31) + stfd 7,220(31) + stfd 8,228(31) + stfd 9,236(31) + stfd 10,244(31) + stfd 11,252(31) + stfd 12,260(31) + stfd 13,268(31) + std 9,136(31) + std 11,144(31) + std 10,408(31) + ld 9,LC..0(2) + ld 9,0(9) + ld 10,0(9) + ld 11,16(9) + mtctr 10 + ld 2,8(9) + bctrl + ld 2,40(1) + lwz 9,152(31) + cmpdi 7,9,0 + beq 7,L..1 + cmplwi 7,9,1 + beq 7,L..20 + cmplwi 7,9,2 + beq 7,L..23 + cmplwi 7,9,3 + beq 7,L..20 + cmplwi 7,9,4 + beq 7,L..24 + cmplwi 7,9,5 + beq 7,L..25 + cmplwi 7,9,6 + beq 7,L..26 + cmplwi 7,9,7 + beq 7,L..27 + cmplwi 7,9,8 + beq 7,L..21 + cmplwi 7,9,9 + beq 7,L..21 + cmplwi 7,9,10 + beq 7,L..21 + cmplwi 7,9,11 + beq 7,L..21 + cmplwi 7,9,12 + beq 7,L..28 + cmplwi 7,9,13 + beq 7,L..29 + cmplwi 7,9,14 + beq 7,L..21 +L..1: + addi 1,31,304 + ld 0,16(1) + ld 31,-8(1) + mtlr 0 + blr + .align 4 +L..20: + lbz 3,120(31) + addi 1,31,304 + ld 0,16(1) + ld 31,-8(1) + mtlr 0 + blr + .align 4 +L..23: + lbz 9,120(31) + extsb 3,9 + b L..1 + .align 4 +L..21: + ld 3,120(31) + b L..1 + .align 4 +L..24: + lha 3,120(31) + b L..1 + .align 4 +L..25: + lhz 3,120(31) + b L..1 + .align 4 +L..26: + lwa 3,120(31) + b L..1 + .align 4 +L..28: + lfs 1,120(31) + b L..1 + .align 4 +L..27: + lwz 3,120(31) + b L..1 +L..29: + lfd 1,120(31) + b L..1 +LT..vacall_receiver: + .long 0 + .byte 0,0,32,97,128,1,8,0 + .long 0 + .long LT..vacall_receiver-.vacall_receiver + .short 15 + .byte "vacall_receiver" + .byte 31 + .align 2 +_section_.text: + .csect .data[RW],4 + .llong _section_.text + .extern vacall_function[UA] diff --git a/vacall/vacall-powerpc64-elfv2-linux.S b/vacall/vacall-powerpc64-elfv2-linux.S new file mode 100644 index 0000000..45e391d --- /dev/null +++ b/vacall/vacall-powerpc64-elfv2-linux.S @@ -0,0 +1,225 @@ + .file "vacall-powerpc64.c" + .machine power4 + .abiversion 2 + .section ".toc","aw" + .section ".text" + .section ".toc","aw" +.LC0: + .quad vacall_function + .section ".text" + .align 2 + .p2align 4,,15 + .globl vacall_receiver + .type vacall_receiver, @function +vacall_receiver: +0: addis 2,12,.TOC.-0b@ha + addi 2,2,.TOC.-0b@l + .localentry vacall_receiver,.-vacall_receiver + mflr 0 + std 31,-8(1) + addis 11,2,.LC0@toc@ha + ld 12,.LC0@toc@l(11) + li 11,0 + std 0,16(1) + stdu 1,-224(1) + mr 31,1 + ld 0,0(12) + std 2,24(1) + std 9,304(31) + li 9,0 + std 3,256(31) + addi 3,31,32 + std 4,264(31) + std 5,272(31) + mtctr 0 + stw 9,32(31) + std 6,280(31) + std 7,288(31) + std 8,296(31) + std 10,312(31) + stfd 1,96(31) + addi 9,31,256 + stfd 2,104(31) + stfd 3,112(31) + stfd 4,120(31) + stfd 5,128(31) + mr 12,0 + std 9,56(31) + stfd 6,136(31) + stfd 7,144(31) + stfd 8,152(31) + stfd 9,160(31) + stfd 10,168(31) + stfd 11,176(31) + stfd 12,184(31) + stfd 13,192(31) + std 11,64(31) + stw 11,72(31) + stw 11,88(31) + bctrl + ld 2,24(1) + lwz 9,72(31) + cmpdi 7,9,0 + beq 7,.L1 + cmplwi 7,9,1 + beq 7,.L27 + cmplwi 7,9,2 + beq 7,.L30 + cmplwi 7,9,3 + beq 7,.L27 + cmplwi 7,9,4 + beq 7,.L31 + cmplwi 7,9,5 + beq 7,.L32 + cmplwi 7,9,6 + beq 7,.L33 + cmplwi 7,9,7 + beq 7,.L34 + cmplwi 7,9,8 + beq 7,.L28 + cmplwi 7,9,9 + beq 7,.L28 + cmplwi 7,9,10 + beq 7,.L28 + cmplwi 7,9,11 + beq 7,.L28 + cmplwi 7,9,12 + beq 7,.L35 + cmplwi 7,9,13 + beq 7,.L36 + cmplwi 7,9,14 + beq 7,.L28 + cmplwi 7,9,15 + bne 7,.L1 + lwz 9,32(31) + rldicl. 10,9,54,63 + beq 0,.L1 + ld 9,80(31) + addi 10,9,-1 + cmpldi 7,10,15 + bgt 7,.L1 + ld 8,64(31) + cmpldi 7,9,8 + rldicl 10,8,0,61 + rldicr 8,8,0,60 + add 9,9,10 + bgt 7,.L17 + cmpldi 7,9,8 + slwi 9,9,3 + bgt 7,.L18 + ld 7,0(8) + addi 9,9,-1 + li 8,2 + slwi 10,10,3 + sld 9,8,9 + addi 9,9,-1 + and 9,9,7 + srad 3,9,10 +.L1: + addi 1,31,224 + ld 0,16(1) + ld 31,-8(1) + mtlr 0 + blr + .p2align 4,,15 +.L27: + addi 1,31,224 + lbz 3,40(31) + ld 0,16(1) + ld 31,-8(1) + mtlr 0 + blr + .p2align 4,,15 +.L30: + lbz 9,40(31) + extsb 3,9 + b .L1 + .p2align 4,,15 +.L28: + ld 3,40(31) + b .L1 + .p2align 4,,15 +.L31: + lha 3,40(31) + b .L1 + .p2align 4,,15 +.L32: + lhz 3,40(31) + b .L1 + .p2align 4,,15 +.L33: + lwa 3,40(31) + b .L1 + .p2align 4,,15 +.L35: + lfs 1,40(31) + b .L1 + .p2align 4,,15 +.L34: + lwz 3,40(31) + b .L1 +.L36: + lfd 1,40(31) + b .L1 +.L17: + cmpldi 7,9,16 + rldicl 10,10,0,32 + slwi 9,9,3 + ble 7,.L37 + li 7,2 + addi 9,9,-129 + ld 11,16(8) + ld 5,0(8) + mulli 6,10,-8 + sld 9,7,9 + ld 7,8(8) + addi 8,9,-1 + slwi 9,10,3 + addi 6,6,64 + and 10,8,11 + srad 8,5,9 + sld 5,7,6 + srad 9,7,9 + sld 10,10,6 + or 3,8,5 + or 4,10,9 + b .L1 +.L18: + rldicl 10,10,0,32 + li 7,2 + ld 6,8(8) + ld 8,0(8) + addi 9,9,-65 + sld 9,7,9 + mulli 7,10,-8 + slwi 10,10,3 + addi 9,9,-1 + srad 10,8,10 + and 9,9,6 + addi 7,7,64 + sld 9,9,7 + or 3,9,10 + b .L1 +.L37: + li 7,2 + addi 9,9,-65 + ld 5,8(8) + ld 6,0(8) + sld 9,7,9 + mulli 7,10,-4 + addi 9,9,-1 + addi 7,7,32 + and 8,9,5 + slwi 9,10,3 + sld 10,8,7 + srad 6,6,9 + srad 4,8,9 + sld 7,10,7 + or 3,6,7 + b .L1 + .long 0 + .byte 0,0,0,1,128,1,0,0 + .size vacall_receiver,.-vacall_receiver +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/vacall/vacall-powerpc64-linux.S b/vacall/vacall-powerpc64-linux.S new file mode 100644 index 0000000..0a402ef --- /dev/null +++ b/vacall/vacall-powerpc64-linux.S @@ -0,0 +1,146 @@ + .file "vacall-powerpc64.c" + .machine power4 + .section ".toc","aw" + .section ".text" + .section ".toc","aw" +.LC0: + .quad vacall_function + .section ".text" + .align 2 + .p2align 4,,15 + .globl vacall_receiver + .section ".opd","aw" + .align 3 +vacall_receiver: + .quad .L.vacall_receiver,.TOC.@tocbase,0 + .previous + .type vacall_receiver, @function +.L.vacall_receiver: + mflr 0 + std 31,-8(1) + li 11,0 + std 0,16(1) + stdu 1,-304(1) + li 0,0 + mr 31,1 + std 2,40(1) + stw 11,152(31) + stw 0,112(31) + stw 11,168(31) + std 9,400(31) + std 3,352(31) + std 4,360(31) + std 5,368(31) + std 6,376(31) + std 7,384(31) + std 8,392(31) + std 10,408(31) + stfd 1,176(31) + addi 9,31,352 + stfd 2,184(31) + stfd 3,192(31) + stfd 4,200(31) + stfd 5,208(31) + addis 10,2,.LC0@toc@ha + addi 3,31,112 + stfd 6,216(31) + stfd 7,224(31) + stfd 8,232(31) + stfd 9,240(31) + stfd 10,248(31) + stfd 11,256(31) + stfd 12,264(31) + stfd 13,272(31) + std 9,136(31) + std 11,144(31) + ld 9,.LC0@toc@l(10) + ld 9,0(9) + ld 10,0(9) + ld 11,16(9) + mtctr 10 + ld 2,8(9) + bctrl + ld 2,40(1) + lwz 9,152(31) + cmpdi 7,9,0 + beq 7,.L1 + cmplwi 7,9,1 + beq 7,.L20 + cmplwi 7,9,2 + beq 7,.L23 + cmplwi 7,9,3 + beq 7,.L20 + cmplwi 7,9,4 + beq 7,.L24 + cmplwi 7,9,5 + beq 7,.L25 + cmplwi 7,9,6 + beq 7,.L26 + cmplwi 7,9,7 + beq 7,.L27 + cmplwi 7,9,8 + beq 7,.L21 + cmplwi 7,9,9 + beq 7,.L21 + cmplwi 7,9,10 + beq 7,.L21 + cmplwi 7,9,11 + beq 7,.L21 + cmplwi 7,9,12 + beq 7,.L28 + cmplwi 7,9,13 + beq 7,.L29 + cmplwi 7,9,14 + beq 7,.L21 +.L1: + addi 1,31,304 + ld 0,16(1) + ld 31,-8(1) + mtlr 0 + blr + .p2align 4,,15 +.L20: + lbz 3,120(31) + addi 1,31,304 + ld 0,16(1) + ld 31,-8(1) + mtlr 0 + blr + .p2align 4,,15 +.L23: + lbz 9,120(31) + extsb 3,9 + b .L1 + .p2align 4,,15 +.L21: + ld 3,120(31) + b .L1 + .p2align 4,,15 +.L24: + lha 3,120(31) + b .L1 + .p2align 4,,15 +.L25: + lhz 3,120(31) + b .L1 + .p2align 4,,15 +.L26: + lwa 3,120(31) + b .L1 + .p2align 4,,15 +.L28: + lfs 1,120(31) + b .L1 + .p2align 4,,15 +.L27: + lwz 3,120(31) + b .L1 +.L29: + lfd 1,120(31) + b .L1 + .long 0 + .byte 0,0,0,1,128,1,0,0 + .size vacall_receiver,.-.L.vacall_receiver +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/vacall/vacall-powerpc64.c b/vacall/vacall-powerpc64.c new file mode 100644 index 0000000..19bcbbc --- /dev/null +++ b/vacall/vacall-powerpc64.c @@ -0,0 +1,293 @@ +/* vacall function for powerpc64 CPU */ + +/* + * Copyright 1995-2017 Bruno Haible + * Copyright 2000 Adam Fedor + * Copyright 2004 Paul Guyot + * + * 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, see . + */ + +#include "vacall-internal.h" + +#ifdef REENTRANT +#define vacall_receiver callback_receiver +register struct { void (*vacall_function) (void*,va_alist); void* arg; } + * env __asm__("r11"); +#endif +register double farg1 __asm__("fr1"); +register double farg2 __asm__("fr2"); +register double farg3 __asm__("fr3"); +register double farg4 __asm__("fr4"); +register double farg5 __asm__("fr5"); +register double farg6 __asm__("fr6"); +register double farg7 __asm__("fr7"); +register double farg8 __asm__("fr8"); +register double farg9 __asm__("fr9"); +register double farg10 __asm__("fr10"); +register double farg11 __asm__("fr11"); +register double farg12 __asm__("fr12"); +register double farg13 __asm__("fr13"); +register __vaword iret __asm__("r3"); +register __vaword iret2 __asm__("r4"); +register float fret __asm__("fr1"); +register double dret __asm__("fr1"); + +#ifdef REENTRANT +static +#endif +void /* the return type is variable, not void! */ +vacall_receiver (__vaword word1, __vaword word2, __vaword word3, __vaword word4, + __vaword word5, __vaword word6, __vaword word7, __vaword word8, + __vaword firstword) +{ + __va_alist list; + /* When a parameter is passed in a register, + * stack space is still allocated for it. + */ + /* Move the arguments passed in registers to their stack locations. */ + (&firstword)[-8] = word1; + (&firstword)[-7] = word2; + (&firstword)[-6] = word3; + (&firstword)[-5] = word4; + (&firstword)[-4] = word5; + (&firstword)[-3] = word6; + (&firstword)[-2] = word7; + (&firstword)[-1] = word8; + list.farg[0] = farg1; + list.farg[1] = farg2; + list.farg[2] = farg3; + list.farg[3] = farg4; + list.farg[4] = farg5; + list.farg[5] = farg6; + list.farg[6] = farg7; + list.farg[7] = farg8; + list.farg[8] = farg9; + list.farg[9] = farg10; + list.farg[10] = farg11; + list.farg[11] = farg12; + list.farg[12] = farg13; + /* Prepare the va_alist. */ + list.flags = 0; + list.aptr = (long)(&firstword - 8); + list.raddr = (void*)0; + list.rtype = __VAvoid; + list.fanum = 0; + /* Call vacall_function. The macros do all the rest. */ +#ifndef REENTRANT + (*vacall_function) (&list); +#else /* REENTRANT */ + (*env->vacall_function) (env->arg,&list); +#endif + /* Put return value into proper register. */ + if (list.rtype == __VAvoid) { + } else + if (list.rtype == __VAchar) { + iret = list.tmp._char; + } else + if (list.rtype == __VAschar) { + iret = list.tmp._schar; + } else + if (list.rtype == __VAuchar) { + iret = list.tmp._uchar; + } else + if (list.rtype == __VAshort) { + iret = list.tmp._short; + } else + if (list.rtype == __VAushort) { + iret = list.tmp._ushort; + } else + if (list.rtype == __VAint) { + iret = list.tmp._int; + } else + if (list.rtype == __VAuint) { + iret = list.tmp._uint; + } else + if (list.rtype == __VAlong) { + iret = list.tmp._long; + } else + if (list.rtype == __VAulong) { + iret = list.tmp._ulong; + } else + if (list.rtype == __VAlonglong) { + iret = list.tmp._long; + } else + if (list.rtype == __VAulonglong) { + iret = list.tmp._ulong; + } else + if (list.rtype == __VAfloat) { + fret = list.tmp._float; + } else + if (list.rtype == __VAdouble) { + dret = list.tmp._double; + } else + if (list.rtype == __VAvoidp) { + iret = (long)list.tmp._ptr; + } else + if (list.rtype == __VAstruct) { +#ifdef __powerpc64_elfv2__ + if (list.flags & __VA_REGISTER_STRUCT_RETURN) { + /* In the ELFv2 ABI, gcc returns structs of size <= 16 in registers. */ + if (list.rsize > 0 && list.rsize <= 16) { + #if 0 /* Unoptimized */ + if (list.rsize == 1) { + iret = (__vaword)((unsigned char *) list.raddr)[0]; + } else + if (list.rsize == 2) { + iret = ((__vaword)((unsigned char *) list.raddr)[0]) + | ((__vaword)((unsigned char *) list.raddr)[1] << 8); + } else + if (list.rsize == 3) { + iret = ((__vaword)((unsigned char *) list.raddr)[0]) + | ((__vaword)((unsigned char *) list.raddr)[1] << 8) + | ((__vaword)((unsigned char *) list.raddr)[2] << 16); + } else + if (list.rsize == 4) { + iret = ((__vaword)((unsigned char *) list.raddr)[0]) + | ((__vaword)((unsigned char *) list.raddr)[1] << 8) + | ((__vaword)((unsigned char *) list.raddr)[2] << 16) + | ((__vaword)((unsigned char *) list.raddr)[3] << 24); + } else + if (list.rsize == 5) { + iret = ((__vaword)((unsigned char *) list.raddr)[0]) + | ((__vaword)((unsigned char *) list.raddr)[1] << 8) + | ((__vaword)((unsigned char *) list.raddr)[2] << 16) + | ((__vaword)((unsigned char *) list.raddr)[3] << 24) + | ((__vaword)((unsigned char *) list.raddr)[4] << 32); + } else + if (list.rsize == 6) { + iret = ((__vaword)((unsigned char *) list.raddr)[0]) + | ((__vaword)((unsigned char *) list.raddr)[1] << 8) + | ((__vaword)((unsigned char *) list.raddr)[2] << 16) + | ((__vaword)((unsigned char *) list.raddr)[3] << 24) + | ((__vaword)((unsigned char *) list.raddr)[4] << 32) + | ((__vaword)((unsigned char *) list.raddr)[5] << 40); + } else + if (list.rsize == 7) { + iret = ((__vaword)((unsigned char *) list.raddr)[0]) + | ((__vaword)((unsigned char *) list.raddr)[1] << 8) + | ((__vaword)((unsigned char *) list.raddr)[2] << 16) + | ((__vaword)((unsigned char *) list.raddr)[3] << 24) + | ((__vaword)((unsigned char *) list.raddr)[4] << 32) + | ((__vaword)((unsigned char *) list.raddr)[5] << 40) + | ((__vaword)((unsigned char *) list.raddr)[6] << 48); + } else + if (list.rsize >= 8 && list.rsize <= 16) { + iret = ((__vaword)((unsigned char *) list.raddr)[0]) + | ((__vaword)((unsigned char *) list.raddr)[1] << 8) + | ((__vaword)((unsigned char *) list.raddr)[2] << 16) + | ((__vaword)((unsigned char *) list.raddr)[3] << 24) + | ((__vaword)((unsigned char *) list.raddr)[4] << 32) + | ((__vaword)((unsigned char *) list.raddr)[5] << 40) + | ((__vaword)((unsigned char *) list.raddr)[6] << 48) + | ((__vaword)((unsigned char *) list.raddr)[7] << 56); + if (list.rsize == 8) { + } else + if (list.rsize == 9) { + iret2 = (__vaword)((unsigned char *) list.raddr)[8]; + } else + if (list.rsize == 10) { + iret2 = ((__vaword)((unsigned char *) list.raddr)[8]) + | ((__vaword)((unsigned char *) list.raddr)[9] << 8); + } else + if (list.rsize == 11) { + iret2 = ((__vaword)((unsigned char *) list.raddr)[8]) + | ((__vaword)((unsigned char *) list.raddr)[9] << 8) + | ((__vaword)((unsigned char *) list.raddr)[10] << 16); + } else + if (list.rsize == 12) { + iret2 = ((__vaword)((unsigned char *) list.raddr)[8]) + | ((__vaword)((unsigned char *) list.raddr)[9] << 8) + | ((__vaword)((unsigned char *) list.raddr)[10] << 16) + | ((__vaword)((unsigned char *) list.raddr)[11] << 24); + } else + if (list.rsize == 13) { + iret2 = ((__vaword)((unsigned char *) list.raddr)[8]) + | ((__vaword)((unsigned char *) list.raddr)[9] << 8) + | ((__vaword)((unsigned char *) list.raddr)[10] << 16) + | ((__vaword)((unsigned char *) list.raddr)[11] << 24) + | ((__vaword)((unsigned char *) list.raddr)[12] << 32); + } else + if (list.rsize == 14) { + iret2 = ((__vaword)((unsigned char *) list.raddr)[8]) + | ((__vaword)((unsigned char *) list.raddr)[9] << 8) + | ((__vaword)((unsigned char *) list.raddr)[10] << 16) + | ((__vaword)((unsigned char *) list.raddr)[11] << 24) + | ((__vaword)((unsigned char *) list.raddr)[12] << 32) + | ((__vaword)((unsigned char *) list.raddr)[13] << 40); + } else + if (list.rsize == 15) { + iret2 = ((__vaword)((unsigned char *) list.raddr)[8]) + | ((__vaword)((unsigned char *) list.raddr)[9] << 8) + | ((__vaword)((unsigned char *) list.raddr)[10] << 16) + | ((__vaword)((unsigned char *) list.raddr)[11] << 24) + | ((__vaword)((unsigned char *) list.raddr)[12] << 32) + | ((__vaword)((unsigned char *) list.raddr)[13] << 40) + | ((__vaword)((unsigned char *) list.raddr)[14] << 48); + } else + if (list.rsize == 16) { + iret2 = ((__vaword)((unsigned char *) list.raddr)[8]) + | ((__vaword)((unsigned char *) list.raddr)[9] << 8) + | ((__vaword)((unsigned char *) list.raddr)[10] << 16) + | ((__vaword)((unsigned char *) list.raddr)[11] << 24) + | ((__vaword)((unsigned char *) list.raddr)[12] << 32) + | ((__vaword)((unsigned char *) list.raddr)[13] << 40) + | ((__vaword)((unsigned char *) list.raddr)[14] << 48) + | ((__vaword)((unsigned char *) list.raddr)[15] << 56); + } + } + #else /* Optimized: fewer conditional jumps, fewer memory accesses */ + uintptr_t count = list.rsize; /* > 0, ≤ 2*sizeof(__vaword) */ + __vaword* wordaddr = (__vaword*)((uintptr_t)list.raddr & ~(uintptr_t)(sizeof(__vaword)-1)); + uintptr_t start_offset = (uintptr_t)list.raddr & (uintptr_t)(sizeof(__vaword)-1); /* ≥ 0, < sizeof(__vaword) */ + uintptr_t end_offset = start_offset + count; /* > 0, < 3*sizeof(__vaword) */ + if (count <= sizeof(__vaword)) { + /* Assign iret. */ + if (end_offset <= sizeof(__vaword)) { + /* 0 < end_offset ≤ sizeof(__vaword) */ + __vaword mask0 = ((__vaword)2 << (end_offset*8-1)) - 1; + iret = (wordaddr[0] & mask0) >> (start_offset*8); + } else { + /* sizeof(__vaword) < end_offset < 2*sizeof(__vaword), start_offset > 0 */ + __vaword mask1 = ((__vaword)2 << (end_offset*8-sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | ((wordaddr[1] & mask1) << (sizeof(__vaword)*8-start_offset*8)); + } + } else { + /* Assign iret, iret2. */ + if (end_offset <= 2*sizeof(__vaword)) { + /* sizeof(__vaword) < end_offset ≤ 2*sizeof(__vaword) */ + __vaword mask1 = ((__vaword)2 << (end_offset*8-sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | ((wordaddr[1] & mask1) << (sizeof(__vaword)*4-start_offset*4) << (sizeof(__vaword)*4-start_offset*4)); + iret2 = (wordaddr[1] & mask1) >> (start_offset*8); + } else { + /* 2*sizeof(__vaword) < end_offset < 3*sizeof(__vaword), start_offset > 0 */ + __vaword mask2 = ((__vaword)2 << (end_offset*8-2*sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | (wordaddr[1] << (sizeof(__vaword)*8-start_offset*8)); + iret2 = (wordaddr[1] >> (start_offset*8)) | ((wordaddr[2] & mask2) << (sizeof(__vaword)*8-start_offset*8)); + } + } + #endif + } + } +#endif + } +} + +#ifdef REENTRANT +__vacall_r_t +callback_get_receiver (void) +{ + return (__vacall_r_t)(void*)&callback_receiver; +} +#endif diff --git a/vacall/vacall-riscv32-ilp32d-linux.s b/vacall/vacall-riscv32-ilp32d-linux.s new file mode 100644 index 0000000..0982775 --- /dev/null +++ b/vacall/vacall-riscv32-ilp32d-linux.s @@ -0,0 +1,163 @@ + .file "vacall-riscv32.c" + .option nopic + .text + .align 1 + .globl vacall_receiver + .type vacall_receiver, @function +vacall_receiver: + add sp,sp,-208 + sw ra,188(sp) + sw s0,184(sp) + add s0,sp,192 + lui t1,%hi(vacall_function) + lw t1,%lo(vacall_function)(t1) + sw a0,-148(s0) + add a0,s0,16 + sw a7,12(s0) + sw a1,-144(s0) + sw a2,-140(s0) + sw a3,-136(s0) + sw a4,-132(s0) + sw a5,-128(s0) + sw a6,-124(s0) + sw a7,-120(s0) + fsw fa0,-112(s0) + fsw fa1,-108(s0) + fsw fa2,-104(s0) + fsw fa3,-100(s0) + fsw fa4,-96(s0) + fsw fa5,-92(s0) + fsw fa6,-88(s0) + fsw fa7,-84(s0) + fsd fa0,-80(s0) + fsd fa1,-72(s0) + fsd fa2,-64(s0) + fsd fa3,-56(s0) + fsd fa4,-48(s0) + fsd fa5,-40(s0) + fsd fa6,-32(s0) + fsd fa7,-24(s0) + sw a0,-168(s0) + sw zero,-184(s0) + sw zero,-164(s0) + sw zero,-160(s0) + add a0,s0,-184 + sw zero,-152(s0) + sw zero,-116(s0) + jalr t1 + lw t1,-160(s0) + beqz t1,.L1 + li t3,1 + beq t1,t3,.L22 + li t3,2 + beq t1,t3,.L25 + li t3,3 + beq t1,t3,.L22 + li t3,4 + beq t1,t3,.L26 + li t3,5 + beq t1,t3,.L27 + li t3,6 + beq t1,t3,.L23 + li t3,7 + beq t1,t3,.L23 + li t3,8 + beq t1,t3,.L23 + li t3,9 + beq t1,t3,.L23 + add t3,t1,-10 + li t4,1 + bleu t3,t4,.L28 + li t3,12 + beq t1,t3,.L29 + li t3,13 + beq t1,t3,.L30 + li t3,14 + beq t1,t3,.L23 + li t3,15 + bne t1,t3,.L1 + lw t1,-184(s0) + and t1,t1,2 + beqz t1,.L1 + lw t3,-156(s0) + li t1,7 + add t5,t3,-1 + bgtu t5,t1,.L1 + lw t1,-164(s0) + lbu t5,0(t1) + mv a0,t5 + beq t3,t4,.L1 + lbu t4,1(t1) + li t6,2 + sll t4,t4,8 + or t5,t4,t5 + mv a0,t5 + beq t3,t6,.L1 + lbu t4,2(t1) + li t6,3 + sll t4,t4,16 + or t4,t4,t5 + mv a0,t4 + beq t3,t6,.L1 + lbu a0,3(t1) + li t5,4 + sll a0,a0,24 + or a0,a0,t4 + beq t3,t5,.L1 + lbu t5,4(t1) + li t4,5 + mv a1,t5 + beq t3,t4,.L1 + lbu t4,5(t1) + li t6,6 + sll t4,t4,8 + or t5,t4,t5 + mv a1,t5 + beq t3,t6,.L1 + lbu t4,6(t1) + li t6,8 + sll t4,t4,16 + or t4,t4,t5 + mv a1,t4 + bne t3,t6,.L1 + lbu a1,7(t1) + sll a1,a1,24 + or a1,a1,t4 +.L1: + lw ra,188(sp) + lw s0,184(sp) + add sp,sp,208 + jr ra +.L22: + lbu a0,-176(s0) + lw ra,188(sp) + lw s0,184(sp) + add sp,sp,208 + jr ra +.L23: + lw a0,-176(s0) + j .L1 +.L25: + lb a0,-176(s0) + lw ra,188(sp) + lw s0,184(sp) + add sp,sp,208 + jr ra +.L26: + lh a0,-176(s0) + j .L1 +.L27: + lhu a0,-176(s0) + j .L1 +.L28: + lw a0,-176(s0) + lw a1,-172(s0) + j .L1 +.L29: + flw fa0,-176(s0) + j .L1 +.L30: + fld fa0,-176(s0) + j .L1 + .size vacall_receiver, .-vacall_receiver + .ident "GCC: (GNU) 7.3.0" diff --git a/vacall/vacall-riscv32-ilp32d-macro.S b/vacall/vacall-riscv32-ilp32d-macro.S new file mode 100644 index 0000000..5142889 --- /dev/null +++ b/vacall/vacall-riscv32-ilp32d-macro.S @@ -0,0 +1,165 @@ + .file "vacall-riscv32.c" + .option nopic + .text + .align 1 + .globl vacall_receiver + .type vacall_receiver, @function +vacall_receiver: + add sp,sp,-208 + sw ra,188(sp) + sw s0,184(sp) + add s0,sp,192 + lui t1,%hi(vacall_function) + lw t1,%lo(vacall_function)(t1) + sw a0,-148(s0) + add a0,s0,16 + sw a7,12(s0) + sw a1,-144(s0) + sw a2,-140(s0) + sw a3,-136(s0) + sw a4,-132(s0) + sw a5,-128(s0) + sw a6,-124(s0) + sw a7,-120(s0) + fsw fa0,-112(s0) + fsw fa1,-108(s0) + fsw fa2,-104(s0) + fsw fa3,-100(s0) + fsw fa4,-96(s0) + fsw fa5,-92(s0) + fsw fa6,-88(s0) + fsw fa7,-84(s0) + fsd fa0,-80(s0) + fsd fa1,-72(s0) + fsd fa2,-64(s0) + fsd fa3,-56(s0) + fsd fa4,-48(s0) + fsd fa5,-40(s0) + fsd fa6,-32(s0) + fsd fa7,-24(s0) + sw a0,-168(s0) + sw zero,-184(s0) + sw zero,-164(s0) + sw zero,-160(s0) + add a0,s0,-184 + sw zero,-152(s0) + sw zero,-116(s0) + jalr t1 + lw t1,-160(s0) + beqz t1,.L1 + li t3,1 + beq t1,t3,.L22 + li t3,2 + beq t1,t3,.L25 + li t3,3 + beq t1,t3,.L22 + li t3,4 + beq t1,t3,.L26 + li t3,5 + beq t1,t3,.L27 + li t3,6 + beq t1,t3,.L23 + li t3,7 + beq t1,t3,.L23 + li t3,8 + beq t1,t3,.L23 + li t3,9 + beq t1,t3,.L23 + add t3,t1,-10 + li t4,1 + bleu t3,t4,.L28 + li t3,12 + beq t1,t3,.L29 + li t3,13 + beq t1,t3,.L30 + li t3,14 + beq t1,t3,.L23 + li t3,15 + bne t1,t3,.L1 + lw t1,-184(s0) + and t1,t1,2 + beqz t1,.L1 + lw t3,-156(s0) + li t1,7 + add t5,t3,-1 + bgtu t5,t1,.L1 + lw t1,-164(s0) + lbu t5,0(t1) + mv a0,t5 + beq t3,t4,.L1 + lbu t4,1(t1) + li t6,2 + sll t4,t4,8 + or t5,t4,t5 + mv a0,t5 + beq t3,t6,.L1 + lbu t4,2(t1) + li t6,3 + sll t4,t4,16 + or t4,t4,t5 + mv a0,t4 + beq t3,t6,.L1 + lbu a0,3(t1) + li t5,4 + sll a0,a0,24 + or a0,a0,t4 + beq t3,t5,.L1 + lbu t5,4(t1) + li t4,5 + mv a1,t5 + beq t3,t4,.L1 + lbu t4,5(t1) + li t6,6 + sll t4,t4,8 + or t5,t4,t5 + mv a1,t5 + beq t3,t6,.L1 + lbu t4,6(t1) + li t6,8 + sll t4,t4,16 + or t4,t4,t5 + mv a1,t4 + bne t3,t6,.L1 + lbu a1,7(t1) + sll a1,a1,24 + or a1,a1,t4 +.L1: + lw ra,188(sp) + lw s0,184(sp) + add sp,sp,208 + jr ra +.L22: + lbu a0,-176(s0) + lw ra,188(sp) + lw s0,184(sp) + add sp,sp,208 + jr ra +.L23: + lw a0,-176(s0) + j .L1 +.L25: + lb a0,-176(s0) + lw ra,188(sp) + lw s0,184(sp) + add sp,sp,208 + jr ra +.L26: + lh a0,-176(s0) + j .L1 +.L27: + lhu a0,-176(s0) + j .L1 +.L28: + lw a0,-176(s0) + lw a1,-172(s0) + j .L1 +.L29: + flw fa0,-176(s0) + j .L1 +.L30: + fld fa0,-176(s0) + j .L1 + .size vacall_receiver, .-vacall_receiver +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/vacall/vacall-riscv32.c b/vacall/vacall-riscv32.c new file mode 100644 index 0000000..b3f581f --- /dev/null +++ b/vacall/vacall-riscv32.c @@ -0,0 +1,226 @@ +/* vacall function for RISC-V 32-bit CPU */ + +/* + * Copyright 1995-2019 Bruno Haible + * + * 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, see . + */ + +#include "vacall-internal.h" + +#ifdef REENTRANT +#define vacall_receiver callback_receiver +register struct { void (*vacall_function) (void*,va_alist); void* arg; } + * env __asm__("t2"); +#endif + +register __vaword iarg1 __asm__("a0"); +register __vaword iarg2 __asm__("a1"); +register __vaword iarg3 __asm__("a2"); +register __vaword iarg4 __asm__("a3"); +register __vaword iarg5 __asm__("a4"); +register __vaword iarg6 __asm__("a5"); +register __vaword iarg7 __asm__("a6"); +register __vaword iarg8 __asm__("a7"); + +register float farg1 __asm__("fa0"); +register float farg2 __asm__("fa1"); +register float farg3 __asm__("fa2"); +register float farg4 __asm__("fa3"); +register float farg5 __asm__("fa4"); +register float farg6 __asm__("fa5"); +register float farg7 __asm__("fa6"); +register float farg8 __asm__("fa7"); + +register double darg1 __asm__("fa0"); +register double darg2 __asm__("fa1"); +register double darg3 __asm__("fa2"); +register double darg4 __asm__("fa3"); +register double darg5 __asm__("fa4"); +register double darg6 __asm__("fa5"); +register double darg7 __asm__("fa6"); +register double darg8 __asm__("fa7"); + +register __vaword iret __asm__("a0"); +register __vaword iret2 __asm__("a1"); +register float fret __asm__("fa0"); +register double dret __asm__("fa0"); + +/* The ABI requires that the first 8 general-purpose argument words are + being passed in registers, even if these words belong to structs that are + at most 2 words large. No room is allocated for these register words on + the stack by the caller, but the callee allocates room for them - at the + right place in the stack frame, that is, above the retaddr - if and only + if they are part of a struct that extends to the stack and the address of + this struct is taken. */ +struct gpargsequence { + __vaword word8; /* a7 */ + __vaword firststackword; +}; + +#ifdef REENTRANT +static +#endif +void /* the return type is variable, not void! */ +vacall_receiver (__vaword word1, __vaword word2, __vaword word3, __vaword word4, + __vaword word5, __vaword word6, __vaword word7, + struct gpargsequence gpargs) +{ + __va_alist list; + /* Move the arguments passed in registers to temp storage. */ + list.iarg[0] = iarg1; + list.iarg[1] = iarg2; + list.iarg[2] = iarg3; + list.iarg[3] = iarg4; + list.iarg[4] = iarg5; + list.iarg[5] = iarg6; + list.iarg[6] = iarg7; + list.iarg[7] = iarg8; /* = gpargs.word8 */ + list.farg[0] = farg1; + list.farg[1] = farg2; + list.farg[2] = farg3; + list.farg[3] = farg4; + list.farg[4] = farg5; + list.farg[5] = farg6; + list.farg[6] = farg7; + list.farg[7] = farg8; + list.darg[0] = darg1; + list.darg[1] = darg2; + list.darg[2] = darg3; + list.darg[3] = darg4; + list.darg[4] = darg5; + list.darg[5] = darg6; + list.darg[6] = darg7; + list.darg[7] = darg8; + /* Prepare the va_alist. */ + list.flags = 0; + list.aptr = (long)&gpargs + sizeof(__vaword); + list.raddr = (void*)0; + list.rtype = __VAvoid; + list.ianum = 0; + list.fanum = 0; + /* Call vacall_function. The macros do all the rest. */ +#ifndef REENTRANT + (*vacall_function) (&list); +#else /* REENTRANT */ + (*env->vacall_function) (env->arg,&list); +#endif + /* Put return value into proper register. */ + if (list.rtype == __VAvoid) { + } else + if (list.rtype == __VAchar) { + iret = list.tmp._char; + } else + if (list.rtype == __VAschar) { + iret = list.tmp._schar; + } else + if (list.rtype == __VAuchar) { + iret = list.tmp._uchar; + } else + if (list.rtype == __VAshort) { + iret = list.tmp._short; + } else + if (list.rtype == __VAushort) { + iret = list.tmp._ushort; + } else + if (list.rtype == __VAint) { + iret = list.tmp._int; + } else + if (list.rtype == __VAuint) { + iret = list.tmp._uint; + } else + if (list.rtype == __VAlong) { + iret = list.tmp._long; + } else + if (list.rtype == __VAulong) { + iret = list.tmp._ulong; + } else + if (list.rtype == __VAlonglong || list.rtype == __VAulonglong) { + iret = ((__vaword *) &list.tmp._longlong)[0]; + iret2 = ((__vaword *) &list.tmp._longlong)[1]; + } else + if (list.rtype == __VAfloat) { + fret = list.tmp._float; + } else + if (list.rtype == __VAdouble) { + dret = list.tmp._double; + } else + if (list.rtype == __VAvoidp) { + iret = (long)list.tmp._ptr; + } else + if (list.rtype == __VAstruct) { + /* normal struct return convention */ + if (list.flags & __VA_SMALL_STRUCT_RETURN) { + /* Return structs of size <= 8 in registers. */ + if (list.rsize > 0 && list.rsize <= 8) { + #if 1 /* Unoptimized */ + iret = (__vaword)((unsigned char *) list.raddr)[0]; + if (list.rsize >= 2) + iret |= (__vaword)((unsigned char *) list.raddr)[1] << 8; + if (list.rsize >= 3) + iret |= (__vaword)((unsigned char *) list.raddr)[2] << 16; + if (list.rsize >= 4) + iret |= (__vaword)((unsigned char *) list.raddr)[3] << 24; + if (list.rsize >= 5) { + iret2 = (__vaword)((unsigned char *) list.raddr)[4]; + if (list.rsize >= 6) + iret2 |= (__vaword)((unsigned char *) list.raddr)[5] << 8; + if (list.rsize >= 7) + iret2 |= (__vaword)((unsigned char *) list.raddr)[6] << 16; + if (list.rsize >= 8) + iret2 |= (__vaword)((unsigned char *) list.raddr)[7] << 24; + } + #else /* Optimized: fewer conditional jumps, fewer memory accesses */ + uintptr_t count = list.rsize; /* > 0, ≤ 2*sizeof(__vaword) */ + __vaword* wordaddr = (__vaword*)((uintptr_t)list.raddr & ~(uintptr_t)(sizeof(__vaword)-1)); + uintptr_t start_offset = (uintptr_t)list.raddr & (uintptr_t)(sizeof(__vaword)-1); /* ≥ 0, < sizeof(__vaword) */ + uintptr_t end_offset = start_offset + count; /* > 0, < 3*sizeof(__vaword) */ + if (count <= sizeof(__vaword)) { + /* Assign iret. */ + if (end_offset <= sizeof(__vaword)) { + /* 0 < end_offset ≤ sizeof(__vaword) */ + __vaword mask0 = ((__vaword)2 << (end_offset*8-1)) - 1; + iret = (wordaddr[0] & mask0) >> (start_offset*8); + } else { + /* sizeof(__vaword) < end_offset < 2*sizeof(__vaword), start_offset > 0 */ + __vaword mask1 = ((__vaword)2 << (end_offset*8-sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | ((wordaddr[1] & mask1) << (sizeof(__vaword)*8-start_offset*8)); + } + } else { + /* Assign iret, iret2. */ + if (end_offset <= 2*sizeof(__vaword)) { + /* sizeof(__vaword) < end_offset ≤ 2*sizeof(__vaword) */ + __vaword mask1 = ((__vaword)2 << (end_offset*8-sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | ((wordaddr[1] & mask1) << (sizeof(__vaword)*4-start_offset*4) << (sizeof(__vaword)*4-start_offset*4)); + iret2 = (wordaddr[1] & mask1) >> (start_offset*8); + } else { + /* 2*sizeof(__vaword) < end_offset < 3*sizeof(__vaword), start_offset > 0 */ + __vaword mask2 = ((__vaword)2 << (end_offset*8-2*sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | (wordaddr[1] << (sizeof(__vaword)*8-start_offset*8)); + iret2 = (wordaddr[1] >> (start_offset*8)) | ((wordaddr[2] & mask2) << (sizeof(__vaword)*8-start_offset*8)); + } + } + #endif + } + } + } +} + +#ifdef REENTRANT +__vacall_r_t +callback_get_receiver (void) +{ + return (__vacall_r_t)(void*)&callback_receiver; +} +#endif diff --git a/vacall/vacall-riscv64-lp64d-linux.s b/vacall/vacall-riscv64-lp64d-linux.s new file mode 100644 index 0000000..65f5bc9 --- /dev/null +++ b/vacall/vacall-riscv64-lp64d-linux.s @@ -0,0 +1,190 @@ + .file "vacall-riscv64.c" + .option nopic + .text + .align 1 + .globl vacall_receiver + .type vacall_receiver, @function +vacall_receiver: + add sp,sp,-288 + sd ra,264(sp) + sd s0,256(sp) + sd s1,248(sp) + add s0,sp,272 + lui t1,%hi(vacall_function) + ld t1,%lo(vacall_function)(t1) + sd a0,-200(s0) + add a0,s0,16 + sd a7,8(s0) + sd a1,-192(s0) + sd a2,-184(s0) + sd a3,-176(s0) + sd a4,-168(s0) + sd a5,-160(s0) + sd a6,-152(s0) + sd a7,-144(s0) + fsw fa0,-132(s0) + fsw fa1,-128(s0) + fsw fa2,-124(s0) + fsw fa3,-120(s0) + fsw fa4,-116(s0) + fsw fa5,-112(s0) + fsw fa6,-108(s0) + fsw fa7,-104(s0) + fsd fa0,-96(s0) + fsd fa1,-88(s0) + fsd fa2,-80(s0) + fsd fa3,-72(s0) + fsd fa4,-64(s0) + fsd fa5,-56(s0) + fsd fa6,-48(s0) + fsd fa7,-40(s0) + sd a0,-240(s0) + sw zero,-264(s0) + sd zero,-232(s0) + add a0,s0,-264 + sw zero,-224(s0) + sw zero,-208(s0) + sw zero,-136(s0) + jalr t1 + lw t1,-224(s0) + beqz t1,.L1 + li t3,1 + beq t1,t3,.L25 + li t3,2 + beq t1,t3,.L29 + li t3,3 + beq t1,t3,.L25 + li t3,4 + beq t1,t3,.L30 + li t3,5 + beq t1,t3,.L31 + li t3,6 + beq t1,t3,.L32 + li t3,7 + beq t1,t3,.L33 + and t3,t1,-3 + li t4,8 + beq t3,t4,.L27 + li t4,9 + beq t3,t4,.L27 + li t3,12 + beq t1,t3,.L34 + li t3,13 + beq t1,t3,.L35 + li t3,14 + beq t1,t3,.L27 + li t3,15 + bne t1,t3,.L1 + lw t3,-264(s0) + and t3,t3,1024 + beqz t3,.L1 + ld t0,-216(s0) + add t3,t0,-1 + bgtu t3,t1,.L1 + ld t5,-232(s0) + li s1,8 + and t6,t5,7 + add t2,t0,t6 + and t5,t5,-8 + sext.w t6,t6 + sllw t1,t2,3 + ld t4,0(t5) + sll t3,t6,3 + bgtu t0,s1,.L15 + bgtu t2,s1,.L16 + addw t1,t1,-1 + li a0,2 + sll a0,a0,t1 + add a0,a0,-1 + and a0,a0,t4 + sra a0,a0,t3 +.L1: + ld ra,264(sp) + ld s0,256(sp) + ld s1,248(sp) + add sp,sp,288 + jr ra +.L25: + lbu a0,-256(s0) + ld ra,264(sp) + ld s0,256(sp) + ld s1,248(sp) + add sp,sp,288 + jr ra +.L29: + lb a0,-256(s0) + ld ra,264(sp) + ld s0,256(sp) + ld s1,248(sp) + add sp,sp,288 + jr ra +.L30: + lh a0,-256(s0) + j .L1 +.L33: + lwu a0,-256(s0) + j .L1 +.L31: + lhu a0,-256(s0) + j .L1 +.L27: + ld a0,-256(s0) + j .L1 +.L32: + lw a0,-256(s0) + j .L1 +.L34: + flw fa0,-256(s0) + j .L1 +.L35: + fld fa0,-256(s0) + j .L1 +.L15: + li s1,16 + sra t4,t4,t3 + ld t0,8(t5) + bleu t2,s1,.L36 + li a1,-8 + mulw t6,a1,t6 + addw t1,t1,-129 + ld a0,16(t5) + li a1,2 + sll a1,a1,t1 + add a1,a1,-1 + and a1,a1,a0 + sra t3,t0,t3 + addw t1,t6,64 + sll a0,t0,t1 + sll a1,a1,t1 + or a0,a0,t4 + or a1,a1,t3 + j .L1 +.L16: + li a0,-8 + mulw t6,a0,t6 + addw t1,t1,-65 + ld t5,8(t5) + li a0,2 + sll a0,a0,t1 + add a0,a0,-1 + and a0,a0,t5 + sra t4,t4,t3 + sll a0,a0,t6 + or a0,a0,t4 + j .L1 +.L36: + li a1,-4 + mulw t6,a1,t6 + addw t1,t1,-65 + li a0,2 + sll a0,a0,t1 + add a0,a0,-1 + and a0,a0,t0 + sra a1,a0,t3 + addw t1,t6,32 + sll a0,a0,t1 + sll a0,a0,t1 + or a0,a0,t4 + j .L1 + .size vacall_receiver, .-vacall_receiver + .ident "GCC: (GNU) 7.3.0" diff --git a/vacall/vacall-riscv64-lp64d-macro.S b/vacall/vacall-riscv64-lp64d-macro.S new file mode 100644 index 0000000..25bb90b --- /dev/null +++ b/vacall/vacall-riscv64-lp64d-macro.S @@ -0,0 +1,192 @@ + .file "vacall-riscv64.c" + .option nopic + .text + .align 1 + .globl vacall_receiver + .type vacall_receiver, @function +vacall_receiver: + add sp,sp,-288 + sd ra,264(sp) + sd s0,256(sp) + sd s1,248(sp) + add s0,sp,272 + lui t1,%hi(vacall_function) + ld t1,%lo(vacall_function)(t1) + sd a0,-200(s0) + add a0,s0,16 + sd a7,8(s0) + sd a1,-192(s0) + sd a2,-184(s0) + sd a3,-176(s0) + sd a4,-168(s0) + sd a5,-160(s0) + sd a6,-152(s0) + sd a7,-144(s0) + fsw fa0,-132(s0) + fsw fa1,-128(s0) + fsw fa2,-124(s0) + fsw fa3,-120(s0) + fsw fa4,-116(s0) + fsw fa5,-112(s0) + fsw fa6,-108(s0) + fsw fa7,-104(s0) + fsd fa0,-96(s0) + fsd fa1,-88(s0) + fsd fa2,-80(s0) + fsd fa3,-72(s0) + fsd fa4,-64(s0) + fsd fa5,-56(s0) + fsd fa6,-48(s0) + fsd fa7,-40(s0) + sd a0,-240(s0) + sw zero,-264(s0) + sd zero,-232(s0) + add a0,s0,-264 + sw zero,-224(s0) + sw zero,-208(s0) + sw zero,-136(s0) + jalr t1 + lw t1,-224(s0) + beqz t1,.L1 + li t3,1 + beq t1,t3,.L25 + li t3,2 + beq t1,t3,.L29 + li t3,3 + beq t1,t3,.L25 + li t3,4 + beq t1,t3,.L30 + li t3,5 + beq t1,t3,.L31 + li t3,6 + beq t1,t3,.L32 + li t3,7 + beq t1,t3,.L33 + and t3,t1,-3 + li t4,8 + beq t3,t4,.L27 + li t4,9 + beq t3,t4,.L27 + li t3,12 + beq t1,t3,.L34 + li t3,13 + beq t1,t3,.L35 + li t3,14 + beq t1,t3,.L27 + li t3,15 + bne t1,t3,.L1 + lw t3,-264(s0) + and t3,t3,1024 + beqz t3,.L1 + ld t0,-216(s0) + add t3,t0,-1 + bgtu t3,t1,.L1 + ld t5,-232(s0) + li s1,8 + and t6,t5,7 + add t2,t0,t6 + and t5,t5,-8 + sext.w t6,t6 + sllw t1,t2,3 + ld t4,0(t5) + sll t3,t6,3 + bgtu t0,s1,.L15 + bgtu t2,s1,.L16 + addw t1,t1,-1 + li a0,2 + sll a0,a0,t1 + add a0,a0,-1 + and a0,a0,t4 + sra a0,a0,t3 +.L1: + ld ra,264(sp) + ld s0,256(sp) + ld s1,248(sp) + add sp,sp,288 + jr ra +.L25: + lbu a0,-256(s0) + ld ra,264(sp) + ld s0,256(sp) + ld s1,248(sp) + add sp,sp,288 + jr ra +.L29: + lb a0,-256(s0) + ld ra,264(sp) + ld s0,256(sp) + ld s1,248(sp) + add sp,sp,288 + jr ra +.L30: + lh a0,-256(s0) + j .L1 +.L33: + lwu a0,-256(s0) + j .L1 +.L31: + lhu a0,-256(s0) + j .L1 +.L27: + ld a0,-256(s0) + j .L1 +.L32: + lw a0,-256(s0) + j .L1 +.L34: + flw fa0,-256(s0) + j .L1 +.L35: + fld fa0,-256(s0) + j .L1 +.L15: + li s1,16 + sra t4,t4,t3 + ld t0,8(t5) + bleu t2,s1,.L36 + li a1,-8 + mulw t6,a1,t6 + addw t1,t1,-129 + ld a0,16(t5) + li a1,2 + sll a1,a1,t1 + add a1,a1,-1 + and a1,a1,a0 + sra t3,t0,t3 + addw t1,t6,64 + sll a0,t0,t1 + sll a1,a1,t1 + or a0,a0,t4 + or a1,a1,t3 + j .L1 +.L16: + li a0,-8 + mulw t6,a0,t6 + addw t1,t1,-65 + ld t5,8(t5) + li a0,2 + sll a0,a0,t1 + add a0,a0,-1 + and a0,a0,t5 + sra t4,t4,t3 + sll a0,a0,t6 + or a0,a0,t4 + j .L1 +.L36: + li a1,-4 + mulw t6,a1,t6 + addw t1,t1,-65 + li a0,2 + sll a0,a0,t1 + add a0,a0,-1 + and a0,a0,t0 + sra a1,a0,t3 + addw t1,t6,32 + sll a0,a0,t1 + sll a0,a0,t1 + or a0,a0,t4 + j .L1 + .size vacall_receiver, .-vacall_receiver +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/vacall/vacall-riscv64.c b/vacall/vacall-riscv64.c new file mode 100644 index 0000000..8789968 --- /dev/null +++ b/vacall/vacall-riscv64.c @@ -0,0 +1,238 @@ +/* vacall function for RISC-V 64-bit CPU */ + +/* + * Copyright 1995-2019 Bruno Haible + * + * 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, see . + */ + +#include "vacall-internal.h" + +#ifdef REENTRANT +#define vacall_receiver callback_receiver +register struct { void (*vacall_function) (void*,va_alist); void* arg; } + * env __asm__("t2"); +#endif + +register __vaword iarg1 __asm__("a0"); +register __vaword iarg2 __asm__("a1"); +register __vaword iarg3 __asm__("a2"); +register __vaword iarg4 __asm__("a3"); +register __vaword iarg5 __asm__("a4"); +register __vaword iarg6 __asm__("a5"); +register __vaword iarg7 __asm__("a6"); +register __vaword iarg8 __asm__("a7"); + +register float farg1 __asm__("fa0"); +register float farg2 __asm__("fa1"); +register float farg3 __asm__("fa2"); +register float farg4 __asm__("fa3"); +register float farg5 __asm__("fa4"); +register float farg6 __asm__("fa5"); +register float farg7 __asm__("fa6"); +register float farg8 __asm__("fa7"); + +register double darg1 __asm__("fa0"); +register double darg2 __asm__("fa1"); +register double darg3 __asm__("fa2"); +register double darg4 __asm__("fa3"); +register double darg5 __asm__("fa4"); +register double darg6 __asm__("fa5"); +register double darg7 __asm__("fa6"); +register double darg8 __asm__("fa7"); + +register __vaword iret __asm__("a0"); +register __vaword iret2 __asm__("a1"); +register float fret __asm__("fa0"); +register double dret __asm__("fa0"); + +/* The ABI requires that the first 8 general-purpose argument words are + being passed in registers, even if these words belong to structs that are + at most 2 words large. No room is allocated for these register words on + the stack by the caller, but the callee allocates room for them - at the + right place in the stack frame, that is, above the retaddr - if and only + if they are part of a struct that extends to the stack and the address of + this struct is taken. */ +struct gpargsequence { + __vaword word8; /* a7 */ + __vaword firststackword; +}; + +#ifdef REENTRANT +static +#endif +void /* the return type is variable, not void! */ +vacall_receiver (__vaword word1, __vaword word2, __vaword word3, __vaword word4, + __vaword word5, __vaword word6, __vaword word7, + struct gpargsequence gpargs) +{ + __va_alist list; + /* Move the arguments passed in registers to temp storage. */ + list.iarg[0] = iarg1; + list.iarg[1] = iarg2; + list.iarg[2] = iarg3; + list.iarg[3] = iarg4; + list.iarg[4] = iarg5; + list.iarg[5] = iarg6; + list.iarg[6] = iarg7; + list.iarg[7] = iarg8; /* = gpargs.word8 */ + list.farg[0] = farg1; + list.farg[1] = farg2; + list.farg[2] = farg3; + list.farg[3] = farg4; + list.farg[4] = farg5; + list.farg[5] = farg6; + list.farg[6] = farg7; + list.farg[7] = farg8; + list.darg[0] = darg1; + list.darg[1] = darg2; + list.darg[2] = darg3; + list.darg[3] = darg4; + list.darg[4] = darg5; + list.darg[5] = darg6; + list.darg[6] = darg7; + list.darg[7] = darg8; + /* Prepare the va_alist. */ + list.flags = 0; + list.aptr = (long)&gpargs + sizeof(__vaword); + list.raddr = (void*)0; + list.rtype = __VAvoid; + list.ianum = 0; + list.fanum = 0; + /* Call vacall_function. The macros do all the rest. */ +#ifndef REENTRANT + (*vacall_function) (&list); +#else /* REENTRANT */ + (*env->vacall_function) (env->arg,&list); +#endif + /* Put return value into proper register. */ + if (list.rtype == __VAvoid) { + } else + if (list.rtype == __VAchar) { + iret = list.tmp._char; + } else + if (list.rtype == __VAschar) { + iret = list.tmp._schar; + } else + if (list.rtype == __VAuchar) { + iret = list.tmp._uchar; + } else + if (list.rtype == __VAshort) { + iret = list.tmp._short; + } else + if (list.rtype == __VAushort) { + iret = list.tmp._ushort; + } else + if (list.rtype == __VAint) { + iret = list.tmp._int; + } else + if (list.rtype == __VAuint) { + iret = list.tmp._uint; + } else + if (list.rtype == __VAlong || list.rtype == __VAlonglong) { + iret = list.tmp._long; + } else + if (list.rtype == __VAulong || list.rtype == __VAulonglong) { + iret = list.tmp._ulong; + } else + if (list.rtype == __VAfloat) { + fret = list.tmp._float; + } else + if (list.rtype == __VAdouble) { + dret = list.tmp._double; + } else + if (list.rtype == __VAvoidp) { + iret = (long)list.tmp._ptr; + } else + if (list.rtype == __VAstruct) { + /* normal struct return convention */ + if (list.flags & __VA_REGISTER_STRUCT_RETURN) { + /* Return structs of size <= 16 in registers. */ + if (list.rsize > 0 && list.rsize <= 16) { + #if 0 /* Unoptimized */ + iret = (__vaword)((unsigned char *) list.raddr)[0]; + if (list.rsize >= 2) + iret |= (__vaword)((unsigned char *) list.raddr)[1] << 8; + if (list.rsize >= 3) + iret |= (__vaword)((unsigned char *) list.raddr)[2] << 16; + if (list.rsize >= 4) + iret |= (__vaword)((unsigned char *) list.raddr)[3] << 24; + if (list.rsize >= 5) + iret |= (__vaword)((unsigned char *) list.raddr)[4] << 32; + if (list.rsize >= 6) + iret |= (__vaword)((unsigned char *) list.raddr)[5] << 40; + if (list.rsize >= 7) + iret |= (__vaword)((unsigned char *) list.raddr)[6] << 48; + if (list.rsize >= 8) + iret |= (__vaword)((unsigned char *) list.raddr)[7] << 56; + if (list.rsize >= 9) { + iret2 = (__vaword)((unsigned char *) list.raddr)[8]; + if (list.rsize >= 10) + iret2 |= (__vaword)((unsigned char *) list.raddr)[9] << 8; + if (list.rsize >= 11) + iret2 |= (__vaword)((unsigned char *) list.raddr)[10] << 16; + if (list.rsize >= 12) + iret2 |= (__vaword)((unsigned char *) list.raddr)[11] << 24; + if (list.rsize >= 13) + iret2 |= (__vaword)((unsigned char *) list.raddr)[12] << 32; + if (list.rsize >= 14) + iret2 |= (__vaword)((unsigned char *) list.raddr)[13] << 40; + if (list.rsize >= 15) + iret2 |= (__vaword)((unsigned char *) list.raddr)[14] << 48; + if (list.rsize >= 16) + iret2 |= (__vaword)((unsigned char *) list.raddr)[15] << 56; + } + #else /* Optimized: fewer conditional jumps, fewer memory accesses */ + uintptr_t count = list.rsize; /* > 0, ≤ 2*sizeof(__vaword) */ + __vaword* wordaddr = (__vaword*)((uintptr_t)list.raddr & ~(uintptr_t)(sizeof(__vaword)-1)); + uintptr_t start_offset = (uintptr_t)list.raddr & (uintptr_t)(sizeof(__vaword)-1); /* ≥ 0, < sizeof(__vaword) */ + uintptr_t end_offset = start_offset + count; /* > 0, < 3*sizeof(__vaword) */ + if (count <= sizeof(__vaword)) { + /* Assign iret. */ + if (end_offset <= sizeof(__vaword)) { + /* 0 < end_offset ≤ sizeof(__vaword) */ + __vaword mask0 = ((__vaword)2 << (end_offset*8-1)) - 1; + iret = (wordaddr[0] & mask0) >> (start_offset*8); + } else { + /* sizeof(__vaword) < end_offset < 2*sizeof(__vaword), start_offset > 0 */ + __vaword mask1 = ((__vaword)2 << (end_offset*8-sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | ((wordaddr[1] & mask1) << (sizeof(__vaword)*8-start_offset*8)); + } + } else { + /* Assign iret, iret2. */ + if (end_offset <= 2*sizeof(__vaword)) { + /* sizeof(__vaword) < end_offset ≤ 2*sizeof(__vaword) */ + __vaword mask1 = ((__vaword)2 << (end_offset*8-sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | ((wordaddr[1] & mask1) << (sizeof(__vaword)*4-start_offset*4) << (sizeof(__vaword)*4-start_offset*4)); + iret2 = (wordaddr[1] & mask1) >> (start_offset*8); + } else { + /* 2*sizeof(__vaword) < end_offset < 3*sizeof(__vaword), start_offset > 0 */ + __vaword mask2 = ((__vaword)2 << (end_offset*8-2*sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | (wordaddr[1] << (sizeof(__vaword)*8-start_offset*8)); + iret2 = (wordaddr[1] >> (start_offset*8)) | ((wordaddr[2] & mask2) << (sizeof(__vaword)*8-start_offset*8)); + } + } + #endif + } + } + } +} + +#ifdef REENTRANT +__vacall_r_t +callback_get_receiver (void) +{ + return (__vacall_r_t)(void*)&callback_receiver; +} +#endif diff --git a/vacall/vacall-s390-linux.s b/vacall/vacall-s390-linux.s new file mode 100644 index 0000000..0b0038f --- /dev/null +++ b/vacall/vacall-s390-linux.s @@ -0,0 +1,144 @@ + .file "vacall-s390.c" +.text + .align 4 +.globl vacall_receiver + .type vacall_receiver,@function +vacall_receiver: + stm %r6,%r15,24(%r15) + bras %r13,.LTN0_0 +.LT0_0: +.LC0: + .long vacall_function +.LC1: + .long 0 +.LC2: + .long 255 +.LC3: + .long 65535 +.LC4: + .long 1 +.LTN0_0: + l %r1,.LC0-.LT0_0(%r13) + lr %r14,%r15 + ahi %r15,-184 + lr %r11,%r15 + l %r12,0(%r1) + st %r14,0(%r15) + la %r1,280(%r11) + st %r2,132(%r11) + la %r2,96(%r11) + st %r4,140(%r11) + st %r5,144(%r11) + st %r6,148(%r11) + st %r3,136(%r11) + std %f2,176(%r11) + std %f0,168(%r11) + ste %f2,160(%r11) + ste %f0,156(%r11) + mvc 96(4,%r11),.LC1-.LT0_0(%r13) + st %r1,112(%r11) + mvc 116(4,%r11),.LC1-.LT0_0(%r13) + mvc 120(4,%r11),.LC1-.LT0_0(%r13) + mvc 128(4,%r11),.LC1-.LT0_0(%r13) + mvc 152(4,%r11),.LC1-.LT0_0(%r13) + basr %r14,%r12 + icm %r4,15,120(%r11) + je .L1 + chi %r4,1 + je .L43 + chi %r4,2 + je .L44 + chi %r4,3 + je .L43 + chi %r4,4 + je .L45 + chi %r4,5 + je .L46 + chi %r4,6 + je .L40 + chi %r4,7 + je .L40 + chi %r4,8 + je .L40 + chi %r4,9 + je .L40 + lr %r1,%r4 + ahi %r1,-10 + cl %r1,.LC4-.LT0_0(%r13) + jh .L22 + l %r2,104(%r11) + l %r3,108(%r11) +.L1: + l %r4,240(%r11) + lm %r6,%r15,208(%r11) + br %r4 +.L22: + chi %r4,12 + je .L47 + chi %r4,13 + je .L48 + chi %r4,14 + je .L40 + chi %r4,15 + jne .L1 + tm 98(%r11),4 + je .L1 + l %r1,124(%r11) + chi %r1,1 + je .L49 + chi %r1,2 + je .L50 + chi %r1,4 + je .L51 + chi %r1,8 + jne .L1 + l %r1,116(%r11) + l %r3,4(%r1) +.L39: + l %r2,0(%r1) + j .L1 +.L51: + l %r1,116(%r11) + j .L39 +.L50: + l %r1,116(%r11) + lh %r4,0(%r1) + lr %r2,%r4 +.L41: + n %r2,.LC3-.LT0_0(%r13) + j .L1 +.L49: + l %r1,116(%r11) + ic %r4,0(%r1) + lr %r2,%r4 +.L42: + n %r2,.LC2-.LT0_0(%r13) + j .L1 +.L40: + l %r2,104(%r11) + j .L1 +.L48: + ld %f0,104(%r11) + j .L1 +.L47: + le %f0,104(%r11) + j .L1 +.L46: + lh %r1,104(%r11) + lr %r2,%r1 + j .L41 +.L45: + lh %r2,104(%r11) + j .L1 +.L43: + ic %r1,104(%r11) + lr %r2,%r1 + j .L42 +.L44: + icm %r1,8,104(%r11) + lr %r2,%r1 + sra %r2,24 + j .L1 +.Lfe1: + .size vacall_receiver,.Lfe1-vacall_receiver + .ident "GCC: (GNU) 3.1" diff --git a/vacall/vacall-s390-macro.S b/vacall/vacall-s390-macro.S new file mode 100644 index 0000000..de4c35e --- /dev/null +++ b/vacall/vacall-s390-macro.S @@ -0,0 +1,146 @@ + .file "vacall-s390.c" +.text + .align 4 +.globl vacall_receiver + .type vacall_receiver,@function +vacall_receiver: + stm %r6,%r15,24(%r15) + bras %r13,.LTN0_0 +.LT0_0: +.LC0: + .long vacall_function +.LC1: + .long 0 +.LC2: + .long 255 +.LC3: + .long 65535 +.LC4: + .long 1 +.LTN0_0: + l %r1,.LC0-.LT0_0(%r13) + lr %r14,%r15 + ahi %r15,-184 + lr %r11,%r15 + l %r12,0(%r1) + st %r14,0(%r15) + la %r1,280(%r11) + st %r2,132(%r11) + la %r2,96(%r11) + st %r4,140(%r11) + st %r5,144(%r11) + st %r6,148(%r11) + st %r3,136(%r11) + std %f2,176(%r11) + std %f0,168(%r11) + ste %f2,160(%r11) + ste %f0,156(%r11) + mvc 96(4,%r11),.LC1-.LT0_0(%r13) + st %r1,112(%r11) + mvc 116(4,%r11),.LC1-.LT0_0(%r13) + mvc 120(4,%r11),.LC1-.LT0_0(%r13) + mvc 128(4,%r11),.LC1-.LT0_0(%r13) + mvc 152(4,%r11),.LC1-.LT0_0(%r13) + basr %r14,%r12 + icm %r4,15,120(%r11) + je .L1 + chi %r4,1 + je .L43 + chi %r4,2 + je .L44 + chi %r4,3 + je .L43 + chi %r4,4 + je .L45 + chi %r4,5 + je .L46 + chi %r4,6 + je .L40 + chi %r4,7 + je .L40 + chi %r4,8 + je .L40 + chi %r4,9 + je .L40 + lr %r1,%r4 + ahi %r1,-10 + cl %r1,.LC4-.LT0_0(%r13) + jh .L22 + l %r2,104(%r11) + l %r3,108(%r11) +.L1: + l %r4,240(%r11) + lm %r6,%r15,208(%r11) + br %r4 +.L22: + chi %r4,12 + je .L47 + chi %r4,13 + je .L48 + chi %r4,14 + je .L40 + chi %r4,15 + jne .L1 + tm 98(%r11),4 + je .L1 + l %r1,124(%r11) + chi %r1,1 + je .L49 + chi %r1,2 + je .L50 + chi %r1,4 + je .L51 + chi %r1,8 + jne .L1 + l %r1,116(%r11) + l %r3,4(%r1) +.L39: + l %r2,0(%r1) + j .L1 +.L51: + l %r1,116(%r11) + j .L39 +.L50: + l %r1,116(%r11) + lh %r4,0(%r1) + lr %r2,%r4 +.L41: + n %r2,.LC3-.LT0_0(%r13) + j .L1 +.L49: + l %r1,116(%r11) + ic %r4,0(%r1) + lr %r2,%r4 +.L42: + n %r2,.LC2-.LT0_0(%r13) + j .L1 +.L40: + l %r2,104(%r11) + j .L1 +.L48: + ld %f0,104(%r11) + j .L1 +.L47: + le %f0,104(%r11) + j .L1 +.L46: + lh %r1,104(%r11) + lr %r2,%r1 + j .L41 +.L45: + lh %r2,104(%r11) + j .L1 +.L43: + ic %r1,104(%r11) + lr %r2,%r1 + j .L42 +.L44: + icm %r1,8,104(%r11) + lr %r2,%r1 + sra %r2,24 + j .L1 +.Lfe1: + .size vacall_receiver,.Lfe1-vacall_receiver +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/vacall/vacall-s390.c b/vacall/vacall-s390.c new file mode 100644 index 0000000..261d190 --- /dev/null +++ b/vacall/vacall-s390.c @@ -0,0 +1,142 @@ +/* vacall function for S/390 32-bit CPU */ + +/* + * Copyright 1995-2017 Bruno Haible + * Copyright 2000 Adam Fedor + * Copyright 2001 Gerhard Tonn + * + * 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, see . + */ + +#include "vacall-internal.h" + +#ifdef REENTRANT +#define vacall_receiver callback_receiver +register struct { void (*vacall_function) (void*,va_alist); void* arg; } + * env __asm__("r0"); +#endif +register float farg1 __asm__("f0"); +register float farg2 __asm__("f2"); +register double darg1 __asm__("f0"); +register double darg2 __asm__("f2"); +register __vaword iret __asm__("%r2"); +register __vaword iret2 __asm__("%r3"); +register float fret __asm__("%f0"); +register double dret __asm__("%f0"); + +#ifdef REENTRANT +static +#endif +void /* the return type is variable, not void! */ +vacall_receiver (__vaword word1, __vaword word2, __vaword word3, __vaword word4, + __vaword word5, + __vaword firstword) +{ + __va_alist list; + /* Move the arguments passed in registers to temp storage, since + moving them to the stack would mess up the stack */ + list.iarg[0] = word1; + list.iarg[1] = word2; + list.iarg[2] = word3; + list.iarg[3] = word4; + list.iarg[4] = word5; + + list.darg[1] = darg2; + list.darg[0] = darg1; + + list.farg[1] = farg2; + list.farg[0] = farg1; + + /* Prepare the va_alist. */ + list.flags = 0; + list.aptr = (long)&firstword; + list.raddr = (void*)0; + list.rtype = __VAvoid; + list.ianum = 0; + list.fanum = 0; + /* Call vacall_function. The macros do all the rest. */ +#ifndef REENTRANT + (*vacall_function) (&list); +#else /* REENTRANT */ + (*env->vacall_function) (env->arg,&list); +#endif + /* Put return value into proper register. */ + if (list.rtype == __VAvoid) { + } else + if (list.rtype == __VAchar) { + iret = list.tmp._char; + } else + if (list.rtype == __VAschar) { + iret = list.tmp._schar; + } else + if (list.rtype == __VAuchar) { + iret = list.tmp._uchar; + } else + if (list.rtype == __VAshort) { + iret = list.tmp._short; + } else + if (list.rtype == __VAushort) { + iret = list.tmp._ushort; + } else + if (list.rtype == __VAint) { + iret = list.tmp._int; + } else + if (list.rtype == __VAuint) { + iret = list.tmp._uint; + } else + if (list.rtype == __VAlong) { + iret = list.tmp._long; + } else + if (list.rtype == __VAulong) { + iret = list.tmp._ulong; + } else + if (list.rtype == __VAlonglong || list.rtype == __VAulonglong) { + iret = ((__vaword *) &list.tmp._longlong)[0]; + iret2 = ((__vaword *) &list.tmp._longlong)[1]; + } else + if (list.rtype == __VAfloat) { + fret = list.tmp._float; + } else + if (list.rtype == __VAdouble) { + dret = list.tmp._double; + } else + if (list.rtype == __VAvoidp) { + iret = (long)list.tmp._ptr; + } else + if (list.rtype == __VAstruct) { + if (list.flags & __VA_REGISTER_STRUCT_RETURN) { + if (list.rsize == sizeof(char)) { + iret = *(unsigned char *) list.raddr; + } else + if (list.rsize == sizeof(short)) { + iret = *(unsigned short *) list.raddr; + } else + if (list.rsize == sizeof(int)) { + iret = *(unsigned int *) list.raddr; + } else + if (list.rsize == 2*sizeof(__vaword)) { + iret = ((__vaword *) list.raddr)[0]; + iret2 = ((__vaword *) list.raddr)[1]; + } + } + } +} + +#ifdef REENTRANT +__vacall_r_t +callback_get_receiver (void) +{ + return (__vacall_r_t)(void*)&callback_receiver; +} +#endif diff --git a/vacall/vacall-s390x-linux.s b/vacall/vacall-s390x-linux.s new file mode 100644 index 0000000..a94a1a8 --- /dev/null +++ b/vacall/vacall-s390x-linux.s @@ -0,0 +1,127 @@ + .file "vacall-s390x.c" +.text + .align 8 +.globl vacall_receiver + .type vacall_receiver, @function +vacall_receiver: +.LFB0: + .cfi_startproc + stmg %r11,%r15,88(%r15) + .cfi_offset 11, -72 + .cfi_offset 12, -64 + .cfi_offset 13, -56 + .cfi_offset 14, -48 + .cfi_offset 15, -40 + aghi %r15,-320 + .cfi_def_cfa_offset 480 + lgr %r11,%r15 + .cfi_def_cfa_register 11 + larl %r1,vacall_function + lhi %r0,0 + lg %r1,0(%r1) + st %r0,160(%r11) + la %r0,480(%r11) + stg %r0,184(%r11) + lghi %r0,0 + stg %r2,224(%r11) + stg %r3,232(%r11) + stg %r4,240(%r11) + stg %r5,248(%r11) + stg %r6,256(%r11) + ste %f0,268(%r11) + ste %f2,272(%r11) + ste %f4,276(%r11) + ste %f6,280(%r11) + std %f0,288(%r11) + std %f2,296(%r11) + std %f4,304(%r11) + std %f6,312(%r11) + stg %r0,192(%r11) + st %r0,200(%r11) + st %r0,216(%r11) + st %r0,264(%r11) + la %r2,160(%r11) + basr %r14,%r1 + icm %r1,15,200(%r11) + je .L1 + chi %r1,1 + je .L18 + chi %r1,2 + je .L21 + chi %r1,3 + je .L18 + chi %r1,4 + je .L22 + chi %r1,5 + je .L23 + chi %r1,6 + je .L24 + chi %r1,7 + je .L25 + lr %r0,%r1 + nill %r0,65533 + chi %r0,8 + je .L19 + chi %r0,9 + je .L19 + chi %r1,12 + je .L26 + chi %r1,13 + je .L27 + chi %r1,14 + je .L19 +.L1: + lg %r4,432(%r11) + lmg %r11,%r15,408(%r11) + .cfi_remember_state + .cfi_restore 15 + .cfi_restore 14 + .cfi_restore 13 + .cfi_restore 12 + .cfi_restore 11 + .cfi_def_cfa 15, 160 + br %r4 +.L18: + .cfi_restore_state + lg %r4,432(%r11) + llgc %r2,168(%r11) + lmg %r11,%r15,408(%r11) + .cfi_remember_state + .cfi_restore 11 + .cfi_restore 12 + .cfi_restore 13 + .cfi_restore 14 + .cfi_restore 15 + .cfi_def_cfa 15, 160 + br %r4 +.L21: + .cfi_restore_state + icmh %r2,8,168(%r11) + srag %r2,%r2,56 + j .L1 +.L19: + lg %r2,168(%r11) + j .L1 +.L22: + lgh %r2,168(%r11) + j .L1 +.L23: + llgh %r2,168(%r11) + j .L1 +.L24: + lgf %r2,168(%r11) + j .L1 +.L26: + le %f0,168(%r11) + j .L1 +.L25: + llgf %r2,168(%r11) + j .L1 +.L27: + ld %f0,168(%r11) + j .L1 + .cfi_endproc +.LFE0: + .size vacall_receiver, .-vacall_receiver + .ident "GCC: (GNU) 5.4.0" + .section .note.GNU-stack,"",@progbits diff --git a/vacall/vacall-s390x-macro.S b/vacall/vacall-s390x-macro.S new file mode 100644 index 0000000..bd0c96c --- /dev/null +++ b/vacall/vacall-s390x-macro.S @@ -0,0 +1,128 @@ + .file "vacall-s390x.c" +.text + .align 8 +.globl vacall_receiver + .type vacall_receiver, @function +vacall_receiver: +.LFB0: + .cfi_startproc + stmg %r11,%r15,88(%r15) + .cfi_offset 11, -72 + .cfi_offset 12, -64 + .cfi_offset 13, -56 + .cfi_offset 14, -48 + .cfi_offset 15, -40 + aghi %r15,-320 + .cfi_def_cfa_offset 480 + lgr %r11,%r15 + .cfi_def_cfa_register 11 + larl %r1,vacall_function + lhi %r0,0 + lg %r1,0(%r1) + st %r0,160(%r11) + la %r0,480(%r11) + stg %r0,184(%r11) + lghi %r0,0 + stg %r2,224(%r11) + stg %r3,232(%r11) + stg %r4,240(%r11) + stg %r5,248(%r11) + stg %r6,256(%r11) + ste %f0,268(%r11) + ste %f2,272(%r11) + ste %f4,276(%r11) + ste %f6,280(%r11) + std %f0,288(%r11) + std %f2,296(%r11) + std %f4,304(%r11) + std %f6,312(%r11) + stg %r0,192(%r11) + st %r0,200(%r11) + st %r0,216(%r11) + st %r0,264(%r11) + la %r2,160(%r11) + basr %r14,%r1 + icm %r1,15,200(%r11) + je .L1 + chi %r1,1 + je .L18 + chi %r1,2 + je .L21 + chi %r1,3 + je .L18 + chi %r1,4 + je .L22 + chi %r1,5 + je .L23 + chi %r1,6 + je .L24 + chi %r1,7 + je .L25 + lr %r0,%r1 + nill %r0,65533 + chi %r0,8 + je .L19 + chi %r0,9 + je .L19 + chi %r1,12 + je .L26 + chi %r1,13 + je .L27 + chi %r1,14 + je .L19 +.L1: + lg %r4,432(%r11) + lmg %r11,%r15,408(%r11) + .cfi_remember_state + .cfi_restore 15 + .cfi_restore 14 + .cfi_restore 13 + .cfi_restore 12 + .cfi_restore 11 + .cfi_def_cfa 15, 160 + br %r4 +.L18: + .cfi_restore_state + lg %r4,432(%r11) + llgc %r2,168(%r11) + lmg %r11,%r15,408(%r11) + .cfi_remember_state + .cfi_restore 11 + .cfi_restore 12 + .cfi_restore 13 + .cfi_restore 14 + .cfi_restore 15 + .cfi_def_cfa 15, 160 + br %r4 +.L21: + .cfi_restore_state + icmh %r2,8,168(%r11) + srag %r2,%r2,56 + j .L1 +.L19: + lg %r2,168(%r11) + j .L1 +.L22: + lgh %r2,168(%r11) + j .L1 +.L23: + llgh %r2,168(%r11) + j .L1 +.L24: + lgf %r2,168(%r11) + j .L1 +.L26: + le %f0,168(%r11) + j .L1 +.L25: + llgf %r2,168(%r11) + j .L1 +.L27: + ld %f0,168(%r11) + j .L1 + .cfi_endproc +.LFE0: + .size vacall_receiver, .-vacall_receiver +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/vacall/vacall-s390x.c b/vacall/vacall-s390x.c new file mode 100644 index 0000000..c3cb71f --- /dev/null +++ b/vacall/vacall-s390x.c @@ -0,0 +1,134 @@ +/* vacall function for s390x (S/390 64-bit) CPU */ + +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +#include "vacall-internal.h" + +#ifdef REENTRANT +#define vacall_receiver callback_receiver +register struct { void (*vacall_function) (void*,va_alist); void* arg; } + * env __asm__("r0"); +#endif + +register __vaword iarg1 __asm__("r2"); +register __vaword iarg2 __asm__("r3"); +register __vaword iarg3 __asm__("r4"); +register __vaword iarg4 __asm__("r5"); +register __vaword iarg5 __asm__("r6"); + +register float farg1 __asm__("f0"); +register float farg2 __asm__("f2"); +register float farg3 __asm__("f4"); +register float farg4 __asm__("f6"); + +register double darg1 __asm__("f0"); +register double darg2 __asm__("f2"); +register double darg3 __asm__("f4"); +register double darg4 __asm__("f6"); + +register __vaword iret __asm__("r2"); +register float fret __asm__("f0"); +register double dret __asm__("f0"); + +#ifdef REENTRANT +static +#endif +void /* the return type is variable, not void! */ +vacall_receiver (__vaword word1, __vaword word2, __vaword word3, __vaword word4, + __vaword word5, + __vaword firstword) +{ + __va_alist list; + /* Move the arguments passed in registers to temp storage. */ + list.iarg[0] = iarg1; + list.iarg[1] = iarg2; + list.iarg[2] = iarg3; + list.iarg[3] = iarg4; + list.iarg[4] = iarg5; + list.farg[0] = farg1; + list.farg[1] = farg2; + list.farg[2] = farg3; + list.farg[3] = farg4; + list.darg[0] = darg1; + list.darg[1] = darg2; + list.darg[2] = darg3; + list.darg[3] = darg4; + /* Prepare the va_alist. */ + list.flags = 0; + list.aptr = (long)&firstword; + list.raddr = (void*)0; + list.rtype = __VAvoid; + list.ianum = 0; + list.fanum = 0; + /* Call vacall_function. The macros do all the rest. */ +#ifndef REENTRANT + (*vacall_function) (&list); +#else /* REENTRANT */ + (*env->vacall_function) (env->arg,&list); +#endif + /* Put return value into proper register. */ + if (list.rtype == __VAvoid) { + } else + if (list.rtype == __VAchar) { + iret = list.tmp._char; + } else + if (list.rtype == __VAschar) { + iret = list.tmp._schar; + } else + if (list.rtype == __VAuchar) { + iret = list.tmp._uchar; + } else + if (list.rtype == __VAshort) { + iret = list.tmp._short; + } else + if (list.rtype == __VAushort) { + iret = list.tmp._ushort; + } else + if (list.rtype == __VAint) { + iret = list.tmp._int; + } else + if (list.rtype == __VAuint) { + iret = list.tmp._uint; + } else + if (list.rtype == __VAlong || list.rtype == __VAlonglong) { + iret = list.tmp._long; + } else + if (list.rtype == __VAulong || list.rtype == __VAulonglong) { + iret = list.tmp._ulong; + } else + if (list.rtype == __VAfloat) { + fret = list.tmp._float; + } else + if (list.rtype == __VAdouble) { + dret = list.tmp._double; + } else + if (list.rtype == __VAvoidp) { + iret = (long)list.tmp._ptr; + } else + if (list.rtype == __VAstruct) { + /* normal struct return convention */ + } +} + +#ifdef REENTRANT +__vacall_r_t +callback_get_receiver (void) +{ + return (__vacall_r_t)(void*)&callback_receiver; +} +#endif diff --git a/vacall/vacall-sparc-linux-pic.s b/vacall/vacall-sparc-linux-pic.s new file mode 100644 index 0000000..48f6d61 --- /dev/null +++ b/vacall/vacall-sparc-linux-pic.s @@ -0,0 +1,138 @@ + .file "vacall-sparc.c" + .section ".text" + .align 4 +.LLGETPC0: + retl + add %o7, %l7, %l7 + .align 4 + .global vacall_receiver + .type vacall_receiver,#function + .proc 020 +vacall_receiver: + !#PROLOGUE# 0 + save %sp, -144, %sp + sethi %hi(vacall_function), %o0 + sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %l7 + call .LLGETPC0 + add %l7, %lo(_GLOBAL_OFFSET_TABLE_+4), %l7 + or %o0, %lo(vacall_function), %o0 + ld [%l7+%o0], %o1 + st %i2, [%fp+76] + ld [%o1], %o2 + add %fp, 68, %o0 + ld [%fp+64], %o1 + st %o0, [%fp-32] + st %o1, [%fp-16] + st %i3, [%fp+80] + st %i4, [%fp+84] + st %i5, [%fp+88] + st %i0, [%fp+68] + st %i1, [%fp+72] + st %g0, [%fp-48] + st %g0, [%fp-28] + st %g0, [%fp-24] + call %o2, 0 + add %fp, -48, %o0 + ld [%fp-24], %o1 + cmp %o1, 0 + be .LL1 + cmp %o1, 1 + be .LL44 + cmp %o1, 2 + be .LL44 + cmp %o1, 3 + be .LL45 + cmp %o1, 4 + be .LL46 + cmp %o1, 5 + be .LL47 + cmp %o1, 6 + be .LL43 + cmp %o1, 7 + be .LL43 + cmp %o1, 8 + be .LL43 + cmp %o1, 9 + be .LL43 + add %o1, -10, %o0 + cmp %o0, 1 + bgu .LL22 + cmp %o1, 12 + ld [%fp-40], %i0 + b .LL1 + ld [%fp-36], %i1 +.LL22: + be .LL48 + cmp %o1, 13 + be .LL49 + cmp %o1, 14 + be .LL43 + cmp %o1, 15 + bne .LL1 + ld [%fp-48], %o0 + andcc %o0, 16, %g0 + be .LL33 + andcc %o0, 2, %g0 + ld [%fp-20], %o0 + ld [%i7+8], %o1 + and %o0, 4095, %o0 + cmp %o0, %o1 + bne .LL1 + ld [%fp-28], %i0 + b .LL1 + add %i7, 4, %i7 +.LL33: + be,a .LL1 + add %i7, 4, %i7 + ld [%fp-20], %o0 + cmp %o0, 1 + be .LL50 + cmp %o0, 2 + be .LL51 + cmp %o0, 4 + bne,a .LL1 + add %i7, 4, %i7 + ld [%fp-28], %o0 + b .LL1 + ld [%o0], %i0 +.LL51: + ld [%fp-28], %o0 + b .LL1 + lduh [%o0], %i0 +.LL50: + ld [%fp-28], %o0 + b .LL1 + ldub [%o0], %i0 +.LL43: + b .LL1 + ld [%fp-40], %i0 +.LL49: + b .LL1 + ldd [%fp-40], %f0 +.LL48: + ld [%fp-48], %o0 + andcc %o0, 32, %g0 + be,a .LL1 + ld [%fp-40], %f0 + ld [%fp-40], %f2 + b .LL1 + fstod %f2, %f0 +.LL47: + b .LL1 + lduh [%fp-40], %i0 +.LL46: + b .LL1 + ldsh [%fp-40], %i0 +.LL45: + b .LL1 + ldub [%fp-40], %i0 +.LL44: + ldsb [%fp-40], %i0 +.LL38: +.LL1: + nop + ret + restore +.LLfe1: + .size vacall_receiver,.LLfe1-vacall_receiver + .ident "GCC: (GNU) 3.1" diff --git a/vacall/vacall-sparc-linux.s b/vacall/vacall-sparc-linux.s new file mode 100644 index 0000000..770fd06 --- /dev/null +++ b/vacall/vacall-sparc-linux.s @@ -0,0 +1,130 @@ + .file "vacall-sparc.c" + .section ".text" + .align 4 + .global vacall_receiver + .type vacall_receiver,#function + .proc 020 +vacall_receiver: + !#PROLOGUE# 0 + save %sp, -144, %sp + !#PROLOGUE# 1 + sethi %hi(vacall_function), %o0 + ld [%o0+%lo(vacall_function)], %o2 + st %i2, [%fp+76] + add %fp, 68, %o0 + ld [%fp+64], %o1 + st %o0, [%fp-32] + st %o1, [%fp-16] + st %i3, [%fp+80] + st %i4, [%fp+84] + st %i5, [%fp+88] + st %i0, [%fp+68] + st %i1, [%fp+72] + st %g0, [%fp-48] + st %g0, [%fp-28] + st %g0, [%fp-24] + call %o2, 0 + add %fp, -48, %o0 + ld [%fp-24], %o1 + cmp %o1, 0 + be .LL1 + cmp %o1, 1 + be .LL44 + cmp %o1, 2 + be .LL44 + cmp %o1, 3 + be .LL45 + cmp %o1, 4 + be .LL46 + cmp %o1, 5 + be .LL47 + cmp %o1, 6 + be .LL43 + cmp %o1, 7 + be .LL43 + cmp %o1, 8 + be .LL43 + cmp %o1, 9 + be .LL43 + add %o1, -10, %o0 + cmp %o0, 1 + bgu .LL22 + cmp %o1, 12 + ld [%fp-40], %i0 + b .LL1 + ld [%fp-36], %i1 +.LL22: + be .LL48 + cmp %o1, 13 + be .LL49 + cmp %o1, 14 + be .LL43 + cmp %o1, 15 + bne .LL1 + ld [%fp-48], %o0 + andcc %o0, 16, %g0 + be .LL33 + andcc %o0, 2, %g0 + ld [%fp-20], %o0 + ld [%i7+8], %o1 + and %o0, 4095, %o0 + cmp %o0, %o1 + bne .LL1 + ld [%fp-28], %i0 + b .LL1 + add %i7, 4, %i7 +.LL33: + be,a .LL1 + add %i7, 4, %i7 + ld [%fp-20], %o0 + cmp %o0, 1 + be .LL50 + cmp %o0, 2 + be .LL51 + cmp %o0, 4 + bne,a .LL1 + add %i7, 4, %i7 + ld [%fp-28], %o0 + b .LL1 + ld [%o0], %i0 +.LL51: + ld [%fp-28], %o0 + b .LL1 + lduh [%o0], %i0 +.LL50: + ld [%fp-28], %o0 + b .LL1 + ldub [%o0], %i0 +.LL43: + b .LL1 + ld [%fp-40], %i0 +.LL49: + b .LL1 + ldd [%fp-40], %f0 +.LL48: + ld [%fp-48], %o0 + andcc %o0, 32, %g0 + be,a .LL1 + ld [%fp-40], %f0 + ld [%fp-40], %f2 + b .LL1 + fstod %f2, %f0 +.LL47: + b .LL1 + lduh [%fp-40], %i0 +.LL46: + b .LL1 + ldsh [%fp-40], %i0 +.LL45: + b .LL1 + ldub [%fp-40], %i0 +.LL44: + ldsb [%fp-40], %i0 +.LL38: +.LL1: + nop + ret + restore +.LLfe1: + .size vacall_receiver,.LLfe1-vacall_receiver + .ident "GCC: (GNU) 3.1" diff --git a/vacall/vacall-sparc-macro.S b/vacall/vacall-sparc-macro.S new file mode 100644 index 0000000..d776589 --- /dev/null +++ b/vacall/vacall-sparc-macro.S @@ -0,0 +1,271 @@ +#include "asm-sparc.h" +#ifdef __PIC__ + .section ".text" + .align 4 +L(LGETPC0): + retl + add %o7, %l7, %l7 + .align 4 + .global C(vacall_receiver) + DECLARE_FUNCTION(vacall_receiver) + .proc 020 +FUNBEGIN(vacall_receiver) + !$PROLOGUE$ 0 + save %sp, -144, %sp + sethi %hi(C(vacall_function)), %o0 + sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %l7 + call L(LGETPC0) + add %l7, %lo(_GLOBAL_OFFSET_TABLE_+4), %l7 + or %o0, %lo(C(vacall_function)), %o0 + ld [%l7+%o0], %o1 + st %i2, [%fp+76] + ld [%o1], %o2 + add %fp, 68, %o0 + ld [%fp+64], %o1 + st %o0, [%fp-32] + st %o1, [%fp-16] + st %i3, [%fp+80] + st %i4, [%fp+84] + st %i5, [%fp+88] + st %i0, [%fp+68] + st %i1, [%fp+72] + st %g0, [%fp-48] + st %g0, [%fp-28] + st %g0, [%fp-24] + call %o2, 0 + add %fp, -48, %o0 + ld [%fp-24], %o1 + cmp %o1, 0 + be L(L1) + cmp %o1, 1 + be L(L44) + cmp %o1, 2 + be L(L44) + cmp %o1, 3 + be L(L45) + cmp %o1, 4 + be L(L46) + cmp %o1, 5 + be L(L47) + cmp %o1, 6 + be L(L43) + cmp %o1, 7 + be L(L43) + cmp %o1, 8 + be L(L43) + cmp %o1, 9 + be L(L43) + add %o1, -10, %o0 + cmp %o0, 1 + bgu L(L22) + cmp %o1, 12 + ld [%fp-40], %i0 + b L(L1) + ld [%fp-36], %i1 +L(L22): + be L(L48) + cmp %o1, 13 + be L(L49) + cmp %o1, 14 + be L(L43) + cmp %o1, 15 + bne L(L1) + ld [%fp-48], %o0 + andcc %o0, 16, %g0 + be L(L33) + andcc %o0, 2, %g0 + ld [%fp-20], %o0 + ld [%i7+8], %o1 + and %o0, 4095, %o0 + cmp %o0, %o1 + bne L(L1) + ld [%fp-28], %i0 + b L(L1) + add %i7, 4, %i7 +L(L33): + be,a L(L1) + add %i7, 4, %i7 + ld [%fp-20], %o0 + cmp %o0, 1 + be L(L50) + cmp %o0, 2 + be L(L51) + cmp %o0, 4 + bne,a L(L1) + add %i7, 4, %i7 + ld [%fp-28], %o0 + b L(L1) + ld [%o0], %i0 +L(L51): + ld [%fp-28], %o0 + b L(L1) + lduh [%o0], %i0 +L(L50): + ld [%fp-28], %o0 + b L(L1) + ldub [%o0], %i0 +L(L43): + b L(L1) + ld [%fp-40], %i0 +L(L49): + b L(L1) + ldd [%fp-40], %f0 +L(L48): + ld [%fp-48], %o0 + andcc %o0, 32, %g0 + be,a L(L1) + ld [%fp-40], %f0 + ld [%fp-40], %f2 + b L(L1) + fstod %f2, %f0 +L(L47): + b L(L1) + lduh [%fp-40], %i0 +L(L46): + b L(L1) + ldsh [%fp-40], %i0 +L(L45): + b L(L1) + ldub [%fp-40], %i0 +L(L44): + ldsb [%fp-40], %i0 +L(L38): +L(L1): + nop + ret + restore +L(Lfe1): + FUNEND(vacall_receiver) +#else + .section ".text" + .align 4 + .global C(vacall_receiver) + DECLARE_FUNCTION(vacall_receiver) + .proc 020 +FUNBEGIN(vacall_receiver) + !$PROLOGUE$ 0 + save %sp, -144, %sp + !$PROLOGUE$ 1 + sethi %hi(C(vacall_function)), %o0 + ld [%o0+%lo(C(vacall_function))], %o2 + st %i2, [%fp+76] + add %fp, 68, %o0 + ld [%fp+64], %o1 + st %o0, [%fp-32] + st %o1, [%fp-16] + st %i3, [%fp+80] + st %i4, [%fp+84] + st %i5, [%fp+88] + st %i0, [%fp+68] + st %i1, [%fp+72] + st %g0, [%fp-48] + st %g0, [%fp-28] + st %g0, [%fp-24] + call %o2, 0 + add %fp, -48, %o0 + ld [%fp-24], %o1 + cmp %o1, 0 + be L(L1) + cmp %o1, 1 + be L(L44) + cmp %o1, 2 + be L(L44) + cmp %o1, 3 + be L(L45) + cmp %o1, 4 + be L(L46) + cmp %o1, 5 + be L(L47) + cmp %o1, 6 + be L(L43) + cmp %o1, 7 + be L(L43) + cmp %o1, 8 + be L(L43) + cmp %o1, 9 + be L(L43) + add %o1, -10, %o0 + cmp %o0, 1 + bgu L(L22) + cmp %o1, 12 + ld [%fp-40], %i0 + b L(L1) + ld [%fp-36], %i1 +L(L22): + be L(L48) + cmp %o1, 13 + be L(L49) + cmp %o1, 14 + be L(L43) + cmp %o1, 15 + bne L(L1) + ld [%fp-48], %o0 + andcc %o0, 16, %g0 + be L(L33) + andcc %o0, 2, %g0 + ld [%fp-20], %o0 + ld [%i7+8], %o1 + and %o0, 4095, %o0 + cmp %o0, %o1 + bne L(L1) + ld [%fp-28], %i0 + b L(L1) + add %i7, 4, %i7 +L(L33): + be,a L(L1) + add %i7, 4, %i7 + ld [%fp-20], %o0 + cmp %o0, 1 + be L(L50) + cmp %o0, 2 + be L(L51) + cmp %o0, 4 + bne,a L(L1) + add %i7, 4, %i7 + ld [%fp-28], %o0 + b L(L1) + ld [%o0], %i0 +L(L51): + ld [%fp-28], %o0 + b L(L1) + lduh [%o0], %i0 +L(L50): + ld [%fp-28], %o0 + b L(L1) + ldub [%o0], %i0 +L(L43): + b L(L1) + ld [%fp-40], %i0 +L(L49): + b L(L1) + ldd [%fp-40], %f0 +L(L48): + ld [%fp-48], %o0 + andcc %o0, 32, %g0 + be,a L(L1) + ld [%fp-40], %f0 + ld [%fp-40], %f2 + b L(L1) + fstod %f2, %f0 +L(L47): + b L(L1) + lduh [%fp-40], %i0 +L(L46): + b L(L1) + ldsh [%fp-40], %i0 +L(L45): + b L(L1) + ldub [%fp-40], %i0 +L(L44): + ldsb [%fp-40], %i0 +L(L38): +L(L1): + nop + ret + restore +L(Lfe1): + FUNEND(vacall_receiver) +#endif +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/vacall/vacall-sparc.c b/vacall/vacall-sparc.c new file mode 100644 index 0000000..787b3f2 --- /dev/null +++ b/vacall/vacall-sparc.c @@ -0,0 +1,141 @@ +/* vacall function for sparc CPU */ + +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +#include "vacall-internal.h" + +#ifdef REENTRANT +#define vacall_receiver callback_receiver +register struct { void (*vacall_function) (void*,va_alist); void* arg; } + * env __asm__("%g2"); +#endif +register __vaword* fp __asm__("%fp"); /* our %fp, caller's %sp */ +register __vaword* ret __asm__("%i7"); /* %i7+8 = return address */ +register int iret __asm__("%i0"); +register int iret2 __asm__("%i1"); +register float fret __asm__("%f0"); /* %f0 */ +register double dret __asm__("%f0"); /* %f0,%f1 */ + +void /* the return type is variable, not void! */ +vacall_receiver (__vaword word1, __vaword word2, __vaword word3, __vaword word4, + __vaword word5, __vaword word6, + __vaword firstword) +{ + __va_alist list; + /* gcc-2.6.3 source says: When a parameter is passed in a register, + * stack space is still allocated for it. + */ + /* Move the arguments passed in registers to their stack locations. */ + (&firstword)[-6] = word1; + (&firstword)[-5] = word2; + (&firstword)[-4] = word3; + (&firstword)[-3] = word4; + (&firstword)[-2] = word5; + (&firstword)[-1] = word6; + /* Prepare the va_alist. */ + list.flags = 0; + list.aptr = (long)(&firstword - 6); + list.raddr = (void*)0; + list.rtype = __VAvoid; + list.structraddr = (void*)((&firstword)[-7]); /* = (void*) fp[16] */ + /* Call vacall_function. The macros do all the rest. */ +#ifndef REENTRANT + (*vacall_function) (&list); +#else /* REENTRANT */ + (*env->vacall_function) (env->arg,&list); +#endif + /* Put return value into proper register. */ + if (list.rtype == __VAvoid) { + } else + if (list.rtype == __VAchar) { + iret = list.tmp._char; + } else + if (list.rtype == __VAschar) { + iret = list.tmp._schar; + } else + if (list.rtype == __VAuchar) { + iret = list.tmp._uchar; + } else + if (list.rtype == __VAshort) { + iret = list.tmp._short; + } else + if (list.rtype == __VAushort) { + iret = list.tmp._ushort; + } else + if (list.rtype == __VAint) { + iret = list.tmp._int; + } else + if (list.rtype == __VAuint) { + iret = list.tmp._uint; + } else + if (list.rtype == __VAlong) { + iret = list.tmp._long; + } else + if (list.rtype == __VAulong) { + iret = list.tmp._ulong; + } else + if (list.rtype == __VAlonglong || list.rtype == __VAulonglong) { + iret = ((__vaword *) &list.tmp._longlong)[0]; + iret2 = ((__vaword *) &list.tmp._longlong)[1]; + } else + if (list.rtype == __VAfloat) { + if (list.flags & __VA_SUNCC_FLOAT_RETURN) { + dret = (double)list.tmp._float; + } else { + fret = list.tmp._float; + } + } else + if (list.rtype == __VAdouble) { + dret = list.tmp._double; + } else + if (list.rtype == __VAvoidp) { + iret = (long)list.tmp._ptr; + } else + if (list.rtype == __VAstruct) { + if (list.flags & __VA_SUNPROCC_STRUCT_RETURN) { + /* Sun cc struct return convention. */ + /* The desired struct return address was passed in fp[16], later on + * list.raddr = list.structraddr = fp[16]. Now the result has + * already been copied there. No need to copy the result once more. + * The caller expects to receive the struct return address in %o0. + */ + iret = (long) list.raddr; + if ((list.rsize & 0xfff) == ret[2]) + ret++; /* skip the "unimp n" instruction at the return address */ + /* else the "unimp n" instruction will cause a core dump */ + } else { + /* normal struct return convention */ + if (list.flags & __VA_SMALL_STRUCT_RETURN) { + if (list.rsize == sizeof(char)) { + iret = *(unsigned char *) list.raddr; + goto done; + } else + if (list.rsize == sizeof(short)) { + iret = *(unsigned short *) list.raddr; + goto done; + } else + if (list.rsize == sizeof(int)) { + iret = *(unsigned int *) list.raddr; + goto done; + } + } + ret++; /* skip the "unimp n" instruction at the return address */ + done: ; + } + } +} diff --git a/vacall/vacall-sparc64-linux-pic.s b/vacall/vacall-sparc64-linux-pic.s new file mode 100644 index 0000000..6d22787 --- /dev/null +++ b/vacall/vacall-sparc64-linux-pic.s @@ -0,0 +1,328 @@ + .file "vacall-sparc64.c" + .section ".text" + .align 4 +.LLADDPC0: + jmp %o7+8 + add %o7, %l7, %l7 + .align 4 + .global vacall_receiver + .type vacall_receiver, #function + .proc 020 +vacall_receiver: + .register %g2, #scratch + .register %g3, #scratch + save %sp, -448, %sp + add %fp, 2175, %g1 + stx %i0, [%fp+2175] + stx %i1, [%fp+2183] + stx %i2, [%fp+2191] + stx %i3, [%fp+2199] + stx %i4, [%fp+2207] + stx %i5, [%fp+2215] + std %f0, [%fp+1903] + std %f2, [%fp+1911] + std %f4, [%fp+1919] + std %f6, [%fp+1927] + std %f8, [%fp+1935] + std %f10, [%fp+1943] + std %f12, [%fp+1951] + std %f14, [%fp+1959] + std %f16, [%fp+1967] + std %f18, [%fp+1975] + std %f20, [%fp+1983] + std %f22, [%fp+1991] + std %f24, [%fp+1999] + std %f26, [%fp+2007] + std %f28, [%fp+2015] + std %f30, [%fp+2023] + st %f1, [%fp+1835] + st %f3, [%fp+1839] + st %f5, [%fp+1843] + st %f7, [%fp+1847] + st %f9, [%fp+1851] + st %f11, [%fp+1855] + st %f13, [%fp+1859] + st %f15, [%fp+1863] + st %f17, [%fp+1867] + st %f19, [%fp+1871] + st %f21, [%fp+1875] + sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %l7 + call .LLADDPC0 + add %l7, %lo(_GLOBAL_OFFSET_TABLE_+4), %l7 + st %f23, [%fp+1879] + stx %g1, [%fp+1799] + sethi %hi(vacall_function), %g1 + or %g1, %lo(vacall_function), %g1 + st %f25, [%fp+1883] + ldx [%l7+%g1], %g2 + st %f27, [%fp+1887] + st %f29, [%fp+1891] + st %f31, [%fp+1895] + st %g0, [%fp+1775] + stx %g0, [%fp+1807] + st %g0, [%fp+1815] + st %g0, [%fp+1831] + ldx [%g2], %g3 + call %g3, 0 + add %fp, 1775, %o0 + lduw [%fp+1815], %g1 + cmp %g1, 0 + be,pn %icc, .LL61 + cmp %g1, 1 + be,pn %icc, .LL50 + cmp %g1, 2 + be,pn %icc, .LL50 + cmp %g1, 3 + be,pn %icc, .LL53 + cmp %g1, 4 + be,pn %icc, .LL54 + cmp %g1, 5 + be,pn %icc, .LL55 + cmp %g1, 6 + be,pn %icc, .LL56 + cmp %g1, 7 + be,pn %icc, .LL57 + cmp %g1, 8 + be,pn %icc, .LL51 + cmp %g1, 9 + be,pn %icc, .LL51 + cmp %g1, 10 + be,pn %icc, .LL51 + cmp %g1, 11 + be,pn %icc, .LL51 + cmp %g1, 12 + be,pn %icc, .LL58 + cmp %g1, 13 + be,pn %icc, .LL59 + cmp %g1, 14 + be,pn %icc, .LL51 + cmp %g1, 15 + bne,pt %icc, .LL61 + lduw [%fp+1775], %g1 + andcc %g1, 1024, %g0 + be,pn %xcc, .LL61 + ldx [%fp+1823], %g5 + add %g5, -1, %g1 + cmp %g1, 31 + bgu,pn %xcc, .LL61 + ldx [%fp+1807], %g1 + cmp %g5, 8 + and %g1, 7, %o2 + and %g1, -8, %l0 + bgu,pt %xcc, .LL35 + add %g5, %o2, %g2 + cmp %g2, 8 + bgu,pt %xcc, .LL37 + sllx %o2, 3, %g4 + sllx %g2, 3, %g2 + ldx [%l0], %g3 + sub %g0, %g2, %g2 + mov -1, %g1 + sllx %g1, %g2, %g1 + and %g1, %g3, %g1 + return %i7+8 + sllx %g1, %g4, %o0 +.LL47: + ldx [%l0], %g1 + sllx %g1, %o4, %g1 + ldx [%l0+8], %g4 + ldx [%l0+16], %g5 + sllx %g4, %o4, %o1 + sllx %g5, %o4, %o0 + ldx [%l0+24], %o5 + sllx %g2, 3, %o3 + sllx %o5, %o4, %o7 + ldx [%l0+32], %o2 + sub %g0, %o3, %o3 + mov 64, %g3 + sub %g3, %o4, %g3 + srax %g4, %g3, %g4 + srax %g5, %g3, %g5 + or %g1, %g4, %i0 + srax %o5, %g3, %o5 + mov -1, %g1 + or %o1, %g5, %i1 + sllx %g1, %o3, %g1 + or %o0, %o5, %i2 + and %g1, %o2, %g1 + srax %g1, %g3, %g1 + or %o7, %g1, %i3 +.LL61: + return %i7+8 + nop +.LL50: + ldsb [%fp+1783], %i0 + return %i7+8 + nop +.LL54: + ldsh [%fp+1783], %i0 + return %i7+8 + nop +.LL53: + ldub [%fp+1783], %i0 + return %i7+8 + nop +.LL51: + ldx [%fp+1783], %i0 + return %i7+8 + nop +.LL55: + lduh [%fp+1783], %i0 + return %i7+8 + nop +.LL56: + ldsw [%fp+1783], %i0 + return %i7+8 + nop +.LL57: + lduw [%fp+1783], %i0 + return %i7+8 + nop +.LL58: + ld [%fp+1783], %f0 + return %i7+8 + nop +.LL59: + ldd [%fp+1783], %f0 + return %i7+8 + nop +.LL35: + cmp %g5, 16 + bgu,pt %xcc, .LL39 + cmp %g5, 24 + cmp %g2, 16 + bgu,pt %xcc, .LL41 + sllx %o2, 3, %o5 + sllx %g2, 3, %g3 + ldx [%l0+8], %g2 + sll %o2, 3, %g5 + sllx %o2, 2, %o5 + sub %g0, %g3, %g3 + ldx [%l0], %g4 + mov -1, %g1 + sllx %g4, %g5, %g4 + sllx %g1, %g3, %g1 + and %g1, %g2, %g1 + mov 32, %g2 + sllx %g1, %g5, %i1 + sub %g2, %o5, %g2 + srax %g1, %g2, %g1 + srax %g1, %g2, %g1 + return %i7+8 + or %g4, %g1, %o0 +.LL37: + sllx %g2, 3, %g3 + ldx [%l0+8], %g5 + sub %g0, %g3, %g3 + sub %g0, %g4, %o5 + ldx [%l0], %g2 + mov -1, %g1 + sllx %g2, %g4, %g2 + sllx %g1, %g3, %g1 + and %g1, %g5, %g1 + srax %g1, %o5, %g1 + return %i7+8 + or %g2, %g1, %o0 +.LL39: + bgu,pt %xcc, .LL43 + cmp %g2, 32 + cmp %g2, 24 + bgu,pt %xcc, .LL45 + sllx %o2, 3, %o4 + sllx %o2, 2, %g1 + sll %o2, 3, %g5 + sllx %g2, 3, %o5 + ldx [%l0+8], %g3 + ldx [%l0+16], %o4 + sllx %g3, %g5, %o3 + sub %g0, %o5, %o5 + mov 32, %g4 + ldx [%l0], %g2 + sub %g4, %g1, %g4 + sllx %g2, %g5, %g2 + srax %g3, %g4, %g3 + mov -1, %g1 + srax %g3, %g4, %g3 + sllx %g1, %o5, %g1 + and %g1, %o4, %g1 + sllx %g1, %g5, %i2 + srax %g1, %g4, %g1 + srax %g1, %g4, %g1 + or %o3, %g1, %i1 + return %i7+8 + or %g2, %g3, %o0 +.LL41: + sllx %g2, 3, %g5 + ldx [%l0+8], %g3 + ldx [%l0+16], %o4 + sllx %g3, %o5, %o3 + sub %g0, %g5, %g5 + mov 64, %g4 + ldx [%l0], %g2 + sub %g4, %o5, %g4 + sllx %g2, %o5, %g2 + srax %g3, %g4, %g3 + mov -1, %g1 + sllx %g1, %g5, %g1 + and %g1, %o4, %g1 + srax %g1, %g4, %g1 + or %o3, %g1, %i1 + return %i7+8 + or %g2, %g3, %o0 +.LL45: + ldx [%l0], %g1 + sllx %g1, %o4, %g1 + ldx [%l0+8], %g3 + ldx [%l0+16], %g4 + sllx %g3, %o4, %o3 + sllx %g4, %o4, %o1 + sllx %g2, 3, %o5 + ldx [%l0+24], %o2 + sub %g0, %o5, %o5 + mov 64, %g5 + sub %g5, %o4, %g5 + srax %g3, %g5, %g3 + srax %g4, %g5, %g4 + or %g1, %g3, %i0 + or %o3, %g4, %i1 + mov -1, %g1 + sllx %g1, %o5, %g1 + and %g1, %o2, %g1 + srax %g1, %g5, %g1 + or %o1, %g1, %i2 + return %i7+8 + nop +.LL43: + bgu,pt %xcc, .LL47 + sllx %o2, 3, %o4 + sll %o2, 3, %o5 + ldx [%l0], %g1 + sllx %g1, %o5, %g1 + sllx %o2, 2, %o4 + sllx %g2, 3, %g5 + ldx [%l0+8], %g3 + ldx [%l0+16], %g4 + sllx %g3, %o5, %o2 + sllx %g4, %o5, %o1 + ldx [%l0+24], %o3 + sub %g0, %g5, %g5 + mov 32, %g2 + sub %g2, %o4, %g2 + srax %g3, %g2, %g3 + srax %g4, %g2, %g4 + srax %g3, %g2, %g3 + srax %g4, %g2, %g4 + or %g1, %g3, %i0 + or %o2, %g4, %i1 + mov -1, %g1 + sllx %g1, %g5, %g1 + and %g1, %o3, %g1 + sllx %g1, %o5, %i3 + srax %g1, %g2, %g1 + srax %g1, %g2, %g1 + or %o1, %g1, %i2 + return %i7+8 + nop + .size vacall_receiver, .-vacall_receiver + .ident "GCC: (GNU) 4.0.2" + .section ".note.GNU-stack" diff --git a/vacall/vacall-sparc64-linux.s b/vacall/vacall-sparc64-linux.s new file mode 100644 index 0000000..92c18cf --- /dev/null +++ b/vacall/vacall-sparc64-linux.s @@ -0,0 +1,323 @@ + .file "vacall-sparc64.c" + .section ".text" + .align 4 + .global vacall_receiver + .type vacall_receiver, #function + .proc 020 +vacall_receiver: + .register %g2, #scratch + .register %g3, #scratch + save %sp, -448, %sp + add %fp, 2175, %g1 + stx %i0, [%fp+2175] + stx %i1, [%fp+2183] + stx %i2, [%fp+2191] + stx %i3, [%fp+2199] + stx %i4, [%fp+2207] + stx %i5, [%fp+2215] + std %f0, [%fp+1903] + std %f2, [%fp+1911] + std %f4, [%fp+1919] + std %f6, [%fp+1927] + std %f8, [%fp+1935] + std %f10, [%fp+1943] + std %f12, [%fp+1951] + std %f14, [%fp+1959] + std %f16, [%fp+1967] + std %f18, [%fp+1975] + std %f20, [%fp+1983] + std %f22, [%fp+1991] + std %f24, [%fp+1999] + std %f26, [%fp+2007] + std %f28, [%fp+2015] + std %f30, [%fp+2023] + st %f1, [%fp+1835] + st %f3, [%fp+1839] + st %f5, [%fp+1843] + st %f7, [%fp+1847] + st %f9, [%fp+1851] + st %f11, [%fp+1855] + st %f13, [%fp+1859] + st %f15, [%fp+1863] + st %f17, [%fp+1867] + st %f19, [%fp+1871] + st %f21, [%fp+1875] + sethi %lm(vacall_function), %g2 + st %f23, [%fp+1879] + stx %g1, [%fp+1799] + st %f25, [%fp+1883] + st %f27, [%fp+1887] + st %f29, [%fp+1891] + st %f31, [%fp+1895] + st %g0, [%fp+1775] + stx %g0, [%fp+1807] + st %g0, [%fp+1815] + st %g0, [%fp+1831] + sethi %hh(vacall_function), %g1 + or %g1, %hm(vacall_function), %g1 + sllx %g1, 32, %g1 + add %g1, %g2, %g1 + ldx [%g1+%lo(vacall_function)], %g3 + call %g3, 0 + add %fp, 1775, %o0 + lduw [%fp+1815], %g1 + cmp %g1, 0 + be,pn %icc, .LL61 + cmp %g1, 1 + be,pn %icc, .LL50 + cmp %g1, 2 + be,pn %icc, .LL50 + cmp %g1, 3 + be,pn %icc, .LL53 + cmp %g1, 4 + be,pn %icc, .LL54 + cmp %g1, 5 + be,pn %icc, .LL55 + cmp %g1, 6 + be,pn %icc, .LL56 + cmp %g1, 7 + be,pn %icc, .LL57 + cmp %g1, 8 + be,pn %icc, .LL51 + cmp %g1, 9 + be,pn %icc, .LL51 + cmp %g1, 10 + be,pn %icc, .LL51 + cmp %g1, 11 + be,pn %icc, .LL51 + cmp %g1, 12 + be,pn %icc, .LL58 + cmp %g1, 13 + be,pn %icc, .LL59 + cmp %g1, 14 + be,pn %icc, .LL51 + cmp %g1, 15 + bne,pt %icc, .LL61 + lduw [%fp+1775], %g1 + andcc %g1, 1024, %g0 + be,pn %xcc, .LL61 + ldx [%fp+1823], %g5 + add %g5, -1, %g1 + cmp %g1, 31 + bgu,pn %xcc, .LL61 + ldx [%fp+1807], %g1 + cmp %g5, 8 + and %g1, 7, %o2 + and %g1, -8, %l0 + bgu,pt %xcc, .LL35 + add %g5, %o2, %g2 + cmp %g2, 8 + bgu,pt %xcc, .LL37 + sllx %o2, 3, %g4 + sllx %g2, 3, %g2 + ldx [%l0], %g3 + sub %g0, %g2, %g2 + mov -1, %g1 + sllx %g1, %g2, %g1 + and %g1, %g3, %g1 + return %i7+8 + sllx %g1, %g4, %o0 +.LL47: + ldx [%l0], %g1 + sllx %g1, %o4, %g1 + ldx [%l0+8], %g4 + ldx [%l0+16], %g5 + sllx %g4, %o4, %o1 + sllx %g5, %o4, %o0 + ldx [%l0+24], %o5 + sllx %g2, 3, %o3 + sllx %o5, %o4, %o7 + ldx [%l0+32], %o2 + sub %g0, %o3, %o3 + mov 64, %g3 + sub %g3, %o4, %g3 + srax %g4, %g3, %g4 + srax %g5, %g3, %g5 + or %g1, %g4, %i0 + srax %o5, %g3, %o5 + mov -1, %g1 + or %o1, %g5, %i1 + sllx %g1, %o3, %g1 + or %o0, %o5, %i2 + and %g1, %o2, %g1 + srax %g1, %g3, %g1 + or %o7, %g1, %i3 +.LL61: + return %i7+8 + nop +.LL50: + ldsb [%fp+1783], %i0 + return %i7+8 + nop +.LL54: + ldsh [%fp+1783], %i0 + return %i7+8 + nop +.LL53: + ldub [%fp+1783], %i0 + return %i7+8 + nop +.LL51: + ldx [%fp+1783], %i0 + return %i7+8 + nop +.LL55: + lduh [%fp+1783], %i0 + return %i7+8 + nop +.LL56: + ldsw [%fp+1783], %i0 + return %i7+8 + nop +.LL57: + lduw [%fp+1783], %i0 + return %i7+8 + nop +.LL58: + ld [%fp+1783], %f0 + return %i7+8 + nop +.LL59: + ldd [%fp+1783], %f0 + return %i7+8 + nop +.LL35: + cmp %g5, 16 + bgu,pt %xcc, .LL39 + cmp %g5, 24 + cmp %g2, 16 + bgu,pt %xcc, .LL41 + sllx %o2, 3, %o5 + sllx %g2, 3, %g3 + ldx [%l0+8], %g2 + sll %o2, 3, %g5 + sllx %o2, 2, %o5 + sub %g0, %g3, %g3 + ldx [%l0], %g4 + mov -1, %g1 + sllx %g4, %g5, %g4 + sllx %g1, %g3, %g1 + and %g1, %g2, %g1 + mov 32, %g2 + sllx %g1, %g5, %i1 + sub %g2, %o5, %g2 + srax %g1, %g2, %g1 + srax %g1, %g2, %g1 + return %i7+8 + or %g4, %g1, %o0 +.LL37: + sllx %g2, 3, %g3 + ldx [%l0+8], %g5 + sub %g0, %g3, %g3 + sub %g0, %g4, %o5 + ldx [%l0], %g2 + mov -1, %g1 + sllx %g2, %g4, %g2 + sllx %g1, %g3, %g1 + and %g1, %g5, %g1 + srax %g1, %o5, %g1 + return %i7+8 + or %g2, %g1, %o0 +.LL39: + bgu,pt %xcc, .LL43 + cmp %g2, 32 + cmp %g2, 24 + bgu,pt %xcc, .LL45 + sllx %o2, 3, %o4 + sllx %o2, 2, %g1 + sll %o2, 3, %g5 + sllx %g2, 3, %o5 + ldx [%l0+8], %g3 + ldx [%l0+16], %o4 + sllx %g3, %g5, %o3 + sub %g0, %o5, %o5 + mov 32, %g4 + ldx [%l0], %g2 + sub %g4, %g1, %g4 + sllx %g2, %g5, %g2 + srax %g3, %g4, %g3 + mov -1, %g1 + srax %g3, %g4, %g3 + sllx %g1, %o5, %g1 + and %g1, %o4, %g1 + sllx %g1, %g5, %i2 + srax %g1, %g4, %g1 + srax %g1, %g4, %g1 + or %o3, %g1, %i1 + return %i7+8 + or %g2, %g3, %o0 +.LL41: + sllx %g2, 3, %g5 + ldx [%l0+8], %g3 + ldx [%l0+16], %o4 + sllx %g3, %o5, %o3 + sub %g0, %g5, %g5 + mov 64, %g4 + ldx [%l0], %g2 + sub %g4, %o5, %g4 + sllx %g2, %o5, %g2 + srax %g3, %g4, %g3 + mov -1, %g1 + sllx %g1, %g5, %g1 + and %g1, %o4, %g1 + srax %g1, %g4, %g1 + or %o3, %g1, %i1 + return %i7+8 + or %g2, %g3, %o0 +.LL45: + ldx [%l0], %g1 + sllx %g1, %o4, %g1 + ldx [%l0+8], %g3 + ldx [%l0+16], %g4 + sllx %g3, %o4, %o3 + sllx %g4, %o4, %o1 + sllx %g2, 3, %o5 + ldx [%l0+24], %o2 + sub %g0, %o5, %o5 + mov 64, %g5 + sub %g5, %o4, %g5 + srax %g3, %g5, %g3 + srax %g4, %g5, %g4 + or %g1, %g3, %i0 + or %o3, %g4, %i1 + mov -1, %g1 + sllx %g1, %o5, %g1 + and %g1, %o2, %g1 + srax %g1, %g5, %g1 + or %o1, %g1, %i2 + return %i7+8 + nop +.LL43: + bgu,pt %xcc, .LL47 + sllx %o2, 3, %o4 + sll %o2, 3, %o5 + ldx [%l0], %g1 + sllx %g1, %o5, %g1 + sllx %o2, 2, %o4 + sllx %g2, 3, %g5 + ldx [%l0+8], %g3 + ldx [%l0+16], %g4 + sllx %g3, %o5, %o2 + sllx %g4, %o5, %o1 + ldx [%l0+24], %o3 + sub %g0, %g5, %g5 + mov 32, %g2 + sub %g2, %o4, %g2 + srax %g3, %g2, %g3 + srax %g4, %g2, %g4 + srax %g3, %g2, %g3 + srax %g4, %g2, %g4 + or %g1, %g3, %i0 + or %o2, %g4, %i1 + mov -1, %g1 + sllx %g1, %g5, %g1 + and %g1, %o3, %g1 + sllx %g1, %o5, %i3 + srax %g1, %g2, %g1 + srax %g1, %g2, %g1 + or %o1, %g1, %i2 + return %i7+8 + nop + .size vacall_receiver, .-vacall_receiver + .ident "GCC: (GNU) 4.0.2" + .section ".note.GNU-stack" diff --git a/vacall/vacall-sparc64-macro.S b/vacall/vacall-sparc64-macro.S new file mode 100644 index 0000000..841398d --- /dev/null +++ b/vacall/vacall-sparc64-macro.S @@ -0,0 +1,652 @@ +#include "asm-sparc.h" +#ifdef __PIC__ + .section ".text" + .align 4 +L(LADDPC0): + jmp %o7+8 + add %o7, %l7, %l7 + .align 4 + .global C(vacall_receiver) + DECLARE_FUNCTION(vacall_receiver) + .proc 020 +FUNBEGIN(vacall_receiver) + .register %g2, $scratch + .register %g3, $scratch + save %sp, -448, %sp + add %fp, 2175, %g1 + stx %i0, [%fp+2175] + stx %i1, [%fp+2183] + stx %i2, [%fp+2191] + stx %i3, [%fp+2199] + stx %i4, [%fp+2207] + stx %i5, [%fp+2215] + std %f0, [%fp+1903] + std %f2, [%fp+1911] + std %f4, [%fp+1919] + std %f6, [%fp+1927] + std %f8, [%fp+1935] + std %f10, [%fp+1943] + std %f12, [%fp+1951] + std %f14, [%fp+1959] + std %f16, [%fp+1967] + std %f18, [%fp+1975] + std %f20, [%fp+1983] + std %f22, [%fp+1991] + std %f24, [%fp+1999] + std %f26, [%fp+2007] + std %f28, [%fp+2015] + std %f30, [%fp+2023] + st %f1, [%fp+1835] + st %f3, [%fp+1839] + st %f5, [%fp+1843] + st %f7, [%fp+1847] + st %f9, [%fp+1851] + st %f11, [%fp+1855] + st %f13, [%fp+1859] + st %f15, [%fp+1863] + st %f17, [%fp+1867] + st %f19, [%fp+1871] + st %f21, [%fp+1875] + sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %l7 + call L(LADDPC0) + add %l7, %lo(_GLOBAL_OFFSET_TABLE_+4), %l7 + st %f23, [%fp+1879] + stx %g1, [%fp+1799] + sethi %hi(C(vacall_function)), %g1 + or %g1, %lo(C(vacall_function)), %g1 + st %f25, [%fp+1883] + ldx [%l7+%g1], %g2 + st %f27, [%fp+1887] + st %f29, [%fp+1891] + st %f31, [%fp+1895] + st %g0, [%fp+1775] + stx %g0, [%fp+1807] + st %g0, [%fp+1815] + st %g0, [%fp+1831] + ldx [%g2], %g3 + call %g3, 0 + add %fp, 1775, %o0 + lduw [%fp+1815], %g1 + cmp %g1, 0 + be,pn %icc, L(L61) + cmp %g1, 1 + be,pn %icc, L(L50) + cmp %g1, 2 + be,pn %icc, L(L50) + cmp %g1, 3 + be,pn %icc, L(L53) + cmp %g1, 4 + be,pn %icc, L(L54) + cmp %g1, 5 + be,pn %icc, L(L55) + cmp %g1, 6 + be,pn %icc, L(L56) + cmp %g1, 7 + be,pn %icc, L(L57) + cmp %g1, 8 + be,pn %icc, L(L51) + cmp %g1, 9 + be,pn %icc, L(L51) + cmp %g1, 10 + be,pn %icc, L(L51) + cmp %g1, 11 + be,pn %icc, L(L51) + cmp %g1, 12 + be,pn %icc, L(L58) + cmp %g1, 13 + be,pn %icc, L(L59) + cmp %g1, 14 + be,pn %icc, L(L51) + cmp %g1, 15 + bne,pt %icc, L(L61) + lduw [%fp+1775], %g1 + andcc %g1, 1024, %g0 + be,pn %xcc, L(L61) + ldx [%fp+1823], %g5 + add %g5, -1, %g1 + cmp %g1, 31 + bgu,pn %xcc, L(L61) + ldx [%fp+1807], %g1 + cmp %g5, 8 + and %g1, 7, %o2 + and %g1, -8, %l0 + bgu,pt %xcc, L(L35) + add %g5, %o2, %g2 + cmp %g2, 8 + bgu,pt %xcc, L(L37) + sllx %o2, 3, %g4 + sllx %g2, 3, %g2 + ldx [%l0], %g3 + sub %g0, %g2, %g2 + mov -1, %g1 + sllx %g1, %g2, %g1 + and %g1, %g3, %g1 + return %i7+8 + sllx %g1, %g4, %o0 +L(L47): + ldx [%l0], %g1 + sllx %g1, %o4, %g1 + ldx [%l0+8], %g4 + ldx [%l0+16], %g5 + sllx %g4, %o4, %o1 + sllx %g5, %o4, %o0 + ldx [%l0+24], %o5 + sllx %g2, 3, %o3 + sllx %o5, %o4, %o7 + ldx [%l0+32], %o2 + sub %g0, %o3, %o3 + mov 64, %g3 + sub %g3, %o4, %g3 + srax %g4, %g3, %g4 + srax %g5, %g3, %g5 + or %g1, %g4, %i0 + srax %o5, %g3, %o5 + mov -1, %g1 + or %o1, %g5, %i1 + sllx %g1, %o3, %g1 + or %o0, %o5, %i2 + and %g1, %o2, %g1 + srax %g1, %g3, %g1 + or %o7, %g1, %i3 +L(L61): + return %i7+8 + nop +L(L50): + ldsb [%fp+1783], %i0 + return %i7+8 + nop +L(L54): + ldsh [%fp+1783], %i0 + return %i7+8 + nop +L(L53): + ldub [%fp+1783], %i0 + return %i7+8 + nop +L(L51): + ldx [%fp+1783], %i0 + return %i7+8 + nop +L(L55): + lduh [%fp+1783], %i0 + return %i7+8 + nop +L(L56): + ldsw [%fp+1783], %i0 + return %i7+8 + nop +L(L57): + lduw [%fp+1783], %i0 + return %i7+8 + nop +L(L58): + ld [%fp+1783], %f0 + return %i7+8 + nop +L(L59): + ldd [%fp+1783], %f0 + return %i7+8 + nop +L(L35): + cmp %g5, 16 + bgu,pt %xcc, L(L39) + cmp %g5, 24 + cmp %g2, 16 + bgu,pt %xcc, L(L41) + sllx %o2, 3, %o5 + sllx %g2, 3, %g3 + ldx [%l0+8], %g2 + sll %o2, 3, %g5 + sllx %o2, 2, %o5 + sub %g0, %g3, %g3 + ldx [%l0], %g4 + mov -1, %g1 + sllx %g4, %g5, %g4 + sllx %g1, %g3, %g1 + and %g1, %g2, %g1 + mov 32, %g2 + sllx %g1, %g5, %i1 + sub %g2, %o5, %g2 + srax %g1, %g2, %g1 + srax %g1, %g2, %g1 + return %i7+8 + or %g4, %g1, %o0 +L(L37): + sllx %g2, 3, %g3 + ldx [%l0+8], %g5 + sub %g0, %g3, %g3 + sub %g0, %g4, %o5 + ldx [%l0], %g2 + mov -1, %g1 + sllx %g2, %g4, %g2 + sllx %g1, %g3, %g1 + and %g1, %g5, %g1 + srax %g1, %o5, %g1 + return %i7+8 + or %g2, %g1, %o0 +L(L39): + bgu,pt %xcc, L(L43) + cmp %g2, 32 + cmp %g2, 24 + bgu,pt %xcc, L(L45) + sllx %o2, 3, %o4 + sllx %o2, 2, %g1 + sll %o2, 3, %g5 + sllx %g2, 3, %o5 + ldx [%l0+8], %g3 + ldx [%l0+16], %o4 + sllx %g3, %g5, %o3 + sub %g0, %o5, %o5 + mov 32, %g4 + ldx [%l0], %g2 + sub %g4, %g1, %g4 + sllx %g2, %g5, %g2 + srax %g3, %g4, %g3 + mov -1, %g1 + srax %g3, %g4, %g3 + sllx %g1, %o5, %g1 + and %g1, %o4, %g1 + sllx %g1, %g5, %i2 + srax %g1, %g4, %g1 + srax %g1, %g4, %g1 + or %o3, %g1, %i1 + return %i7+8 + or %g2, %g3, %o0 +L(L41): + sllx %g2, 3, %g5 + ldx [%l0+8], %g3 + ldx [%l0+16], %o4 + sllx %g3, %o5, %o3 + sub %g0, %g5, %g5 + mov 64, %g4 + ldx [%l0], %g2 + sub %g4, %o5, %g4 + sllx %g2, %o5, %g2 + srax %g3, %g4, %g3 + mov -1, %g1 + sllx %g1, %g5, %g1 + and %g1, %o4, %g1 + srax %g1, %g4, %g1 + or %o3, %g1, %i1 + return %i7+8 + or %g2, %g3, %o0 +L(L45): + ldx [%l0], %g1 + sllx %g1, %o4, %g1 + ldx [%l0+8], %g3 + ldx [%l0+16], %g4 + sllx %g3, %o4, %o3 + sllx %g4, %o4, %o1 + sllx %g2, 3, %o5 + ldx [%l0+24], %o2 + sub %g0, %o5, %o5 + mov 64, %g5 + sub %g5, %o4, %g5 + srax %g3, %g5, %g3 + srax %g4, %g5, %g4 + or %g1, %g3, %i0 + or %o3, %g4, %i1 + mov -1, %g1 + sllx %g1, %o5, %g1 + and %g1, %o2, %g1 + srax %g1, %g5, %g1 + or %o1, %g1, %i2 + return %i7+8 + nop +L(L43): + bgu,pt %xcc, L(L47) + sllx %o2, 3, %o4 + sll %o2, 3, %o5 + ldx [%l0], %g1 + sllx %g1, %o5, %g1 + sllx %o2, 2, %o4 + sllx %g2, 3, %g5 + ldx [%l0+8], %g3 + ldx [%l0+16], %g4 + sllx %g3, %o5, %o2 + sllx %g4, %o5, %o1 + ldx [%l0+24], %o3 + sub %g0, %g5, %g5 + mov 32, %g2 + sub %g2, %o4, %g2 + srax %g3, %g2, %g3 + srax %g4, %g2, %g4 + srax %g3, %g2, %g3 + srax %g4, %g2, %g4 + or %g1, %g3, %i0 + or %o2, %g4, %i1 + mov -1, %g1 + sllx %g1, %g5, %g1 + and %g1, %o3, %g1 + sllx %g1, %o5, %i3 + srax %g1, %g2, %g1 + srax %g1, %g2, %g1 + or %o1, %g1, %i2 + return %i7+8 + nop + FUNEND(vacall_receiver) +#else + .section ".text" + .align 4 + .global C(vacall_receiver) + DECLARE_FUNCTION(vacall_receiver) + .proc 020 +FUNBEGIN(vacall_receiver) + .register %g2, $scratch + .register %g3, $scratch + save %sp, -448, %sp + add %fp, 2175, %g1 + stx %i0, [%fp+2175] + stx %i1, [%fp+2183] + stx %i2, [%fp+2191] + stx %i3, [%fp+2199] + stx %i4, [%fp+2207] + stx %i5, [%fp+2215] + std %f0, [%fp+1903] + std %f2, [%fp+1911] + std %f4, [%fp+1919] + std %f6, [%fp+1927] + std %f8, [%fp+1935] + std %f10, [%fp+1943] + std %f12, [%fp+1951] + std %f14, [%fp+1959] + std %f16, [%fp+1967] + std %f18, [%fp+1975] + std %f20, [%fp+1983] + std %f22, [%fp+1991] + std %f24, [%fp+1999] + std %f26, [%fp+2007] + std %f28, [%fp+2015] + std %f30, [%fp+2023] + st %f1, [%fp+1835] + st %f3, [%fp+1839] + st %f5, [%fp+1843] + st %f7, [%fp+1847] + st %f9, [%fp+1851] + st %f11, [%fp+1855] + st %f13, [%fp+1859] + st %f15, [%fp+1863] + st %f17, [%fp+1867] + st %f19, [%fp+1871] + st %f21, [%fp+1875] + sethi %lm(C(vacall_function)), %g2 + st %f23, [%fp+1879] + stx %g1, [%fp+1799] + st %f25, [%fp+1883] + st %f27, [%fp+1887] + st %f29, [%fp+1891] + st %f31, [%fp+1895] + st %g0, [%fp+1775] + stx %g0, [%fp+1807] + st %g0, [%fp+1815] + st %g0, [%fp+1831] + sethi %hh(C(vacall_function)), %g1 + or %g1, %hm(C(vacall_function)), %g1 + sllx %g1, 32, %g1 + add %g1, %g2, %g1 + ldx [%g1+%lo(C(vacall_function))], %g3 + call %g3, 0 + add %fp, 1775, %o0 + lduw [%fp+1815], %g1 + cmp %g1, 0 + be,pn %icc, L(L61) + cmp %g1, 1 + be,pn %icc, L(L50) + cmp %g1, 2 + be,pn %icc, L(L50) + cmp %g1, 3 + be,pn %icc, L(L53) + cmp %g1, 4 + be,pn %icc, L(L54) + cmp %g1, 5 + be,pn %icc, L(L55) + cmp %g1, 6 + be,pn %icc, L(L56) + cmp %g1, 7 + be,pn %icc, L(L57) + cmp %g1, 8 + be,pn %icc, L(L51) + cmp %g1, 9 + be,pn %icc, L(L51) + cmp %g1, 10 + be,pn %icc, L(L51) + cmp %g1, 11 + be,pn %icc, L(L51) + cmp %g1, 12 + be,pn %icc, L(L58) + cmp %g1, 13 + be,pn %icc, L(L59) + cmp %g1, 14 + be,pn %icc, L(L51) + cmp %g1, 15 + bne,pt %icc, L(L61) + lduw [%fp+1775], %g1 + andcc %g1, 1024, %g0 + be,pn %xcc, L(L61) + ldx [%fp+1823], %g5 + add %g5, -1, %g1 + cmp %g1, 31 + bgu,pn %xcc, L(L61) + ldx [%fp+1807], %g1 + cmp %g5, 8 + and %g1, 7, %o2 + and %g1, -8, %l0 + bgu,pt %xcc, L(L35) + add %g5, %o2, %g2 + cmp %g2, 8 + bgu,pt %xcc, L(L37) + sllx %o2, 3, %g4 + sllx %g2, 3, %g2 + ldx [%l0], %g3 + sub %g0, %g2, %g2 + mov -1, %g1 + sllx %g1, %g2, %g1 + and %g1, %g3, %g1 + return %i7+8 + sllx %g1, %g4, %o0 +L(L47): + ldx [%l0], %g1 + sllx %g1, %o4, %g1 + ldx [%l0+8], %g4 + ldx [%l0+16], %g5 + sllx %g4, %o4, %o1 + sllx %g5, %o4, %o0 + ldx [%l0+24], %o5 + sllx %g2, 3, %o3 + sllx %o5, %o4, %o7 + ldx [%l0+32], %o2 + sub %g0, %o3, %o3 + mov 64, %g3 + sub %g3, %o4, %g3 + srax %g4, %g3, %g4 + srax %g5, %g3, %g5 + or %g1, %g4, %i0 + srax %o5, %g3, %o5 + mov -1, %g1 + or %o1, %g5, %i1 + sllx %g1, %o3, %g1 + or %o0, %o5, %i2 + and %g1, %o2, %g1 + srax %g1, %g3, %g1 + or %o7, %g1, %i3 +L(L61): + return %i7+8 + nop +L(L50): + ldsb [%fp+1783], %i0 + return %i7+8 + nop +L(L54): + ldsh [%fp+1783], %i0 + return %i7+8 + nop +L(L53): + ldub [%fp+1783], %i0 + return %i7+8 + nop +L(L51): + ldx [%fp+1783], %i0 + return %i7+8 + nop +L(L55): + lduh [%fp+1783], %i0 + return %i7+8 + nop +L(L56): + ldsw [%fp+1783], %i0 + return %i7+8 + nop +L(L57): + lduw [%fp+1783], %i0 + return %i7+8 + nop +L(L58): + ld [%fp+1783], %f0 + return %i7+8 + nop +L(L59): + ldd [%fp+1783], %f0 + return %i7+8 + nop +L(L35): + cmp %g5, 16 + bgu,pt %xcc, L(L39) + cmp %g5, 24 + cmp %g2, 16 + bgu,pt %xcc, L(L41) + sllx %o2, 3, %o5 + sllx %g2, 3, %g3 + ldx [%l0+8], %g2 + sll %o2, 3, %g5 + sllx %o2, 2, %o5 + sub %g0, %g3, %g3 + ldx [%l0], %g4 + mov -1, %g1 + sllx %g4, %g5, %g4 + sllx %g1, %g3, %g1 + and %g1, %g2, %g1 + mov 32, %g2 + sllx %g1, %g5, %i1 + sub %g2, %o5, %g2 + srax %g1, %g2, %g1 + srax %g1, %g2, %g1 + return %i7+8 + or %g4, %g1, %o0 +L(L37): + sllx %g2, 3, %g3 + ldx [%l0+8], %g5 + sub %g0, %g3, %g3 + sub %g0, %g4, %o5 + ldx [%l0], %g2 + mov -1, %g1 + sllx %g2, %g4, %g2 + sllx %g1, %g3, %g1 + and %g1, %g5, %g1 + srax %g1, %o5, %g1 + return %i7+8 + or %g2, %g1, %o0 +L(L39): + bgu,pt %xcc, L(L43) + cmp %g2, 32 + cmp %g2, 24 + bgu,pt %xcc, L(L45) + sllx %o2, 3, %o4 + sllx %o2, 2, %g1 + sll %o2, 3, %g5 + sllx %g2, 3, %o5 + ldx [%l0+8], %g3 + ldx [%l0+16], %o4 + sllx %g3, %g5, %o3 + sub %g0, %o5, %o5 + mov 32, %g4 + ldx [%l0], %g2 + sub %g4, %g1, %g4 + sllx %g2, %g5, %g2 + srax %g3, %g4, %g3 + mov -1, %g1 + srax %g3, %g4, %g3 + sllx %g1, %o5, %g1 + and %g1, %o4, %g1 + sllx %g1, %g5, %i2 + srax %g1, %g4, %g1 + srax %g1, %g4, %g1 + or %o3, %g1, %i1 + return %i7+8 + or %g2, %g3, %o0 +L(L41): + sllx %g2, 3, %g5 + ldx [%l0+8], %g3 + ldx [%l0+16], %o4 + sllx %g3, %o5, %o3 + sub %g0, %g5, %g5 + mov 64, %g4 + ldx [%l0], %g2 + sub %g4, %o5, %g4 + sllx %g2, %o5, %g2 + srax %g3, %g4, %g3 + mov -1, %g1 + sllx %g1, %g5, %g1 + and %g1, %o4, %g1 + srax %g1, %g4, %g1 + or %o3, %g1, %i1 + return %i7+8 + or %g2, %g3, %o0 +L(L45): + ldx [%l0], %g1 + sllx %g1, %o4, %g1 + ldx [%l0+8], %g3 + ldx [%l0+16], %g4 + sllx %g3, %o4, %o3 + sllx %g4, %o4, %o1 + sllx %g2, 3, %o5 + ldx [%l0+24], %o2 + sub %g0, %o5, %o5 + mov 64, %g5 + sub %g5, %o4, %g5 + srax %g3, %g5, %g3 + srax %g4, %g5, %g4 + or %g1, %g3, %i0 + or %o3, %g4, %i1 + mov -1, %g1 + sllx %g1, %o5, %g1 + and %g1, %o2, %g1 + srax %g1, %g5, %g1 + or %o1, %g1, %i2 + return %i7+8 + nop +L(L43): + bgu,pt %xcc, L(L47) + sllx %o2, 3, %o4 + sll %o2, 3, %o5 + ldx [%l0], %g1 + sllx %g1, %o5, %g1 + sllx %o2, 2, %o4 + sllx %g2, 3, %g5 + ldx [%l0+8], %g3 + ldx [%l0+16], %g4 + sllx %g3, %o5, %o2 + sllx %g4, %o5, %o1 + ldx [%l0+24], %o3 + sub %g0, %g5, %g5 + mov 32, %g2 + sub %g2, %o4, %g2 + srax %g3, %g2, %g3 + srax %g4, %g2, %g4 + srax %g3, %g2, %g3 + srax %g4, %g2, %g4 + or %g1, %g3, %i0 + or %o2, %g4, %i1 + mov -1, %g1 + sllx %g1, %g5, %g1 + and %g1, %o3, %g1 + sllx %g1, %o5, %i3 + srax %g1, %g2, %g1 + srax %g1, %g2, %g1 + or %o1, %g1, %i2 + return %i7+8 + nop + FUNEND(vacall_receiver) +#endif +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/vacall/vacall-sparc64.c b/vacall/vacall-sparc64.c new file mode 100644 index 0000000..3d78c94 --- /dev/null +++ b/vacall/vacall-sparc64.c @@ -0,0 +1,460 @@ +/* vacall function for sparc64 CPU */ + +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +#include "vacall-internal.h" + +#ifdef REENTRANT +#define vacall_receiver callback_receiver +register struct { void (*vacall_function) (void*,va_alist); void* arg; } + * env __asm__("%g5"); +#endif +register __vaword* fp __asm__("%fp"); /* our %fp, caller's %sp */ +register __vaword* ret __asm__("%i7"); /* %i7+8 = return address */ +register float farg0 __asm__("%f1"); +register float farg1 __asm__("%f3"); +register float farg2 __asm__("%f5"); +register float farg3 __asm__("%f7"); +register float farg4 __asm__("%f9"); +register float farg5 __asm__("%f11"); +register float farg6 __asm__("%f13"); +register float farg7 __asm__("%f15"); +register float farg8 __asm__("%f17"); +register float farg9 __asm__("%f19"); +register float farg10 __asm__("%f21"); +register float farg11 __asm__("%f23"); +register float farg12 __asm__("%f25"); +register float farg13 __asm__("%f27"); +register float farg14 __asm__("%f29"); +register float farg15 __asm__("%f31"); +register double darg0 __asm__("%f0"); +register double darg1 __asm__("%f2"); +register double darg2 __asm__("%f4"); +register double darg3 __asm__("%f6"); +register double darg4 __asm__("%f8"); +register double darg5 __asm__("%f10"); +register double darg6 __asm__("%f12"); +register double darg7 __asm__("%f14"); +register double darg8 __asm__("%f16"); +register double darg9 __asm__("%f18"); +register double darg10 __asm__("%f20"); +register double darg11 __asm__("%f22"); +register double darg12 __asm__("%f24"); +register double darg13 __asm__("%f26"); +register double darg14 __asm__("%f28"); +register double darg15 __asm__("%f30"); +register __vaword iret __asm__("%i0"); +register __vaword o1 __asm__("%i1"); +register __vaword o2 __asm__("%i2"); +register __vaword o3 __asm__("%i3"); +register __vaword o4 __asm__("%i4"); +register __vaword o5 __asm__("%i5"); +register float fret __asm__("%f0"); /* %f0 */ +register double dret __asm__("%f0"); /* %f0,%f1 */ + +void /* the return type is variable, not void! */ +vacall_receiver (__vaword word1, __vaword word2, __vaword word3, __vaword word4, + __vaword word5, __vaword word6, + __vaword firstword) +{ + __va_alist list; + /* Move the arguments passed in registers to their stack locations. */ + (&firstword)[-6] = word1; + (&firstword)[-5] = word2; + (&firstword)[-4] = word3; + (&firstword)[-3] = word4; + (&firstword)[-2] = word5; + (&firstword)[-1] = word6; + list.darg[0] = darg0; + list.darg[1] = darg1; + list.darg[2] = darg2; + list.darg[3] = darg3; + list.darg[4] = darg4; + list.darg[5] = darg5; + list.darg[6] = darg6; + list.darg[7] = darg7; + list.darg[8] = darg8; + list.darg[9] = darg9; + list.darg[10] = darg10; + list.darg[11] = darg11; + list.darg[12] = darg12; + list.darg[13] = darg13; + list.darg[14] = darg14; + list.darg[15] = darg15; + list.farg[0] = farg0; + list.farg[1] = farg1; + list.farg[2] = farg2; + list.farg[3] = farg3; + list.farg[4] = farg4; + list.farg[5] = farg5; + list.farg[6] = farg6; + list.farg[7] = farg7; + list.farg[8] = farg8; + list.farg[9] = farg9; + list.farg[10] = farg10; + list.farg[11] = farg11; + list.farg[12] = farg12; + list.farg[13] = farg13; + list.farg[14] = farg14; + list.farg[15] = farg15; + /* Prepare the va_alist. */ + list.flags = 0; + list.aptr = (long)(&firstword - 6); + list.raddr = (void*)0; + list.rtype = __VAvoid; + list.anum = 0; + /* Call vacall_function. The macros do all the rest. */ +#ifndef REENTRANT + (*vacall_function) (&list); +#else /* REENTRANT */ + (*env->vacall_function) (env->arg,&list); +#endif + /* Put return value into proper register. */ + if (list.rtype == __VAvoid) { + } else + if (list.rtype == __VAchar) { + iret = list.tmp._char; + } else + if (list.rtype == __VAschar) { + iret = list.tmp._schar; + } else + if (list.rtype == __VAuchar) { + iret = list.tmp._uchar; + } else + if (list.rtype == __VAshort) { + iret = list.tmp._short; + } else + if (list.rtype == __VAushort) { + iret = list.tmp._ushort; + } else + if (list.rtype == __VAint) { + iret = list.tmp._int; + } else + if (list.rtype == __VAuint) { + iret = list.tmp._uint; + } else + if (list.rtype == __VAlong) { + iret = list.tmp._long; + } else + if (list.rtype == __VAulong) { + iret = list.tmp._ulong; + } else + if (list.rtype == __VAlonglong) { + iret = list.tmp._long; + } else + if (list.rtype == __VAulonglong) { + iret = list.tmp._ulong; + } else + if (list.rtype == __VAfloat) { + fret = list.tmp._float; + } else + if (list.rtype == __VAdouble) { + dret = list.tmp._double; + } else + if (list.rtype == __VAvoidp) { + iret = (long)list.tmp._ptr; + } else + if (list.rtype == __VAstruct) { + if (list.flags & __VA_REGISTER_STRUCT_RETURN) { + /* Return structs of size <= 32 in registers. */ + #define iret2 o1 + #define iret3 o2 + #define iret4 o3 + if (list.rsize > 0 && list.rsize <= 32) { + #if 0 /* Unoptimized */ + if (list.rsize == 1) { + iret = (__vaword)((unsigned char *) list.raddr)[0] << 56; + } else + if (list.rsize == 2) { + iret = ((__vaword)((unsigned char *) list.raddr)[0] << 56) + | ((__vaword)((unsigned char *) list.raddr)[1] << 48); + } else + if (list.rsize == 3) { + iret = ((__vaword)((unsigned char *) list.raddr)[0] << 56) + | ((__vaword)((unsigned char *) list.raddr)[1] << 48) + | ((__vaword)((unsigned char *) list.raddr)[2] << 40); + } else + if (list.rsize == 4) { + iret = ((__vaword)((unsigned char *) list.raddr)[0] << 56) + | ((__vaword)((unsigned char *) list.raddr)[1] << 48) + | ((__vaword)((unsigned char *) list.raddr)[2] << 40) + | ((__vaword)((unsigned char *) list.raddr)[3] << 32); + } else + if (list.rsize == 5) { + iret = ((__vaword)((unsigned char *) list.raddr)[0] << 56) + | ((__vaword)((unsigned char *) list.raddr)[1] << 48) + | ((__vaword)((unsigned char *) list.raddr)[2] << 40) + | ((__vaword)((unsigned char *) list.raddr)[3] << 32) + | ((__vaword)((unsigned char *) list.raddr)[4] << 24); + } else + if (list.rsize == 6) { + iret = ((__vaword)((unsigned char *) list.raddr)[0] << 56) + | ((__vaword)((unsigned char *) list.raddr)[1] << 48) + | ((__vaword)((unsigned char *) list.raddr)[2] << 40) + | ((__vaword)((unsigned char *) list.raddr)[3] << 32) + | ((__vaword)((unsigned char *) list.raddr)[4] << 24) + | ((__vaword)((unsigned char *) list.raddr)[5] << 16); + } else + if (list.rsize == 7) { + iret = ((__vaword)((unsigned char *) list.raddr)[0] << 56) + | ((__vaword)((unsigned char *) list.raddr)[1] << 48) + | ((__vaword)((unsigned char *) list.raddr)[2] << 40) + | ((__vaword)((unsigned char *) list.raddr)[3] << 32) + | ((__vaword)((unsigned char *) list.raddr)[4] << 24) + | ((__vaword)((unsigned char *) list.raddr)[5] << 16) + | ((__vaword)((unsigned char *) list.raddr)[6] << 8); + } else + if (list.rsize >= 8 && list.rsize <= 32) { + iret = ((__vaword)((unsigned char *) list.raddr)[0] << 56) + | ((__vaword)((unsigned char *) list.raddr)[1] << 48) + | ((__vaword)((unsigned char *) list.raddr)[2] << 40) + | ((__vaword)((unsigned char *) list.raddr)[3] << 32) + | ((__vaword)((unsigned char *) list.raddr)[4] << 24) + | ((__vaword)((unsigned char *) list.raddr)[5] << 16) + | ((__vaword)((unsigned char *) list.raddr)[6] << 8) + | (__vaword)((unsigned char *) list.raddr)[7]; + if (list.rsize == 8) { + } else + if (list.rsize == 9) { + iret2 = (__vaword)((unsigned char *) list.raddr)[8] << 56; + } else + if (list.rsize == 10) { + iret2 = ((__vaword)((unsigned char *) list.raddr)[8] << 56) + | ((__vaword)((unsigned char *) list.raddr)[9] << 48); + } else + if (list.rsize == 11) { + iret2 = ((__vaword)((unsigned char *) list.raddr)[8] << 56) + | ((__vaword)((unsigned char *) list.raddr)[9] << 48) + | ((__vaword)((unsigned char *) list.raddr)[10] << 40); + } else + if (list.rsize == 12) { + iret2 = ((__vaword)((unsigned char *) list.raddr)[8] << 56) + | ((__vaword)((unsigned char *) list.raddr)[9] << 48) + | ((__vaword)((unsigned char *) list.raddr)[10] << 40) + | ((__vaword)((unsigned char *) list.raddr)[11] << 32); + } else + if (list.rsize == 13) { + iret2 = ((__vaword)((unsigned char *) list.raddr)[8] << 56) + | ((__vaword)((unsigned char *) list.raddr)[9] << 48) + | ((__vaword)((unsigned char *) list.raddr)[10] << 40) + | ((__vaword)((unsigned char *) list.raddr)[11] << 32) + | ((__vaword)((unsigned char *) list.raddr)[12] << 24); + } else + if (list.rsize == 14) { + iret2 = ((__vaword)((unsigned char *) list.raddr)[8] << 56) + | ((__vaword)((unsigned char *) list.raddr)[9] << 48) + | ((__vaword)((unsigned char *) list.raddr)[10] << 40) + | ((__vaword)((unsigned char *) list.raddr)[11] << 32) + | ((__vaword)((unsigned char *) list.raddr)[12] << 24) + | ((__vaword)((unsigned char *) list.raddr)[13] << 16); + } else + if (list.rsize == 15) { + iret2 = ((__vaword)((unsigned char *) list.raddr)[8] << 56) + | ((__vaword)((unsigned char *) list.raddr)[9] << 48) + | ((__vaword)((unsigned char *) list.raddr)[10] << 40) + | ((__vaword)((unsigned char *) list.raddr)[11] << 32) + | ((__vaword)((unsigned char *) list.raddr)[12] << 24) + | ((__vaword)((unsigned char *) list.raddr)[13] << 16) + | ((__vaword)((unsigned char *) list.raddr)[14] << 8); + } else + if (list.rsize >= 16 && list.rsize <= 32) { + iret2 = ((__vaword)((unsigned char *) list.raddr)[8] << 56) + | ((__vaword)((unsigned char *) list.raddr)[9] << 48) + | ((__vaword)((unsigned char *) list.raddr)[10] << 40) + | ((__vaword)((unsigned char *) list.raddr)[11] << 32) + | ((__vaword)((unsigned char *) list.raddr)[12] << 24) + | ((__vaword)((unsigned char *) list.raddr)[13] << 16) + | ((__vaword)((unsigned char *) list.raddr)[14] << 8) + | (__vaword)((unsigned char *) list.raddr)[15]; + if (list.rsize == 16) { + } else + if (list.rsize == 17) { + iret3 = (__vaword)((unsigned char *) list.raddr)[16] << 56; + } else + if (list.rsize == 18) { + iret3 = ((__vaword)((unsigned char *) list.raddr)[16] << 56) + | ((__vaword)((unsigned char *) list.raddr)[17] << 48); + } else + if (list.rsize == 19) { + iret3 = ((__vaword)((unsigned char *) list.raddr)[16] << 56) + | ((__vaword)((unsigned char *) list.raddr)[17] << 48) + | ((__vaword)((unsigned char *) list.raddr)[18] << 40); + } else + if (list.rsize == 20) { + iret3 = ((__vaword)((unsigned char *) list.raddr)[16] << 56) + | ((__vaword)((unsigned char *) list.raddr)[17] << 48) + | ((__vaword)((unsigned char *) list.raddr)[18] << 40) + | ((__vaword)((unsigned char *) list.raddr)[19] << 32); + } else + if (list.rsize == 21) { + iret3 = ((__vaword)((unsigned char *) list.raddr)[16] << 56) + | ((__vaword)((unsigned char *) list.raddr)[17] << 48) + | ((__vaword)((unsigned char *) list.raddr)[18] << 40) + | ((__vaword)((unsigned char *) list.raddr)[19] << 32) + | ((__vaword)((unsigned char *) list.raddr)[20] << 24); + } else + if (list.rsize == 22) { + iret3 = ((__vaword)((unsigned char *) list.raddr)[16] << 56) + | ((__vaword)((unsigned char *) list.raddr)[17] << 48) + | ((__vaword)((unsigned char *) list.raddr)[18] << 40) + | ((__vaword)((unsigned char *) list.raddr)[19] << 32) + | ((__vaword)((unsigned char *) list.raddr)[20] << 24) + | ((__vaword)((unsigned char *) list.raddr)[21] << 16); + } else + if (list.rsize == 23) { + iret3 = ((__vaword)((unsigned char *) list.raddr)[16] << 56) + | ((__vaword)((unsigned char *) list.raddr)[17] << 48) + | ((__vaword)((unsigned char *) list.raddr)[18] << 40) + | ((__vaword)((unsigned char *) list.raddr)[19] << 32) + | ((__vaword)((unsigned char *) list.raddr)[20] << 24) + | ((__vaword)((unsigned char *) list.raddr)[21] << 16) + | ((__vaword)((unsigned char *) list.raddr)[22] << 8); + } else + if (list.rsize >= 24 && list.rsize <= 32) { + iret3 = ((__vaword)((unsigned char *) list.raddr)[16] << 56) + | ((__vaword)((unsigned char *) list.raddr)[17] << 48) + | ((__vaword)((unsigned char *) list.raddr)[18] << 40) + | ((__vaword)((unsigned char *) list.raddr)[19] << 32) + | ((__vaword)((unsigned char *) list.raddr)[20] << 24) + | ((__vaword)((unsigned char *) list.raddr)[21] << 16) + | ((__vaword)((unsigned char *) list.raddr)[22] << 8) + | (__vaword)((unsigned char *) list.raddr)[23]; + if (list.rsize == 24) { + } else + if (list.rsize == 25) { + iret4 = (__vaword)((unsigned char *) list.raddr)[24] << 56; + } else + if (list.rsize == 26) { + iret4 = ((__vaword)((unsigned char *) list.raddr)[24] << 56) + | ((__vaword)((unsigned char *) list.raddr)[25] << 48); + } else + if (list.rsize == 27) { + iret4 = ((__vaword)((unsigned char *) list.raddr)[24] << 56) + | ((__vaword)((unsigned char *) list.raddr)[25] << 48) + | ((__vaword)((unsigned char *) list.raddr)[26] << 40); + } else + if (list.rsize == 28) { + iret4 = ((__vaword)((unsigned char *) list.raddr)[24] << 56) + | ((__vaword)((unsigned char *) list.raddr)[25] << 48) + | ((__vaword)((unsigned char *) list.raddr)[26] << 40) + | ((__vaword)((unsigned char *) list.raddr)[27] << 32); + } else + if (list.rsize == 29) { + iret4 = ((__vaword)((unsigned char *) list.raddr)[24] << 56) + | ((__vaword)((unsigned char *) list.raddr)[25] << 48) + | ((__vaword)((unsigned char *) list.raddr)[26] << 40) + | ((__vaword)((unsigned char *) list.raddr)[27] << 32) + | ((__vaword)((unsigned char *) list.raddr)[28] << 24); + } else + if (list.rsize == 30) { + iret4 = ((__vaword)((unsigned char *) list.raddr)[24] << 56) + | ((__vaword)((unsigned char *) list.raddr)[25] << 48) + | ((__vaword)((unsigned char *) list.raddr)[26] << 40) + | ((__vaword)((unsigned char *) list.raddr)[27] << 32) + | ((__vaword)((unsigned char *) list.raddr)[28] << 24) + | ((__vaword)((unsigned char *) list.raddr)[29] << 16); + } else + if (list.rsize == 31) { + iret4 = ((__vaword)((unsigned char *) list.raddr)[24] << 56) + | ((__vaword)((unsigned char *) list.raddr)[25] << 48) + | ((__vaword)((unsigned char *) list.raddr)[26] << 40) + | ((__vaword)((unsigned char *) list.raddr)[27] << 32) + | ((__vaword)((unsigned char *) list.raddr)[28] << 24) + | ((__vaword)((unsigned char *) list.raddr)[29] << 16) + | ((__vaword)((unsigned char *) list.raddr)[30] << 8); + } else + if (list.rsize == 32) { + iret4 = ((__vaword)((unsigned char *) list.raddr)[24] << 56) + | ((__vaword)((unsigned char *) list.raddr)[25] << 48) + | ((__vaword)((unsigned char *) list.raddr)[26] << 40) + | ((__vaword)((unsigned char *) list.raddr)[27] << 32) + | ((__vaword)((unsigned char *) list.raddr)[28] << 24) + | ((__vaword)((unsigned char *) list.raddr)[29] << 16) + | ((__vaword)((unsigned char *) list.raddr)[30] << 8) + | (__vaword)((unsigned char *) list.raddr)[31]; + } + } + } + } + #else /* Optimized: fewer conditional jumps, fewer memory accesses */ + uintptr_t count = list.rsize; /* > 0, ≤ 4*sizeof(__vaword) */ + __vaword* wordaddr = (__vaword*)((uintptr_t)list.raddr & ~(uintptr_t)(sizeof(__vaword)-1)); + uintptr_t start_offset = (uintptr_t)list.raddr & (uintptr_t)(sizeof(__vaword)-1); /* ≥ 0, < sizeof(__vaword) */ + uintptr_t end_offset = start_offset + count; /* > 0, < 5*sizeof(__vaword) */ + if (count <= sizeof(__vaword)) { + /* Assign iret. */ + if (end_offset <= sizeof(__vaword)) { + /* 0 < end_offset ≤ sizeof(__vaword) */ + __vaword mask0 = - ((__vaword)1 << (sizeof(__vaword)*8-end_offset*8)); + iret = (wordaddr[0] & mask0) << (start_offset*8); + } else { + /* sizeof(__vaword) < end_offset < 2*sizeof(__vaword), start_offset > 0 */ + __vaword mask1 = - ((__vaword)1 << (2*sizeof(__vaword)*8-end_offset*8)); + iret = (wordaddr[0] << (start_offset*8)) | ((wordaddr[1] & mask1) >> (sizeof(__vaword)*8-start_offset*8)); + } + } else if (count <= 2*sizeof(__vaword)) { + /* Assign iret, iret2. */ + if (end_offset <= 2*sizeof(__vaword)) { + /* sizeof(__vaword) < end_offset ≤ 2*sizeof(__vaword) */ + __vaword mask1 = - ((__vaword)1 << (2*sizeof(__vaword)*8-end_offset*8)); + iret = (wordaddr[0] << (start_offset*8)) | ((wordaddr[1] & mask1) >> (sizeof(__vaword)*4-start_offset*4) >> (sizeof(__vaword)*4-start_offset*4)); + iret2 = (wordaddr[1] & mask1) << (start_offset*8); + } else { + /* 2*sizeof(__vaword) < end_offset < 3*sizeof(__vaword), start_offset > 0 */ + __vaword mask2 = - ((__vaword)1 << (3*sizeof(__vaword)*8-end_offset*8)); + iret = (wordaddr[0] << (start_offset*8)) | (wordaddr[1] >> (sizeof(__vaword)*8-start_offset*8)); + iret2 = (wordaddr[1] << (start_offset*8)) | ((wordaddr[2] & mask2) >> (sizeof(__vaword)*8-start_offset*8)); + } + } else if (count <= 3*sizeof(__vaword)) { + /* Assign iret, iret2, iret3. */ + if (end_offset <= 3*sizeof(__vaword)) { + /* 2*sizeof(__vaword) < end_offset ≤ 3*sizeof(__vaword) */ + __vaword mask2 = - ((__vaword)1 << (3*sizeof(__vaword)*8-end_offset*8)); + iret = (wordaddr[0] << (start_offset*8)) | (wordaddr[1] >> (sizeof(__vaword)*4-start_offset*4) >> (sizeof(__vaword)*4-start_offset*4)); + iret2 = (wordaddr[1] << (start_offset*8)) | ((wordaddr[2] & mask2) >> (sizeof(__vaword)*4-start_offset*4) >> (sizeof(__vaword)*4-start_offset*4)); + iret3 = (wordaddr[2] & mask2) << (start_offset*8); + } else { + /* 3*sizeof(__vaword) < end_offset < 4*sizeof(__vaword), start_offset > 0 */ + __vaword mask3 = - ((__vaword)1 << (4*sizeof(__vaword)*8-end_offset*8)); + iret = (wordaddr[0] << (start_offset*8)) | (wordaddr[1] >> (sizeof(__vaword)*8-start_offset*8)); + iret2 = (wordaddr[1] << (start_offset*8)) | (wordaddr[2] >> (sizeof(__vaword)*8-start_offset*8)); + iret3 = (wordaddr[2] << (start_offset*8)) | ((wordaddr[3] & mask3) >> (sizeof(__vaword)*8-start_offset*8)); + } + } else { + /* Assign iret, iret2, iret3, iret4. */ + if (end_offset <= 4*sizeof(__vaword)) { + /* 3*sizeof(__vaword) < end_offset ≤ 4*sizeof(__vaword) */ + __vaword mask3 = - ((__vaword)1 << (4*sizeof(__vaword)*8-end_offset*8)); + iret = (wordaddr[0] << (start_offset*8)) | (wordaddr[1] >> (sizeof(__vaword)*4-start_offset*4) >> (sizeof(__vaword)*4-start_offset*4)); + iret2 = (wordaddr[1] << (start_offset*8)) | (wordaddr[2] >> (sizeof(__vaword)*4-start_offset*4) >> (sizeof(__vaword)*4-start_offset*4)); + iret3 = (wordaddr[2] << (start_offset*8)) | ((wordaddr[3] & mask3) >> (sizeof(__vaword)*4-start_offset*4) >> (sizeof(__vaword)*4-start_offset*4)); + iret4 = (wordaddr[3] & mask3) << (start_offset*8); + } else { + /* 4*sizeof(__vaword) < end_offset < 5*sizeof(__vaword), start_offset > 0 */ + __vaword mask4 = - ((__vaword)1 << (5*sizeof(__vaword)*8-end_offset*8)); + iret = (wordaddr[0] << (start_offset*8)) | (wordaddr[1] >> (sizeof(__vaword)*8-start_offset*8)); + iret2 = (wordaddr[1] << (start_offset*8)) | (wordaddr[2] >> (sizeof(__vaword)*8-start_offset*8)); + iret3 = (wordaddr[2] << (start_offset*8)) | (wordaddr[3] >> (sizeof(__vaword)*8-start_offset*8)); + iret4 = (wordaddr[3] << (start_offset*8)) | ((wordaddr[4] & mask4) >> (sizeof(__vaword)*8-start_offset*8)); + } + } + #endif + } + } + } +} diff --git a/vacall/vacall-structcpy.c b/vacall/vacall-structcpy.c new file mode 100644 index 0000000..b6ffb90 --- /dev/null +++ b/vacall/vacall-structcpy.c @@ -0,0 +1,22 @@ +/* copy structs */ + +/* + * Copyright 2016 Bruno Haible + * + * 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, see . + */ + +#define __structcpy vacall_structcpy + +#include "structcpy.c" diff --git a/vacall/vacall-x86_64-linux.s b/vacall/vacall-x86_64-linux.s new file mode 100644 index 0000000..aaaa1c5 --- /dev/null +++ b/vacall/vacall-x86_64-linux.s @@ -0,0 +1,258 @@ + .file "vacall-x86_64.c" + .text + .p2align 4,,15 +.globl vacall_receiver + .type vacall_receiver, @function +vacall_receiver: +.LFB2: + pushq %rbp +.LCFI0: + movq %rsp, %rbp +.LCFI1: + pushq %r12 +.LCFI2: + subq $200, %rsp +.LCFI3: + movq %rcx, -48(%rbp) + leaq 16(%rbp), %rcx + movq %rdi, -72(%rbp) + movq %rsi, -64(%rbp) + movsd %xmm0, -144(%rbp) + movq %rcx, -184(%rbp) + movq %rdx, -56(%rbp) + movsd %xmm1, -136(%rbp) + movq %r8, -40(%rbp) + movsd %xmm2, -128(%rbp) + leaq -208(%rbp), %rdi + movq %r9, -32(%rbp) + movsd %xmm3, -120(%rbp) + movsd %xmm4, -112(%rbp) + movl $0, -208(%rbp) + movsd %xmm5, -104(%rbp) + movq $0, -176(%rbp) + movsd %xmm6, -96(%rbp) + movl $0, -168(%rbp) + movsd %xmm7, -88(%rbp) + movl $0, -80(%rbp) + movl $0, -152(%rbp) + call *vacall_function(%rip) + movl -168(%rbp), %ecx + testl %ecx, %ecx + je .L41 + cmpl $1, %ecx + je .L42 + cmpl $2, %ecx + je .L42 + cmpl $3, %ecx + .p2align 4,,5 + je .L48 + cmpl $4, %ecx + .p2align 4,,5 + je .L49 + cmpl $5, %ecx + .p2align 4,,5 + je .L50 + cmpl $6, %ecx + .p2align 4,,5 + je .L51 + cmpl $7, %ecx + .p2align 4,,5 + je .L52 + cmpl $8, %ecx + .p2align 4,,5 + je .L46 + cmpl $9, %ecx + .p2align 4,,5 + je .L46 + cmpl $10, %ecx + .p2align 4,,5 + je .L46 + cmpl $11, %ecx + .p2align 4,,5 + je .L46 + cmpl $12, %ecx + .p2align 4,,5 + je .L53 + cmpl $13, %ecx + .p2align 4,,5 + je .L54 + cmpl $14, %ecx + .p2align 4,,5 + je .L46 + cmpl $15, %ecx + .p2align 4,,5 + jne .L41 + testb $4, -207(%rbp) + .p2align 4,,2 + je .L41 + movq -160(%rbp), %rsi + leaq -1(%rsi), %rcx + cmpq $15, %rcx + ja .L41 + movq -176(%rbp), %rcx + movq %rcx, %r11 + movq %rcx, %r8 + andl $7, %r8d + andq $-8, %r11 + cmpq $8, %rsi + leaq (%rsi,%r8), %r10 + ja .L35 + cmpq $8, %r10 + ja .L37 + leal -1(,%r10,8), %ecx + movl $2, %esi + salq %cl, %rsi + leal 0(,%r8,8), %ecx + decq %rsi + andq (%r11), %rsi + movq %rsi, %rax + sarq %cl, %rax + .p2align 4,,7 +.L41: + addq $200, %rsp + popq %r12 + leave + ret + .p2align 4,,7 +.L42: + movsbq -200(%rbp),%rax + addq $200, %rsp + popq %r12 + leave + ret +.L49: + movswq -200(%rbp),%rax + jmp .L41 +.L48: + movzbq -200(%rbp), %rax + jmp .L41 +.L46: + movq -200(%rbp), %rax + jmp .L41 +.L50: + movzwq -200(%rbp), %rax + jmp .L41 +.L51: + movslq -200(%rbp),%rax + jmp .L41 +.L52: + mov -200(%rbp), %eax + jmp .L41 +.L53: + movss -200(%rbp), %xmm0 + jmp .L41 +.L54: + movlpd -200(%rbp), %xmm0 + jmp .L41 +.L35: + cmpq $16, %r10 + ja .L39 + leal -65(,%r10,8), %ecx + movl $2, %esi + leal 0(,%r8,8), %r9d + movl $32, %edi + salq %cl, %rsi + leaq 0(,%r8,4), %rcx + movq (%r11), %r8 + decq %rsi + andq 8(%r11), %rsi + subl %ecx, %edi + movl %r9d, %ecx + sarq %cl, %r8 + movl %edi, %ecx + movq %r8, %rax + movq %rsi, %r10 + movq %rsi, %rdx + salq %cl, %r10 + salq %cl, %r10 + movl %r9d, %ecx + orq %r10, %rax + sarq %cl, %rdx + jmp .L41 +.L37: + movq (%r11), %rdi + leal -65(,%r10,8), %esi + salq $3, %r8 + movl %r8d, %ecx + movl $2, %r10d + sarq %cl, %rdi + movl %esi, %ecx + movl $64, %esi + salq %cl, %r10 + subl %r8d, %esi + movq %rdi, %rax + decq %r10 + andq 8(%r11), %r10 + movl %esi, %ecx + salq %cl, %r10 + orq %r10, %rax + jmp .L41 +.L39: + leaq 0(,%r8,8), %rcx + movq (%r11), %r12 + movq 8(%r11), %r8 + movl $64, %edi + subl %ecx, %edi + movl %ecx, %r9d + sarq %cl, %r12 + movq %r8, %rsi + movl %edi, %ecx + salq %cl, %rsi + movq %r12, %rax + movl %r9d, %ecx + orq %rsi, %rax + leal -129(,%r10,8), %esi + sarq %cl, %r8 + movl $2, %r9d + movq %r8, %rdx + movl %esi, %ecx + salq %cl, %r9 + movl %edi, %ecx + leaq -1(%r9), %rsi + andq 16(%r11), %rsi + salq %cl, %rsi + orq %rsi, %rdx + jmp .L41 +.LFE2: + .size vacall_receiver, .-vacall_receiver + .section .eh_frame,"a",@progbits +.Lframe1: + .long .LECIE1-.LSCIE1 +.LSCIE1: + .long 0x0 + .byte 0x1 + .string "" + .uleb128 0x1 + .sleb128 -8 + .byte 0x10 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x90 + .uleb128 0x1 + .align 8 +.LECIE1: +.LSFDE1: + .long .LEFDE1-.LASFDE1 +.LASFDE1: + .long .LASFDE1-.Lframe1 + .quad .LFB2 + .quad .LFE2-.LFB2 + .byte 0x4 + .long .LCFI0-.LFB2 + .byte 0xe + .uleb128 0x10 + .byte 0x86 + .uleb128 0x2 + .byte 0x4 + .long .LCFI1-.LCFI0 + .byte 0xd + .uleb128 0x6 + .byte 0x4 + .long .LCFI3-.LCFI1 + .byte 0x8c + .uleb128 0x3 + .align 8 +.LEFDE1: + .ident "GCC: (GNU) 4.0.2" + .section .note.GNU-stack,"",@progbits diff --git a/vacall/vacall-x86_64-macro.S b/vacall/vacall-x86_64-macro.S new file mode 100644 index 0000000..0668ba5 --- /dev/null +++ b/vacall/vacall-x86_64-macro.S @@ -0,0 +1,261 @@ +#include "asm-x86_64.h" + TEXT() + P2ALIGN(4,15) +GLOBL(C(vacall_receiver)) + DECLARE_FUNCTION(vacall_receiver) +FUNBEGIN(vacall_receiver) +L(FB2): + INSN1(push,q ,R(rbp)) +L(CFI0): + INSN2(mov,q ,R(rsp), R(rbp)) +L(CFI1): + INSN1(push,q ,R(r12)) +L(CFI2): + INSN2(sub,q ,NUM(200), R(rsp)) +L(CFI3): + INSN2(mov,q ,R(rcx),X8 MEM_DISP(rbp,-48)) + INSN2(lea,q ,X8 MEM_DISP(rbp,16), R(rcx)) + INSN2(mov,q ,R(rdi),X8 MEM_DISP(rbp,-72)) + INSN2(mov,q ,R(rsi),X8 MEM_DISP(rbp,-64)) + INSN2S(movs,d ,R(xmm0),X8 MEM_DISP(rbp,-144)) + INSN2(mov,q ,R(rcx),X8 MEM_DISP(rbp,-184)) + INSN2(mov,q ,R(rdx),X8 MEM_DISP(rbp,-56)) + INSN2S(movs,d ,R(xmm1),X8 MEM_DISP(rbp,-136)) + INSN2(mov,q ,R(r8),X8 MEM_DISP(rbp,-40)) + INSN2S(movs,d ,R(xmm2),X8 MEM_DISP(rbp,-128)) + INSN2(lea,q ,X8 MEM_DISP(rbp,-208), R(rdi)) + INSN2(mov,q ,R(r9),X8 MEM_DISP(rbp,-32)) + INSN2S(movs,d ,R(xmm3),X8 MEM_DISP(rbp,-120)) + INSN2S(movs,d ,R(xmm4),X8 MEM_DISP(rbp,-112)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(rbp,-208)) + INSN2S(movs,d ,R(xmm5),X8 MEM_DISP(rbp,-104)) + INSN2(mov,q ,NUM(0),X8 MEM_DISP(rbp,-176)) + INSN2S(movs,d ,R(xmm6),X8 MEM_DISP(rbp,-96)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(rbp,-168)) + INSN2S(movs,d ,R(xmm7),X8 MEM_DISP(rbp,-88)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(rbp,-80)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(rbp,-152)) + INSN1(call,_ ,INDIR(X8 MEM_PCRELATIVE(C(vacall_function)))) + INSN2(mov,l ,X4 MEM_DISP(rbp,-168), R(ecx)) + INSN2(test,l ,R(ecx), R(ecx)) + INSN1(je,_ ,L(41)) + INSN2(cmp,l ,NUM(1), R(ecx)) + INSN1(je,_ ,L(42)) + INSN2(cmp,l ,NUM(2), R(ecx)) + INSN1(je,_ ,L(42)) + INSN2(cmp,l ,NUM(3), R(ecx)) + P2ALIGN(4,5) + INSN1(je,_ ,L(48)) + INSN2(cmp,l ,NUM(4), R(ecx)) + P2ALIGN(4,5) + INSN1(je,_ ,L(49)) + INSN2(cmp,l ,NUM(5), R(ecx)) + P2ALIGN(4,5) + INSN1(je,_ ,L(50)) + INSN2(cmp,l ,NUM(6), R(ecx)) + P2ALIGN(4,5) + INSN1(je,_ ,L(51)) + INSN2(cmp,l ,NUM(7), R(ecx)) + P2ALIGN(4,5) + INSN1(je,_ ,L(52)) + INSN2(cmp,l ,NUM(8), R(ecx)) + P2ALIGN(4,5) + INSN1(je,_ ,L(46)) + INSN2(cmp,l ,NUM(9), R(ecx)) + P2ALIGN(4,5) + INSN1(je,_ ,L(46)) + INSN2(cmp,l ,NUM(10), R(ecx)) + P2ALIGN(4,5) + INSN1(je,_ ,L(46)) + INSN2(cmp,l ,NUM(11), R(ecx)) + P2ALIGN(4,5) + INSN1(je,_ ,L(46)) + INSN2(cmp,l ,NUM(12), R(ecx)) + P2ALIGN(4,5) + INSN1(je,_ ,L(53)) + INSN2(cmp,l ,NUM(13), R(ecx)) + P2ALIGN(4,5) + INSN1(je,_ ,L(54)) + INSN2(cmp,l ,NUM(14), R(ecx)) + P2ALIGN(4,5) + INSN1(je,_ ,L(46)) + INSN2(cmp,l ,NUM(15), R(ecx)) + P2ALIGN(4,5) + INSN1(jne,_ ,L(41)) + INSN2(test,b ,NUM(4),X1 MEM_DISP(rbp,-207)) + P2ALIGN(4,2) + INSN1(je,_ ,L(41)) + INSN2(mov,q ,X8 MEM_DISP(rbp,-160), R(rsi)) + INSN2(lea,q ,X8 MEM_DISP(rsi,-1), R(rcx)) + INSN2(cmp,q ,NUM(15), R(rcx)) + INSN1(ja,_ ,L(41)) + INSN2(mov,q ,X8 MEM_DISP(rbp,-176), R(rcx)) + INSN2(mov,q ,R(rcx), R(r11)) + INSN2(mov,q ,R(rcx), R(r8)) + INSN2(and,l ,NUM(7), R(r8d)) + INSN2(and,q ,NUM(-8), R(r11)) + INSN2(cmp,q ,NUM(8), R(rsi)) + INSN2(lea,q ,X8 MEM_INDEX(rsi,r8), R(r10)) + INSN1(ja,_ ,L(35)) + INSN2(cmp,q ,NUM(8), R(r10)) + INSN1(ja,_ ,L(37)) + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(-1,r10,8), R(ecx)) + INSN2(mov,l ,NUM(2), R(esi)) + INSN2(sal,q ,R(cl), R(rsi)) + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(0,r8,8), R(ecx)) + INSN1(dec,q ,R(rsi)) + INSN2(and,q ,X8 MEM(r11), R(rsi)) + INSN2(mov,q ,R(rsi), R(rax)) + INSN2(sar,q ,R(cl), R(rax)) + P2ALIGN(4,7) +L(41): + INSN2(add,q ,NUM(200), R(rsp)) + INSN1(pop,q ,R(r12)) + leave + ret + P2ALIGN(4,7) +L(42): + INSN2MOVXQ(movs,b,X1 MEM_DISP(rbp,-200),R(rax)) + INSN2(add,q ,NUM(200), R(rsp)) + INSN1(pop,q ,R(r12)) + leave + ret +L(49): + INSN2MOVXQ(movs,w,X2 MEM_DISP(rbp,-200),R(rax)) + INSN1(jmp,_ ,L(41)) +L(48): + INSN2MOVXQ(movz,b,X1 MEM_DISP(rbp,-200), R(rax)) + INSN1(jmp,_ ,L(41)) +L(46): + INSN2(mov,q ,X8 MEM_DISP(rbp,-200), R(rax)) + INSN1(jmp,_ ,L(41)) +L(50): + INSN2MOVXQ(movz,w,X2 MEM_DISP(rbp,-200), R(rax)) + INSN1(jmp,_ ,L(41)) +L(51): + INSN2MOVXLQ(movs,l,X4 MEM_DISP(rbp,-200),R(rax)) + INSN1(jmp,_ ,L(41)) +L(52): + INSN2(mov,l ,X4 MEM_DISP(rbp,-200), R(eax)) + INSN1(jmp,_ ,L(41)) +L(53): + INSN2S(movs,s ,X4 MEM_DISP(rbp,-200), R(xmm0)) + INSN1(jmp,_ ,L(41)) +L(54): + INSN2(movlp,d ,X8 MEM_DISP(rbp,-200), R(xmm0)) + INSN1(jmp,_ ,L(41)) +L(35): + INSN2(cmp,q ,NUM(16), R(r10)) + INSN1(ja,_ ,L(39)) + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(-65,r10,8), R(ecx)) + INSN2(mov,l ,NUM(2), R(esi)) + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(0,r8,8), R(r9d)) + INSN2(mov,l ,NUM(32), R(edi)) + INSN2(sal,q ,R(cl), R(rsi)) + INSN2(lea,q ,X8 MEM_DISP_SHINDEX0(0,r8,4), R(rcx)) + INSN2(mov,q ,X8 MEM(r11), R(r8)) + INSN1(dec,q ,R(rsi)) + INSN2(and,q ,X8 MEM_DISP(r11,8), R(rsi)) + INSN2(sub,l ,R(ecx), R(edi)) + INSN2(mov,l ,R(r9d), R(ecx)) + INSN2(sar,q ,R(cl), R(r8)) + INSN2(mov,l ,R(edi), R(ecx)) + INSN2(mov,q ,R(r8), R(rax)) + INSN2(mov,q ,R(rsi), R(r10)) + INSN2(mov,q ,R(rsi), R(rdx)) + INSN2(sal,q ,R(cl), R(r10)) + INSN2(sal,q ,R(cl), R(r10)) + INSN2(mov,l ,R(r9d), R(ecx)) + INSN2(or,q ,R(r10), R(rax)) + INSN2(sar,q ,R(cl), R(rdx)) + INSN1(jmp,_ ,L(41)) +L(37): + INSN2(mov,q ,X8 MEM(r11), R(rdi)) + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(-65,r10,8), R(esi)) + INSN2(sal,q ,NUM(3), R(r8)) + INSN2(mov,l ,R(r8d), R(ecx)) + INSN2(mov,l ,NUM(2), R(r10d)) + INSN2(sar,q ,R(cl), R(rdi)) + INSN2(mov,l ,R(esi), R(ecx)) + INSN2(mov,l ,NUM(64), R(esi)) + INSN2(sal,q ,R(cl), R(r10)) + INSN2(sub,l ,R(r8d), R(esi)) + INSN2(mov,q ,R(rdi), R(rax)) + INSN1(dec,q ,R(r10)) + INSN2(and,q ,X8 MEM_DISP(r11,8), R(r10)) + INSN2(mov,l ,R(esi), R(ecx)) + INSN2(sal,q ,R(cl), R(r10)) + INSN2(or,q ,R(r10), R(rax)) + INSN1(jmp,_ ,L(41)) +L(39): + INSN2(lea,q ,X8 MEM_DISP_SHINDEX0(0,r8,8), R(rcx)) + INSN2(mov,q ,X8 MEM(r11), R(r12)) + INSN2(mov,q ,X8 MEM_DISP(r11,8), R(r8)) + INSN2(mov,l ,NUM(64), R(edi)) + INSN2(sub,l ,R(ecx), R(edi)) + INSN2(mov,l ,R(ecx), R(r9d)) + INSN2(sar,q ,R(cl), R(r12)) + INSN2(mov,q ,R(r8), R(rsi)) + INSN2(mov,l ,R(edi), R(ecx)) + INSN2(sal,q ,R(cl), R(rsi)) + INSN2(mov,q ,R(r12), R(rax)) + INSN2(mov,l ,R(r9d), R(ecx)) + INSN2(or,q ,R(rsi), R(rax)) + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(-129,r10,8), R(esi)) + INSN2(sar,q ,R(cl), R(r8)) + INSN2(mov,l ,NUM(2), R(r9d)) + INSN2(mov,q ,R(r8), R(rdx)) + INSN2(mov,l ,R(esi), R(ecx)) + INSN2(sal,q ,R(cl), R(r9)) + INSN2(mov,l ,R(edi), R(ecx)) + INSN2(lea,q ,X8 MEM_DISP(r9,-1), R(rsi)) + INSN2(and,q ,X8 MEM_DISP(r11,16), R(rsi)) + INSN2(sal,q ,R(cl), R(rsi)) + INSN2(or,q ,R(rsi), R(rdx)) + INSN1(jmp,_ ,L(41)) +L(FE2): + FUNEND(vacall_receiver, .-vacall_receiver) +#if !(defined __sun || (defined __APPLE__ && defined __MACH__) || (defined _WIN32 || defined __CYGWIN__)) + .section EH_FRAME_SECTION +L(frame1): + .long L(ECIE1)-.LSCIE1 +L(SCIE1): + .long 0x0 + .byte 0x1 + .string "" + .uleb128 0x1 + .sleb128 -8 + .byte 0x10 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x90 + .uleb128 0x1 + .align 8 +L(ECIE1): +L(SFDE1): + .long L(EFDE1)-.LASFDE1 +L(ASFDE1): + .long L(ASFDE1)-.Lframe1 + .quad L(FB2) + .quad L(FE2)-.LFB2 + .byte 0x4 + .long L(CFI0)-.LFB2 + .byte 0xe + .uleb128 0x10 + .byte 0x86 + .uleb128 0x2 + .byte 0x4 + .long L(CFI1)-.LCFI0 + .byte 0xd + .uleb128 0x6 + .byte 0x4 + .long L(CFI3)-.LCFI1 + .byte 0x8c + .uleb128 0x3 + .align 8 +L(EFDE1): +#endif +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/vacall/vacall-x86_64-windows-macro.S b/vacall/vacall-x86_64-windows-macro.S new file mode 100644 index 0000000..d3e076a --- /dev/null +++ b/vacall/vacall-x86_64-windows-macro.S @@ -0,0 +1,350 @@ +#include "asm-x86_64.h" + TEXT() + P2ALIGN(4,15) + GLOBL(C(vacall_receiver)) + DECLARE_FUNCTION(vacall_receiver) +FUNBEGIN(vacall_receiver) +L(FB0): + INSN1(push,q ,R(rbp)) +L(CFI0): + INSN2(mov,q ,R(rsp), R(rbp)) +L(CFI1): + INSN2(sub,q ,NUM(144), R(rsp)) + INSN2(mov,q ,R(rcx),X8 MEM_DISP(rbp,16)) + INSN2(lea,q ,X8 MEM_DISP(rbp,16), R(rcx)) + INSN2(mov,q ,R(rdx),X8 MEM_DISP(rbp,24)) + INSN2(mov,q ,R(r8),X8 MEM_DISP(rbp,32)) + INSN2(mov,q ,R(r9),X8 MEM_DISP(rbp,40)) + INSN2S(movs,s ,R(xmm0),X4 MEM_DISP(rbp,-52)) + INSN2(mov,q ,R(rcx),X8 MEM_DISP(rbp,-88)) + INSN2S(movs,s ,R(xmm1),X4 MEM_DISP(rbp,-48)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(rbp,-112)) + INSN2S(movs,s ,R(xmm2),X4 MEM_DISP(rbp,-44)) + INSN2(mov,q ,NUM(0),X8 MEM_DISP(rbp,-80)) + INSN2(lea,q ,X8 MEM_DISP(rbp,-112), R(rcx)) + INSN2S(movs,s ,R(xmm3),X4 MEM_DISP(rbp,-40)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(rbp,-72)) + INSN2S(movs,d ,R(xmm0),X8 MEM_DISP(rbp,-32)) + INSN2(mov,l ,NUM(0),X4 MEM_DISP(rbp,-56)) + INSN2S(movs,d ,R(xmm1),X8 MEM_DISP(rbp,-24)) + INSN2S(movs,d ,R(xmm2),X8 MEM_DISP(rbp,-16)) + INSN2S(movs,d ,R(xmm3),X8 MEM_DISP(rbp,-8)) + INSN1(call,_ ,INDIR(X8 MEM_PCRELATIVE(C(vacall_function)))) + INSN2(mov,l ,X4 MEM_DISP(rbp,-72), R(edx)) + INSN2(test,l ,R(edx), R(edx)) + INSN1(je,_ ,L(1)) + INSN2(cmp,l ,NUM(1), R(edx)) + INSN1(je,_ ,L(34)) + INSN2(cmp,l ,NUM(2), R(edx)) + INSN1(je,_ ,L(34)) + INSN2(cmp,l ,NUM(3), R(edx)) + INSN1(je,_ ,L(37)) + INSN2(cmp,l ,NUM(4), R(edx)) + INSN1(je,_ ,L(38)) + INSN2(cmp,l ,NUM(5), R(edx)) + INSN1(je,_ ,L(39)) + INSN2(cmp,l ,NUM(6), R(edx)) + INSN1(je,_ ,L(40)) + INSN2(cmp,l ,NUM(7), R(edx)) + INSN1(je,_ ,L(41)) + INSN2(cmp,l ,NUM(8), R(edx)) + INSN1(je,_ ,L(35)) + INSN2(cmp,l ,NUM(9), R(edx)) + INSN1(je,_ ,L(35)) + INSN2(cmp,l ,NUM(10), R(edx)) + INSN1(je,_ ,L(35)) + INSN2(cmp,l ,NUM(11), R(edx)) + INSN1(je,_ ,L(35)) + INSN2(cmp,l ,NUM(12), R(edx)) + INSN1(je,_ ,L(42)) + INSN2(cmp,l ,NUM(13), R(edx)) + INSN1(je,_ ,L(43)) + INSN2(cmp,l ,NUM(14), R(edx)) + INSN1(je,_ ,L(35)) + INSN2(cmp,l ,NUM(15), R(edx)) + INSN1(jne,_ ,L(1)) + INSN2(test,b ,NUM(4),X1 MEM_DISP(rbp,-111)) + INSN1(je,_ ,L(17)) + INSN2(mov,q ,X8 MEM_DISP(rbp,-64), R(rdx)) + INSN2(lea,q ,X8 MEM_DISP(rdx,-4), R(rcx)) + INSN2(test,q ,NUM(-5), R(rcx)) + INSN1(je,_ ,L(20)) + INSN2(lea,q ,X8 MEM_DISP(rdx,-1), R(rcx)) + INSN2(cmp,q ,NUM(1), R(rcx)) + INSN1(ja,_ ,L(1)) +L(20): + INSN2(mov,q ,X8 MEM_DISP(rbp,-80), R(r8)) + INSN2(mov,q ,R(r8), R(r9)) + INSN2(and,l ,NUM(7), R(r8d)) + INSN2(add,q ,R(r8), R(rdx)) + INSN2(and,q ,NUM(-8), R(r9)) + INSN2(cmp,q ,NUM(8), R(rdx)) + INSN1(ja,_ ,L(19)) + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(-1,rdx,8), R(ecx)) + INSN2(mov,l ,NUM(2), R(edx)) + INSN2(sal,q ,R(cl), R(rdx)) + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(0,r8,8), R(ecx)) + INSN2(sub,q ,NUM(1), R(rdx)) + INSN2(and,q ,X8 MEM(r9), R(rdx)) + INSN2(sar,q ,R(cl), R(rdx)) + INSN2(mov,q ,R(rdx), R(rax)) +L(1): + leave +L(CFI2): + ret + P2ALIGN(4,10) + P2ALIGN(3,7) +L(34): +L(CFI3): + INSN2MOVXQ(movs,b,X1 MEM_DISP(rbp,-104), R(rax)) + leave +L(CFI4): + ret + P2ALIGN(4,10) + P2ALIGN(3,7) +L(35): +L(CFI5): + INSN2(mov,q ,X8 MEM_DISP(rbp,-104), R(rax)) + leave +L(CFI6): + ret + P2ALIGN(4,10) + P2ALIGN(3,7) +L(37): +L(CFI7): + INSN2MOVXL(movz,b,X1 MEM_DISP(rbp,-104), R(eax)) + leave +L(CFI8): + ret + P2ALIGN(4,10) + P2ALIGN(3,7) +L(38): +L(CFI9): + INSN2MOVXQ(movs,w,X2 MEM_DISP(rbp,-104), R(rax)) + leave +L(CFI10): + ret + P2ALIGN(4,10) + P2ALIGN(3,7) +L(39): +L(CFI11): + INSN2MOVXL(movz,w,X2 MEM_DISP(rbp,-104), R(eax)) + leave +L(CFI12): + ret + P2ALIGN(4,10) + P2ALIGN(3,7) +L(40): +L(CFI13): + INSN2MOVXLQ(movs,l,X4 MEM_DISP(rbp,-104), R(rax)) + leave +L(CFI14): + ret + P2ALIGN(4,10) + P2ALIGN(3,7) +L(42): +L(CFI15): + INSN2S(movs,s ,X4 MEM_DISP(rbp,-104), R(xmm0)) + leave +L(CFI16): + ret + P2ALIGN(4,10) + P2ALIGN(3,7) +L(41): +L(CFI17): + INSN2(mov,l ,X4 MEM_DISP(rbp,-104), R(eax)) + leave +L(CFI18): + ret +L(43): +L(CFI19): + INSN2S(movs,d ,X8 MEM_DISP(rbp,-104), R(xmm0)) + leave +L(CFI20): + ret +L(17): +L(CFI21): + INSN2(mov,q ,X8 MEM_DISP(rbp,-80), R(rax)) + leave +L(CFI22): + ret +L(19): +L(CFI23): + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(-65,rdx,8), R(ecx)) + INSN2(mov,l ,NUM(2), R(edx)) + INSN2(sal,q ,R(cl), R(rdx)) + INSN2(mov,l ,R(r8d), R(ecx)) + INSN2(sub,q ,NUM(1), R(rdx)) + INSN2(and,q ,X8 MEM_DISP(r9,8), R(rdx)) + INSN1(neg,l ,R(ecx)) + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(64,rcx,8), R(ecx)) + INSN2(sal,q ,R(cl), R(rdx)) + INSN2(lea,l ,X4 MEM_DISP_SHINDEX0(0,r8,8), R(ecx)) + INSN2(mov,q ,X8 MEM(r9), R(r8)) + leave +L(CFI24): + INSN2(sar,q ,R(cl), R(r8)) + INSN2(or,q ,R(r8), R(rdx)) + INSN2(mov,q ,R(rdx), R(rax)) + ret +L(FE0): + FUNEND(vacall_receiver, .-vacall_receiver) +#if !(defined __sun || (defined __APPLE__ && defined __MACH__) || (defined _WIN32 || defined __CYGWIN__)) + .section EH_FRAME_SECTION +L(frame1): + .long L(ECIE1)-.LSCIE1 +L(SCIE1): + .long 0 + .byte 0x3 + .string "zR" + .uleb128 0x1 + .sleb128 -8 + .uleb128 0x10 + .uleb128 0x1 + .byte 0x3 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x90 + .uleb128 0x1 + .align 8 +L(ECIE1): +L(SFDE1): + .long L(EFDE1)-.LASFDE1 +L(ASFDE1): + .long L(ASFDE1)-.Lframe1 + .long L(FB0) + .long L(FE0)-.LFB0 + .uleb128 0 + .byte 0x4 + .long L(CFI0)-.LFB0 + .byte 0xe + .uleb128 0x10 + .byte 0x86 + .uleb128 0x2 + .byte 0x4 + .long L(CFI1)-.LCFI0 + .byte 0xd + .uleb128 0x6 + .byte 0x4 + .long L(CFI2)-.LCFI1 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long L(CFI3)-.LCFI2 + .byte 0xb + .byte 0x4 + .long L(CFI4)-.LCFI3 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long L(CFI5)-.LCFI4 + .byte 0xb + .byte 0x4 + .long L(CFI6)-.LCFI5 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long L(CFI7)-.LCFI6 + .byte 0xb + .byte 0x4 + .long L(CFI8)-.LCFI7 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long L(CFI9)-.LCFI8 + .byte 0xb + .byte 0x4 + .long L(CFI10)-.LCFI9 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long L(CFI11)-.LCFI10 + .byte 0xb + .byte 0x4 + .long L(CFI12)-.LCFI11 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long L(CFI13)-.LCFI12 + .byte 0xb + .byte 0x4 + .long L(CFI14)-.LCFI13 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long L(CFI15)-.LCFI14 + .byte 0xb + .byte 0x4 + .long L(CFI16)-.LCFI15 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long L(CFI17)-.LCFI16 + .byte 0xb + .byte 0x4 + .long L(CFI18)-.LCFI17 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long L(CFI19)-.LCFI18 + .byte 0xb + .byte 0x4 + .long L(CFI20)-.LCFI19 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long L(CFI21)-.LCFI20 + .byte 0xb + .byte 0x4 + .long L(CFI22)-.LCFI21 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long L(CFI23)-.LCFI22 + .byte 0xb + .byte 0x4 + .long L(CFI24)-.LCFI23 + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .align 8 +L(EFDE1): +#endif +#if defined __linux__ || defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/vacall/vacall-x86_64-windows.c b/vacall/vacall-x86_64-windows.c new file mode 100644 index 0000000..95ef376 --- /dev/null +++ b/vacall/vacall-x86_64-windows.c @@ -0,0 +1,191 @@ +/* vacall function for x86_64 CPU with the Windows ABI ('gcc -mabi=ms') */ + +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +#include "vacall-internal.h" + +#ifdef REENTRANT +#define vacall_receiver callback_receiver +register struct { void (*vacall_function) (void*,va_alist); void* arg; } + * env __asm__("r10"); +#endif + +/*register __vaword iarg1 __asm__("rcx");*/ +/*register __vaword iarg2 __asm__("rdx");*/ +/*register __vaword iarg3 __asm__("r8");*/ +/*register __vaword iarg4 __asm__("r9");*/ + +register float farg1 __asm__("xmm0"); +register float farg2 __asm__("xmm1"); +register float farg3 __asm__("xmm2"); +register float farg4 __asm__("xmm3"); + +register double darg1 __asm__("xmm0"); +register double darg2 __asm__("xmm1"); +register double darg3 __asm__("xmm2"); +register double darg4 __asm__("xmm3"); + +register __vaword iret __asm__("rax"); +register float fret __asm__("xmm0"); +register double dret __asm__("xmm0"); + +/* + * Tell gcc to not use the call-saved registers %rbx, %rsi, %rdi. + * This ensures that the return sequence does not need to restore registers + * from the stack. + */ +register void* dummy1 __asm__("%rbx"); +register void* dummy2 __asm__("%rsi"); +register void* dummy3 __asm__("%rdi"); + +#ifdef REENTRANT +static +#endif +void /* the return type is variable, not void! */ +vacall_receiver (__vaword word1, __vaword word2, __vaword word3, __vaword word4, + __vaword firstword) +{ + __va_alist list; + /* Move the arguments passed in registers to their stack locations. */ + (&firstword)[-4] = word1; + (&firstword)[-3] = word2; + (&firstword)[-2] = word3; + (&firstword)[-1] = word4; + /* Move the floating-point arguments passed in registers to temp storage. */ + list.farg[0] = farg1; + list.farg[1] = farg2; + list.farg[2] = farg3; + list.farg[3] = farg4; + list.darg[0] = darg1; + list.darg[1] = darg2; + list.darg[2] = darg3; + list.darg[3] = darg4; + /* Prepare the va_alist. */ + list.flags = 0; + list.aptr = (long)(&firstword - 4); + list.raddr = (void*)0; + list.rtype = __VAvoid; + list.anum = 0; + /* Call vacall_function. The macros do all the rest. */ +#ifndef REENTRANT + (*vacall_function) (&list); +#else /* REENTRANT */ + (*env->vacall_function) (env->arg,&list); +#endif + /* Put return value into proper register. */ + if (list.rtype == __VAvoid) { + } else + if (list.rtype == __VAchar) { + iret = list.tmp._char; + } else + if (list.rtype == __VAschar) { + iret = list.tmp._schar; + } else + if (list.rtype == __VAuchar) { + iret = list.tmp._uchar; + } else + if (list.rtype == __VAshort) { + iret = list.tmp._short; + } else + if (list.rtype == __VAushort) { + iret = list.tmp._ushort; + } else + if (list.rtype == __VAint) { + iret = list.tmp._int; + } else + if (list.rtype == __VAuint) { + iret = list.tmp._uint; + } else + if (list.rtype == __VAlong) { + iret = list.tmp._long; + } else + if (list.rtype == __VAulong) { + iret = list.tmp._ulong; + } else + if (list.rtype == __VAlonglong) { + iret = list.tmp._long; + } else + if (list.rtype == __VAulonglong) { + iret = list.tmp._ulong; + } else + if (list.rtype == __VAfloat) { + fret = list.tmp._float; + } else + if (list.rtype == __VAdouble) { + dret = list.tmp._double; + } else + if (list.rtype == __VAvoidp) { + iret = (long)list.tmp._ptr; + } else + if (list.rtype == __VAstruct) { + if (list.flags & __VA_REGISTER_STRUCT_RETURN) { + /* Return structs of size 1, 2, 4, 8 in registers. */ + #if 0 /* Unoptimized */ + if (list.rsize == 1) { + iret = (__vaword)((unsigned char *) list.raddr)[0]; + } else + if (list.rsize == 2) { + iret = (__vaword)((unsigned char *) list.raddr)[0] + | ((__vaword)((unsigned char *) list.raddr)[1] << 8); + } else + if (list.rsize == 4) { + iret = (__vaword)((unsigned char *) list.raddr)[0] + | ((__vaword)((unsigned char *) list.raddr)[1] << 8) + | ((__vaword)((unsigned char *) list.raddr)[2] << 16) + | ((__vaword)((unsigned char *) list.raddr)[3] << 24); + } else + if (list.rsize == 8) { + iret = (__vaword)((unsigned char *) list.raddr)[0] + | ((__vaword)((unsigned char *) list.raddr)[1] << 8) + | ((__vaword)((unsigned char *) list.raddr)[2] << 16) + | ((__vaword)((unsigned char *) list.raddr)[3] << 24) + | ((__vaword)((unsigned char *) list.raddr)[4] << 32) + | ((__vaword)((unsigned char *) list.raddr)[5] << 40) + | ((__vaword)((unsigned char *) list.raddr)[6] << 48) + | ((__vaword)((unsigned char *) list.raddr)[7] << 56); + } + #else /* Optimized: fewer conditional jumps, fewer memory accesses */ + uintptr_t count = list.rsize; /* > 0, ≤ sizeof(__vaword) */ + if (count == 1 || count == 2 || count == 4 || count == 8) { + __vaword* wordaddr = (__vaword*)((uintptr_t)list.raddr & ~(uintptr_t)(sizeof(__vaword)-1)); + uintptr_t start_offset = (uintptr_t)list.raddr & (uintptr_t)(sizeof(__vaword)-1); /* ≥ 0, < sizeof(__vaword) */ + uintptr_t end_offset = start_offset + count; /* > 0, < 2*sizeof(__vaword) */ + if (end_offset <= sizeof(__vaword)) { + /* 0 < end_offset ≤ sizeof(__vaword) */ + __vaword mask0 = ((__vaword)2 << (end_offset*8-1)) - 1; + iret = (wordaddr[0] & mask0) >> (start_offset*8); + } else { + /* sizeof(__vaword) < end_offset < 2*sizeof(__vaword), start_offset > 0 */ + __vaword mask1 = ((__vaword)2 << (end_offset*8-sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | ((wordaddr[1] & mask1) << (sizeof(__vaword)*8-start_offset*8)); + } + } + #endif + } else { + iret = (long)list.raddr; + } + } +} + +#ifdef REENTRANT +__vacall_r_t +callback_get_receiver (void) +{ + return (__vacall_r_t)(void*)&callback_receiver; +} +#endif diff --git a/vacall/vacall-x86_64-windows.s b/vacall/vacall-x86_64-windows.s new file mode 100644 index 0000000..e1cadfb --- /dev/null +++ b/vacall/vacall-x86_64-windows.s @@ -0,0 +1,347 @@ + .file "vacall-x86_64-windows.c" + .text + .p2align 4,,15 + .globl vacall_receiver + .type vacall_receiver, @function +vacall_receiver: +.LFB0: + pushq %rbp +.LCFI0: + movq %rsp, %rbp +.LCFI1: + subq $144, %rsp + movq %rcx, 16(%rbp) + leaq 16(%rbp), %rcx + movq %rdx, 24(%rbp) + movq %r8, 32(%rbp) + movq %r9, 40(%rbp) + movss %xmm0, -52(%rbp) + movq %rcx, -88(%rbp) + movss %xmm1, -48(%rbp) + movl $0, -112(%rbp) + movss %xmm2, -44(%rbp) + movq $0, -80(%rbp) + leaq -112(%rbp), %rcx + movss %xmm3, -40(%rbp) + movl $0, -72(%rbp) + movsd %xmm0, -32(%rbp) + movl $0, -56(%rbp) + movsd %xmm1, -24(%rbp) + movsd %xmm2, -16(%rbp) + movsd %xmm3, -8(%rbp) + call *vacall_function(%rip) + movl -72(%rbp), %edx + testl %edx, %edx + je .L1 + cmpl $1, %edx + je .L34 + cmpl $2, %edx + je .L34 + cmpl $3, %edx + je .L37 + cmpl $4, %edx + je .L38 + cmpl $5, %edx + je .L39 + cmpl $6, %edx + je .L40 + cmpl $7, %edx + je .L41 + cmpl $8, %edx + je .L35 + cmpl $9, %edx + je .L35 + cmpl $10, %edx + je .L35 + cmpl $11, %edx + je .L35 + cmpl $12, %edx + je .L42 + cmpl $13, %edx + je .L43 + cmpl $14, %edx + je .L35 + cmpl $15, %edx + jne .L1 + testb $4, -111(%rbp) + je .L17 + movq -64(%rbp), %rdx + leaq -4(%rdx), %rcx + testq $-5, %rcx + je .L20 + leaq -1(%rdx), %rcx + cmpq $1, %rcx + ja .L1 +.L20: + movq -80(%rbp), %r8 + movq %r8, %r9 + andl $7, %r8d + addq %r8, %rdx + andq $-8, %r9 + cmpq $8, %rdx + ja .L19 + leal -1(,%rdx,8), %ecx + movl $2, %edx + salq %cl, %rdx + leal 0(,%r8,8), %ecx + subq $1, %rdx + andq (%r9), %rdx + sarq %cl, %rdx + movq %rdx, %rax +.L1: + leave +.LCFI2: + ret + .p2align 4,,10 + .p2align 3 +.L34: +.LCFI3: + movsbq -104(%rbp), %rax + leave +.LCFI4: + ret + .p2align 4,,10 + .p2align 3 +.L35: +.LCFI5: + movq -104(%rbp), %rax + leave +.LCFI6: + ret + .p2align 4,,10 + .p2align 3 +.L37: +.LCFI7: + movzbl -104(%rbp), %eax + leave +.LCFI8: + ret + .p2align 4,,10 + .p2align 3 +.L38: +.LCFI9: + movswq -104(%rbp), %rax + leave +.LCFI10: + ret + .p2align 4,,10 + .p2align 3 +.L39: +.LCFI11: + movzwl -104(%rbp), %eax + leave +.LCFI12: + ret + .p2align 4,,10 + .p2align 3 +.L40: +.LCFI13: + movslq -104(%rbp), %rax + leave +.LCFI14: + ret + .p2align 4,,10 + .p2align 3 +.L42: +.LCFI15: + movss -104(%rbp), %xmm0 + leave +.LCFI16: + ret + .p2align 4,,10 + .p2align 3 +.L41: +.LCFI17: + movl -104(%rbp), %eax + leave +.LCFI18: + ret +.L43: +.LCFI19: + movsd -104(%rbp), %xmm0 + leave +.LCFI20: + ret +.L17: +.LCFI21: + movq -80(%rbp), %rax + leave +.LCFI22: + ret +.L19: +.LCFI23: + leal -65(,%rdx,8), %ecx + movl $2, %edx + salq %cl, %rdx + movl %r8d, %ecx + subq $1, %rdx + andq 8(%r9), %rdx + negl %ecx + leal 64(,%rcx,8), %ecx + salq %cl, %rdx + leal 0(,%r8,8), %ecx + movq (%r9), %r8 + leave +.LCFI24: + sarq %cl, %r8 + orq %r8, %rdx + movq %rdx, %rax + ret +.LFE0: + .size vacall_receiver, .-vacall_receiver + .section .eh_frame,"a",@progbits +.Lframe1: + .long .LECIE1-.LSCIE1 +.LSCIE1: + .long 0 + .byte 0x3 + .string "zR" + .uleb128 0x1 + .sleb128 -8 + .uleb128 0x10 + .uleb128 0x1 + .byte 0x3 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x90 + .uleb128 0x1 + .align 8 +.LECIE1: +.LSFDE1: + .long .LEFDE1-.LASFDE1 +.LASFDE1: + .long .LASFDE1-.Lframe1 + .long .LFB0 + .long .LFE0-.LFB0 + .uleb128 0 + .byte 0x4 + .long .LCFI0-.LFB0 + .byte 0xe + .uleb128 0x10 + .byte 0x86 + .uleb128 0x2 + .byte 0x4 + .long .LCFI1-.LCFI0 + .byte 0xd + .uleb128 0x6 + .byte 0x4 + .long .LCFI2-.LCFI1 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI3-.LCFI2 + .byte 0xb + .byte 0x4 + .long .LCFI4-.LCFI3 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI5-.LCFI4 + .byte 0xb + .byte 0x4 + .long .LCFI6-.LCFI5 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI7-.LCFI6 + .byte 0xb + .byte 0x4 + .long .LCFI8-.LCFI7 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI9-.LCFI8 + .byte 0xb + .byte 0x4 + .long .LCFI10-.LCFI9 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI11-.LCFI10 + .byte 0xb + .byte 0x4 + .long .LCFI12-.LCFI11 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI13-.LCFI12 + .byte 0xb + .byte 0x4 + .long .LCFI14-.LCFI13 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI15-.LCFI14 + .byte 0xb + .byte 0x4 + .long .LCFI16-.LCFI15 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI17-.LCFI16 + .byte 0xb + .byte 0x4 + .long .LCFI18-.LCFI17 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI19-.LCFI18 + .byte 0xb + .byte 0x4 + .long .LCFI20-.LCFI19 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI21-.LCFI20 + .byte 0xb + .byte 0x4 + .long .LCFI22-.LCFI21 + .byte 0xa + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI23-.LCFI22 + .byte 0xb + .byte 0x4 + .long .LCFI24-.LCFI23 + .byte 0xc6 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .align 8 +.LEFDE1: + .ident "GCC: (GNU) 5.4.0" + .section .note.GNU-stack,"",@progbits diff --git a/vacall/vacall-x86_64-x32-linux.s b/vacall/vacall-x86_64-x32-linux.s new file mode 100644 index 0000000..127f761 --- /dev/null +++ b/vacall/vacall-x86_64-x32-linux.s @@ -0,0 +1,286 @@ + .file "vacall-x86_64.c" + .section .text.unlikely,"ax",@progbits +.LCOLDB0: + .text +.LHOTB0: + .p2align 4,,15 + .globl vacall_receiver + .type vacall_receiver, @function +vacall_receiver: +.LFB0: + pushq %rbp +.LCFI0: + movl %esp, %ebp +.LCFI1: + pushq %r14 + subl $184, %esp +.LCFI2: + movq %rsi, -64(%ebp) + leal 16(%rbp), %esi + movq %rcx, -48(%ebp) + movl vacall_function(%rip), %ecx + movsd %xmm0, -144(%ebp) + movq %rdi, -72(%ebp) + movq %rdx, -56(%ebp) + movsd %xmm1, -136(%ebp) + movq %r8, -40(%ebp) + movsd %xmm2, -128(%ebp) + leal -192(%rbp), %edi + movq %r9, -32(%ebp) + movsd %xmm3, -120(%ebp) + movsd %xmm4, -112(%ebp) + movl $0, -192(%ebp) + movsd %xmm5, -104(%ebp) + movl %esi, -168(%ebp) + movsd %xmm6, -96(%ebp) + movl $0, -164(%ebp) + movsd %xmm7, -88(%ebp) + movl $0, -160(%ebp) + movl $0, -80(%ebp) + movl $0, -152(%ebp) + call *%rcx + movl -160(%ebp), %ecx + testl %ecx, %ecx + je .L1 + cmpl $1, %ecx + je .L27 + cmpl $2, %ecx + je .L27 + cmpl $3, %ecx + je .L33 + cmpl $4, %ecx + je .L34 + cmpl $5, %ecx + je .L35 + cmpl $6, %ecx + je .L28 + cmpl $7, %ecx + je .L30 + cmpl $8, %ecx + je .L28 + cmpl $9, %ecx + je .L30 + cmpl $10, %ecx + je .L31 + cmpl $11, %ecx + je .L31 + cmpl $12, %ecx + je .L36 + cmpl $13, %ecx + je .L37 + cmpl $14, %ecx + je .L30 + cmpl $15, %ecx + jne .L1 + testb $4, -191(%ebp) + je .L1 + movl -156(%ebp), %ecx + leal -1(%rcx), %esi + cmpl $15, %esi + ja .L1 + movl -164(%ebp), %esi + movl %esi, %edi + andl $7, %esi + andl $-8, %edi + cmpl $8, %ecx + leal (%rcx,%rsi), %r10d + ja .L17 + cmpl $8, %r10d + ja .L18 + leal -1(,%r10,8), %ecx + movl $2, %r8d + salq %cl, %r8 + movq %r8, %rcx + subq $1, %rcx + andq (%edi), %rcx + movq %rcx, %rdi + leal 0(,%rsi,8), %ecx + sarq %cl, %rdi + movq %rdi, %rax +.L1: + addl $184, %esp + popq %r14 + popq %rbp +.LCFI3: + ret + .p2align 4,,10 + .p2align 3 +.L27: +.LCFI4: + movsbq -184(%ebp), %rax + addl $184, %esp + popq %r14 + popq %rbp +.LCFI5: + ret + .p2align 4,,10 + .p2align 3 +.L28: +.LCFI6: + movslq -184(%ebp), %rax + jmp .L1 + .p2align 4,,10 + .p2align 3 +.L33: + movzbl -184(%ebp), %eax + jmp .L1 + .p2align 4,,10 + .p2align 3 +.L34: + movswq -184(%ebp), %rax + jmp .L1 + .p2align 4,,10 + .p2align 3 +.L30: + movl -184(%ebp), %eax + jmp .L1 + .p2align 4,,10 + .p2align 3 +.L35: + movzwl -184(%ebp), %eax + jmp .L1 + .p2align 4,,10 + .p2align 3 +.L36: + movss -184(%ebp), %xmm0 + jmp .L1 + .p2align 4,,10 + .p2align 3 +.L31: + movq -184(%ebp), %rax + jmp .L1 +.L37: + movsd -184(%ebp), %xmm0 + jmp .L1 +.L17: + cmpl $16, %r10d + leal 0(,%rsi,8), %r9d + jbe .L38 + negl %esi + movq 8(%edi), %r8 + movl %r9d, %ecx + leal 64(,%rsi,8), %r11d + movq (%edi), %rsi + movq %r8, %r14 + sarq %cl, %rsi + movl %r11d, %ecx + salq %cl, %r14 + leal -129(,%r10,8), %ecx + orq %r14, %rsi + movq %rsi, %rax + movl $2, %esi + salq %cl, %rsi + movl %r11d, %ecx + subq $1, %rsi + andq 16(%edi), %rsi + salq %cl, %rsi + movl %r9d, %ecx + sarq %cl, %r8 + orq %r8, %rsi + movq %rsi, %rdx + jmp .L1 +.L18: + leal -65(,%r10,8), %ecx + movl $2, %r8d + salq %cl, %r8 + movl %esi, %ecx + subq $1, %r8 + andq 8(%edi), %r8 + negl %ecx + leal 64(,%rcx,8), %ecx + movq (%edi), %rdi + salq %cl, %r8 + leal 0(,%rsi,8), %ecx + sarq %cl, %rdi + orq %rdi, %r8 + movq %r8, %rax + jmp .L1 +.L38: + leal -65(,%r10,8), %ecx + movl $2, %r8d + movq (%edi), %r10 + imull $-4, %esi, %esi + salq %cl, %r8 + movl %r9d, %ecx + subq $1, %r8 + andq 8(%edi), %r8 + sarq %cl, %r10 + addl $32, %esi + movl %esi, %ecx + movq %r8, %rdi + salq %cl, %rdi + salq %cl, %rdi + movl %r9d, %ecx + orq %rdi, %r10 + sarq %cl, %r8 + movq %r10, %rax + movq %r8, %rdx + jmp .L1 +.LFE0: + .size vacall_receiver, .-vacall_receiver + .section .text.unlikely +.LCOLDE0: + .text +.LHOTE0: + .section .eh_frame,"a",@progbits +.Lframe1: + .long .LECIE1-.LSCIE1 +.LSCIE1: + .long 0 + .byte 0x3 + .string "zR" + .uleb128 0x1 + .sleb128 -8 + .uleb128 0x10 + .uleb128 0x1 + .byte 0x3 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x90 + .uleb128 0x1 + .align 4 +.LECIE1: +.LSFDE1: + .long .LEFDE1-.LASFDE1 +.LASFDE1: + .long .LASFDE1-.Lframe1 + .long .LFB0 + .long .LFE0-.LFB0 + .uleb128 0 + .byte 0x4 + .long .LCFI0-.LFB0 + .byte 0xe + .uleb128 0x10 + .byte 0x86 + .uleb128 0x2 + .byte 0x4 + .long .LCFI1-.LCFI0 + .byte 0xd + .uleb128 0x6 + .byte 0x4 + .long .LCFI2-.LCFI1 + .byte 0x8e + .uleb128 0x3 + .byte 0x4 + .long .LCFI3-.LCFI2 + .byte 0xa + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI4-.LCFI3 + .byte 0xb + .byte 0x4 + .long .LCFI5-.LCFI4 + .byte 0xa + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x4 + .long .LCFI6-.LCFI5 + .byte 0xb + .align 4 +.LEFDE1: + .ident "GCC: (GNU) 5.4.0" + .section .note.GNU-stack,"",@progbits diff --git a/vacall/vacall-x86_64.c b/vacall/vacall-x86_64.c new file mode 100644 index 0000000..5d50a04 --- /dev/null +++ b/vacall/vacall-x86_64.c @@ -0,0 +1,234 @@ +/* vacall function for x86_64 CPU with the Unix ABI ('gcc -mabi=sysv') */ + +/* + * Copyright 1995-2017 Bruno Haible + * + * 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, see . + */ + +#include "vacall-internal.h" + +#ifdef REENTRANT +#define vacall_receiver callback_receiver +register struct { void (*vacall_function) (void*,va_alist); void* arg; } + * env __asm__("r10"); +#endif + +/*register __vaword iarg1 __asm__("rdi");*/ +/*register __vaword iarg2 __asm__("rsi");*/ +/*register __vaword iarg3 __asm__("rdx");*/ +/*register __vaword iarg4 __asm__("rcx");*/ +/*register __vaword iarg5 __asm__("r8");*/ +/*register __vaword iarg6 __asm__("r9");*/ + +register double farg1 __asm__("xmm0"); +register double farg2 __asm__("xmm1"); +register double farg3 __asm__("xmm2"); +register double farg4 __asm__("xmm3"); +register double farg5 __asm__("xmm4"); +register double farg6 __asm__("xmm5"); +register double farg7 __asm__("xmm6"); +register double farg8 __asm__("xmm7"); + +register __vaword iret __asm__("rax"); +register __vaword iret2 __asm__("rdx"); +register float fret __asm__("xmm0"); +register double dret __asm__("xmm0"); + +/* + * Tell gcc to not use the call-saved registers %rbx, %rbp. + * This ensures that the return sequence does not need to restore registers + * from the stack. + */ +register void* dummy1 __asm__("%rbx"); +#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 9) +register void* dummy2 __asm__("%rbp"); +#endif + +#ifdef REENTRANT +static +#endif +void /* the return type is variable, not void! */ +vacall_receiver (__vaword word1, __vaword word2, __vaword word3, __vaword word4, + __vaword word5, __vaword word6, + __vaword firstword) +{ + __va_alist list; + /* Move the arguments passed in registers to temp storage. */ + list.iarg[0] = word1; + list.iarg[1] = word2; + list.iarg[2] = word3; + list.iarg[3] = word4; + list.iarg[4] = word5; + list.iarg[5] = word6; + list.farg[0] = farg1; + list.farg[1] = farg2; + list.farg[2] = farg3; + list.farg[3] = farg4; + list.farg[4] = farg5; + list.farg[5] = farg6; + list.farg[6] = farg7; + list.farg[7] = farg8; + /* Prepare the va_alist. */ + list.flags = 0; + list.aptr = (long)&firstword; + list.raddr = (void*)0; + list.rtype = __VAvoid; + list.ianum = 0; + list.fanum = 0; + /* Call vacall_function. The macros do all the rest. */ +#ifndef REENTRANT + (*vacall_function) (&list); +#else /* REENTRANT */ + (*env->vacall_function) (env->arg,&list); +#endif + /* Put return value into proper register. */ + if (list.rtype == __VAvoid) { + } else + if (list.rtype == __VAchar) { + iret = list.tmp._char; + } else + if (list.rtype == __VAschar) { + iret = list.tmp._schar; + } else + if (list.rtype == __VAuchar) { + iret = list.tmp._uchar; + } else + if (list.rtype == __VAshort) { + iret = list.tmp._short; + } else + if (list.rtype == __VAushort) { + iret = list.tmp._ushort; + } else + if (list.rtype == __VAint) { + iret = list.tmp._int; + } else + if (list.rtype == __VAuint) { + iret = list.tmp._uint; + } else + if (list.rtype == __VAlong) { + iret = list.tmp._long; + } else + if (list.rtype == __VAulong) { + iret = list.tmp._ulong; + } else + if (list.rtype == __VAlonglong) { +#ifdef __x86_64_x32__ + iret = list.tmp._longlong; +#else + iret = list.tmp._long; +#endif + } else + if (list.rtype == __VAulonglong) { +#ifdef __x86_64_x32__ + iret = list.tmp._ulonglong; +#else + iret = list.tmp._ulong; +#endif + } else + if (list.rtype == __VAfloat) { + fret = list.tmp._float; + } else + if (list.rtype == __VAdouble) { + dret = list.tmp._double; + } else + if (list.rtype == __VAvoidp) { +#ifdef __x86_64_x32__ + /* The x86_64 ABI, section 10.1, specifies that pointers are zero-extended + from 32 bits to 64 bits. */ + iret = (unsigned long long)(unsigned long)list.tmp._ptr; +#else + iret = (long)list.tmp._ptr; +#endif + } else + if (list.rtype == __VAstruct) { + if (list.flags & __VA_REGISTER_STRUCT_RETURN) { + /* Return structs of size <= 16 in registers. */ + if (list.rsize > 0 && list.rsize <= 16) { + #if 0 /* Unoptimized */ + iret = (__vaword)((unsigned char *) list.raddr)[0]; + if (list.rsize >= 2) + iret |= (__vaword)((unsigned char *) list.raddr)[1] << 8; + if (list.rsize >= 3) + iret |= (__vaword)((unsigned char *) list.raddr)[2] << 16; + if (list.rsize >= 4) + iret |= (__vaword)((unsigned char *) list.raddr)[3] << 24; + if (list.rsize >= 5) + iret |= (__vaword)((unsigned char *) list.raddr)[4] << 32; + if (list.rsize >= 6) + iret |= (__vaword)((unsigned char *) list.raddr)[5] << 40; + if (list.rsize >= 7) + iret |= (__vaword)((unsigned char *) list.raddr)[6] << 48; + if (list.rsize >= 8) + iret |= (__vaword)((unsigned char *) list.raddr)[7] << 56; + if (list.rsize >= 9) { + iret2 = (__vaword)((unsigned char *) list.raddr)[8]; + if (list.rsize >= 10) + iret2 |= (__vaword)((unsigned char *) list.raddr)[9] << 8; + if (list.rsize >= 11) + iret2 |= (__vaword)((unsigned char *) list.raddr)[10] << 16; + if (list.rsize >= 12) + iret2 |= (__vaword)((unsigned char *) list.raddr)[11] << 24; + if (list.rsize >= 13) + iret2 |= (__vaword)((unsigned char *) list.raddr)[12] << 32; + if (list.rsize >= 14) + iret2 |= (__vaword)((unsigned char *) list.raddr)[13] << 40; + if (list.rsize >= 15) + iret2 |= (__vaword)((unsigned char *) list.raddr)[14] << 48; + if (list.rsize >= 16) + iret2 |= (__vaword)((unsigned char *) list.raddr)[15] << 56; + } + #else /* Optimized: fewer conditional jumps, fewer memory accesses */ + uintptr_t count = list.rsize; /* > 0, ≤ 2*sizeof(__vaword) */ + __vaword* wordaddr = (__vaword*)((uintptr_t)list.raddr & ~(uintptr_t)(sizeof(__vaword)-1)); + uintptr_t start_offset = (uintptr_t)list.raddr & (uintptr_t)(sizeof(__vaword)-1); /* ≥ 0, < sizeof(__vaword) */ + uintptr_t end_offset = start_offset + count; /* > 0, < 3*sizeof(__vaword) */ + if (count <= sizeof(__vaword)) { + /* Assign iret. */ + if (end_offset <= sizeof(__vaword)) { + /* 0 < end_offset ≤ sizeof(__vaword) */ + __vaword mask0 = ((__vaword)2 << (end_offset*8-1)) - 1; + iret = (wordaddr[0] & mask0) >> (start_offset*8); + } else { + /* sizeof(__vaword) < end_offset < 2*sizeof(__vaword), start_offset > 0 */ + __vaword mask1 = ((__vaword)2 << (end_offset*8-sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | ((wordaddr[1] & mask1) << (sizeof(__vaword)*8-start_offset*8)); + } + } else { + /* Assign iret, iret2. */ + if (end_offset <= 2*sizeof(__vaword)) { + /* sizeof(__vaword) < end_offset ≤ 2*sizeof(__vaword) */ + __vaword mask1 = ((__vaword)2 << (end_offset*8-sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | ((wordaddr[1] & mask1) << (sizeof(__vaword)*4-start_offset*4) << (sizeof(__vaword)*4-start_offset*4)); + iret2 = (wordaddr[1] & mask1) >> (start_offset*8); + } else { + /* 2*sizeof(__vaword) < end_offset < 3*sizeof(__vaword), start_offset > 0 */ + __vaword mask2 = ((__vaword)2 << (end_offset*8-2*sizeof(__vaword)*8-1)) - 1; + iret = (wordaddr[0] >> (start_offset*8)) | (wordaddr[1] << (sizeof(__vaword)*8-start_offset*8)); + iret2 = (wordaddr[1] >> (start_offset*8)) | ((wordaddr[2] & mask2) << (sizeof(__vaword)*8-start_offset*8)); + } + } + #endif + } + } + } +} + +#ifdef REENTRANT +__vacall_r_t +callback_get_receiver (void) +{ + return (__vacall_r_t)(void*)&callback_receiver; +} +#endif diff --git a/vacall/vacall.3 b/vacall/vacall.3 new file mode 100644 index 0000000..2737b2c --- /dev/null +++ b/vacall/vacall.3 @@ -0,0 +1,295 @@ +.\" Copyright (C) 1995-2017 Bruno Haible +.\" +.\" This manual is free documentation. It is dually licensed under the +.\" GNU FDL and the GNU GPL. This means that you can redistribute this +.\" manual under either of these two licenses, at your choice. +.\" +.\" This manual is covered by the GNU FDL. Permission is granted to copy, +.\" distribute and/or modify this document under the terms of the +.\" GNU Free Documentation License (FDL), either version 1.2 of the +.\" License, or (at your option) any later version published by the +.\" Free Software Foundation (FSF); with no Invariant Sections, with no +.\" Front-Cover Text, and with no Back-Cover Texts. +.\" A copy of the license is at . +.\" +.\" This manual is covered by the GNU GPL. You can redistribute it and/or +.\" modify it under the terms of the GNU General Public License (GPL), either +.\" version 2 of the License, or (at your option) any later version published +.\" by the Free Software Foundation (FSF). +.\" A copy of the license is at . +.\" +.TH VACALL 3 "1 January 2017" +.SH NAME +vacall \- C functions called with variable arguments +.SH SYNOPSIS +.B #include +.LP +.B extern void* vacall_function; +.LP +.nf +.BI "void " function " (va_alist" alist ")" +.BI "{" +.BI " va_start_" type "(" alist "[, " return_type "]);" +.BI " " arg " = va_arg_" type "(" alist "[, " arg_type "]);" +.BI " va_return_" type "(" alist "[[, " return_type "], " return_value "]);" +.BI "}" +.fi +.LP +.BI "vacall_function = " "&function" ";" +.LP +.IB "val" " = ((" return_type " (*) ()) vacall) (" arg1 , arg2 , ... ");" +.SH DESCRIPTION +This set of macros permit a C function +.I function +to be called with variable arguments and to return variable return values. +This is much like the +.BR stdarg (3) +facility, but also allows the return value to be specified at run time. + +Function calling conventions differ considerably on different machines, and +.I vacall +attempts to provide some degree of isolation from such architecture +dependencies. + +The function that can be called with any number and type of arguments +and which will return any type of return value is +.BR vacall . +It will do some magic and call the function stored in the variable +.BR vacall_function . +If you want to make more than one use of +.IR vacall , +use the +.IR trampoline (3) +facility to store +.I &function +into +.B vacall_function +just before calling +.BR vacall . + +Within +.IR function , +the following macros can be used to walk through the argument list and +specify a return value: +.RS 0 +.TP +.BI "va_start_" type "(" alist "[, " return_type "]);" +starts the walk through the argument list and specifies the return type. +.TP +.IB arg " = va_arg_" type "(" alist "[, " arg_type "]);" +fetches the next argument from the argument list. +.TP +.BI "va_return_" type "(" alist "[[, " return_type "], " return_value "]);" +ends the walk through the argument list and specifies the return value. +.RE + +The +.I type +in +.BI va_start_ type +and +.BI va_return_ type +shall be one of +.BR void ", " int ", " uint ", " long ", " ulong ", " longlong ", " ulonglong ", " double ", " struct ", " ptr +or (for ANSI C calling conventions only) +.BR char ", " schar ", " uchar ", " short ", " ushort ", " float , +depending on the class of +.IR return_type . + +The +.I type +specifiers in +.BI va_start_ type +and +.BI va_return_ type +must be the same. +The +.I return_type +specifiers passed to +.BI va_start_ type +and +.BI va_return_ type +must be the same. + +The +.I type +in +.BI va_arg_ type +shall be one of +.BR int ", " uint ", " long ", " ulong ", " longlong ", " ulonglong ", " double ", " struct ", " ptr +or (for ANSI C calling conventions only) +.BR char ", " schar ", " uchar ", " short ", " ushort ", " float , +depending on the class of +.IR arg_type . + +In +.BI "va_start_struct(" alist ", " return_type ", " splittable ); +the +.I splittable +flag specifies whether the struct +.I return_type +can be returned in registers such that every struct field fits entirely in +a single register. This needs to be specified for structs of size +2*sizeof(long). For structs of size <= sizeof(long), +.I splittable +is ignored and assumed to be 1. For structs of size > 2*sizeof(long), +.I splittable +is ignored and assumed to be 0. There are some handy macros for this: +.nf +.BI "va_word_splittable_1 (" type1 ) +.BI "va_word_splittable_2 (" type1 ", " type2 ) +.BI "va_word_splittable_3 (" type1 ", " type2 ", " type3 ) +.BI "va_word_splittable_4 (" type1 ", " type2 ", " type3 ", " type4 ) +.fi +For a struct with three slots +.nf +.BI "struct { " "type1 id1" "; " "type2 id2" "; " "type3 id3" "; }" +.fi +you can specify +.I splittable +as +.BI "va_word_splittable_3 (" type1 ", " type2 ", " type3 ) +.RB . + +.SH NOTES + +Functions which want to emulate Kernighan & Ritchie style functions (i.e., +in ANSI C, functions without a typed argument list) cannot use the +.I type +values +.BR char ", " schar ", " uchar ", " short ", " ushort ", " float . +As prescribed by the default K&R C expression promotions, they have +to use +.B int +instead of +.BR char ", " schar ", " uchar ", " short ", " ushort +and +.B double +instead of +.BR float . + +The macros +.BR va_start_longlong(\|) , +.BR va_start_ulonglong(\|) , +.BR va_return_longlong(\|) , +.BR va_return_ulonglong(\|) , +.B va_arg_longlong(\|) +and +.B va_arg_ulonglong(\|) +work only if the C compiler has a working +.B long long +64-bit integer type. + +The struct types used in +.B va_start_struct(\|) +and +.B va_struct(\|) +must only contain (signed or unsigned) int, long, long long or pointer fields. +Struct types containing (signed or unsigned) char, short, float, double or +other structs are not supported. + +.SH EXAMPLE + +This example, a possible implementation of +.BR execl (3) +on top of +.BR execv (2) +using +.BR stdarg (3), + +.nf +.ft B +#include +#define MAXARGS 100 +/* execl is called by execl(file, arg1, arg2, ..., (char *)0); */ +int execl (...) +{ + va_list ap; + char* file; + char* args[MAXARGS]; + int argno = 0; + va_start (ap); + file = va_arg(ap, char*); + while ((args[argno] = va_arg(ap, char*)) != (char *)0) + argno++; + va_end (ap); + return execv(file, args); +} +.ft +.fi + +looks like this using +.BR vacall (3): + +.nf +.ft B +#include +#define MAXARGS 100 +/* execl is called by vacall(file, arg1, arg2, ..., (char *)0); */ +void execl (va_alist ap) +{ + char* file; + char* args[MAXARGS]; + int argno = 0; + int retval; + va_start_int (ap); + file = va_arg_ptr(ap, char*); + while ((args[argno] = va_arg_ptr(ap, char*)) != (char *)0) + argno++; + retval = execv(file, args); + va_return_int (ap, retval); +} +vacall_function = &execl; +.ft +.fi + +.SH SEE ALSO +.BR stdarg (3), +.BR trampoline (3), +.BR callback (3). + +.SH BUGS + +The current implementations have been tested on a selection of common +cases but there are probably still many bugs. + +There are typically built-in limits on the size of the argument-list, +which may also include the size of any structure arguments. + +The decision whether a struct is to be returned in registers or in memory +considers only the struct's size and alignment. This is inaccurate: for +example, gcc on m68k-next returns +.B "struct { char a,b,c; }" +in registers and +.B "struct { char a[3]; }" +in memory, although both types have the same size and the same alignment. + +The argument list can only be walked once. + +The use of the global variable +.B vacall_function +is not reentrant. This is fixed in the +.BR callback (3) +package. + +.SH PORTING + +Knowledge about argument passing conventions can be found in the gcc +source, file +.RI gcc-2.6.3/config/ cpu / cpu .h, +section "Stack layout; function entry, exit and calling." + +The implementation of varargs for gcc can be found in the gcc source, files +gcc-2.6.3/ginclude/va*.h. + +gcc's __builtin_saveregs() function is defined in the gcc source, file +gcc-2.6.3/libgcc2.c. + +.SH AUTHOR + +Bruno Haible + +.SH ACKNOWLEDGEMENTS + +Many ideas and a lot of code were cribbed from the gcc source. + diff --git a/vacall/vacall.h b/vacall/vacall.h new file mode 100644 index 0000000..9485356 --- /dev/null +++ b/vacall/vacall.h @@ -0,0 +1,457 @@ +/* + * Copyright 1995-2019 Bruno Haible + * + * 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, see . + */ + +#ifndef _VACALL_H +#define _VACALL_H + +#include + +#include "ffcall-version.h" +#include "ffcall-abi.h" + + +/* Determine whether the current ABI is LLP64 + ('long' = 32-bit, 'long long' = 'void*' = 64-bit). */ +#if defined(__x86_64__) && defined(_WIN32) && !defined(__CYGWIN__) +#define __VA_LLP64 1 +#endif + +/* Determine the alignment of a type at compile time. + */ +#if defined(__GNUC__) || defined(__IBM__ALIGNOF__) +#define __VA_alignof __alignof__ +#elif defined(__cplusplus) +template struct __VA_alignof_helper { char __slot1; type __slot2; }; +#define __VA_alignof(type) offsetof (__VA_alignof_helper, __slot2) +#elif defined(__mips__) || defined(__mipsn32__) || defined(__mips64__) /* SGI compiler */ +#define __VA_alignof __builtin_alignof +#else +#define __VA_offsetof(type,ident) ((unsigned long)&(((type*)0)->ident)) +#define __VA_alignof(type) __VA_offsetof(struct { char __slot1; type __slot2; }, __slot2) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* C builtin types. + */ +#if defined(__mipsn32__) || defined(__x86_64_x32__) || defined(__VA_LLP64) +typedef long long __vaword; +#else +typedef long __vaword; +#endif + +enum __VAtype +{ + __VAvoid, + __VAchar, + __VAschar, + __VAuchar, + __VAshort, + __VAushort, + __VAint, + __VAuint, + __VAlong, + __VAulong, + __VAlonglong, + __VAulonglong, + __VAfloat, + __VAdouble, + __VAvoidp, + __VAstruct +}; + +enum __VA_alist_flags +{ + + /* how to return structs */ + /* There are basically 3 ways to return structs: + * a. The called function returns a pointer to static data. Not reentrant. + * Not supported any more. + * b. The caller passes the return structure address in a dedicated register + * or as a first (or last), invisible argument. The called function stores + * its result there. + * c. Like b, and the called function also returns the return structure + * address in the return value register. (This is not very distinguishable + * from b.) + * Independently of this, + * r. small structures (<= 4 or <= 8 bytes) may be returned in the return + * value register(s), or + * m. even small structures are passed in memory. + */ + /* gcc-2.6.3 employs the following strategy: + * - If PCC_STATIC_STRUCT_RETURN is defined in the machine description + * it uses method a, else method c. + * - If flag_pcc_struct_return is set (either by -fpcc-struct-return or if + * DEFAULT_PCC_STRUCT_RETURN is defined to 1 in the machine description) + * it uses method m, else (either by -freg-struct-return or if + * DEFAULT_PCC_STRUCT_RETURN is defined to 0 in the machine description) + * method r. + */ + __VA_SMALL_STRUCT_RETURN = 1<<1, /* r: special case for small structs */ + __VA_GCC_STRUCT_RETURN = 1<<2, /* consider 8 byte structs as small */ +#if defined(__sparc__) && !defined(__sparc64__) + __VA_SUNCC_STRUCT_RETURN = 1<<3, + __VA_SUNPROCC_STRUCT_RETURN = 1<<4, +#else + __VA_SUNCC_STRUCT_RETURN = 0, + __VA_SUNPROCC_STRUCT_RETURN = 0, +#endif +#if defined(__i386__) + __VA_MSVC_STRUCT_RETURN = 1<<4, +#endif + /* the default way to return structs */ + /* This choice here is based on the assumption that the function you are + * going to call has been compiled with the same compiler you are using to + * include this file. + * If you want to call functions with another struct returning convention, + * just #define __VA_STRUCT_RETURN ... + * before or after #including . + */ +#ifndef __VA_STRUCT_RETURN + __VA_STRUCT_RETURN = +#if defined(__sparc__) && !defined(__sparc64__) && defined(__sun) && (defined(__SUNPRO_C) || defined(__SUNPRO_CC)) /* SUNWspro cc or CC */ + __VA_SUNPROCC_STRUCT_RETURN, +#else +#if (defined(__i386__) && (defined(_WIN32) || defined(__CYGWIN__) || (defined(__MACH__) && defined(__APPLE__)) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__))) || defined(__m68k__) || defined(__mipsn32__) || defined(__mips64__) || defined(__sparc64__) || defined(__hppa__) || defined(__hppa64__) || defined(__arm__) || defined(__armhf__) || defined(__arm64__) || defined(__powerpc64_elfv2__) || defined(__ia64__) || defined(__x86_64__) || defined(__riscv32__) || defined(__riscv64__) + __VA_SMALL_STRUCT_RETURN | +#endif +#if defined(__GNUC__) && !((defined(__mipsn32__) || defined(__mips64__)) && ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ > 3))) + __VA_GCC_STRUCT_RETURN | +#endif +#if defined(__i386__) && defined(_WIN32) && !defined(__CYGWIN__) /* native Windows */ + __VA_MSVC_STRUCT_RETURN | +#endif + 0, +#endif +#endif + + /* how to return floats */ +#if defined(__m68k__) || (defined(__sparc__) && !defined(__sparc64__)) + __VA_SUNCC_FLOAT_RETURN = 1<<5, +#endif +#if defined(__m68k__) + __VA_FREG_FLOAT_RETURN = 1<<6, +#endif + /* the default way to return floats */ + /* This choice here is based on the assumption that the function you are + * going to call has been compiled with the same compiler you are using to + * include this file. + * If you want to call functions with another float returning convention, + * just #define __VA_FLOAT_RETURN ... + * before or after #including . + */ +#ifndef __VA_FLOAT_RETURN +#if (defined(__m68k__) || (defined(__sparc__) && !defined(__sparc64__))) && !defined(__GNUC__) && defined(__sun) && !(defined(__SUNPRO_C) || defined(__SUNPRO_CC)) /* Sun cc or CC */ + __VA_FLOAT_RETURN = __VA_SUNCC_FLOAT_RETURN, +#elif defined(__m68k__) + __VA_FLOAT_RETURN = __VA_FREG_FLOAT_RETURN, +#else + __VA_FLOAT_RETURN = 0, +#endif +#endif + + /* how to pass structs */ +#if defined(__mips__) || defined(__mipsn32__) || defined(__mips64__) + __VA_SGICC_STRUCT_ARGS = 1<<7, +#endif +#if defined(__powerpc__) || defined(__powerpc64__) + __VA_AIXCC_STRUCT_ARGS = 1<<7, +#endif +#if defined(__ia64__) + __VA_OLDGCC_STRUCT_ARGS = 1<<7, +#endif + /* the default way to pass structs */ + /* This choice here is based on the assumption that the function you are + * going to call has been compiled with the same compiler you are using to + * include this file. + * If you want to call functions with another structs passing convention, + * just #define __VA_STRUCT_ARGS ... + * before or after #including . + */ +#ifndef __VA_STRUCT_ARGS +#if (defined(__mips__) && !defined(__mipsn32__) && !defined(__mips64__)) && !defined(__GNUC__) /* SGI mips cc */ + __VA_STRUCT_ARGS = __VA_SGICC_STRUCT_ARGS, +#else +#if (defined(__mipsn32__) || defined(__mips64__)) && (!defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ > 3)) /* SGI mips cc or gcc >= 3.4 */ + __VA_STRUCT_ARGS = __VA_SGICC_STRUCT_ARGS, +#else +#if defined(__powerpc__) && !defined(__powerpc64__) && defined(_AIX) && !defined(__GNUC__) /* AIX 32-bit cc, xlc */ + __VA_STRUCT_ARGS = __VA_AIXCC_STRUCT_ARGS, +#else +#if defined(__powerpc64__) && defined(_AIX) /* AIX 64-bit cc, xlc, gcc */ + __VA_STRUCT_ARGS = __VA_AIXCC_STRUCT_ARGS, +#else +#if defined(__ia64__) && !(defined(__GNUC__) && (__GNUC__ >= 3)) + __VA_STRUCT_ARGS = __VA_OLDGCC_STRUCT_ARGS, +#else + __VA_STRUCT_ARGS = 0, +#endif +#endif +#endif +#endif +#endif +#endif + + /* how to pass floats */ + /* ANSI C compilers and GNU gcc pass floats as floats. + * K&R C compilers pass floats as doubles. We don't support them any more. + */ +#if defined(__powerpc64__) + __VA_AIXCC_FLOAT_ARGS = 1<<8, /* pass floats in the low 4 bytes of an 8-bytes word */ +#endif + /* the default way to pass floats */ + /* This choice here is based on the assumption that the function you are + * going to call has been compiled with the same compiler you are using to + * include this file. + * If you want to call functions with another float passing convention, + * just #define __VA_FLOAT_ARGS ... + * before or after #including . + */ +#ifndef __VA_FLOAT_ARGS +#if defined(__powerpc64__) && defined(_AIX) && !defined(__GNUC__) /* AIX 64-bit xlc */ + __VA_FLOAT_ARGS = __VA_AIXCC_FLOAT_ARGS, +#else + __VA_FLOAT_ARGS = 0, +#endif +#endif + + /* how to pass and return small integer arguments */ + __VA_ANSI_INTEGERS = 0, /* no promotions */ + __VA_TRADITIONAL_INTEGERS = 0, /* promote [u]char, [u]short to [u]int */ + /* Fortunately these two methods are compatible. Our macros work with both. */ + + /* stack cleanup policy */ + __VA_CDECL_CLEANUP = 0, /* caller pops args after return */ + __VA_STDCALL_CLEANUP = 1<<9, /* callee pops args before return */ + /* currently only supported on __i386__ */ +#ifndef __VA_CLEANUP + __VA_CLEANUP = __VA_CDECL_CLEANUP, +#endif + + /* These are for internal use only */ +#if defined(__i386__) || defined(__m68k__) || defined(__mipsn32__) || defined(__mips64__) || defined(__sparc64__) || defined(__alpha__) || defined(__hppa64__) || defined(__arm__) || defined(__armhf__) || defined(__arm64__) || defined(__powerpc__) || defined(__powerpc64__) || defined(__ia64__) || defined(__x86_64__) || (defined(__s390__) && !defined(__s390x__)) || defined(__riscv64__) + __VA_REGISTER_STRUCT_RETURN = 1<<10, +#endif +#if defined(__mipsn32__) || defined(__mips64__) + __VA_REGISTER_FLOATSTRUCT_RETURN = 1<<11, + __VA_REGISTER_DOUBLESTRUCT_RETURN = 1<<12, +#endif + + __VA_flag_for_broken_compilers_that_dont_like_trailing_commas +}; + +/* + * Definition of the ‘va_alist’ type. + */ +struct vacall_alist; +typedef struct vacall_alist * va_alist; + + +/* + * Definition of the va_start_xxx macros. + */ +#define __VA_START_FLAGS \ + __VA_STRUCT_RETURN | __VA_FLOAT_RETURN | __VA_STRUCT_ARGS | __VA_FLOAT_ARGS | __VA_CLEANUP + +extern void vacall_start (va_alist /* LIST */, int /* RETTYPE */, int /* FLAGS */); + +#define va_start_void(LIST) vacall_start(LIST,__VAvoid, __VA_START_FLAGS) +#define va_start_char(LIST) vacall_start(LIST,__VAchar, __VA_START_FLAGS) +#define va_start_schar(LIST) vacall_start(LIST,__VAschar, __VA_START_FLAGS) +#define va_start_uchar(LIST) vacall_start(LIST,__VAuchar, __VA_START_FLAGS) +#define va_start_short(LIST) vacall_start(LIST,__VAshort, __VA_START_FLAGS) +#define va_start_ushort(LIST) vacall_start(LIST,__VAushort, __VA_START_FLAGS) +#define va_start_int(LIST) vacall_start(LIST,__VAint, __VA_START_FLAGS) +#define va_start_uint(LIST) vacall_start(LIST,__VAuint, __VA_START_FLAGS) +#define va_start_long(LIST) vacall_start(LIST,__VAlong, __VA_START_FLAGS) +#define va_start_ulong(LIST) vacall_start(LIST,__VAulong, __VA_START_FLAGS) +#define va_start_longlong(LIST) vacall_start(LIST,__VAlonglong, __VA_START_FLAGS) +#define va_start_ulonglong(LIST) vacall_start(LIST,__VAulonglong,__VA_START_FLAGS) +#define va_start_float(LIST) vacall_start(LIST,__VAfloat, __VA_START_FLAGS) +#define va_start_double(LIST) vacall_start(LIST,__VAdouble, __VA_START_FLAGS) +#define va_start_ptr(LIST,TYPE) vacall_start(LIST,__VAvoidp, __VA_START_FLAGS) + +/* + * va_start_struct: Preparing structure return. + */ +extern void vacall_start_struct (va_alist /* LIST */, size_t /* TYPE_SIZE */, size_t /* TYPE_ALIGN */, int /* TYPE_SPLITTABLE */, int /* FLAGS */); + +#define va_start_struct(LIST,TYPE,TYPE_SPLITTABLE) \ + _va_start_struct(LIST,sizeof(TYPE),__VA_alignof(TYPE),TYPE_SPLITTABLE) +/* _va_start_struct() is like va_start_struct(), except that you pass + * the type's size and alignment instead of the type itself. + * Undocumented, but used by GNU clisp. + */ +#define _va_start_struct(LIST,TYPE_SIZE,TYPE_ALIGN,TYPE_SPLITTABLE) \ + vacall_start_struct(LIST,TYPE_SIZE,TYPE_ALIGN,TYPE_SPLITTABLE,__VA_START_FLAGS) + + +/* + * Definition of the va_arg_xxx macros. + */ + +extern char vacall_arg_char (va_alist /* LIST */); +extern signed char vacall_arg_schar (va_alist /* LIST */); +extern unsigned char vacall_arg_uchar (va_alist /* LIST */); +extern short vacall_arg_short (va_alist /* LIST */); +extern unsigned short vacall_arg_ushort (va_alist /* LIST */); +extern int vacall_arg_int (va_alist /* LIST */); +extern unsigned int vacall_arg_uint (va_alist /* LIST */); +extern long vacall_arg_long (va_alist /* LIST */); +extern unsigned long vacall_arg_ulong (va_alist /* LIST */); + +#define va_arg_char(LIST) vacall_arg_char(LIST) +#define va_arg_schar(LIST) vacall_arg_schar(LIST) +#define va_arg_uchar(LIST) vacall_arg_uchar(LIST) +#define va_arg_short(LIST) vacall_arg_short(LIST) +#define va_arg_ushort(LIST) vacall_arg_ushort(LIST) +#define va_arg_int(LIST) vacall_arg_int(LIST) +#define va_arg_uint(LIST) vacall_arg_uint(LIST) +#define va_arg_long(LIST) vacall_arg_long(LIST) +#define va_arg_ulong(LIST) vacall_arg_ulong(LIST) + +extern long long vacall_arg_longlong (va_alist /* LIST */); +extern unsigned long long vacall_arg_ulonglong (va_alist /* LIST */); + +#define va_arg_longlong(LIST) vacall_arg_longlong(LIST) +#define va_arg_ulonglong(LIST) vacall_arg_ulonglong(LIST) + +/* Floating point arguments. */ + +extern float vacall_arg_float (va_alist /* LIST */); +extern double vacall_arg_double (va_alist /* LIST */); + +#define va_arg_float(LIST) vacall_arg_float(LIST) +#define va_arg_double(LIST) vacall_arg_double(LIST) + +/* Pointer arguments. */ + +extern void* vacall_arg_ptr (va_alist /* LIST */); +#define va_arg_ptr(LIST,TYPE) ((TYPE)vacall_arg_ptr(LIST)) + +/* Structure arguments. */ + +extern void* vacall_arg_struct (va_alist /* LIST */, size_t /* TYPE_SIZE */, size_t /* TYPE_ALIGN */); + +#define va_arg_struct(LIST,TYPE) \ + *(TYPE*)vacall_arg_struct(LIST,sizeof(TYPE),__VA_alignof(TYPE)) +/* _va_arg_struct() is like va_arg_struct(), except that you pass the type's + * size and alignment instead of the type and get the value's address instead + * of the value itself. + * Undocumented, but used by GNU clisp. + */ +#define _va_arg_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ + vacall_arg_struct(LIST,TYPE_SIZE,TYPE_ALIGN) + + +/* + * Definition of the va_return_xxx macros. + */ + +extern void vacall_return_void (va_alist /* LIST */); +#define va_return_void(LIST) vacall_return_void(LIST) + +extern void vacall_return_char (va_alist /* LIST */, char /* VAL */); +extern void vacall_return_schar (va_alist /* LIST */, signed char /* VAL */); +extern void vacall_return_uchar (va_alist /* LIST */, unsigned char /* VAL */); +extern void vacall_return_short (va_alist /* LIST */, short /* VAL */); +extern void vacall_return_ushort (va_alist /* LIST */, unsigned short /* VAL */); +extern void vacall_return_int (va_alist /* LIST */, int /* VAL */); +extern void vacall_return_uint (va_alist /* LIST */, unsigned int /* VAL */); +extern void vacall_return_long (va_alist /* LIST */, long /* VAL */); +extern void vacall_return_ulong (va_alist /* LIST */, unsigned long /* VAL */); +#define va_return_char(LIST,VAL) vacall_return_char(LIST,VAL) +#define va_return_schar(LIST,VAL) vacall_return_schar(LIST,VAL) +#define va_return_uchar(LIST,VAL) vacall_return_uchar(LIST,VAL) +#define va_return_short(LIST,VAL) vacall_return_short(LIST,VAL) +#define va_return_ushort(LIST,VAL) vacall_return_ushort(LIST,VAL) +#define va_return_int(LIST,VAL) vacall_return_int(LIST,VAL) +#define va_return_uint(LIST,VAL) vacall_return_uint(LIST,VAL) +#define va_return_long(LIST,VAL) vacall_return_long(LIST,VAL) +#define va_return_ulong(LIST,VAL) vacall_return_ulong(LIST,VAL) + +extern void vacall_return_longlong (va_alist /* LIST */, long long /* VAL */); +extern void vacall_return_ulonglong (va_alist /* LIST */, unsigned long long /* VAL */); +#define va_return_longlong(LIST,VAL) vacall_return_longlong(LIST,VAL) +#define va_return_ulonglong(LIST,VAL) vacall_return_ulonglong(LIST,VAL) + +extern void vacall_return_float (va_alist /* LIST */, float /* VAL */); +extern void vacall_return_double (va_alist /* LIST */, double /* VAL */); +#define va_return_float(LIST,VAL) vacall_return_float(LIST,VAL) +#define va_return_double(LIST,VAL) vacall_return_double(LIST,VAL) + +extern void vacall_return_ptr (va_alist /* LIST */, void* /* VAL */); +#define va_return_ptr(LIST,TYPE,VAL) vacall_return_ptr(LIST,(void*)(TYPE)(VAL)) + +extern void vacall_return_struct (va_alist /* LIST */, size_t /* TYPE_SIZE */, size_t /* TYPE_ALIGN */, const void* /* VAL_ADDR */); + +#define va_return_struct(LIST,TYPE,VAL) \ + _va_return_struct(LIST,sizeof(TYPE),__VA_alignof(TYPE),&(VAL)) +/* Undocumented, but used by GNU clisp. */ +#define _va_return_struct(LIST,TYPE_SIZE,TYPE_ALIGN,VAL_ADDR) \ + vacall_return_struct(LIST,TYPE_SIZE,TYPE_ALIGN,VAL_ADDR) + + +/* Determine whether a struct type is word-splittable, i.e. whether each of + * its components fit into a register. + * The entire computation is done at compile time. + */ +#define va_word_splittable_1(slot1) \ + (__va_offset1(slot1)/sizeof(__vaword) == (__va_offset1(slot1)+sizeof(slot1)-1)/sizeof(__vaword)) +#define va_word_splittable_2(slot1,slot2) \ + ((__va_offset1(slot1)/sizeof(__vaword) == (__va_offset1(slot1)+sizeof(slot1)-1)/sizeof(__vaword)) \ + && (__va_offset2(slot1,slot2)/sizeof(__vaword) == (__va_offset2(slot1,slot2)+sizeof(slot2)-1)/sizeof(__vaword)) \ + ) +#define va_word_splittable_3(slot1,slot2,slot3) \ + ((__va_offset1(slot1)/sizeof(__vaword) == (__va_offset1(slot1)+sizeof(slot1)-1)/sizeof(__vaword)) \ + && (__va_offset2(slot1,slot2)/sizeof(__vaword) == (__va_offset2(slot1,slot2)+sizeof(slot2)-1)/sizeof(__vaword)) \ + && (__va_offset3(slot1,slot2,slot3)/sizeof(__vaword) == (__va_offset3(slot1,slot2,slot3)+sizeof(slot3)-1)/sizeof(__vaword)) \ + ) +#define va_word_splittable_4(slot1,slot2,slot3,slot4) \ + ((__va_offset1(slot1)/sizeof(__vaword) == (__va_offset1(slot1)+sizeof(slot1)-1)/sizeof(__vaword)) \ + && (__va_offset2(slot1,slot2)/sizeof(__vaword) == (__va_offset2(slot1,slot2)+sizeof(slot2)-1)/sizeof(__vaword)) \ + && (__va_offset3(slot1,slot2,slot3)/sizeof(__vaword) == (__va_offset3(slot1,slot2,slot3)+sizeof(slot3)-1)/sizeof(__vaword)) \ + && (__va_offset4(slot1,slot2,slot3,slot4)/sizeof(__vaword) == (__va_offset4(slot1,slot2,slot3,slot4)+sizeof(slot4)-1)/sizeof(__vaword)) \ + ) +#define __va_offset1(slot1) \ + 0 +#define __va_offset2(slot1,slot2) \ + ((__va_offset1(slot1)+sizeof(slot1)+__VA_alignof(slot2)-1) & -(long)__VA_alignof(slot2)) +#define __va_offset3(slot1,slot2,slot3) \ + ((__va_offset2(slot1,slot2)+sizeof(slot2)+__VA_alignof(slot3)-1) & -(long)__VA_alignof(slot3)) +#define __va_offset4(slot1,slot2,slot3,slot4) \ + ((__va_offset3(slot1,slot2,slot3)+sizeof(slot3)+__VA_alignof(slot4)-1) & -(long)__VA_alignof(slot4)) + + +/* + * Miscellaneous declarations. + */ +#ifdef __cplusplus +extern "C" void (*vacall) (); /* the return type is variable, not void! */ +#else +extern void (*vacall) (); /* the return type is variable, not void! */ +#endif +extern void (* vacall_function) (va_alist); + + +#ifdef __cplusplus +} +#endif + +#endif /* _VACALL_H */ diff --git a/vacall/vacall.html b/vacall/vacall.html new file mode 100644 index 0000000..fa61554 --- /dev/null +++ b/vacall/vacall.html @@ -0,0 +1,315 @@ + + + + VACALL manual page + + +

VACALL manual page

+ + +

+ +


+ + +

Name

+
+ +vacall - C functions called with variable arguments + + +

Synopsis

+
+ +
+#include <vacall.h>
+
+

+

+extern void* vacall_function;
+
+

+

+void function (va_alist alist)
+{
+  va_start_type(alist[, return_type]);
+  arg = va_arg_type(alist[, arg_type]);
+  va_return_type(alist[[, return_type], return_value]);
+}
+
+

+

+vacall_function = &function;
+
+

+

+val = ((return_type (*) ()) vacall) (arg1,arg2,...);
+
+ + +

Description

+
+ +This set of macros permit a C function function to be +called with variable arguments and to return variable +return values. This is much like the stdarg(3) facility, +but also allows the return value to be specified at run +time. +

+Function calling conventions differ considerably on different +machines, and vacall attempts to provide some +degree of isolation from such architecture dependencies. +

+The function that can be called with any number and type +of arguments and which will return any type of return +value is vacall. It will do some magic and call the function +stored in the variable vacall_function. If you want +to make more than one use of vacall, +use the trampoline(3) +facility to store &function + into vacall_function just +before calling vacall. +

+Within function, the following macros can be used to walk +through the argument list and specify a return value: +

+

+va_start_type(alist[, return_type]);
+
+starts the walk through the argument list and specifies the return type. +

+

+arg = va_arg_type(alist[, arg_type]);
+
+fetches the next argument from the argument list. +

+

+va_return_type(alist[[, return_type], return_value]);
+
+ends the walk through the argument list and specifies the return value. +

+The type in va_start_type + and va_return_type shall be one +of void, int, uint, long, +ulong, longlong, ulonglong, +double, struct, ptr +or +(for ANSI C calling conventions only) +char, schar, uchar, +short, ushort, float, +depending on the class of return_type. +

+The type specifiers in +va_start_type and va_return_type + must be the same. +The return_type specifiers passed to +va_start_type and va_return_type + must be the same. +

+The type in va_arg_type +shall be one of int, uint, long, +ulong, longlong, ulonglong, +double, struct, ptr +or (for ANSI C calling conventions only) +char, schar, uchar, +short, ushort, float, +depending on the class of arg_type. +

+In va_start_struct(alist, return_type, splittable); the +splittable flag specifies whether the struct return_type can +be returned in registers such that every struct field fits +entirely in a single register. This needs to be specified +for structs of size 2*sizeof(long). For structs of size +<= sizeof(long), splittable is ignored and assumed to be 1. +For structs of size > 2*sizeof(long), splittable is +ignored and assumed to be 0. There are some handy macros +for this: +

+va_word_splittable_1 (type1)
+va_word_splittable_2 (type1, type2)
+va_word_splittable_3 (type1, type2, type3)
+va_word_splittable_4 (type1, type2, type3, type4)
+
+For a struct with three slots +
+struct { type1 id1; type2 id2; type3 id3; }
+
+you can specify splittable as +va_word_splittable_3 (type1, type2, type3). + + +

Notes

+
+ +
    +
  1. Functions which want to emulate Kernighan & Ritchie style +functions (i.e., in ANSI C, functions without a typed +argument list) cannot use the type values +char, schar, uchar, +short, ushort, float. +As prescribed by the default +K&R C expression promotions, they have to use int instead +of char, schar, uchar, +short, ushort and double instead of +float. +

    +

  2. The macros va_start_longlong(), +va_start_ulonglong(), va_return_longlong(), +va_return_ulonglong(), va_arg_longlong() and +va_arg_ulonglong() work only if the C compiler has a working +long long 64-bit integer type. +

    +

  3. The struct types used in va_start_struct() and +va_struct() must only contain (signed or unsigned) int, +long, long long or pointer fields. Struct types containing +(signed or unsigned) char, short, float, double or other +structs are not supported. +

    +

+ + +

Example

+
+ +This example, a possible implementation of execl(3) on top +of execv(2) using stdarg(3), +
#include <stdarg.h>
+#define MAXARGS 100
+/* execl is called by execl(file, arg1, arg2, ..., (char *)0); */
+int execl (...)
+{
+  va_list ap;
+  char* file;
+  char* args[MAXARGS];
+  int argno = 0;
+  va_start (ap);
+  file = va_arg(ap, char*);
+  while ((args[argno] = va_arg(ap, char*)) != (char *)0)
+    argno++;
+  va_end (ap);
+  return execv(file, args);
+}
+
+looks like this using vacall(3): +
#include <vacall.h>
+#define MAXARGS 100
+/* execl is called by vacall(file, arg1, arg2, ..., (char *)0); */
+void execl (va_alist ap)
+{
+  char* file;
+  char* args[MAXARGS];
+  int argno = 0;
+  int retval;
+  va_start_int (ap);
+  file = va_arg_ptr(ap, char*);
+  while ((args[argno] = va_arg_ptr(ap, char*)) != (char *)0)
+    argno++;
+  retval = execv(file, args);
+  va_return_int (ap, retval);
+}
+vacall_function = &execl;
+
+

+ + +

See also

+ + +stdarg(3), trampoline(3), callback(3). + + +

Bugs

+
+ +The current implementations have been tested on a selection +of common cases but there are probably still many +bugs. +

+There are typically built-in limits on the size of the +argument-list, which may also include the size of any +structure arguments. +

+The decision whether a struct is to be returned in registers or in memory +considers only the struct's size and alignment. This is inaccurate: for +example, gcc on m68k-next returns +struct { char a,b,c; } +in registers and +struct { char a[3]; } +in memory, although both types have the same size and the same alignment. +

+The argument list can only be walked once. +

+The use of the global variable vacall_function is not +reentrant. This is fixed in the callback(3) package. + + +

Porting

+ + +Knowledge about argument passing conventions can be found +in the gcc source, file +gcc-2.6.3/config/cpu/cpu.h, +section "Stack layout; function entry, exit and calling." +

+The implementation of varargs for gcc can be found in the +gcc source, files gcc-2.6.3/ginclude/va*.h. +

+gcc's __builtin_saveregs() function is defined in the gcc +source, file gcc-2.6.3/libgcc2.c. +

+ + +

Author

+ + +Bruno Haible <bruno@clisp.org> + + +

Acknowledgements

+
+ +Many ideas and a lot of code were cribbed from the gcc +source. +

+ +


+ +
VACALL manual page
+Bruno Haible <bruno@clisp.org> +
+

+Last modified: 1 January 2017. + + + diff --git a/vacall/vacall.man b/vacall/vacall.man new file mode 100644 index 0000000..b69c7fb --- /dev/null +++ b/vacall/vacall.man @@ -0,0 +1,192 @@ +VACALL(3) Library Functions Manual VACALL(3) + + + +NAME + vacall - C functions called with variable arguments + +SYNOPSIS + #include  + + extern void* vacall_function; + + void function (va_alistalist) + { + va_start_type(alist[, return_type]); + arg = va_arg_type(alist[, arg_type]); + va_return_type(alist[[, return_type], return_value]); + } + + vacall_function = &function; + + val = ((return_type (*) ()) vacall) (arg1,arg2,...); + +DESCRIPTION + This set of macros permit a C function function to be called with vari‐ + able arguments and to return variable return values. This is much like + the stdarg(3) facility, but also allows the return value to be speci‐ + fied at run time. + + Function calling conventions differ considerably on different machines, + and vacall attempts to provide some degree of isolation from such + architecture dependencies. + + The function that can be called with any number and type of arguments + and which will return any type of return value is vacall. It will do + some magic and call the function stored in the variable vacall_func‐ + tion. If you want to make more than one use of vacall, use the trampo‐ + line(3) facility to store &function into vacall_function just before + calling vacall. + + Within function, the following macros can be used to walk through the + argument list and specify a return value: + + va_start_type(alist[, return_type]); + starts the walk through the argument list and specifies the + return type. + + arg = va_arg_type(alist[, arg_type]); + fetches the next argument from the argument list. + + va_return_type(alist[[, return_type], return_value]); + ends the walk through the argument list and specifies the return + value. + + The type in va_start_type and va_return_type shall be one of void, int, + uint, long, ulong, longlong, ulonglong, double, struct, ptr or (for + ANSI C calling conventions only) char, schar, uchar, short, ushort, + float, depending on the class of return_type. + + The type specifiers in va_start_type and va_return_type must be the + same. The return_type specifiers passed to va_start_type and + va_return_type must be the same. + + The type in va_arg_type shall be one of int, uint, long, ulong, long‐ + long, ulonglong, double, struct, ptr or (for ANSI C calling conventions + only) char, schar, uchar, short, ushort, float, depending on the class + of arg_type. + + In va_start_struct(alist, return_type, splittable); the splittable flag + specifies whether the struct return_type can be returned in registers + such that every struct field fits entirely in a single register. This + needs to be specified for structs of size 2*sizeof(long). For structs + of size <= sizeof(long), splittable is ignored and assumed to be 1. For + structs of size > 2*sizeof(long), splittable is ignored and assumed to + be 0. There are some handy macros for this: + va_word_splittable_1 (type1) + va_word_splittable_2 (type1, type2) + va_word_splittable_3 (type1, type2, type3) + va_word_splittable_4 (type1, type2, type3, type4) + For a struct with three slots + struct { type1 id1; type2 id2; type3 id3; } + you can specify splittable as va_word_splittable_3 (type1, type2, + type3) . + + +NOTES + Functions which want to emulate Kernighan & Ritchie style functions + (i.e., in ANSI C, functions without a typed argument list) cannot use + the type values char, schar, uchar, short, ushort, float. As pre‐ + scribed by the default K&R C expression promotions, they have to use + int instead of char, schar, uchar, short, ushort and double instead of + float. + + The macros va_start_longlong(), va_start_ulonglong(), va_return_long‐ + long(), va_return_ulonglong(), va_arg_longlong() and va_arg_ulonglong() + work only if the C compiler has a working long long 64-bit integer + type. + + The struct types used in va_start_struct() and va_struct() must only + contain (signed or unsigned) int, long, long long or pointer fields. + Struct types containing (signed or unsigned) char, short, float, double + or other structs are not supported. + + +EXAMPLE + This example, a possible implementation of execl(3) on top of execv(2) + using stdarg(3), + + #include  + #define MAXARGS 100 + /* execl is called by execl(file, arg1, arg2, ..., (char *)0); */ + int execl (...) + { + va_list ap; + char* file; + char* args[MAXARGS]; + int argno = 0; + va_start (ap); + file = va_arg(ap, char*); + while ((args[argno] = va_arg(ap, char*)) != (char *)0) + argno++; + va_end (ap); + return execv(file, args); + } + + looks like this using vacall(3): + + #include  + #define MAXARGS 100 + /* execl is called by vacall(file, arg1, arg2, ..., (char *)0); */ + void execl (va_alist ap) + { + char* file; + char* args[MAXARGS]; + int argno = 0; + int retval; + va_start_int (ap); + file = va_arg_ptr(ap, char*); + while ((args[argno] = va_arg_ptr(ap, char*)) != (char *)0) + argno++; + retval = execv(file, args); + va_return_int (ap, retval); + } + vacall_function = &execl; + + +SEE ALSO + stdarg(3), trampoline(3), callback(3). + + +BUGS + The current implementations have been tested on a selection of common + cases but there are probably still many bugs. + + There are typically built-in limits on the size of the argument-list, + which may also include the size of any structure arguments. + + The decision whether a struct is to be returned in registers or in mem‐ + ory considers only the struct's size and alignment. This is inaccurate: + for example, gcc on m68k-next returns struct { char a,b,c; } in regis‐ + ters and struct { char a[3]; } in memory, although both types have the + same size and the same alignment. + + The argument list can only be walked once. + + The use of the global variable vacall_function is not reentrant. This + is fixed in the callback(3) package. + + +PORTING + Knowledge about argument passing conventions can be found in the gcc + source, file gcc-2.6.3/config/cpu/cpu.h, section "Stack layout; func‐ + tion entry, exit and calling." + + The implementation of varargs for gcc can be found in the gcc source, + files gcc-2.6.3/ginclude/va*.h. + + gcc's __builtin_saveregs() function is defined in the gcc source, file + gcc-2.6.3/libgcc2.c. + + +AUTHOR + Bruno Haible + + +ACKNOWLEDGEMENTS + Many ideas and a lot of code were cribbed from the gcc source. + + + + + 1 January 2017 VACALL(3)