-Subproject commit d81417a103945ab1c393e74557983b1163e9e353
+Subproject commit 47d51c3f04e416caa4c43c72a5458df99cf09c3a
+++ /dev/null
- ____ _ _
- | _ \| |_| |__
- | |_) | __| '_ \ ``Some people have entirely too
- | __/| |_| | | | much free time on their hands.''
- |_| \__|_| |_| -- Gene Spafford
-
- GNU Pth - The GNU Portable Threads
-
- AUTHORS
- =======
-
- This is a list of authors who have written
- or edited major parts of the GNU Pth sources.
-
- o GNU Pth (as a whole):
- Written by: Ralf S. Engelschall
- Edited by: Ralf S. Engelschall
-
- o pthread.pod:
- Written by: Ralf S. Engelschall
- Parts from: The Open Group
- Edited by: Ralf S. Engelschall
-
-Modified for inclusion in GStreamer by Andy Wingo <wingo@pobox.com>
-All bugs to gstreamer-devel@lists.sourceforge.net
+++ /dev/null
- GNU LIBRARY GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the library GPL. It is
- numbered 2 because it goes with version 2 of the ordinary GPL.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Library General Public License, applies to some
-specially designated Free Software Foundation software, and to any
-other libraries whose authors decide to use it. You can use it for
-your libraries, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if
-you distribute copies of the library, or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link a program with the library, you must provide
-complete object files to the recipients so that they can relink them
-with the library, after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- Our method of protecting your rights has two steps: (1) copyright
-the library, and (2) offer you this license which gives you legal
-permission to copy, distribute and/or modify the library.
-
- Also, for each distributor's protection, we want to make certain
-that everyone understands that there is no warranty for this free
-library. If the library is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original
-version, so that any problems introduced by others will not reflect on
-the original authors' reputations.
-\f
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that companies distributing free
-software will individually obtain patent licenses, thus in effect
-transforming the program into proprietary software. To prevent this,
-we have made it clear that any patent must be licensed for everyone's
-free use or not licensed at all.
-
- Most GNU software, including some libraries, is covered by the ordinary
-GNU General Public License, which was designed for utility programs. This
-license, the GNU Library General Public License, applies to certain
-designated libraries. This license is quite different from the ordinary
-one; be sure to read it in full, and don't assume that anything in it is
-the same as in the ordinary license.
-
- The reason we have a separate public license for some libraries is that
-they blur the distinction we usually make between modifying or adding to a
-program and simply using it. Linking a program with a library, without
-changing the library, is in some sense simply using the library, and is
-analogous to running a utility program or application program. However, in
-a textual and legal sense, the linked executable is a combined work, a
-derivative of the original library, and the ordinary General Public License
-treats it as such.
-
- Because of this blurred distinction, using the ordinary General
-Public License for libraries did not effectively promote software
-sharing, because most developers did not use the libraries. We
-concluded that weaker conditions might promote sharing better.
-
- However, unrestricted linking of non-free programs would deprive the
-users of those programs of all benefit from the free status of the
-libraries themselves. This Library General Public License is intended to
-permit developers of non-free programs to use free libraries, while
-preserving your freedom as a user of such programs to change the free
-libraries that are incorporated in them. (We have not seen how to achieve
-this as regards changes in header files, but we have achieved it as regards
-changes in the actual functions of the Library.) The hope is that this
-will lead to faster development of free libraries.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, while the latter only
-works together with the library.
-
- Note that it is possible for a library to be covered by the ordinary
-General Public License rather than by this special one.
-\f
- GNU LIBRARY GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library which
-contains a notice placed by the copyright holder or other authorized
-party saying it may be distributed under the terms of this Library
-General Public License (also called "this License"). Each licensee is
-addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-\f
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-\f
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-\f
- 6. As an exception to the Sections above, you may also compile or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- c) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- d) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the source code distributed need not include anything that is normally
-distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-\f
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-\f
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Library General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-\f
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-\f
- Appendix: How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
- <one line to give the library's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- <signature of Ty Coon>, 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
+++ /dev/null
-This package has been modified for use with GStreamer. Go to the root gstreamer
-directory to install.
+++ /dev/null
-## Makefile.am: NGPT Makefile.in hacked into an automake file by wingo
-## <wingo@pobox.com>
-##
- # ``UNIX -- where you can do anything
- # in two keystrokes, or less...''
-
-noinst_LTLIBRARIES = libpth-mctx.la libgstcothreads.la
-
-libpth_mctx_la_SOURCES = pth_mctx.c pth_p.h pth_vers.c pth.h pth_acdef.h pth_acmac.h
-
-libgstcothreads_la_SOURCES = cothreads.c cothread-stack.c cothreads.h
-libgstcothreads_la_LIBADD = libpth-mctx.la $(GLIB_LIBS)
-libgstcothreads_la_CFLAGS = $(GLIB_CFLAGS)
-
-noinst_PROGRAMS = test-pth test-pth-pthreads test-pthreads test-pth-pthreads2 test-cothreads
-noinst_HEADERS = linuxthreads.h cothreads-private.h cothreads.h
-
-test_pth_LDADD = libpth-mctx.la
-test_pth_pthreads_LDADD = libpth-mctx.la -lpthread
-test_pthreads_LDADD = -lpthread
-test_pth_pthreads2_LDADD = -lpthread libpth-mctx.la
-test_cothreads_CFLAGS = $(GLIB_CFLAGS)
-test_cothreads_LDADD = libgstcothreads.la
-
-BUILT_SOURCES = pth_p.h
-
-EXTRA_DIST = ltmain.sh mkinstalldirs config.guess config.sub install-sh missing
-
-HSRCS = $(srcdir)/pth_debug.c $(srcdir)/pth_errno.c $(srcdir)/pth_mctx.c
-
-pth_p.h: $(srcdir)/pth_p.h.in $(HSRCS)
- $(srcdir)/shtool scpp -o pth_p.h -t $(srcdir)/pth_p.h.in -Dcpp -Cintern -M '==#==' $(HSRCS)
-
-#pth_mctx_a_DEPENDENCIES = shtool
-#shtool:
-# shtoolize -o shtool scpp
+++ /dev/null
-no gnus here
+++ /dev/null
-I ripped the core out of GNU pth to provide cothreading for GStreamer. That's
-what this package is. It was written by Ralf Engelschall. Plaudits to him, bug
-reports to gstreamer-devel@lists.sourceforge.net.
-
-wingo <wingo@pobox.com>, 20 Jan 2002
+++ /dev/null
-/*
-** GNU Pth - The GNU Portable Threads
-** Copyright (c) 1999-2001 Ralf S. Engelschall <rse@engelschall.com>
-**
-** This file is part of GNU Pth, a non-preemptive thread scheduling
-** library which can be found at http://www.gnu.org/software/pth/.
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-** USA, or contact Ralf S. Engelschall <rse@engelschall.com>.
-**
-** pth_acdef.h Autoconf defines
-*/
-
-#ifndef _PTH_ACDEF_H_
-#define _PTH_ACDEF_H_
-
-@TOP@
-
-/* the custom Autoconf defines */
-#undef HAVE_SIG_ATOMIC_T
-#undef HAVE_PID_T
-#undef HAVE_STACK_T
-#undef HAVE_SIZE_T
-#undef HAVE_SSIZE_T
-#undef HAVE_SOCKLEN_T
-#undef HAVE_NFDS_T
-#undef HAVE_OFF_T
-#undef HAVE_GETTIMEOFDAY_ARGS1
-#undef HAVE_STRUCT_TIMESPEC
-#undef HAVE_SYS_READ
-#undef HAVE_POLLIN
-#undef HAVE_SS_SP
-#undef HAVE_SS_BASE
-#undef HAVE_LONGLONG
-#undef HAVE_LONGDOUBLE
-#undef PTH_DEBUG
-#undef PTH_NSIG
-#undef PTH_MCTX_MTH_use
-#undef PTH_MCTX_DSP_use
-#undef PTH_MCTX_STK_use
-#undef PTH_STACKGROWTH
-#undef PTH_DMALLOC
-#undef PTH_NEED_SEPARATE_REGISTER_STACK
-
-#undef HAVE_LINUXTHREADS
-
-@BOTTOM@
-
-#endif /* _PTH_ACDEF_H_ */
+++ /dev/null
-#!/bin/bash
-# Run this to generate all the initial makefiles, etc.
-
-DIE=0
-package=gstpth
-srcfile=pth_mctx.c
-#DEBUG=defined
-
-for i in $@; do
- if test "$i" = "--autogen-noconfigure"; then
- NOCONFIGURE=defined
- echo "+ configure run disabled"
- elif test "$i" = "--autogen-nocheck"; then
- NOCHECK=defined
- echo "+ autotools version check disabled"
- elif test "$i" = "--autogen-debug"; then
- DEBUG=defined
- echo "+ debug output enabled"
- elif test "$i" = "--help"; then
- echo "autogen.sh help options: "
- echo " --autogen-noconfigure don't run the configure script"
- echo " --autogen-nocheck don't do version checks"
- echo " --autogen-debug debug the autogen process"
- echo "continuing with the autogen in order to get configure help messages..."
- fi
-done
-
-debug ()
-# print out a debug message if DEBUG is a defined variable
-{
- if test ! -z "$DEBUG"
- then
- echo "DEBUG: $1"
- fi
-}
-
-version_check ()
-# check the version of a package
-# first argument : package name (executable)
-# second argument : source download url
-# rest of arguments : major, minor, micro version
-{
- PACKAGE=$1
- URL=$2
- MAJOR=$3
- MINOR=$4
- MICRO=$5
-
- WRONG=
-
- debug "major $MAJOR minor $MINOR micro $MICRO"
- VERSION=$MAJOR
- if test ! -z "$MINOR"; then VERSION=$VERSION.$MINOR; else MINOR=0; fi
- if test ! -z "$MICRO"; then VERSION=$VERSION.$MICRO; else MICRO=0; fi
-
- debug "major $MAJOR minor $MINOR micro $MICRO"
-
- test -z "$NOCHECK" && {
- echo -n "+ checking for $1 >= $VERSION ... "
- } || {
- echo "+ NOT checking for $1 >= $VERSION, as requested ..."
- return 0
- }
-
- ($PACKAGE --version) < /dev/null > /dev/null 2>&1 ||
- {
- echo
- echo "You must have $PACKAGE installed to compile $package."
- echo "Download the appropriate package for your distribution,"
- echo "or get the source tarball at $URL"
- return 1
- }
- # the following line is carefully crafted sed magic
- pkg_version=`$PACKAGE --version|head -n 1|sed 's/^[a-zA-z\.\ ()]*//;s/ .*$//'`
- debug "pkg_version $pkg_version"
- pkg_major=`echo $pkg_version | cut -d. -f1`
- pkg_minor=`echo $pkg_version | cut -d. -f2`
- pkg_micro=`echo $pkg_version | cut -d. -f3`
- test -z "$pkg_minor" && pkg_minor=0
- test -z "$pkg_micro" && pkg_micro=0
-
- debug "found major $pkg_major minor $pkg_minor micro $pkg_micro"
-
- #start checking the version
- debug "version check"
-
- if [ ! "$pkg_major" \> "$MAJOR" ]; then
- debug "$pkg_major <= $MAJOR"
- if [ "$pkg_major" \< "$MAJOR" ]; then
- WRONG=1
- elif [ ! "$pkg_minor" \> "$MINOR" ]; then
- if [ "$pkg_minor" \< "$MINOR" ]; then
- WRONG=1
- elif [ "$pkg_micro" \< "$MICRO" ]; then
- WRONG=1
- fi
- fi
- fi
-
- if test ! -z "$WRONG"; then
- echo "found $pkg_version, not ok !"
- echo
- echo "You must have $PACKAGE $VERSION or greater to compile $package."
- echo "Get the latest version from $URL"
- return 1
- else
- echo "found $pkg_version, ok."
- fi
-}
-
-# autoconf 2.52d has a weird issue involving a yes:no error
-# so don't allow it's use
-ac_version=`autoconf --version|head -n 1|sed 's/^[a-zA-z\.\ ()]*//;s/ .*$//'`
-if test "$ac_version" = "2.52d"; then
- echo "autoconf 2.52d has an issue with our current build."
- echo "We don't know who's to blame however. So until we do, get a"
- echo "regular version. RPM's of a working version are on the gstreamer site."
- exit 1
-fi
-
-
-version_check "autoconf" "ftp://ftp.gnu.org/pub/gnu/autoconf/" 2 52 || DIE=1
-version_check "automake" "ftp://ftp.gnu.org/pub/gnu/automake/" 1 5 || DIE=1
-version_check "libtool" "ftp://ftp.gnu.org/pub/gnu/libtool/" 1 4 0 || DIE=1
-
-if test "$DIE" -eq 1; then
- exit 1
-fi
-
-test -f $srcfile || {
- echo "You must run this script in the top-level $package directory"
- exit 1
-}
-
-if test -z "$*"; then
- echo "I am going to run ./configure with no arguments - if you wish "
- echo "to pass any to it, please specify them on the $0 command line."
-fi
-
-echo "+ creating acinclude.m4"
-cat m4/*.m4 > acinclude.m4
-
-echo "+ running aclocal ..."
-aclocal $ACLOCAL_FLAGS || {
- echo
- echo "aclocal failed - check that all needed development files are present on system"
- exit 1
-}
-
-# FIXME : why does libtoolize keep complaining about aclocal ?
-#echo "+ running libtoolize ..."
-#libtoolize --copy --force || {
-# echo
-# echo "libtoolize failed"
-# exit 1
-#}
-
-echo "+ running autoheader ... "
-autoheader || {
- echo
- echo "autoheader failed"
- exit 1
-}
-# touch the stamp-h.in build stamp so we don't re-run autoheader in maintainer mode -- wingo
-echo timestamp > stamp-h.in 2> /dev/null
-echo "+ running autoconf ... "
-autoconf || {
- echo
- echo "autoconf failed"
- exit 1
-}
-echo "+ running automake ... "
-automake -a -c || {
- echo
- echo "automake failed"
- exit 1
-}
-
-CONFIGURE_OPT='--enable-maintainer-mode'
-
-# work around some wierd sort of autotools buglet
-for i in install-sh mkinstalldirs config.sub config.guess missing ltmain.sh; do
- ln -sf ../../$i $i
-done
-
-test -n "$NOCONFIGURE" && {
- echo "skipping configure stage for package $package, as requested."
- echo "autogen.sh done."
- exit 0
-}
-
-echo "+ running configure ... "
-echo "./configure default flags: $CONFIGURE_OPT"
-echo "using: $CONFIGURE_OPT $@"
-echo
-
-./configure $CONFIGURE_OPT "$@" || {
- echo
- echo "configure failed"
- exit 1
-}
-
-echo
-echo "Now type 'make' to compile $package."
+++ /dev/null
-dnl ##
-dnl ## NGPT - Next Generation POSIX Threading
-dnl ## Copyright (c) 2001 IBM Corporation <babt@us.ibm.com>
-dnl ## Portions Copyright (c) 1999-2000 Ralf S. Engelschall <rse@engelschall.com>
-dnl ##
-dnl ## This file is part of BlueThreads, a non-preemptive thread scheduling
-dnl ## library which can be found at http://www.ibm.com/developer
-dnl ##
-dnl ## This library is free software; you can redistribute it and/or
-dnl ## modify it under the terms of the GNU Lesser General Public
-dnl ## License as published by the Free Software Foundation; either
-dnl ## version 2.1 of the License, or (at your option) any later version.
-dnl ##
-dnl ## This library 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 GNU
-dnl ## Lesser General Public License for more details.
-dnl ##
-dnl ## You should have received a copy of the GNU Lesser General Public
-dnl ## License along with this library; if not, write to the Free Software
-dnl ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-dnl ## USA.
-dnl ##
-dnl ## configure.in: ngpt Autoconf specification
-dnl ##
-
-dnl # hacked on for inclusion into the gstreamer project 20 Jan 2002 by Andy
-dnl # Wingo <wingo@pobox.com>
-
-dnl # ``Programming in Bourne-Shell
-dnl # is a higher form of masochism.''
-dnl # -- Unknown
-
-AC_INIT
-AM_CONFIG_HEADER(pth_acdef.h)
-AM_INIT_AUTOMAKE(pth, 1400)
-
-AC_MSG_PART(Build Tools)
-
-AC_PROG_CC
-AC_PROG_CPP
-AC_SET_MAKE
-AM_PROG_LIBTOOL
-
-dnl ## Support for some special platform/compiler options
-case "$PLATFORM:$CC" in
- *-sun-solaris2*:cc )
- # shut-up harmless warnings caused by do-while macros on Solaris
- test ".$ac_cv_prog_gcc" = ".no" && PTH_CFLAGS="$PTH_CFLAGS -w"
- ;;
- *-*-sysv*uw[27]*:cc )
- # shut-up harmless warnings caused by do-while macros on UnixWare
- PTH_CFLAGS="$PTH_CFLAGS -w"
- ;;
- *-hp-hpux*:cc )
- # HPUX needs a few special options to find its ANSI C brain
- PTH_CFLAGS="$PTH_CFLAGS -Ae -O"
- ;;
- *-hp-hpux*:CC )
- # HPUX outputs useless warnings
- PTH_CFLAGS="$PTH_CFLAGS -w"
- ;;
- *-sgi-irix6.2:cc )
- # shut-up warnings caused by IRIX brain-dead 32/64 bit stuff
- PTH_LDFLAGS="$PTH_LDFLAGS -woff 85 -Wl,-woff,84 -Wl,-woff,85"
- ;;
- *-sgi-irix6.5.[2-9]:cc )
- # since IRIX 6.5.2 the C compiler is smart enough,
- # but the linker is still complaining, of course
- PTH_LDFLAGS="$PTH_LDFLAGS -woff 84,85,134"
- ;;
- *-sgi-irix6.5:cc )
- # shut-up warnings caused by IRIX brain-dead 32/64 bit stuff
- PTH_CFLAGS="$PTH_CFLAGS -woff 1110,1048"
- PTH_LDFLAGS="$PTH_LDFLAGS -woff 84,85,134"
- ;;
- *-dec-osf4*:cc )
- # make sure the standard compliant functions are used on Tru64/OSF1 4.x
- PTH_CFLAGS="$PTH_CFLAGS -std"
- ;;
- *-dec-osf5*:cc )
- # make sure the standard compliant functions are used on Tru64/OSF1 5.x
- PTH_CFLAGS="$PTH_CFLAGS -std -D_XOPEN_SOURCE_EXTENDED"
- ;;
- *-*-isc*:* )
- # ISC is brain-dead and needs a bunch of options to find its brain
- PTH_CPPFLAGS="$PTH_CPPFLAGS -D_POSIX_SOURCE";
- PTH_LIBS="$PTH_LIBS -lcposix -linet";
- ;;
-esac
-
-AC_MSG_PART(Mandatory Platform Environment)
-
-dnl # check for standard headers
-AC_HEADER_STDC
-# FIXME
-AC_HAVE_HEADERS(dnl
- stdio.h stdlib.h stdarg.h string.h signal.h unistd.h setjmp.h fcntl.h dnl
- errno.h sys/types.h)
-AC_CHECK_FUNCTIONS(dnl
- sigaction sigprocmask sigpending sigsuspend)
-AC_BEGIN_DECISION([mandatory system headers and functions])
-AC_IFALLYES(dnl
- header:stdio.h header:stdlib.h header:stdarg.h header:string.h dnl
- header:signal.h header:unistd.h header:setjmp.h header:fcntl.h header:errno.h dnl
- header:sys/types.h dnl
- func:sigaction func:sigprocmask dnl
- func:sigpending func:sigsuspend,
- AC_DECIDE(fine, [all fine]))
-AC_END_DECISION
-
-AC_MSG_PART(Optional Platform Environment)
-
-dnl # check whether ss_base instead of ss_sp attribute exists
-AC_CHECK_STRUCTATTR(ss_base, sigaltstack, sys/signal.h)
-AC_CHECK_STRUCTATTR(ss_sp, sigaltstack, sys/signal.h)
-
-dnl ##
-dnl ## MACHINE CONTEXT IMPLEMENTATION
-dnl ##
-
-AC_MSG_PART(Machine Context Implementation)
-
-dnl #
-dnl # 1. determine possibilities
-dnl #
-
-dnl # check for MCSC method
-AC_CHECK_HEADERS(ucontext.h)
-AC_CHECK_FUNCTIONS(makecontext swapcontext getcontext setcontext)
-AC_CHECK_MCSC(mcsc=yes, mcsc=no)
-
-dnl # check for SJLJ method
-AC_CHECK_HEADERS(signal.h)
-AC_CHECK_FUNCTIONS(sigsetjmp siglongjmp setjmp longjmp _setjmp _longjmp)
-AC_CHECK_FUNCTIONS(sigaltstack sigstack)
-AC_CHECK_SJLJ(sjlj=yes, sjlj=no, sjlj_type)
-
-dnl #
-dnl # 2. make a general decision
-dnl #
-
-if test ".$mcsc" = .yes; then
- mctx_mth=mcsc
- mctx_dsp=sc
- mctx_stk=mc
-elif test ".$sjlj" = .yes; then
- mctx_mth=sjlj
- mctx_dsp=$sjlj_type
- mctx_stk=none
- AC_IFALLYES(func:sigstack, mctx_stk=ss)
- AC_IFALLYES(func:sigaltstack, mctx_stk=sas)
- case $mctx_dsp in
- sjljlx|sjljisc|sjljw32 ) mctx_stk=none
- esac
-else
- AC_ERROR([no appropriate mctx method found])
-fi
-
-dnl #
-dnl # 3. allow decision to be overridden by user
-dnl #
-
-AC_ARG_WITH(mctx-mth,dnl
-[ --with-mctx-mth=ID force mctx method (mcsc,sjlj)],[
-case $withval in
- mcsc|sjlj ) mctx_mth=$withval ;;
- * ) AC_ERROR([invalid mctx method -- allowed: mcsc,sjlj]) ;;
-esac
-])dnl
-AC_ARG_WITH(mctx-dsp,dnl
-[ --with-mctx-dsp=ID force mctx dispatching (sc,ssjlj,sjlj,usjlj,sjlje,...)],[
-case $withval in
- sc|ssjlj|sjlj|usjlj|sjlje|sjljlx|sjljisc|sjljw32 ) mctx_dsp=$withval ;;
- * ) AC_ERROR([invalid mctx dispatching -- allowed: sc,ssjlj,sjlj,usjlj,sjlje,sjljlx,sjljisc,sjljw32]) ;;
-esac
-])dnl
-AC_ARG_WITH(mctx-stk,dnl
-[ --with-mctx-stk=ID force mctx stack setup (mc,ss,sas,...)],[
-case $withval in
- mc|ss|sas|none ) mctx_stk=$withval ;;
- * ) AC_ERROR([invalid mctx stack setup -- allowed: mc,ss,sas,none]) ;;
-esac
-])dnl
-
-dnl #
-dnl # 4. determine a few additional details
-dnl #
-
-dnl # whether sigaltstack has to use stack_t instead of struct sigaltstack
-AC_CHECK_TYPEDEF(stack_t, signal.h)
-
-dnl # ibm - test whether we need a separate register stack (IA64).
-AC_CHECK_NEED_FOR_SEPARATE_STACK(PTH_NEED_SEPARATE_REGISTER_STACK)
-dnl # ibm - end
-
-dnl # direction of stack grow
-AC_CHECK_STACKGROWTH(PTH_STACKGROWTH)
-if test ".$ac_cv_check_stackgrowth" = ".down"; then
- PTH_STACK_GROWTH="down"
-else
- PTH_STACK_GROWTH="up"
-fi
-AC_SUBST(PTH_STACK_GROWTH)
-
-dnl # how to specify stacks for the various functions
-AC_CHECK_STACKSETUP(makecontext, pth_skaddr_makecontext, pth_sksize_makecontext)
-AC_CHECK_STACKSETUP(sigaltstack, pth_skaddr_sigaltstack, pth_sksize_sigaltstack)
-AC_CHECK_STACKSETUP(sigstack, pth_skaddr_sigstack, pth_sksize_sigstack)
-
-dnl # how to implement POSIX compliant sig{set,long}jmp()
-case $mctx_dsp in [
- ssjlj )
- pth_sigjmpbuf='sigjmp_buf'
- pth_sigsetjmp='sigsetjmp(buf,1)'
- pth_siglongjmp='siglongjmp(buf,val)'
- ;;
- sjlj )
- pth_sigjmpbuf='jmp_buf'
- pth_sigsetjmp='setjmp(buf)'
- pth_siglongjmp='longjmp(buf,val)'
- ;;
- usjlj )
- pth_sigjmpbuf='jmp_buf'
- pth_sigsetjmp='_setjmp(buf)'
- pth_siglongjmp='_longjmp(buf,val)'
- ;;
- sjlje )
- pth_sigjmpbuf='jmp_buf'
- pth_sigsetjmp='setjmp(buf)'
- pth_siglongjmp='longjmp(buf,val)'
- ;;
- sjljlx|sjljisc|sjljw32 )
- pth_sigjmpbuf='sigjmp_buf'
- pth_sigsetjmp='sigsetjmp(buf,1)'
- pth_siglongjmp='siglongjmp(buf,val)'
- ;;
-] esac
-pth_sigjmpbuf="#define pth_sigjmpbuf $pth_sigjmpbuf"
-pth_sigsetjmp="#define pth_sigsetjmp(buf) $pth_sigsetjmp"
-pth_siglongjmp="#define pth_siglongjmp(buf,val) $pth_siglongjmp"
-AC_SUBST(pth_sigjmpbuf)
-AC_SUBST(pth_sigsetjmp)
-AC_SUBST(pth_siglongjmp)
-
-dnl #
-dnl # 5. export the results
-dnl #
-
-AC_DEFINE_UNQUOTED(PTH_MCTX_MTH_use, [PTH_MCTX_MTH_$mctx_mth])
-AC_DEFINE_UNQUOTED(PTH_MCTX_DSP_use, [PTH_MCTX_DSP_$mctx_dsp])
-AC_DEFINE_UNQUOTED(PTH_MCTX_STK_use, [PTH_MCTX_STK_$mctx_stk])
-
-PTH_MCTX_ID="$mctx_mth/$mctx_dsp/$mctx_stk"
-AC_MSG_RESULT([decision on mctx implementation... ${TB}${PTH_MCTX_ID}${TN}])
-AC_SUBST(PTH_MCTX_ID)
-
-AC_MSG_VERBOSE([decided mctx method: $mctx_mth])
-AC_MSG_VERBOSE([decided mctx dispatching: $mctx_dsp])
-AC_MSG_VERBOSE([decided mctx stack setup: $mctx_stk])
-
-AC_MSG_PART(Checking for GLib)
-
-dnl Check for glib2
-translit(dnm, m, l) AM_CONDITIONAL(USE_GLIB2, true)
-GST_CHECK_FEATURE(GLIB2, [use of glib-2.0 and GObject], , [
- PKG_CHECK_MODULES(GLIB2, glib-2.0 gthread-2.0,
- HAVE_GLIB2=yes,HAVE_GLIB2=no)
- GLIB_LIBS=$GLIB2_LIBS
- GLIB_CFLAGS=$GLIB2_CFLAGS
- AC_SUBST(GLIB_LIBS)
- AC_SUBST(GLIB_CFLAGS)
- # glib2 is now the default. so if we don't have it here, then use glib1
- if test "x$HAVE_GLIB2" = "xno"; then
- AC_MSG_WARN([no glib2 found, falling back to glib1])
- fi
-], enabled, [
-dnl AC_DEFINE(USE_GLIB2)
-])
-dnl AC_SUBST(USE_GLIB2)
-
-if test x$USE_GLIB2 = xno; then
- dnl Check for glib and gtk
- AM_PATH_GLIB(1.2.0,,
- AC_MSG_ERROR(Cannot find glib: Is glib-config in path?),
- glib gmodule gthread)
-fi
-
-
-dnl ## Additional support for some special platform/compiler options
-case "$PLATFORM:$CC" in
-*-ibm-mvs*:cc | *-ibm-mvs*:c++ )
- mvs_extras='-W "c,float(ieee)" -W "c,langlvl(extended)" -W "c,expo,dll"'
- PTH_CFLAGS="$PTH_CFLAGS $mvs_extras"
- mvs_extras='-W "l,p,map" -W "l,map,list"'
- PTH_LDFLAGS="$PTH_LDFLAGS $mvs_extras"
- ;;
-esac
-
-AC_MSG_PART(Output Substitution)
-
-AC_OUTPUT(
-Makefile
-pth.h
-pth_acmac.h
-)
+++ /dev/null
-/* Pthread-friendly coroutines with pth
- * Copyright (C) 2001 Andy Wingo <wingo@pobox.com>
- *
- * cothread-stack.c: various methods of allocating cothread stacks
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include "cothreads-private.h"
-#include "linuxthreads.h"
-#include <unistd.h>
-#include <sys/resource.h>
-
-typedef enum _cothread_block_state cothread_block_state;
-typedef struct _cothread_chunk cothread_chunk;
-
-enum _cothread_block_state
-{
- COTHREAD_BLOCK_STATE_UNUSED=0,
- COTHREAD_BLOCK_STATE_IN_USE
-};
-
-struct _cothread_chunk {
- cothread_chunk *next;
- cothread_block_state *block_states;
- char *chunk;
- int size;
- int reserved_bottom;
- gboolean needs_free;
- int nblocks;
-};
-
-
-static cothread_chunk* cothread_chunk_new (unsigned long size, gboolean allocate);
-static void cothread_chunk_free (cothread_chunk *chunk);
-static gboolean cothread_stack_alloc_chunked (cothread_chunk *chunk, char **low, char **high,
- cothread_chunk *(*chunk_new)(cothread_chunk*));
-static cothread_chunk* cothread_chunk_new_linuxthreads (cothread_chunk* old);
-static cothread_chunk* cothread_chunk_new_on_stack (cothread_chunk* old);
-
-
-gboolean
-cothread_stack_alloc_on_heap (char **low, char **high)
-{
- if (posix_memalign (low, _cothreads_config_global->chunk_size / _cothreads_config_global->blocks_per_chunk,
- _cothreads_config_global->chunk_size / _cothreads_config_global->blocks_per_chunk)) {
- g_error ("could not memalign stack");
- return FALSE;
- }
-
- *high = *low + sizeof (*low) - 1;
- return TRUE;
-}
-
-gboolean
-cothread_stack_alloc_on_gthread_stack (char **low, char **high)
-{
- cothread_chunk *chunk = NULL;
- static GStaticPrivate chunk_key = G_STATIC_PRIVATE_INIT;
-
- if (!(chunk = g_static_private_get(&chunk_key))) {
- chunk = cothread_chunk_new (_cothreads_config_global->chunk_size, FALSE);
- g_static_private_set (&chunk_key, chunk, (GDestroyNotify) cothread_chunk_free);
- }
-
- return cothread_stack_alloc_chunked (chunk, low, high, cothread_chunk_new_on_stack);
-}
-
-gboolean
-cothread_stack_alloc_linuxthreads (char **low, char **high)
-{
- cothread_chunk *chunk = NULL;
- static GStaticPrivate chunk_key = G_STATIC_PRIVATE_INIT;
-
- if (!(chunk = g_static_private_get(&chunk_key))) {
- chunk = cothread_chunk_new (_cothreads_config_global->chunk_size, FALSE);
- g_message ("created new chunk, %p, size=0x%x", chunk->chunk, chunk->size);
- g_static_private_set (&chunk_key, chunk, (GDestroyNotify) cothread_chunk_free);
- }
-
- return cothread_stack_alloc_chunked (chunk, low, high, cothread_chunk_new_linuxthreads);
-}
-
-
-/* size must be a power of two. */
-static cothread_chunk*
-cothread_chunk_new (unsigned long size, gboolean allocate)
-{
- cothread_chunk *ret;
- char *sp = CURRENT_STACK_FRAME;
-
- ret = g_new0 (cothread_chunk, 1);
- ret->nblocks = _cothreads_config_global->blocks_per_chunk;
- ret->block_states = g_new0 (cothread_block_state, ret->nblocks);
-
- if (allocate) {
- if (posix_memalign(&ret->chunk, size, size))
- g_error ("memalign operation failed");
- } else {
- /* if we don't allocate the chunk, we must already be in it. */
-
- ret->chunk = (char*) ((unsigned long) sp &~ (size - 1));
-#if PTH_STACK_GROWTH > 0
- ret->reserved_bottom = sp - ret->chunk;
-#else
- ret->reserved_bottom = ret->chunk + size - sp;
-#endif
- }
-
- ret->size = size;
- ret->needs_free = allocate;
-
- return ret;
-}
-
-/**
- * cothread_stack_alloc_chunked:
- * @chunk: the chunk for the
- * Make a new cothread stack out of a chunk. Chunks are assumed to be aligned on
- * boundaries of _cothreads_config_global->chunk_size.
- *
- * Returns: the new cothread context
- */
- /* we assume that the stack is aligned on _cothreads_config_global->chunk_size boundaries */
-static gboolean
-cothread_stack_alloc_chunked (cothread_chunk *chunk, char **low, char **high,
- cothread_chunk *(*chunk_new)(cothread_chunk*))
-{
- int block;
- cothread_chunk *walk, *last;
-
- for (walk=chunk; walk; last=walk, walk=walk->next) {
- if (walk->block_states[0] == COTHREAD_BLOCK_STATE_UNUSED) {
- walk->block_states[0] = COTHREAD_BLOCK_STATE_IN_USE;
-#if PTH_STACK_GROWTH > 0
- *low = walk->chunk + walk->reserved_bottom;
- *high = walk->chunk + walk->size / walk->nblocks;
-#else
- *low = walk->chunk + walk->size * (walk->nblocks - 1) / walk->nblocks;
- *high = walk->chunk + walk->size - walk->reserved_bottom;
-#endif
- return TRUE;
- }
-
- for (block = 1; block < walk->nblocks; block++) {
- if (walk->block_states[block] == COTHREAD_BLOCK_STATE_UNUSED) {
- walk->block_states[block] = COTHREAD_BLOCK_STATE_IN_USE;
-#if PTH_STACK_GROWTH > 0
- *low = walk->chunk + walk->size * block / walk->nblocks;
-#else
- *low = walk->chunk + walk->size * (walk->nblocks - block - 1) / walk->nblocks;
-#endif
- *high = *low + walk->size / walk->nblocks;
- return TRUE;
- }
- }
- }
-
- if (!chunk_new)
- return FALSE;
- else
- return cothread_stack_alloc_chunked (chunk_new (last), low, high, NULL);
-}
-
-static void
-cothread_chunk_free (cothread_chunk *chunk)
-{
- /* FIXME: implement me please */
-}
-
-static cothread_chunk*
-cothread_chunk_new_linuxthreads (cothread_chunk* old)
-{
- cothread_chunk *new;
- void *pthread_descr;
-
- new = cothread_chunk_new (_cothreads_config_global->chunk_size, TRUE);
- pthread_descr = __linuxthreads_self();
-#if PTH_STACK_GROWTH > 0
- /* we don't really know pthread_descr's size in this case, but we can be
- * conservative. it's normally 1K in the down-growing case, so we allocate 2K.
- */
- new->reserved_bottom = 2048;
- memcpy(new->chunk, pthread_descr, 2048);
-#else
- new->reserved_bottom = ((unsigned long) pthread_descr | (new->size - 1)) - (unsigned long) pthread_descr;
- memcpy(new->chunk + new->size - new->reserved_bottom - 1, pthread_descr, new->reserved_bottom);
-#endif
-
- old->next = new;
- return new;
-}
-
-static cothread_chunk*
-cothread_chunk_new_on_stack (cothread_chunk* old)
-{
- cothread_chunk *new;
- void *pthread_descr;
- struct rlimit limit;
-
- getrlimit (RLIMIT_STACK, &limit);
- g_print ("stack limit: %d\nstack max: %d\n", limit.rlim_cur, limit.rlim_max);
- limit.rlim_cur += old->size;
- if (setrlimit (RLIMIT_STACK, &limit)) {
- perror ("Could not increase the stack size, aborting...");
- return NULL;
- }
-
- new = cothread_chunk_new (old->size, FALSE);
- new->reserved_bottom = 0;
-
-#if PTH_STACK_GROWTH > 0
- /* we don't really know pthread_descr's size in this case, but we can be
- * conservative. it's normally 1K in the down-growing case, so we allocate 2K.
- */
- new->chunk += new->size;
-#else
- new->chunk -= new->size;
-#endif
-
- old->next = new;
- return new;
-}
+++ /dev/null
-/* Pthread-friendly coroutines with pth
- * Copyright (C) 2002 Andy Wingo <wingo@pobox.com>
- *
- * cothread-private.h: private prototypes
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __COTHREAD_PRIVATE_H__
-#define __COTHREAD_PRIVATE_H__
-
-#include <cothreads.h>
-
-typedef struct _cothread_private cothread_private;
-
-struct _cothread_private {
- int argc;
- void **argv;
- void (*func) (int argc, void **argv);
-};
-
-extern cothreads_config *_cothreads_config_global;
-
-
-gboolean cothread_stack_alloc_on_gthread_stack (char **low, char **high);
-gboolean cothread_stack_alloc_linuxthreads (char **low, char **high);
-gboolean cothread_stack_alloc_on_heap (char **low, char **high);
-
-
-#endif /* __COTHREAD_PRIVATE_H__ */
+++ /dev/null
-/* Pthread-friendly coroutines with pth
- * Copyright (C) 2002 Andy Wingo <wingo@pobox.com>
- *
- * cothreads.c: public API implementation
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include "cothreads-private.h"
-
-#define HAVE_LINUXTHREADS
-
-#ifdef HAVE_LINUXTHREADS
-static cothreads_config cothreads_config_default = COTHREADS_CONFIG_LINUXTHREADS_INITIALIZER;
-#else
-static cothreads_config cothreads_config_default = COTHREADS_CONFIG_GTHREAD_INITIALIZER;
-#endif
-
-cothreads_config *_cothreads_config_global = NULL;
-
-static gboolean (*stack_alloc_func) (char**, char**);
-
-static void cothread_private_set (char *sp, void *priv, size_t size);
-static void cothread_private_get (char *sp, void *priv, size_t size);
-static void cothread_stub (void);
-
-
-/**
- * cothreads_initialized:
- *
- * Query the state of the cothreads system.
- *
- * Returns: TRUE if cothreads_init() has already been called, FALSE otherwise
- */
-gboolean
-cothreads_initialized (void)
-{
- return (_cothreads_config_global != NULL);
-}
-
-/**
- * cothreads_init:
- * @config: attributes for creation of cothread stacks
- *
- * Initialize the cothreads system. If @config is NULL, use the default parameters
- * detected at compile-time.
- */
-void
-cothreads_init (cothreads_config *config)
-{
- static cothreads_config _config;
-
- if (cothreads_initialized()) {
- g_warning ("cothread system has already been initialized");
- return;
- }
-
- /* we don't hold on to *config, we copy it (if it's supplied) */
- if (!config)
- _config = cothreads_config_default;
- else
- _config = *config;
-
- _cothreads_config_global = &_config;
-
- switch (_cothreads_config_global->method) {
- case COTHREADS_ALLOC_METHOD_MALLOC:
- stack_alloc_func = cothread_stack_alloc_on_heap;
- break;
- case COTHREADS_ALLOC_METHOD_GTHREAD_STACK:
- stack_alloc_func = cothread_stack_alloc_on_gthread_stack;
- break;
- case COTHREADS_ALLOC_METHOD_LINUXTHREADS:
- stack_alloc_func = cothread_stack_alloc_linuxthreads;
- break;
- default:
- g_error ("unexpected value for config method %d", _cothreads_config_global->method);
- }
-}
-
-/**
- * cothread_create:
- * @func: function to start with this cothread
- * @argc: argument count
- * @argv: argument vector
- *
- * Create a new cothread running a given function. You must explictly switch
- * into this cothread to give it control. If @func is NULL, a cothread is
- * created on the current stack with the current stack pointer.
- *
- * Returns: A pointer to the new cothread
- */
-cothread*
-cothread_create (void (*func)(int, void **), int argc, void **argv)
-{
- char *low, *high;
- cothread_private priv;
- cothread *ret = g_new0 (cothread, 1);
-
- if (!func) {
- /* we are being asked to save the current thread into a new cothread. this
- * only happens for the first cothread. */
- if (_cothreads_config_global->alloc_cothread_0)
- if (!stack_alloc_func (&low, &high))
- g_error ("couldn't create cothread 0");
- else
- g_message ("created cothread 0 with low=%p, high=%p", low, high);
- else
- g_message ("created cothread 0");
-
- pth_mctx_save (ret);
- return ret;
- }
-
- if (!stack_alloc_func (&low, &high))
- g_error ("could not allocate a new cothread stack");
-
- g_message ("created a cothread with low=%p, high=%p", low, high);
-
- pth_mctx_set (ret, cothread_stub, low, high);
-
- priv.argc = argc;
- priv.argv = argv;
- priv.func = func;
- cothread_private_set (low, &priv, sizeof(priv));
-
- return ret;
-}
-
-/**
- * cothread_destroy:
- * @thread: cothread to destroy
- *
- * Deallocate any memory used by the cothread data structures.
- */
-void
-cothread_destroy (cothread *thread)
-{
- /* FIXME: have method-specific destroy functions. */
-
- g_free (thread);
-}
-
-/* the whole 'page size' thing is to allow for the last page of a stack or chunk
- * to be mmap'd as a boundary page */
-
-static void
-cothread_private_set (char *sp, void *priv, size_t size)
-{
- char *dest;
-
-#if PTH_STACK_GROWTH > 0
- dest = (char*) ((gulong)sp | (_cothreads_config_global->chunk_size / _cothreads_config_global->blocks_per_chunk - 1))
- - size + 1 - getpagesize();
-#else
- dest = (char*) ((gulong)sp &~ (_cothreads_config_global->chunk_size / _cothreads_config_global->blocks_per_chunk - 1))
- + getpagesize();
-#endif
-
- memcpy (dest, priv, size);
-}
-
-static void
-cothread_private_get (char *sp, void *priv, size_t size)
-{
- char *src;
-
-#if PTH_STACK_GROWTH > 0
- src = (char*) ((gulong)sp | (_cothreads_config_global->chunk_size / _cothreads_config_global->blocks_per_chunk - 1))
- - size + 1 - getpagesize();
-#else
- src = (char*) ((gulong)sp &~ (_cothreads_config_global->chunk_size / _cothreads_config_global->blocks_per_chunk - 1))
- + getpagesize();
-#endif
-
- memcpy (priv, src, size);
-}
-
-static void
-cothread_stub (void)
-{
- cothread_private priv;
-
- cothread_private_get (CURRENT_STACK_FRAME, &priv, sizeof (priv));
-
- priv.func (priv.argc, priv.argv);
-
- g_warning ("we really shouldn't get here");
-}
-
+++ /dev/null
-/* Pthread-friendly coroutines with pth
- * Copyright (C) 2002 Andy Wingo <wingo@pobox.com>
- *
- * cothread.h: public API
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __COTHREAD_H__
-#define __COTHREAD_H__
-
-#include <glib.h>
-#include <pth_p.h>
-
-
-#ifndef CURRENT_STACK_FRAME
-#define CURRENT_STACK_FRAME ({ char __csf; &__csf; })
-#endif /* CURRENT_STACK_FRAME */
-
-
-typedef pth_mctx_t cothread;
-typedef enum _cothreads_alloc_method cothreads_alloc_method;
-typedef struct _cothreads_config cothreads_config;
-
-
-enum _cothreads_alloc_method
-{
- COTHREADS_ALLOC_METHOD_MALLOC, /* cothread stacks on the heap, one block per chunk */
- COTHREADS_ALLOC_METHOD_GTHREAD_STACK, /* cothread stacks within the current gthread's stack */
- COTHREADS_ALLOC_METHOD_LINUXTHREADS, /* a hack that allows for linuxthreads compatibility */
-};
-
-struct _cothreads_config {
- cothreads_alloc_method method; /* the method of allocating new cothread stacks */
- int chunk_size; /* size of contiguous chunk of memory for cothread stacks */
- int blocks_per_chunk; /* cothreads per chunk */
- gboolean alloc_cothread_0; /* if the first cothread needs to be allocated */
-};
-
-#define COTHREADS_CONFIG_HEAP_INITIALIZER { \
- COTHREADS_ALLOC_METHOD_MALLOC, /* each cothread on the heap */ \
- 0x20000, /* stack size of 128 kB */ \
- 1, /* we aren't chunked */ \
- FALSE /* nothing special for cothread 0 */ \
-}
-
-#define COTHREADS_CONFIG_GTHREAD_INITIALIZER { \
- COTHREADS_ALLOC_METHOD_GTHREAD_STACK, /* this is what the old cothreads code does */ \
- 0x100000, /* only 1 MB due the the FreeBSD defaults */ \
- 8, /* for a stack size of 128 KB */ \
- TRUE /* set up the first chunk */ \
-}
-
-#define COTHREADS_CONFIG_LINUXTHREADS_INITIALIZER { \
- COTHREADS_ALLOC_METHOD_LINUXTHREADS, /* use the linuxthreads hack */ \
- 0x200000, /* 2 MB */ \
- 8, /* for a stack size of 256 KB */ \
- TRUE /* set up the first chunk */ \
-}
-
-gboolean cothreads_initialized (void);
-void cothreads_init (cothreads_config *config);
-
-cothread* cothread_create (void (*func)(int, void**), int argc, void **argv);
-void cothread_destroy (cothread *thread);
-
-/* 'old' and 'new' are of type (cothread*) */
-#define cothread_switch(old,new) pth_mctx_switch(old,new)
-#define cothread_yield(new) pth_mctx_restore(new);
-
-#endif /* __COTHREAD_H__ */
+++ /dev/null
-#ifndef _GNU_SOURCE /* pull in the nonposix static mutex initializers */
-#define _GNU_SOURCE
-#define __USE_GNU /* just to be sure */
-#endif
-
-#include <pthread.h>
-
-#ifndef CURRENT_STACK_FRAME
-#define CURRENT_STACK_FRAME ({ char __csf; &__csf; })
-#endif /* CURRENT_STACK_FRAME */
-
-#define STACK_SIZE 0x200000
-
-/* this function is only really necessary to get the main thread's
- * pthread_descr, as the other threads store the pthread_descr (actually the
- * first member of struct _pthread_descr_struct, which points to itself for the
- * default non-indirected case) at the top of the stack. */
-static inline _pthread_descr __linuxthreads_self()
-{
- pthread_mutex_t mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
- _pthread_descr self;
-
- pthread_mutex_lock (&mutex);
- self = mutex.__m_owner;
- pthread_mutex_unlock (&mutex);
-
- printf ("pthread_self: %d\n", pthread_self());
- printf ("descr: %p\n", self);
- printf ("*descr: %p\n", *(int*)self);
-
- return self;
-}
-
+++ /dev/null
-# Configure paths for GLIB
-# Owen Taylor 97-11-3
-
-dnl AM_PATH_GLIB([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
-dnl Test for GLIB, and define GLIB_CFLAGS and GLIB_LIBS, if "gmodule" or
-dnl gthread is specified in MODULES, pass to glib-config
-dnl
-AC_DEFUN(AM_PATH_GLIB,
-[dnl
-dnl Get the cflags and libraries from the glib-config script
-dnl
-AC_ARG_WITH(glib-prefix,[ --with-glib-prefix=PFX Prefix where GLIB is installed (optional)],
- glib_config_prefix="$withval", glib_config_prefix="")
-AC_ARG_WITH(glib-exec-prefix,[ --with-glib-exec-prefix=PFX Exec prefix where GLIB is installed (optional)],
- glib_config_exec_prefix="$withval", glib_config_exec_prefix="")
-AC_ARG_ENABLE(glibtest, [ --disable-glibtest Do not try to compile and run a test GLIB program],
- , enable_glibtest=yes)
-
- if test x$glib_config_exec_prefix != x ; then
- glib_config_args="$glib_config_args --exec-prefix=$glib_config_exec_prefix"
- if test x${GLIB_CONFIG+set} != xset ; then
- GLIB_CONFIG=$glib_config_exec_prefix/bin/glib-config
- fi
- fi
- if test x$glib_config_prefix != x ; then
- glib_config_args="$glib_config_args --prefix=$glib_config_prefix"
- if test x${GLIB_CONFIG+set} != xset ; then
- GLIB_CONFIG=$glib_config_prefix/bin/glib-config
- fi
- fi
-
- for module in . $4
- do
- case "$module" in
- gmodule)
- glib_config_args="$glib_config_args gmodule"
- ;;
- gthread)
- glib_config_args="$glib_config_args gthread"
- ;;
- esac
- done
-
- AC_PATH_PROG(GLIB_CONFIG, glib-config, no)
- min_glib_version=ifelse([$1], ,0.99.7,$1)
- AC_MSG_CHECKING(for GLIB - version >= $min_glib_version)
- no_glib=""
- if test "$GLIB_CONFIG" = "no" ; then
- no_glib=yes
- else
- GLIB_CFLAGS=`$GLIB_CONFIG $glib_config_args --cflags`
- GLIB_LIBS=`$GLIB_CONFIG $glib_config_args --libs`
- glib_config_major_version=`$GLIB_CONFIG $glib_config_args --version | \
- sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
- glib_config_minor_version=`$GLIB_CONFIG $glib_config_args --version | \
- sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
- glib_config_micro_version=`$GLIB_CONFIG $glib_config_args --version | \
- sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
- if test "x$enable_glibtest" = "xyes" ; then
- ac_save_CFLAGS="$CFLAGS"
- ac_save_LIBS="$LIBS"
- CFLAGS="$CFLAGS $GLIB_CFLAGS"
- LIBS="$GLIB_LIBS $LIBS"
-dnl
-dnl Now check if the installed GLIB is sufficiently new. (Also sanity
-dnl checks the results of glib-config to some extent
-dnl
- rm -f conf.glibtest
- AC_TRY_RUN([
-#include <glib.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-int
-main ()
-{
- int major, minor, micro;
- char *tmp_version;
-
- system ("touch conf.glibtest");
-
- /* HP/UX 9 (%@#!) writes to sscanf strings */
- tmp_version = g_strdup("$min_glib_version");
- if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
- printf("%s, bad version string\n", "$min_glib_version");
- exit(1);
- }
-
- if ((glib_major_version != $glib_config_major_version) ||
- (glib_minor_version != $glib_config_minor_version) ||
- (glib_micro_version != $glib_config_micro_version))
- {
- printf("\n*** 'glib-config --version' returned %d.%d.%d, but GLIB (%d.%d.%d)\n",
- $glib_config_major_version, $glib_config_minor_version, $glib_config_micro_version,
- glib_major_version, glib_minor_version, glib_micro_version);
- printf ("*** was found! If glib-config was correct, then it is best\n");
- printf ("*** to remove the old version of GLIB. You may also be able to fix the error\n");
- printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
- printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
- printf("*** required on your system.\n");
- printf("*** If glib-config was wrong, set the environment variable GLIB_CONFIG\n");
- printf("*** to point to the correct copy of glib-config, and remove the file config.cache\n");
- printf("*** before re-running configure\n");
- }
- else if ((glib_major_version != GLIB_MAJOR_VERSION) ||
- (glib_minor_version != GLIB_MINOR_VERSION) ||
- (glib_micro_version != GLIB_MICRO_VERSION))
- {
- printf("*** GLIB header files (version %d.%d.%d) do not match\n",
- GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION);
- printf("*** library (version %d.%d.%d)\n",
- glib_major_version, glib_minor_version, glib_micro_version);
- }
- else
- {
- if ((glib_major_version > major) ||
- ((glib_major_version == major) && (glib_minor_version > minor)) ||
- ((glib_major_version == major) && (glib_minor_version == minor) && (glib_micro_version >= micro)))
- {
- return 0;
- }
- else
- {
- printf("\n*** An old version of GLIB (%d.%d.%d) was found.\n",
- glib_major_version, glib_minor_version, glib_micro_version);
- printf("*** You need a version of GLIB newer than %d.%d.%d. The latest version of\n",
- major, minor, micro);
- printf("*** GLIB is always available from ftp://ftp.gtk.org.\n");
- printf("***\n");
- printf("*** If you have already installed a sufficiently new version, this error\n");
- printf("*** probably means that the wrong copy of the glib-config shell script is\n");
- printf("*** being found. The easiest way to fix this is to remove the old version\n");
- printf("*** of GLIB, but you can also set the GLIB_CONFIG environment to point to the\n");
- printf("*** correct copy of glib-config. (In this case, you will have to\n");
- printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
- printf("*** so that the correct libraries are found at run-time))\n");
- }
- }
- return 1;
-}
-],, no_glib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
- CFLAGS="$ac_save_CFLAGS"
- LIBS="$ac_save_LIBS"
- fi
- fi
- if test "x$no_glib" = x ; then
- AC_MSG_RESULT(yes)
- ifelse([$2], , :, [$2])
- else
- AC_MSG_RESULT(no)
- if test "$GLIB_CONFIG" = "no" ; then
- echo "*** The glib-config script installed by GLIB could not be found"
- echo "*** If GLIB was installed in PREFIX, make sure PREFIX/bin is in"
- echo "*** your path, or set the GLIB_CONFIG environment variable to the"
- echo "*** full path to glib-config."
- else
- if test -f conf.glibtest ; then
- :
- else
- echo "*** Could not run GLIB test program, checking why..."
- CFLAGS="$CFLAGS $GLIB_CFLAGS"
- LIBS="$LIBS $GLIB_LIBS"
- AC_TRY_LINK([
-#include <glib.h>
-#include <stdio.h>
-], [ return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); ],
- [ echo "*** The test program compiled, but did not run. This usually means"
- echo "*** that the run-time linker is not finding GLIB or finding the wrong"
- echo "*** version of GLIB. If it is not finding GLIB, you'll need to set your"
- echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
- echo "*** to the installed location Also, make sure you have run ldconfig if that"
- echo "*** is required on your system"
- echo "***"
- echo "*** If you have an old version installed, it is best to remove it, although"
- echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
- echo "***"
- echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
- echo "*** came with the system with the command"
- echo "***"
- echo "*** rpm --erase --nodeps gtk gtk-devel" ],
- [ echo "*** The test program failed to compile or link. See the file config.log for the"
- echo "*** exact error that occured. This usually means GLIB was incorrectly installed"
- echo "*** or that you have moved GLIB since it was installed. In the latter case, you"
- echo "*** may want to edit the glib-config script: $GLIB_CONFIG" ])
- CFLAGS="$ac_save_CFLAGS"
- LIBS="$ac_save_LIBS"
- fi
- fi
- GLIB_CFLAGS=""
- GLIB_LIBS=""
- ifelse([$3], , :, [$3])
- fi
- AC_SUBST(GLIB_CFLAGS)
- AC_SUBST(GLIB_LIBS)
- rm -f conf.glibtest
-])
+++ /dev/null
-dnl Perform a check for a feature for GStreamer
-dnl Richard Boulton <richard-alsa@tartarus.org>
-dnl Thomas Vander Stichele <thomas@apestaart.org> added useful stuff
-dnl Last modification: 25/06/2001
-dnl GST_CHECK_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION,
-dnl DEPENDENT-PLUGINS, TEST-FOR-FEATURE,
-dnl DISABLE-BY-DEFAULT, ACTION-IF-USE, ACTION-IF-NOTUSE)
-dnl
-dnl This macro adds a command line argument to enable the user to enable
-dnl or disable a feature, and if the feature is enabled, performs a supplied
-dnl test to check if the feature is available.
-dnl
-dnl The test should define HAVE_<FEATURE-NAME> to "yes" or "no" depending
-dnl on whether the feature is available.
-dnl
-dnl The macro will set USE_<FEATURE-NAME> to "yes" or "no" depending on
-dnl whether the feature is to be used.
-dnl Thomas changed this, so that when USE_<FEATURE-NAME> was already set
-dnl to no, then it stays that way.
-dnl
-dnl The macro will call AM_CONDITIONAL(USE_<<FEATURE-NAME>, ...) to allow
-dnl the feature to control what is built in Makefile.ams. If you want
-dnl additional actions resulting from the test, you can add them with the
-dnl ACTION-IF-USE and ACTION-IF-NOTUSE parameters.
-dnl
-dnl FEATURE-NAME is the name of the feature, and should be in
-dnl purely upper case characters.
-dnl FEATURE-DESCRIPTION is used to describe the feature in help text for
-dnl the command line argument.
-dnl DEPENDENT-PLUGINS lists any plugins which depend on this feature.
-dnl TEST-FOR-FEATURE is a test which sets HAVE_<FEATURE-NAME> to "yes"
-dnl or "no" depending on whether the feature is
-dnl available.
-dnl DISABLE-BY-DEFAULT if "disabled", the feature is disabled by default,
-dnl if any other value, the feature is enabled by default.
-dnl ACTION-IF-USE any extra actions to perform if the feature is to be
-dnl used.
-dnl ACTION-IF-NOTUSE any extra actions to perform if the feature is not to
-dnl be used.
-dnl
-dnl
-dnl thomas :
-dnl we also added a history.
-dnl GST_PLUGINS_YES will contain all plugins to be built
-dnl that were checked through GST_CHECK_FEATURE
-dnl GST_PLUGINS_NO will contain those that won't be built
-
-AC_DEFUN(GST_CHECK_FEATURE,
-[dnl
-builtin(define, [gst_endisable], ifelse($5, [disabled], [enable], [disable]))dnl
-dnl if it is set to NO, then don't even consider it for building
-NOUSE=
-if test "x$USE_[$1]" = "xno"; then
- NOUSE="yes"
-fi
-AC_ARG_ENABLE(translit([$1], A-Z, a-z),
- [ ]builtin(format, --%-26s gst_endisable %s, gst_endisable-translit([$1], A-Z, a-z), [$2]ifelse([$3],,,: [$3])),
- [ case "${enableval}" in
- yes) USE_[$1]=yes;;
- no) USE_[$1]=no;;
- *) AC_MSG_ERROR(bad value ${enableval} for --enable-translit([$1], A-Z, a-z)) ;;
- esac],
- [ USE_$1=]ifelse($5, [disabled], [no], [yes])) dnl DEFAULT
-
-dnl *** set it back to no if it was preset to no
-if test "x$NOUSE" = "xyes"; then
- USE_[$1]="no"
- AC_MSG_WARN(*** $3 pre-configured not to be built)
-fi
-NOUSE=
-
-dnl *** If it's enabled
-
-if test x$USE_[$1] = xyes; then
- gst_check_save_LIBS=$LIBS
- gst_check_save_LDFLAGS=$LDFLAGS
- gst_check_save_CFLAGS=$CFLAGS
- gst_check_save_CPPFLAGS=$CPPFLAGS
- gst_check_save_CXXFLAGS=$CXXFLAGS
- HAVE_[$1]=no
- $4
- LIBS=$gst_check_save_LIBS
- LDFLAGS=$gst_check_save_LDFLAGS
- CFLAGS=$gst_check_save_CFLAGS
- CPPFLAGS=$gst_check_save_CPPFLAGS
- CXXFLAGS=$gst_check_save_CXXFLAGS
-
- dnl If it isn't found, unset USE_[$1]
- if test x$HAVE_[$1] = xno; then
- USE_[$1]=no
- fi
-fi
-dnl *** Warn if it's disabled or not found
-if test x$USE_[$1] = xyes; then
- ifelse([$6], , :, [$6])
- GST_PLUGINS_YES="$GST_PLUGINS_YES \n\t[$3]"
-else
- ifelse([$3], , :, [AC_MSG_NOTICE(
-These plugins will not be built: [$3]
-)])
- GST_PLUGINS_NO="$GST_PLUGINS_NO \n\t[$3]"
- ifelse([$7], , :, [$7])
-fi
-dnl *** Define the conditional as appropriate
-AM_CONDITIONAL(USE_[$1], test x$USE_[$1] = xyes)
-])
-
-dnl Use a -config program which accepts --cflags and --libs parameters
-dnl to set *_CFLAGS and *_LIBS and check existence of a feature.
-dnl Richard Boulton <richard-alsa@tartarus.org>
-dnl Last modification: 26/06/2001
-dnl GST_CHECK_CONFIGPROG(FEATURE-NAME, CONFIG-PROG-FILENAME, MODULES)
-dnl
-dnl This check was written for GStreamer: it should be renamed and checked
-dnl for portability if you decide to use it elsewhere.
-dnl
-AC_DEFUN(GST_CHECK_CONFIGPROG,
-[
- AC_PATH_PROG([$1]_CONFIG, [$2], no)
- if test x$[$1]_CONFIG = xno; then
- [$1]_LIBS=
- [$1]_CFLAGS=
- HAVE_[$1]=no
- else
- [$1]_LIBS=`[$2] --libs [$3]`
- [$1]_CFLAGS=`[$2] --cflags [$3]`
- HAVE_[$1]=yes
- fi
- AC_SUBST([$1]_LIBS)
- AC_SUBST([$1]_CFLAGS)
-])
-
-dnl Use AC_CHECK_LIB and AC_CHECK_HEADER to do both tests at once
-dnl sets HAVE_module if we have it
-dnl Richard Boulton <richard-alsa@tartarus.org>
-dnl Last modification: 26/06/2001
-dnl GST_CHECK_LIBHEADER(FEATURE-NAME, LIB NAME, LIB FUNCTION, EXTRA LD FLAGS,
-dnl HEADER NAME, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
-dnl
-dnl This check was written for GStreamer: it should be renamed and checked
-dnl for portability if you decide to use it elsewhere.
-dnl
-AC_DEFUN(GST_CHECK_LIBHEADER,
-[
- AC_CHECK_LIB([$2], [$3], HAVE_[$1]=yes, HAVE_[$1]=no,[$4])
- if test "x$HAVE_[$1]" = "xyes"; then
- AC_CHECK_HEADER([$5], :, HAVE_[$1]=no)
- if test "x$HAVE_[$1]" = "xyes"; then
- dnl execute what needs to be
- ifelse([$6], , :, [$6])
- else
- ifelse([$7], , :, [$7])
- fi
- else
- AC_MSG_WARN([$1] not found)
- fi
- AC_SUBST(HAVE_[$1])
-]
-)
-
-dnl
-dnl Add a subsystem --disable flag and all the necessary symbols and substitions
-dnl
-dnl GST_SUBSYSTEM_DISABLE(SYSNAME, [subsystem name])
-dnl
-AC_DEFUN(GST_SUBSYSTEM_DISABLE,
-[AC_ARG_ENABLE(translit([$1], A-Z, a-z),
-[ ]builtin(format, --disable-%-17s disable %s, translit([$1], A-Z, a-z), $2),
-[ case "${enableval}" in
- yes) GST_DISABLE_[$1]=no ;;
- no) GST_DISABLE_[$1]=yes ;;
- *) AC_MSG_ERROR(bad value ${enableval} for --enable-translit([$1], A-Z, a-z)) ;;
- esac],
-[GST_DISABLE_[$1]=no]) dnl Default value
-if test x$GST_DISABLE_[$1] = xyes; then
- AC_DEFINE(GST_DISABLE_[$1], 1, [Disable $2])
- GST_DISABLE_[$1]_DEFINE=-DGST_DISABLE_[$1]
-fi
-AM_CONDITIONAL(GST_DISABLE_[$1], test x$GST_DISABLE_[$1] = xyes)
-AC_SUBST(GST_DISABLE_[$1]_DEFINE)
-GST_SUBSYSTEM_DISABLE_DEFINES="$GST_SUBSYTEM_DISABLE_DEFINES $GST_DISABLE_[$1]_DEFINE"
-])
+++ /dev/null
-dnl Check for LinuxThreads
-dnl COTHREADS_CHECK_LINUXTHREADS
-dnl no arguments
-AC_DEFUN([COTHREADS_CHECK_LINUXTHREADS], [
- AC_CACHE_CHECK([for LinuxThreads],
- [cothreads_cv_linuxthreads],
- [AC_EGREP_CPP(pthread_kill_other_threads_np,
- [#include <pthread.h>],
- [cothreads_cv_linuxthreads=yes],
- [cothreads_cv_linuxthreads=no])
- ])
- if test $cothreads_cv_linuxthreads = yes; then
- AC_DEFINE(HAVE_LINUXTHREADS,1,[if you have LinuxThreads])
- fi
-])
+++ /dev/null
-
-dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not)
-dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
-dnl also defines GSTUFF_PKG_ERRORS on error
-AC_DEFUN(PKG_CHECK_MODULES, [
- succeeded=no
-
- if test -z "$PKG_CONFIG"; then
- AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
- fi
-
- if test "$PKG_CONFIG" = "no" ; then
- echo "*** The pkg-config script could not be found. Make sure it is"
- echo "*** in your path, or set the PKG_CONFIG environment variable"
- echo "*** to the full path to pkg-config."
- echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
- else
- if ! $PKG_CONFIG --atleast-pkgconfig-version 0.7.0; then
- echo "*** Your version of pkg-config is too old. You need version 0.7.0 or newer."
- echo "*** See http://www.freedesktop.org/software/pkgconfig"
- else
- AC_MSG_CHECKING(for $2)
-
- if $PKG_CONFIG --exists "$2" ; then
- AC_MSG_RESULT(yes)
- succeeded=yes
-
- AC_MSG_CHECKING($1_CFLAGS)
- $1_CFLAGS=`$PKG_CONFIG --cflags "$2"`
- AC_MSG_RESULT($$1_CFLAGS)
-
- AC_MSG_CHECKING($1_LIBS)
- $1_LIBS=`$PKG_CONFIG --libs "$2"`
- AC_MSG_RESULT($$1_LIBS)
- else
- $1_CFLAGS=""
- $1_LIBS=""
- ## If we have a custom action on failure, don't print errors, but
- ## do set a variable so people can do so.
- $1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
- ifelse([$4], ,echo $$1_PKG_ERRORS,)
- fi
-
- AC_SUBST($1_CFLAGS)
- AC_SUBST($1_LIBS)
- fi
- fi
-
- if test $succeeded = yes; then
- ifelse([$3], , :, [$3])
- else
- ifelse([$4], , AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.]), [$4])
- fi
-])
-
-
+++ /dev/null
-dnl ##
-dnl ## NGPT - Next Generation POSIX Threading
-dnl ## Copyright (c) 2001 IBM Corporation <babt@us.ibm.com>
-dnl ## Copyright (c) 1999-2000 Ralf S. Engelschall <rse@engelschall.com>
-dnl ##
-dnl ## This file is part of NGPT, a non-preemptive thread scheduling
-dnl ## library which can be found at http://www.ibm.com/developer
-dnl ##
-dnl ## This library is free software; you can redistribute it and/or
-dnl ## modify it under the terms of the GNU Lesser General Public
-dnl ## License as published by the Free Software Foundation; either
-dnl ## version 2.1 of the License, or (at your option) any later version.
-dnl ##
-dnl ## This library 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 GNU
-dnl ## Lesser General Public License for more details.
-dnl ##
-dnl ## You should have received a copy of the GNU Lesser General Public
-dnl ## License along with this library; if not, write to the Free Software
-dnl ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-dnl ## USA, or contact Bill Abt <babt@us.ibm.com>
-dnl ##
-dnl ## aclocal.m4: Pth Autoconf macros
-dnl ##
- dnl # ``"Reuse an expert's code" is the right
- dnl # advice for most people. But it's a useless
- dnl # advice for the experts writing the code
- dnl # in the first place.'
- dnl # -- Dan J. Bernstein
-
-dnl ##
-dnl ## Display Configuration Headers
-dnl ##
-dnl ## configure.in:
-dnl ## AC_MSG_PART(<text>)
-dnl ##
-
-define(AC_MSG_PART,[dnl
-if test ".$enable_subdir" != .yes; then
- AC_MSG_RESULT()
- AC_MSG_RESULT(${TB}$1:${TN})
-fi
-])dnl
-
-dnl ##
-dnl ## Display a message under --verbose
-dnl ##
-dnl ## configure.in:
-dnl ## AC_MSG_VERBOSE(<text>)
-dnl ##
-
-define(AC_MSG_VERBOSE,[dnl
-if test ".$verbose" = .yes; then
- AC_MSG_RESULT([ $1])
-fi
-])
-
-dnl ##
-dnl ## Do not display message for a command
-dnl ##
-dnl ## configure.in:
-dnl ## AC_MSG_SILENT(...)
-dnl ##
-
-define(AC_FD_TMP, 9)
-define(AC_MSG_SILENT,[dnl
-exec AC_FD_TMP>&AC_FD_MSG AC_FD_MSG>/dev/null
-$1
-exec AC_FD_MSG>&AC_FD_TMP AC_FD_TMP>&-
-])
-
-dnl ##
-dnl ## Perform something only once
-dnl ##
-dnl ## configure.in:
-dnl ## AC_ONCE(<action>)
-dnl ##
-
-define(AC_ONCE,[
-ifelse(ac_once_$1, already_done, ,[
- define(ac_once_$1, already_done)
- $2
-])dnl
-])
-
-dnl ##
-dnl ## Support for $(S)
-dnl ##
-dnl ## configure.in:
-dnl ## AC_SRCDIR_PREFIX(<varname>)
-dnl ##
-
-AC_DEFUN(AC_SRCDIR_PREFIX,[
-ac_prog=[$]0
-changequote(, )dnl
-ac_srcdir=`echo $ac_prog | sed -e 's%/[^/][^/]*$%%' -e 's%\([^/]\)/*$%\1%'`
-changequote([, ])dnl
-if test ".$ac_srcdir" = ".$ac_prog"; then
- ac_srcdir=""
-elif test "x$ac_srcdir" = "x."; then
- ac_srcdir=""
-else
- if test ".$CFLAGS" = .; then
- CFLAGS="-I$ac_srcdir"
- else
- CFLAGS="$CFLAGS -I$ac_srcdir"
- fi
- ac_srcdir="$ac_srcdir/"
-fi
-$1="$ac_srcdir"
-AC_SUBST($1)
-])dnl
-
-dnl ##
-dnl ## Support for --enable-subdir (for use with pth.m4)
-dnl ##
-dnl ## configure.in:
-dnl ## AC_ENABLESUBDIR
-dnl ##
-
-AC_DEFUN(AC_ENABLESUBDIR,[
-AC_ARG_ENABLE(subdir,dnl
-[ --enable-subdir enable local building as subdirectory (default=no)],[dnl
-],[dnl
-enable_subdir=no
-])dnl
-if test ".$enable_subdir" = .yes; then
- enable_batch=yes
- enable_shared=no
-fi
-])dnl
-
-dnl ##
-dnl ## Support for Configuration Headers
-dnl ##
-dnl ## configure.in:
-dnl ## AC_HEADLINE(<short-name>, <long-name>,
-dnl ## <vers-var>, <vers-file>,
-dnl ## <copyright>)
-dnl ##
-
-AC_DEFUN(AC_HEADLINE,[dnl
-AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)dnl
-# configuration header
-if test ".`echo dummy [$]@ | grep enable-subdir`" != .; then
- enable_subdir=yes
-fi
-if test ".`echo dummy [$]@ | grep help`" = .; then
- # bootstrapping shtool
- ac_prog=[$]0
-changequote(, )dnl
- ac_srcdir=`echo $ac_prog | sed -e 's%/[^/][^/]*$%%' -e 's%\([^/]\)/*$%\1%'`
-changequote([, ])dnl
- test ".$ac_srcdir" = ".$ac_prog" && ac_srcdir=.
- ac_shtool="${CONFIG_SHELL-/bin/sh} $ac_srcdir/shtool"
-
- # find out terminal sequences
- if test ".$enable_subdir" != .yes; then
- TB=`$ac_shtool echo -n -e %B 2>/dev/null`
- TN=`$ac_shtool echo -n -e %b 2>/dev/null`
- else
- TB=''
- TN=''
- fi
-
- # find out package version
- $3_STR="`$ac_shtool version -lc -dlong $ac_srcdir/$4`"
- AC_SUBST($3_STR)
-
- # friendly header ;)
- if test ".$enable_subdir" != .yes; then
- echo "Configuring ${TB}$1${TN} ($2), Version ${TB}${$3_STR}${TN}"
- echo "$5"
- fi
-
- # additionally find out hex version
- $3_HEX="`$ac_shtool version -lc -dhex $ac_srcdir/$4`"
- AC_SUBST($3_HEX)
-fi
-AC_DIVERT_POP()
-])dnl
-
-dnl ##
-dnl ## Support for Platform IDs
-dnl ##
-dnl ## configure.in:
-dnl ## AC_PLATFORM(<variable>)
-dnl ##
-
-AC_DEFUN(AC_PLATFORM,[
-if test ".$host" != .NONE; then
- $1="$host"
-elif test ".$nonopt" != .NONE; then
- $1="$nonopt"
-else
- $1=`${CONFIG_SHELL-/bin/sh} $srcdir/config.guess`
-fi
-$1=`${CONFIG_SHELL-/bin/sh} $srcdir/config.sub $$1` || exit 1
-AC_SUBST($1)
-if test ".$enable_subdir" != .yes; then
- echo "Platform: ${TB}${$1}${TN}"
-fi
-])dnl
-
-dnl ##
-dnl ## Support for config.param files
-dnl ##
-dnl ## configure.in:
-dnl ## AC_CONFIG_PARAM(<file>)
-dnl ##
-
-AC_DEFUN(AC_CONFIG_PARAM,[
-AC_DIVERT_PUSH(-1)
-AC_ARG_WITH(param,[ --with-param=ID[,ID,..] load parameters from $1])
-AC_DIVERT_POP()
-AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)
-ac_prev=""
-ac_param=""
-if test -f $1; then
- ac_param="$1:common"
-fi
-for ac_option
-do
- if test ".$ac_prev" != .; then
- eval "$ac_prev=\$ac_option"
- ac_prev=""
- continue
- fi
- case "$ac_option" in
- -*=*) ac_optarg=`echo "$ac_option" | sed 's/[[-_a-zA-Z0-9]]*=//'` ;;
- *) ac_optarg="" ;;
- esac
- case "$ac_option" in
- --with-param=* )
- case $ac_optarg in
- *:* )
- ac_from=`echo $ac_optarg | sed -e 's/:.*//'`
- ac_what=`echo $ac_optarg | sed -e 's/.*://'`
- ;;
- * )
- ac_from="$1"
- ac_what="$ac_optarg"
- ;;
- esac
- if test ".$ac_param" = .; then
- ac_param="$ac_from:$ac_what"
- else
- ac_param="$ac_param,$ac_from:$ac_what"
- fi
- ;;
- esac
-done
-if test ".$ac_param" != .; then
- # echo "loading parameters"
- OIFS="$IFS"
- IFS=","
- pconf="/tmp/autoconf.$$"
- echo "ac_options=''" >$pconf
- ac_from="$1"
- for ac_section in $ac_param; do
- changequote(, )
- case $ac_section in
- *:* )
- ac_from=`echo "$ac_section" | sed -e 's/:.*//'`
- ac_section=`echo "$ac_section" | sed -e 's/.*://'`
- ;;
- esac
- (echo ''; cat $ac_from; echo '') |\
- sed -e "1,/[ ]*[ ]*${ac_section}[ ]*{[ ]*/d" \
- -e '/[ ]*}[ ]*/,$d' \
- -e ':join' -e '/\\[ ]*$/N' -e 's/\\[ ]*\n[ ]*//' -e 'tjoin' \
- -e 's/^[ ]*//g' \
- -e 's/^\([^-].*=.*\) IF \(.*\)$/if \2; then \1; fi/' \
- -e 's/^\(--.*=.*\) IF \(.*\)$/if \2; then ac_options="$ac_options \1"; fi/' \
- -e 's/^\(--.*\) IF \(.*\)$/if \2; then ac_options="$ac_options \1"; fi/' \
- -e 's/^\(--.*=.*\)$/ac_options="$ac_options \1"/' \
- -e 's/^\(--.*\)$/ac_options="$ac_options \1"/' \
- >>$pconf
- changequote([, ])
- done
- IFS="$OIFS"
- . $pconf
- rm -f $pconf >/dev/null 2>&1
- if test ".[$]*" = .; then
- set -- $ac_options
- else
- set -- "[$]@" $ac_options
- fi
-fi
-AC_DIVERT_POP()
-])dnl
-
-dnl ##
-dnl ## Check whether compiler option works
-dnl ##
-dnl ## configure.in:
-dnl ## AC_COMPILER_OPTION(<name>, <display>, <option>,
-dnl ## <action-success>, <action-failure>)
-dnl ##
-
-AC_DEFUN(AC_COMPILER_OPTION,[dnl
-AC_MSG_CHECKING(for compiler option $2)
-AC_CACHE_VAL(ac_cv_compiler_option_$1,[
-cat >conftest.$ac_ext <<EOF
-int main() { return 0; }
-EOF
-${CC-cc} -c $CFLAGS $CPPFLAGS $3 conftest.$ac_ext 1>conftest.out 2>conftest.err
-if test $? -ne 0 -o -s conftest.err; then
- ac_cv_compiler_option_$1=no
-else
- ac_cv_compiler_option_$1=yes
-fi
-rm -f conftest.$ac_ext conftest.out conftest.err
-])dnl
-if test ".$ac_cv_compiler_option_$1" = .yes; then
- ifelse([$4], , :, [$4])
-else
- ifelse([$5], , :, [$5])
-fi
-AC_MSG_RESULT([$ac_cv_compiler_option_$1])
-])dnl
-
-dnl ##
-dnl ## Check whether `long long' and `long double' type exists
-dnl ##
-dnl ## configure.in:
-dnl ## AC_CHECK_LONGLONG
-dnl ## AC_CHECK_LONGDOUBLE
-dnl ##
-
-AC_DEFUN(AC_CHECK_LONGLONG,[dnl
-AC_MSG_CHECKING(for built-in type long long)
- AC_CACHE_VAL(ac_cv_type_longlong,[
- AC_TRY_LINK([
-#include <sys/types.h>
- ],[
- long long X = 2, Y = 1, Z;
- Z = X / Y;
- ],
- AC_DEFINE(HAVE_LONGLONG)
- ac_cv_type_longlong=yes,
- ac_cv_type_longlong=no
- )dnl
- ])dnl
-AC_MSG_RESULT([$ac_cv_type_longlong])
-])dnl
-
-AC_DEFUN(AC_CHECK_LONGDOUBLE,[dnl
-AC_MSG_CHECKING(for built-in type long double)
- AC_CACHE_VAL(ac_cv_type_longdouble,[
- AC_TRY_LINK([
-#include <sys/types.h>
- ],[
- long double X = 2, Y = 1, Z;
- Z = X / Y;
- ],
- AC_DEFINE(HAVE_LONGDOUBLE)
- ac_cv_type_longdouble=yes,
- ac_cv_type_longdouble=no
- )dnl
- ])dnl
-AC_MSG_RESULT([$ac_cv_type_longdouble])
-])dnl
-
-dnl ##
-dnl ## Minimalistic Libtool Glue Code
-dnl ##
-dnl ## configure.in:
-dnl ## AC_PROG_LIBTOOL(<platform-variable>)
-dnl ##
-
-AC_DEFUN(AC_PROG_LIBTOOL,[dnl
-AC_ARG_ENABLE(static,dnl
-[ --enable-static build static libraries (default=yes)],
-enable_static="$enableval",
-if test ".$enable_static" = .; then
- enable_static=yes
-fi
-)dnl
-AC_ARG_ENABLE(shared,dnl
-[ --enable-shared build shared libraries (default=yes)],
-enable_shared="$enableval",
-if test ".$enable_shared" = .; then
- enable_shared=yes
-fi
-)dnl
-libtool_flags=''
-dnl libtool_flags="$libtool_flags --cache-file=$cache_file"
-test ".$silent" = .yes && libtool_flags="$libtool_flags --silent"
-test ".$enable_static" = .no && libtool_flags="$libtool_flags --disable-static"
-test ".$enable_shared" = .no && libtool_flags="$libtool_flags --disable-shared"
-test ".$ac_cv_prog_gcc" = .yes && libtool_flags="$libtool_flags --with-gcc"
-test ".$ac_cv_prog_gnu_ld" = .yes && libtool_flags="$libtool_flags --with-gnu-ld"
-CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" LD="$LD" \
-${CONFIG_SHELL-/bin/sh} $srcdir/ltconfig --no-reexec \
-$libtool_flags --srcdir=$srcdir --no-verify $srcdir/ltmain.sh $1 ||\
-AC_MSG_ERROR([libtool configuration failed])
-dnl (AC_CACHE_LOAD) >/dev/null 2>&1
-])dnl
-
-dnl ##
-dnl ## Disable kernel patch warning
-dnl ##
-dnl ## configure.in:
-dnl ## AC_CHECK_KERNEL_PATCH_WARNING
-dnl ##
-
-AC_DEFUN(AC_CHECK_KERNEL_PATCH_WARNING,[dnl
-AC_ARG_ENABLE(kernel-patch,dnl
-[ --disable-kernel-patch-warning disable kernel patch warning(default=no)],
-[dnl
-AC_DEFINE(PTH_NO_PATCH_WARNING)
-msg="disabled"
-],[
-msg="enabled"
-])dnl
-AC_MSG_CHECKING(for 2.4 kernel patch warning)
-AC_MSG_RESULT([$msg])
-])
-
-dnl ##
-dnl ## Verbose Debugging Support
-dnl ##
-dnl ## configure.in:
-dnl ## AC_CHECK_VERBOSE_DEBUGGING
-dnl ##
-
-AC_DEFUN(AC_CHECK_VERBOSE_DEBUGGING,[dnl
-AC_ARG_ENABLE(verbose-debug,dnl
-[ --enable-verbose-debug build for verbose debugging (default=no)],
-[dnl
-if test ".$ac_cv_prog_gcc" = ".yes"; then
- case "$CFLAGS" in
- *-O* ) ;;
- * ) CFLAGS="$CFLAGS -O2" ;;
- esac
- case "$CFLAGS" in
- *-g* ) ;;
- * ) CFLAGS="$CFLAGS -g" ;;
- esac
- case "$CFLAGS" in
- *-pipe* ) ;;
- * ) AC_COMPILER_OPTION(pipe, -pipe, -pipe, CFLAGS="$CFLAGS -pipe") ;;
- esac
- AC_COMPILER_OPTION(ggdb3, -ggdb3, -ggdb3, CFLAGS="$CFLAGS -ggdb3")
- case $PLATFORM in
- *-*-freebsd*|*-*-solaris* ) CFLAGS="$CFLAGS -pedantic" ;;
- esac
- CFLAGS="$CFLAGS -Wall"
- WMORE="-Wshadow -Wpointer-arith -Wcast-align -Winline -Wno-unused-function"
- WMORE="$WMORE -Wmissing-prototypes -Wmissing-declarations -Wnested-externs"
- AC_COMPILER_OPTION(wmore, -W<xxx>, $WMORE, CFLAGS="$CFLAGS $WMORE")
- AC_COMPILER_OPTION(wnolonglong, -Wno-long-long, -Wno-long-long, CFLAGS="$CFLAGS -Wno-long-long")
-else
- case "$CFLAGS" in
- *-g* ) ;;
- * ) CFLAGS="$CFLAGS -g" ;;
- esac
-fi
-msg="enabled"
-AC_DEFINE(PTH_DEBUG)
-],[
-if test ".$ac_cv_prog_gcc" = ".yes"; then
-case "$CFLAGS" in
- *-pipe* ) ;;
- * ) AC_COMPILER_OPTION(pipe, -pipe, -pipe, CFLAGS="$CFLAGS -pipe") ;;
-esac
-fi
-case "$CFLAGS" in
- *-g* ) CFLAGS=`echo "$CFLAGS" |\
- sed -e 's/ -g / /g' -e 's/ -g$//' -e 's/^-g //g' -e 's/^-g$//'` ;;
-esac
-case "$CXXFLAGS" in
- *-g* ) CXXFLAGS=`echo "$CXXFLAGS" |\
- sed -e 's/ -g / /g' -e 's/ -g$//' -e 's/^-g //g' -e 's/^-g$//'` ;;
-esac
-msg="disabled"
-])dnl
-AC_MSG_CHECKING(for compilation debug mode)
-AC_MSG_RESULT([$msg])
- case $PLATFORM in
- *-*-mvs* )
- # Don't turn off shared libaries on OS/390.
- ;;
- * )
- if test ".$msg" = .enabled; then
- enable_shared=no
- fi
- ;;
- esac
-])
-
-dnl ##
-dnl ## Standard Debugging Support
-dnl ##
-dnl ## configure.in:
-dnl ## AC_CHECK_STD_DEBUGGING
-dnl ##
-
-AC_DEFUN(AC_CHECK_STD_DEBUGGING,[dnl
-AC_ARG_ENABLE(debug,dnl
-[ --enable-debug build for debugging (default=no)],
-[dnl
-if test ".$ac_cv_prog_gcc" = ".yes"; then
- case "$CFLAGS" in
- *-O* ) ;;
- * ) CFLAGS="$CFLAGS -O2" ;;
- esac
- case "$CFLAGS" in
- *-g* ) ;;
- * ) CFLAGS="$CFLAGS -g" ;;
- esac
- case "$CFLAGS" in
- *-pipe* ) ;;
- * ) AC_COMPILER_OPTION(pipe, -pipe, -pipe, CFLAGS="$CFLAGS -pipe") ;;
- esac
- AC_COMPILER_OPTION(ggdb3, -ggdb3, -ggdb3, CFLAGS="$CFLAGS -ggdb3")
- case $PLATFORM in
- *-*-freebsd*|*-*-solaris* ) CFLAGS="$CFLAGS -pedantic" ;;
- esac
- CFLAGS="$CFLAGS -DASSERTS_ON -Wall"
- WMORE="-Wshadow -Wpointer-arith -Wcast-align -Winline -Wno-unused-function"
- WMORE="$WMORE -Wmissing-prototypes -Wmissing-declarations -Wnested-externs"
- AC_COMPILER_OPTION(wmore, -W<xxx>, $WMORE, CFLAGS="$CFLAGS $WMORE")
- AC_COMPILER_OPTION(wnolonglong, -Wno-long-long, -Wno-long-long, CFLAGS="$CFLAGS -Wno-long-long")
-else
- case "$CFLAGS" in
- *-g* ) ;;
- * ) CFLAGS="$CFLAGS -g" ;;
- esac
-fi
-msg="enabled"
-],[
-if test ".$ac_cv_prog_gcc" = ".yes"; then
-case "$CFLAGS" in
- *-pipe* ) ;;
- * ) AC_COMPILER_OPTION(pipe, -pipe, -pipe, CFLAGS="$CFLAGS -pipe") ;;
-esac
-fi
-case "$CFLAGS" in
- *-g* ) CFLAGS=`echo "$CFLAGS" |\
- sed -e 's/ -g / /g' -e 's/ -g$//' -e 's/^-g //g' -e 's/^-g$//'` ;;
-esac
-case "$CXXFLAGS" in
- *-g* ) CXXFLAGS=`echo "$CXXFLAGS" |\
- sed -e 's/ -g / /g' -e 's/ -g$//' -e 's/^-g //g' -e 's/^-g$//'` ;;
-esac
-msg="disabled"
-])dnl
-AC_MSG_CHECKING(for compilation debug mode)
-AC_MSG_RESULT([$msg])
- case $PLATFORM in
- * )
- ;;
- esac
-])
-
-dnl ##
-dnl ## Profiling Support
-dnl ##
-dnl ## configure.in:
-dnl ## AC_CHECK_PROFILING
-dnl ##
-
-AC_DEFUN(AC_CHECK_PROFILING,[dnl
-AC_MSG_CHECKING(for compilation profile mode)
-AC_ARG_ENABLE(profile,dnl
-[ --enable-profile build for profiling (default=no)],
-[dnl
-if test ".$ac_cv_prog_gcc" = ".no"; then
- AC_MSG_ERROR([profiling requires gcc and gprof])
-fi
-CFLAGS=`echo "$CFLAGS" | sed -e 's/-O2//g'`
-CFLAGS="$CFLAGS -O0 -pg"
-LDFLAGS="$LDFLAGS -pg"
-msg="enabled"
-],[
-msg="disabled"
-])dnl
-AC_MSG_RESULT([$msg])
-if test ".$msg" = .enabled; then
- enable_shared=no
-fi
-])
-
-dnl ##
-dnl ## Build Parameters
-dnl ##
-dnl ## configure.in:
-dnl ## AC_CHECK_BUILDPARAM
-dnl ##
-
-AC_DEFUN(AC_CHECK_BUILDPARAM,[dnl
-dnl # determine build mode
-AC_MSG_CHECKING(whether to activate batch build mode)
-AC_ARG_ENABLE(batch,dnl
-[ --enable-batch enable batch build mode (default=no)],[dnl
-],[dnl
-enable_batch=no
-])dnl
-if test ".$silent" = .yes; then
- enable_batch=yes
-fi
-AC_MSG_RESULT([$enable_batch])
-BATCH="$enable_batch"
-AC_SUBST(BATCH)
-dnl # determine build targets
-TARGET_ALL='$(TARGET_PREQ) $(TARGET_LIBS)'
-AC_MSG_CHECKING(whether to activate maintainer build targets)
-AC_ARG_ENABLE(maintainer,dnl
-[ --enable-maintainer enable maintainer build targets (default=no)],[dnl
-],[dnl
-enable_maintainer=no
-])dnl
-AC_MSG_RESULT([$enable_maintainer])
-if test ".$enable_maintainer" = .yes; then
- TARGET_ALL="$TARGET_ALL \$(TARGET_MANS)"
-fi
-AC_MSG_CHECKING(whether to activate test build targets)
-AC_ARG_ENABLE(tests,dnl
-[ --enable-tests enable test build targets (default=yes)],[dnl
-],[dnl
-enable_tests=yes
-])dnl
-AC_MSG_RESULT([$enable_tests])
-if test ".$enable_tests" = .yes; then
- TARGET_ALL="$TARGET_ALL \$(TARGET_TEST)"
-fi
-AC_SUBST(TARGET_ALL)
-])
-
-dnl ##
-dnl ## Optimization Support
-dnl ##
-dnl ## configure.in:
-dnl ## AC_CHECK_OPTIMIZE
-dnl ##
-
-AC_DEFUN(AC_CHECK_OPTIMIZE,[dnl
-AC_ARG_ENABLE(optimize,dnl
-[ --enable-optimize build with optimization (default=no)],
-[dnl
-if test ".$ac_cv_prog_gcc" = ".yes"; then
- # compiler is gcc
- case "$CFLAGS" in
- *-O* ) ;;
- * ) CFLAGS="$CFLAGS -O2" ;;
- esac
- case "$CFLAGS" in
- *-pipe* ) ;;
- * ) AC_COMPILER_OPTION(pipe, -pipe, -pipe, CFLAGS="$CFLAGS -pipe") ;;
- esac
- OPT_CFLAGS='-funroll-loops -fstrength-reduce -fomit-frame-pointer -ffast-math'
- AC_COMPILER_OPTION(optimize_std, [-f<xxx> for optimizations], $OPT_CFLAGS, CFLAGS="$CFLAGS $OPT_CFLAGS")
- case $PLATFORM in
- i?86*-*-*|?86*-*-* )
- OPT_CFLAGS='-malign-functions=4 -malign-jumps=4 -malign-loops=4'
- AC_COMPILER_OPTION(optimize_x86, [-f<xxx> for Intel x86 CPU], $OPT_CFLAGS, CFLAGS="$CFLAGS $OPT_CFLAGS")
- ;;
- esac
-else
- # compiler is NOT gcc
- case "$CFLAGS" in
- *-O* ) ;;
- * ) CFLAGS="$CFLAGS -O" ;;
- esac
- case $PLATFORM in
- *-*-solaris* )
- AC_COMPILER_OPTION(fast, -fast, -fast, CFLAGS="$CFLAGS -fast")
- ;;
- esac
-fi
-msg="enabled"
-],[
-msg="disabled"
-])dnl
-AC_MSG_CHECKING(for compilation optimization mode)
-AC_MSG_RESULT([$msg])
-])
-
-dnl ##
-dnl ## Check for a pre-processor define in a header
-dnl ##
-dnl ## configure.in:
-dnl ## AC_CHECK_DEFINE(<define>, <header>)
-dnl ## acconfig.h:
-dnl ## #undef HAVE_<define>
-dnl ##
-
-AC_DEFUN(AC_CHECK_DEFINE,[dnl
-AC_MSG_CHECKING(for define $1 in $2)
-AC_CACHE_VAL(ac_cv_define_$1,
-[AC_EGREP_CPP([YES_IS_DEFINED], [
-#include <$2>
-#ifdef $1
-YES_IS_DEFINED
-#endif
-], ac_cv_define_$1=yes, ac_cv_define_$1=no)])dnl
-AC_MSG_RESULT($ac_cv_define_$1)
-if test $ac_cv_define_$1 = yes; then
- AC_DEFINE(HAVE_[]translit($1, [a-z], [A-Z]))
-fi
-])
-
-dnl ##
-dnl ## Check for an ANSI C typedef in a header
-dnl ##
-dnl ## configure.in:
-dnl ## AC_CHECK_TYPEDEF(<typedef>, <header>)
-dnl ## acconfig.h:
-dnl ## #undef HAVE_<typedef>
-dnl ##
-
-AC_DEFUN(AC_CHECK_TYPEDEF,[dnl
-AC_REQUIRE([AC_HEADER_STDC])dnl
-AC_MSG_CHECKING(for typedef $1)
-AC_CACHE_VAL(ac_cv_typedef_$1,
-[AC_EGREP_CPP(dnl
-changequote(<<,>>)dnl
-<<(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]>>dnl
-changequote([,]), [
-#include <$2>
-], ac_cv_typedef_$1=yes, ac_cv_typedef_$1=no)])dnl
-AC_MSG_RESULT($ac_cv_typedef_$1)
-if test $ac_cv_typedef_$1 = yes; then
- AC_DEFINE(HAVE_[]translit($1, [a-z], [A-Z]))
-fi
-])
-
-dnl ##
-dnl ## Check for an ANSI C struct attribute in a structure defined in a header
-dnl ##
-dnl ## configure.in:
-dnl ## AC_CHECK_STRUCTATTR(<attr>, <struct>, <header>)
-dnl ## acconfig.h:
-dnl ## #undef HAVE_<attr>
-dnl ##
-
-AC_DEFUN(AC_CHECK_STRUCTATTR,[dnl
-AC_REQUIRE([AC_HEADER_STDC])dnl
-AC_MSG_CHECKING(for attribute $1 in struct $2 from $3)
-AC_CACHE_VAL(ac_cv_structattr_$1,[dnl
-
-AC_TRY_LINK([
-#include <sys/types.h>
-#include <$3>
-],[
-struct $2 *sp1;
-struct $2 *sp2;
-sp1->$1 = sp2->$1;
-], ac_cv_structattr_$1=yes, ac_cv_structattr_$1=no)])dnl
-AC_MSG_RESULT($ac_cv_structattr_$1)
-if test $ac_cv_structattr_$1 = yes; then
- AC_DEFINE(HAVE_[]translit($1, [a-z], [A-Z]))
-fi
-])
-
-dnl ##
-dnl ## Check for argument type of a function
-dnl ##
-dnl ## configure.in:
-dnl ## AC_CHECK_ARGTYPE(<header> [...], <func>, <arg-number>,
-dnl ## <max-arg-number>, <action-with-${ac_type}>)
-dnl ##
-
-AC_DEFUN(AC_CHECK_ARGTYPE,[dnl
-AC_REQUIRE_CPP()dnl
-AC_MSG_CHECKING([for type of argument $3 for $2()])
-AC_CACHE_VAL([ac_cv_argtype_$2$3],[
-cat >conftest.$ac_ext <<EOF
-[#]line __oline__ "configure"
-#include "confdefs.h"
-EOF
-for ifile in $1; do
- echo "#include <$ifile>" >>conftest.$ac_ext
-done
-gpat=''
-spat=''
-i=1
-changequote(, )dnl
-while test $i -le $4; do
- gpat="$gpat[^,]*"
- if test $i -eq $3; then
- spat="$spat\\([^,]*\\)"
- else
- spat="$spat[^,]*"
- fi
- if test $i -lt $4; then
- gpat="$gpat,"
- spat="$spat,"
- fi
- i=`expr $i + 1`
-done
-(eval "$ac_cpp conftest.$ac_ext") 2>&AC_FD_CC |\
-sed -e ':join' \
- -e '/,[ ]*$/N' \
- -e 's/,[ ]*\n[ ]*/, /' \
- -e 'tjoin' |\
-egrep "[^a-zA-Z0-9_]$2[ ]*\\($gpat\\)" | head -1 |\
-sed -e "s/.*[^a-zA-Z0-9_]$2[ ]*($spat).*/\\1/" \
- -e 's/(\*[a-zA-Z_][a-zA-Z_0-9]*)/(*)/' \
- -e 's/^[ ]*//' -e 's/[ ]*$//' \
- -e 's/^/arg:/' \
- -e 's/^arg:\([^ ]*\)$/type:\1/' \
- -e 's/^arg:\(.*_t\)*$/type:\1/' \
- -e 's/^arg:\(.*\*\)$/type:\1/' \
- -e 's/^arg:\(.*[ ]\*\)[_a-zA-Z][_a-zA-Z0-9]*$/type:\1/' \
- -e 's/^arg:\(.*[ ]char\)$/type:\1/' \
- -e 's/^arg:\(.*[ ]short\)$/type:\1/' \
- -e 's/^arg:\(.*[ ]int\)$/type:\1/' \
- -e 's/^arg:\(.*[ ]long\)$/type:\1/' \
- -e 's/^arg:\(.*[ ]float\)$/type:\1/' \
- -e 's/^arg:\(.*[ ]double\)$/type:\1/' \
- -e 's/^arg:\(.*[ ]unsigned\)$/type:\1/' \
- -e 's/^arg:\(.*[ ]signed\)$/type:\1/' \
- -e 's/^arg:\(.*struct[ ][_a-zA-Z][_a-zA-Z0-9]*\)$/type:\1/' \
- -e 's/^arg:\(.*\)[ ]_[_a-zA-Z0-9]*$/type:\1/' \
- -e 's/^arg:\(.*\)[ ]\([^ ]*\)$/type:\1/' \
- -e 's/^type://' >conftest.output
-ac_cv_argtype_$2$3=`cat conftest.output`
-changequote([, ])dnl
-rm -f conftest*
-])
-AC_MSG_RESULT([$ac_cv_argtype_$2$3])
-ac_type="$ac_cv_argtype_$2$3"
-[$5]
-])
-
-dnl ##
-dnl ## Check for existance of a function
-dnl ##
-dnl ## configure.in:
-dnl ## AC_CHECK_FUNCTION(<function> [, <action-if-found> [, <action-if-not-found>]])
-dnl ## AC_CHECK_FUNCTIONS(<function> [...] [, <action-if-found> [, <action-if-not-found>]])
-dnl ##
-
-AC_DEFUN(AC_CHECK_FUNCTIONS,[dnl
-for ac_func in $1; do
- AC_CHECK_FUNCTION($ac_func,
- [changequote(, )dnl
- ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
- changequote([, ])dnl
- AC_DEFINE_UNQUOTED($ac_tr_func) $2], $3)dnl
-done
-])
-
-AC_DEFUN(AC_CHECK_FUNCTION, [dnl
-AC_MSG_CHECKING([for function $1])
-AC_CACHE_VAL(ac_cv_func_$1, [dnl
-AC_TRY_LINK([
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $1(); below. */
-#include <assert.h>
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char $1();
-char (*f)();
-], [
-/* 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_$1) || defined (__stub___$1)
-choke me
-#else
-f = $1;
-#endif
-], eval "ac_cv_func_$1=yes", eval "ac_cv_func_$1=no")])
-if eval "test \"`echo '$ac_cv_func_'$1`\" = yes"; then
- AC_MSG_RESULT(yes)
- ifelse([$2], , :, [$2])
-else
- AC_MSG_RESULT(no)
-ifelse([$3], , , [$3
-])dnl
-fi
-])
-
-dnl ##
-dnl ## Decision Hierachy
-dnl ##
-
-define(AC_IFALLYES,[dnl
-ac_rc=yes
-for ac_spec in $1; do
- ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'`
- ac_item=`echo "$ac_spec" | sed -e 's/^.*://'`
- case $ac_type in
- header [)]
- ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'`
- ac_var="ac_cv_header_$ac_item"
- ;;
- file [)]
- ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'`
- ac_var="ac_cv_file_$ac_item"
- ;;
- func [)] ac_var="ac_cv_func_$ac_item" ;;
- lib [)] ac_var="ac_cv_lib_$ac_item" ;;
- define [)] ac_var="ac_cv_define_$ac_item" ;;
- typedef [)] ac_var="ac_cv_typedef_$ac_item" ;;
- custom [)] ac_var="$ac_item" ;;
- esac
- eval "ac_val=\$$ac_var"
- if test ".$ac_val" != .yes; then
- ac_rc=no
- break
- fi
-done
-if test ".$ac_rc" = .yes; then
- :
- $2
-else
- :
- $3
-fi
-])
-
-define(AC_BEGIN_DECISION,[dnl
-ac_decision_item='$1'
-ac_decision_msg='FAILED'
-ac_decision=''
-])
-
-define(AC_DECIDE,[dnl
-ac_decision='$1'
-ac_decision_msg='$2'
-ac_decision_$1=yes
-ac_decision_$1_msg='$2'
-])
-
-define(AC_DECISION_OVERRIDE,[dnl
- ac_decision=''
- for ac_item in $1; do
- eval "ac_decision_this=\$ac_decision_${ac_item}"
- if test ".$ac_decision_this" = .yes; then
- ac_decision=$ac_item
- eval "ac_decision_msg=\$ac_decision_${ac_item}_msg"
- fi
- done
-])
-
-define(AC_DECISION_FORCE,[dnl
-ac_decision="$1"
-eval "ac_decision_msg=\"\$ac_decision_${ac_decision}_msg\""
-])
-
-define(AC_END_DECISION,[dnl
-if test ".$ac_decision" = .; then
- echo "[$]0:Error: decision on $ac_decision_item failed." 1>&2
- echo "[$]0:Hint: see config.log for more details!" 1>&2
- exit 1
-else
- if test ".$ac_decision_msg" = .; then
- ac_decision_msg="$ac_decision"
- fi
- AC_MSG_RESULT([decision on $ac_decision_item... ${TB}$ac_decision_msg${TN}])
-fi
-])
-
-dnl ##
-dnl ## Check for existance of a file
-dnl ##
-dnl ## configure.in:
-dnl ## AC_TEST_FILE(<file>, <success-action>, <failure-action>)
-dnl ##
-
-AC_DEFUN(AC_TEST_FILE, [
-ac_safe=`echo "$1" | sed 'y%./+-%__p_%'`
-AC_MSG_CHECKING([for $1])
-AC_CACHE_VAL(ac_cv_file_$ac_safe, [
-if test -r $1; then
- eval "ac_cv_file_$ac_safe=yes"
-else
- eval "ac_cv_file_$ac_safe=no"
-fi
-])dnl
-if eval "test \"`echo '$ac_cv_file_'$ac_safe`\" = yes"; then
- AC_MSG_RESULT(yes)
- ifelse([$2], , :, [$2])
-else
- AC_MSG_RESULT(no)
- ifelse([$3], , :, [$3])
-fi
-])
-
-dnl ##
-dnl ## Check for socket/network size type
-dnl ##
-dnl ## configure.in:
-dnl ## AC_CHECK_SOCKLENTYPE(<action-with-${ac_type}>)
-dnl ##
-
-dnl # Background:
-dnl # this exists because of shortsightedness on the POSIX committee.
-dnl # BSD systems used "int *" as the parameter to accept(2),
-dnl # getsockname(2), getpeername(2) et al. Consequently many Unix
-dnl # flavors took an "int *" for that parameter. The POSIX committee
-dnl # decided that "int" was just too generic and had to be replaced
-dnl # with "size_t" almost everywhere. There's no problem with that
-dnl # when you're passing by value. But when you're passing by
-dnl # reference (as it is the case for accept(2) and friends) this
-dnl # creates a gross source incompatibility with existing programs.
-dnl # On 32-bit architectures it creates only a warning. On 64-bit
-dnl # architectures it creates broken code -- because "int *" is a
-dnl # pointer to a 64-bit quantity and "size_t *" is usually a pointer
-dnl # to a 32-bit quantity. Some Unix flavors adopted "size_t *" for
-dnl # the sake of POSIX compliance. Others ignored it because it was
-dnl # such a broken interface. Chaos ensued. POSIX finally woke up
-dnl # and decided that it was wrong and created a new type socklen_t.
-dnl # The only useful value for socklen_t is "int", and that's how
-dnl # everyone who has a clue implements it. It is almost always the
-dnl # case that this type should be defined to be an "int", unless the
-dnl # system being compiled for was created in the window of POSIX
-dnl # madness.
-
-AC_DEFUN(AC_CHECK_SOCKLENTYPE,[dnl
-AC_CHECK_TYPEDEF(socklen_t, sys/socket.h)
-AC_CHECK_ARGTYPE(sys/types.h sys/socket.h, accept, 3, 3, [:])
-AC_MSG_CHECKING(for fallback socklen_t)
-AC_CACHE_VAL(ac_cv_check_socklentype, [
-if test ".$ac_cv_typedef_socklen_t" = .yes; then
- ac_cv_check_socklentype='socklen_t'
-elif test ".$ac_type" != .; then
- ac_cv_check_socklentype=`echo "$ac_type" | sed -e 's/[ ]*\*$//'`
-else
- ac_cv_check_socklentype='int'
-fi
-])
-AC_MSG_RESULT([$ac_cv_check_socklentype])
-ac_type="$ac_cv_check_socklentype"
-ifelse([$1], , :, [$1])
-])
-
-dnl ##
-dnl ## Check for filedescriptor number type
-dnl ##
-dnl ## configure.in:
-dnl ## AC_CHECK_NFDSTYPE(<action-with-${ac_type}>)
-dnl ##
-
-AC_DEFUN(AC_CHECK_NFDSTYPE,[dnl
-AC_CHECK_TYPEDEF(nfds_t, poll.h)
-AC_CHECK_ARGTYPE(sys/types.h poll.h, poll, 2, 3, [:])
-AC_MSG_CHECKING(for fallback nfds_t)
-AC_CACHE_VAL(ac_cv_check_nfdstype, [
-if test ".$ac_cv_typedef_nfds_t" = .yes; then
- ac_cv_check_nfdstype='nfds_t'
-elif test ".$ac_type" != .; then
- ac_cv_check_nfdstype=`echo "$ac_type" | sed -e 's/[ ]*\*$//'`
-else
- ac_cv_check_nfdstype='unsigned int'
-fi
-])
-AC_MSG_RESULT([$ac_cv_check_nfdstype])
-ac_type="$ac_cv_check_nfdstype"
-ifelse([$1], , :, [$1])
-])
-
-dnl ##
-dnl ## Check for need of stackguard
-dnl ##
-dnl ## configure.in:
-dnl ## AC_CHECK_NEED_FOR_SEPARATE_STACK(<define>)
-dnl ## acconfig.h:
-dnl ## #undef <define>
-dnl ## source.c:
-dnl ## #include "config.h"
-dnl ## #if <define> > 0
-dnl ## ...separate stack needed...
-dnl ## #else
-dnl ## ...separate stack not needed...
-dnl ## #endif
-dnl ##
-
-AC_DEFUN(AC_CHECK_NEED_FOR_SEPARATE_STACK,[dnl
-AC_MSG_CHECKING(for need for separate stack)
-AC_CACHE_VAL(ac_cv_need_for_separate_stack, [
-case $HOSTTYPE in
-ia64 )
- ac_cv_need_for_separate_stack=yes
- ;;
-* )
- ac_cv_need_for_separate_stack=no
- ;;
-esac
-])dnl
-AC_MSG_RESULT([$ac_cv_need_for_separate_stack])
-if test ".$ac_cv_need_for_separate_stack" = .yes; then
- val="1"
-else
- val="0"
-fi
-AC_DEFINE_UNQUOTED($1, $val)
-])
-
-dnl ##
-dnl ## Check for direction of stack growth
-dnl ##
-dnl ## configure.in:
-dnl ## AC_CHECK_STACKGROWTH(<define>)
-dnl ## acconfig.h:
-dnl ## #undef <define>
-dnl ## source.c:
-dnl ## #include "config.h"
-dnl ## #if <define> < 0
-dnl ## ...stack grow down...
-dnl ## #else
-dnl ## ...stack grow up...
-dnl ## #endif
-dnl ##
-
-AC_DEFUN(AC_CHECK_STACKGROWTH,[dnl
-AC_MSG_CHECKING(for direction of stack growth)
-AC_CACHE_VAL(ac_cv_check_stackgrowth, [
-cross_compile=no
-AC_TRY_RUN(
-changequote(<<, >>)dnl
-<<
-#include <stdio.h>
-#include <stdlib.h>
-static int iterate = 10;
-static int growsdown(int *x)
-{
- auto int y;
- y = (x > &y);
- if (--iterate > 0)
- y = growsdown(&y);
- if (y != (x > &y))
- exit(1);
- return y;
-}
-int main(int argc, char *argv[])
-{
- FILE *f;
- auto int x;
- if ((f = fopen("conftestval", "w")) == NULL)
- exit(1);
- fprintf(f, "%s\n", growsdown(&x) ? "down" : "up");;
- fclose(f);
- exit(0);
-}
->>
-changequote([, ])dnl
-,
-ac_cv_check_stackgrowth=`cat conftestval`,
-ac_cv_check_stackgrowth=down,
-ac_cv_check_stackgrowth=down
-)dnl
-])dnl
-AC_MSG_RESULT([$ac_cv_check_stackgrowth])
-if test ".$ac_cv_check_stackgrowth" = ".down"; then
- val="-1"
-else
- val="+1"
-fi
-AC_DEFINE_UNQUOTED($1, $val)
-])
-
-dnl ##
-dnl ## Check whether and how a POSIX compliant sigsetjmp(3) can be achieved
-dnl ##
-dnl ## configure.in:
-dnl ## AC_CHECK_SJLJ(<success-action>, <failure-action>, <type-var>)
-dnl ##
-
-AC_DEFUN(AC_CHECK_SJLJ,[
-AC_MSG_CHECKING(for signal-mask aware setjmp(3)/longjmp(3))
-AC_CACHE_VAL(ac_cv_check_sjlj, [
-AC_IFALLYES(func:setjmp func:longjmp, ac_cv_check_sjlj=sjlje, ac_cv_check_sjlj=none)
-cross_compile=no
-for testtype in ssjlj sjlj usjlj; do
-OCFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -DTEST_${testtype}"
-AC_TRY_RUN(
-changequote(<<, >>)dnl
-<<
-#if defined(TEST_ssjlj)
-#define __JMP_BUF sigjmp_buf
-#define __SETJMP(buf) sigsetjmp(buf,1)
-#define __LONGJMP(buf,val) siglongjmp(buf,val)
-#elif defined(TEST_sjlj)
-#define __JMP_BUF jmp_buf
-#define __SETJMP(buf) setjmp(buf)
-#define __LONGJMP(buf,val) longjmp(buf,val)
-#elif defined(TEST_usjlj)
-#define __JMP_BUF jmp_buf
-#define __SETJMP(buf) _setjmp(buf)
-#define __LONGJMP(buf,val) _longjmp(buf,val)
-#endif
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <setjmp.h>
-#include <unistd.h>
-
-static __JMP_BUF jb;
-
-static void sighandler(int sig)
-{
- sigset_t sigs;
-
- /* get signal mask */
- sigprocmask(SIG_SETMASK, NULL, &sigs);
-
- /* make sure USR1 is still blocked */
- if (!sigismember(&sigs, SIGUSR1))
- exit(1);
-
- /* block USR2 for us */
- sigaddset(&sigs, SIGUSR2);
- sigprocmask(SIG_SETMASK, &sigs, NULL);
-
- /* jump back to main */
- __LONGJMP(jb, 1);
- exit(1);
-}
-
-int main(int argc, char *argv[])
-{
- FILE *fp;
- sigset_t sigs;
- struct sigaction sa;
-
- /* the default is that it fails */
- if ((fp = fopen("conftestval", "w")) == NULL)
- exit(1);
- fprintf(fp, "failed\n");
- fclose(fp);
-
- /* block USR1 and unblock USR2 signal */
- sigprocmask(SIG_SETMASK, NULL, &sigs);
- sigaddset(&sigs, SIGUSR1);
- sigdelset(&sigs, SIGUSR2);
- sigprocmask(SIG_SETMASK, &sigs, NULL);
-
- /* set jump buffer */
- if (__SETJMP(jb) == 0) {
-
- /* install signal handler for USR1 */
- memset((void *)&sa, 0, sizeof(struct sigaction));
- sigemptyset(&sa.sa_mask);
- sa.sa_handler = sighandler;
- sa.sa_flags = 0;
- sigaction(SIGUSR1, &sa, NULL);
-
- /* send USR1 signal (which is still blocked) */
- kill(getpid(), SIGUSR1);
-
- /* unblock USR1 and wait for it */
- sigprocmask(SIG_SETMASK, NULL, &sigs);
- sigdelset(&sigs, SIGUSR1);
- sigsuspend(&sigs);
- exit(1);
- }
-
- /* get signal mask again */
- sigprocmask(SIG_SETMASK, NULL, &sigs);
-
- /* make sure USR2 is again unblocked */
- if (sigismember(&sigs, SIGUSR2))
- exit(1);
-
- /* Fine... */
- if ((fp = fopen("conftestval", "w")) == NULL)
- exit(1);
- fprintf(fp, "ok\n");
- fclose(fp);
- exit(0);
-}
->>
-changequote([, ]),
-rc=`cat conftestval`,
-rc=failed,
-rc=failed
-)
-CFLAGS="$OCFLAGS"
-if test ".$rc" = .ok; then
- ac_cv_check_sjlj=$testtype
- break
-fi
-done
-case $PLATFORM in
- *-*-linux* )
- braindead=no
- case "x`uname -r`" in
-changequote(, )dnl
- x2.[23456789]* ) ;;
-changequote([, ])
- * ) braindead=yes ;;
- esac
- case `grep __GLIBC_MINOR /usr/include/features.h | grep '#define' |\
- awk '{ printf("%s", [$]3 >= 1 ? "yes" : "no"); }'` in
- yes ) ;;
- * ) braindead=yes ;;
- esac
- case $braindead in
- yes ) ac_cv_check_sjlj=sjljlx ;;
- no ) ac_cv_check_sjlj=ssjlj ;;
- esac
- ;;
- *-*-isc* )
- ac_cv_check_sjlj=sjljisc
- ;;
- *-*-interix )
- # Interix is a POSIX sub-system on Windows-NT which
- # can use the Interactive UNIX dispatching code.
- ac_cv_check_sjlj=sjljisc
- ;;
- *-*-cygwin* )
- ac_cv_check_sjlj=sjljw32
- ;;
-esac
-])dnl
-$3="$ac_cv_check_sjlj"
-if test ".$ac_cv_check_sjlj" != .none; then
- AC_MSG_RESULT([yes: $ac_cv_check_sjlj])
- ifelse([$1], , :, [$1])
-else
- AC_MSG_RESULT([no])
- ifelse([$2], , :, [$2])
-fi
-])dnl
-
-dnl ##
-dnl ## Check for number of signals (NSIG)
-dnl ##
-dnl ## configure.in:
-dnl ## AC_CHECK_NSIG(<define>)
-dnl ## acconfig.h:
-dnl ## #undef <define>
-dnl ## source.c:
-dnl ## #include "config.h"
-dnl ## ...<define>...
-
-AC_DEFUN(AC_CHECK_NSIG,[dnl
-AC_MSG_CHECKING(for number of signals)
-cross_compile=no
-AC_TRY_RUN(
-changequote(<<, >>)dnl
-<<
-#include <stdio.h>
-#include <sys/types.h>
-#include <signal.h>
-
-int main(int argc, char *argv[])
-{
- FILE *fp;
- int nsig;
-
-#if defined(NSIG)
- nsig = NSIG;
-#elif defined(_NSIG)
- nsig = _NSIG;
-#else
- nsig = (sizeof(sigset_t)*8);
- if (nsig < 32)
- nsig = 32;
-#endif
- if ((fp = fopen("conftestval", "w")) == NULL)
- exit(1);
- fprintf(fp, "%d\n", nsig);
- fclose(fp);
- exit(0);
-}
->>
-changequote([, ])dnl
-,
-nsig=`cat conftestval`,
-nsig=32,
-nsig=32
-)dnl
-AC_MSG_RESULT([$nsig])
-AC_DEFINE_UNQUOTED($1, $nsig)
-])
-
-dnl ##
-dnl ## Check for an external/extension library.
-dnl ## - is aware of <libname>-config style scripts
-dnl ## - searches under standard paths include, lib, etc.
-dnl ## - searches under subareas like .libs, etc.
-dnl ##
-dnl ## configure.in:
-dnl ## AC_CHECK_EXTLIB(<realname>, <libname>, <func>, <header>,
-dnl ## [<success-action> [, <fail-action>]])
-dnl ## Makefile.in:
-dnl ## CFLAGS = @CFLAGS@
-dnl ## LDFLAGS = @LDFLAGS@
-dnl ## LIBS = @LIBS@
-dnl ## shell:
-dnl ## $ ./configure --with-<libname>[=DIR]
-dnl ##
-
-AC_DEFUN(AC_CHECK_EXTLIB,[dnl
-AC_ARG_WITH($2,dnl
-[ --with-]substr([$2[[=DIR]] ], 0, 19)[build against $1 library (default=no)],
- if test ".$with_$2" = .yes; then
- # via config script
- $2_version=`($2-config --version) 2>/dev/null`
- if test ".$$2_version" != .; then
- CPPFLAGS="$CPPFLAGS `$2-config --cflags`"
- CFLAGS="$CFLAGS `$2-config --cflags`"
- LDFLAGS="$LDFLAGS `$2-config --ldflags`"
- fi
- else
- if test -d "$with_$2"; then
- found=0
- # via config script
- for dir in $with_$2/bin $with_$2; do
- if test -f "$dir/$2-config"; then
- $2_version=`($dir/$2-config --version) 2>/dev/null`
- if test ".$$2_version" != .; then
- CPPFLAGS="$CPPFLAGS `$dir/$2-config --cflags`"
- CFLAGS="$CFLAGS `$dir/$2-config --cflags`"
- LDFLAGS="$LDFLAGS `$dir/$2-config --ldflags`"
- found=1
- break
- fi
- fi
- done
- # via standard paths
- if test ".$found" = .0; then
- for dir in $with_$2/include/$2 $with_$2/include $with_$2; do
- if test -f "$dir/$4"; then
- CPPFLAGS="$CPPFLAGS -I$dir"
- CFLAGS="$CFLAGS -I$dir"
- found=1
- break
- fi
- done
- for dir in $with_$2/lib/$2 $with_$2/lib $with_$2; do
- if test -f "$dir/lib$2.a" -o -f "$dir/lib$2.so"; then
- LDFLAGS="$LDFLAGS -L$dir"
- found=1
- break
- fi
- done
- fi
- # in any subarea
- if test ".$found" = .0; then
-changequote(, )dnl
- for file in x `find $with_$2 -name "$4" -type f -print`; do
- test .$file = .x && continue
- dir=`echo $file | sed -e 's;[[^/]]*$;;' -e 's;\(.\)/$;\1;'`
- CPPFLAGS="$CPPFLAGS -I$dir"
- CFLAGS="$CFLAGS -I$dir"
- done
- for file in x `find $with_$2 -name "lib$2.[[aso]]" -type f -print`; do
- test .$file = .x && continue
- dir=`echo $file | sed -e 's;[[^/]]*$;;' -e 's;\(.\)/$;\1;'`
- LDFLAGS="$LDFLAGS -L$dir"
- done
-changequote([, ])dnl
- fi
- fi
- fi
- AC_HAVE_HEADERS($4)
- AC_CHECK_LIB($2, $3)
- AC_IFALLYES(header:$4 lib:$2_$3, with_$2=yes, with_$2=no)
- if test ".$with_$2" = .no; then
- AC_ERROR([Unable to find $1 library])
- fi
-,
-if test ".$with_$2" = .; then
- with_$2=no
-fi
-)dnl
-AC_MSG_CHECKING(whether to build against $1 library)
-if test ".$with_$2" = .yes; then
- ifelse([$5], , :, [$5])
-else
- ifelse([$6], , :, [$6])
-fi
-AC_MSG_RESULT([$with_$2])
-])dnl
-
-dnl ##
-dnl ## Check whether SVR4/SUSv2 makecontext(2), swapcontext(2) and
-dnl ## friends can be used for user-space context switching
-dnl ##
-dnl ## configure.in:
-dnl ## AC_CHECK_MCSC(<success-action>, <failure-action>)
-dnl ##
-
-AC_DEFUN(AC_CHECK_MCSC, [
-AC_MSG_CHECKING(for usable SVR4/SUSv2 makecontext(2)/swapcontext(2))
-AC_CACHE_VAL(ac_cv_check_mcsc, [
-AC_TRY_RUN([
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <ucontext.h>
-
-ucontext_t uc_child;
-ucontext_t uc_main;
-
-void child(void *arg)
-{
- if (arg != (void *)12345)
- exit(1);
- if (swapcontext(&uc_child, &uc_main) != 0)
- exit(1);
-}
-
-int main(int argc, char *argv[])
-{
- FILE *fp;
- void *stack;
-
- /* the default is that it fails */
- if ((fp = fopen("conftestval", "w")) == NULL)
- exit(1);
- fprintf(fp, "no\n");
- fclose(fp);
-
- /* configure a child user-space context */
- if ((stack = malloc(64*1024)) == NULL)
- exit(1);
- if (getcontext(&uc_child) != 0)
- exit(1);
- uc_child.uc_link = NULL;
- uc_child.uc_stack.ss_sp = (char *)stack+(32*1024);
- uc_child.uc_stack.ss_size = 32*1024;
- uc_child.uc_stack.ss_flags = 0;
- makecontext(&uc_child, child, 2, (void *)12345);
-
- /* switch into the user context */
- if (swapcontext(&uc_main, &uc_child) != 0)
- exit(1);
-
- /* Fine, child came home */
- if ((fp = fopen("conftestval", "w")) == NULL)
- exit(1);
- fprintf(fp, "yes\n");
- fclose(fp);
-
- /* die successfully */
- exit(0);
-}
-],
-ac_cv_check_mcsc=`cat conftestval`,
-ac_cv_check_mcsc=no,
-ac_cv_check_mcsc=no
-)dnl
-])dnl
-AC_MSG_RESULT([$ac_cv_check_mcsc])
-if test ".$ac_cv_check_mcsc" = .yes; then
- ifelse([$1], , :, [$1])
-else
- ifelse([$2], , :, [$2])
-fi
-])dnl
-
-dnl ##
-dnl ## Check how stacks have to be setup for the functions
-dnl ## sigstack(2), sigaltstack(2) and makecontext(2).
-dnl ##
-dnl ## configure.in:
-dnl ## AC_CHECK_STACKSETUP(sigstack|sigaltstack|makecontext, <macro-addr>, <macro-size>)
-dnl ## acconfig.h:
-dnl ## #undef HAVE_{SIGSTACK|SIGALTSTACK|MAKECONTEXT}
-dnl ## #undef HAVE_STACK_T
-dnl ## header.h.in:
-dnl ## @<macro-addr>@
-dnl ## @<macro-size>@
-dnl ## source.c:
-dnl ## #include "header.h"
-dnl ## xxx.sp_ss = <macro-addr>(skaddr, sksize);
-dnl ## xxx.sp_size = <macro-size>(skaddr, sksize);
-dnl ##
-
-AC_DEFUN(AC_CHECK_STACKSETUP,[dnl
-dnl # check for consistent usage
-ifelse($1,[sigstack],,[
-ifelse($1,[sigaltstack],,[
-ifelse($1,[makecontext],,[
-errprint(__file__:__line__: [AC_CHECK_STACKSETUP: only sigstack, sigaltstack and makecontext supported
-])])])])
-dnl # we require the C compiler and the standard headers
-AC_REQUIRE([AC_HEADER_STDC])dnl
-dnl # we at least require the function to check
-AC_CHECK_FUNCTIONS($1)
-dnl # sigaltstack on some platforms uses stack_t instead of struct sigaltstack
-ifelse($1, sigaltstack, [
- AC_ONCE(stacksetup_stack_t, [
- AC_CHECK_TYPEDEF(stack_t, signal.h)
- ])
-])
-dnl # display processing header
-AC_MSG_CHECKING(for stack setup via $1)
-dnl # but cache the whole results
-AC_CACHE_VAL(ac_cv_stacksetup_$1,[
-if test ".$ac_cv_func_$1" = .no; then
- dnl # no need to check anything when function is already missing
- ac_cv_stacksetup_$1="N.A.:/*N.A.*/,/*N.A.*/"
-else
- dnl # setup compile environment
- OCFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -DTEST_$1"
- cross_compile=no
- dnl # compile and run the test program
- AC_TRY_RUN([
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#if defined(TEST_sigstack) || defined(TEST_sigaltstack)
-#include <sys/types.h>
-#include <signal.h>
-#include <unistd.h>
-#endif
-#if defined(TEST_makecontext)
-#include <ucontext.h>
-#endif
-union alltypes {
- long l;
- double d;
- void *vp;
- void (*fp)(void);
- char *cp;
-};
-static volatile char *handler_addr = (char *)0xDEAD;
-#if defined(TEST_sigstack) || defined(TEST_sigaltstack)
-static volatile int handler_done = 0;
-void handler(int sig)
-{
- char garbage[1024];
- int i;
- auto int dummy;
- for (i = 0; i < 1024; i++)
- garbage[i] = 'X';
- handler_addr = (char *)&dummy;
- handler_done = 1;
- return;
-}
-#endif
-#if defined(TEST_makecontext)
-static ucontext_t uc_handler;
-static ucontext_t uc_main;
-void handler(void)
-{
- char garbage[1024];
- int i;
- auto int dummy;
- for (i = 0; i < 1024; i++)
- garbage[i] = 'X';
- handler_addr = (char *)&dummy;
- swapcontext(&uc_handler, &uc_main);
- return;
-}
-#endif
-int main(int argc, char *argv[])
-{
- FILE *f;
- char *skaddr;
- char *skbuf;
- int sksize;
- char result[1024];
- int i;
- sksize = 32768;
- skbuf = (char *)malloc(sksize*2+2*sizeof(union alltypes));
- if (skbuf == NULL)
- exit(1);
- for (i = 0; i < sksize*2+2*sizeof(union alltypes); i++)
- skbuf[i] = 'A';
- skaddr = skbuf+sizeof(union alltypes);
-#if defined(TEST_sigstack) || defined(TEST_sigaltstack)
- {
- struct sigaction sa;
-#if defined(TEST_sigstack)
- struct sigstack ss;
-#elif defined(TEST_sigaltstack) && defined(HAVE_STACK_T)
- stack_t ss;
-#else
- struct sigaltstack ss;
-#endif
-#if defined(TEST_sigstack)
- ss.ss_sp = (void *)(skaddr + sksize);
- ss.ss_onstack = 0;
- if (sigstack(&ss, NULL) < 0)
- exit(1);
-#elif defined(TEST_sigaltstack)
- ss.ss_sp = (void *)(skaddr + sksize);
- ss.ss_size = sksize;
- ss.ss_flags = 0;
- if (sigaltstack(&ss, NULL) < 0)
- exit(1);
-#endif
- memset((void *)&sa, 0, sizeof(struct sigaction));
- sa.sa_handler = handler;
- sa.sa_flags = SA_ONSTACK;
- sigemptyset(&sa.sa_mask);
- sigaction(SIGUSR1, &sa, NULL);
- kill(getpid(), SIGUSR1);
- while (!handler_done)
- /*nop*/;
- }
-#endif
-#if defined(TEST_makecontext)
- {
- if (getcontext(&uc_handler) != 0)
- exit(1);
- uc_handler.uc_link = NULL;
- uc_handler.uc_stack.ss_sp = (void *)(skaddr + sksize);
- uc_handler.uc_stack.ss_size = sksize;
- uc_handler.uc_stack.ss_flags = 0;
- makecontext(&uc_handler, handler, 1);
- swapcontext(&uc_main, &uc_handler);
- }
-#endif
- if (handler_addr == (char *)0xDEAD)
- exit(1);
- if (handler_addr < skaddr+sksize) {
- /* stack was placed into lower area */
- if (*(skaddr+sksize) != 'A')
- sprintf(result, "(skaddr)+(sksize)-%d,(sksize)-%d",
- sizeof(union alltypes), sizeof(union alltypes));
- else
- strcpy(result, "(skaddr)+(sksize),(sksize)");
- }
- else {
- /* stack was placed into higher area */
- if (*(skaddr+sksize*2) != 'A')
- sprintf(result, "(skaddr),(sksize)-%d", sizeof(union alltypes));
- else
- strcpy(result, "(skaddr),(sksize)");
- }
- if ((f = fopen("conftestval", "w")) == NULL)
- exit(1);
- fprintf(f, "%s\n", result);
- fclose(f);
- exit(0);
-}
-],[
-dnl # test successully passed
-ac_cv_stacksetup_$1=`cat conftestval`
-ac_cv_stacksetup_$1="ok:$ac_cv_stacksetup_$1"
-],[
-dnl # test failed
-ac_cv_stacksetup_$1='guessed:(skaddr),(sksize)'
-],[
-dnl # cross-platform => failed
-ac_cv_stacksetup_$1='guessed:(skaddr),(sksize)'
-])
-dnl # restore original compile environment
-CFLAGS="$OCFLAGS"
-])dnl
-fi
-dnl # extract result ingredients of single cached result value
-type=`echo $ac_cv_stacksetup_$1 | sed -e 's;:.*$;;'`
-addr=`echo $ac_cv_stacksetup_$1 | sed -e 's;^.*:;;' -e 's;,.*$;;'`
-size=`echo $ac_cv_stacksetup_$1 | sed -e 's;^.*:;;' -e 's;^.*,;;'`
-dnl # export result ingredients
-$2="#define $2(skaddr,sksize) ($addr)"
-$3="#define $3(skaddr,sksize) ($size)"
-AC_SUBST($2)dnl
-AC_SUBST($3)dnl
-dnl # display result indicator
-AC_MSG_RESULT([$type])
-dnl # display results in detail
-AC_MSG_VERBOSE([$]$2)
-AC_MSG_VERBOSE([$]$3)
-])
+++ /dev/null
-/*
-** GNU Pth - The GNU Portable Threads
-** Copyright (c) 1999-2001 Ralf S. Engelschall <rse@engelschall.com>
-**
-** This file is part of GNU Pth, a non-preemptive thread scheduling
-** library which can be found at http://www.gnu.org/software/pth/.
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-** USA, or contact Ralf S. Engelschall <rse@engelschall.com>.
-**
-** pth.h: Pth public API definitions
-*/
- /* ``What you see is all you get.''
- -- Brian Kernighan */
-/* hacked, needs updated docs - wingo <wingo@pobox.com> */
-
-#ifndef _PTH_H_
-#define _PTH_H_
-
- /* the library version */
-#ifndef PTH_VERSION_STR
-#define PTH_VERSION_STR "@PTH_VERSION_STR@"
-#endif
-#ifndef PTH_VERSION_HEX
-#define PTH_VERSION_HEX @PTH_VERSION_HEX@
-#endif
-#ifndef PTH_VERSION
-#define PTH_VERSION PTH_VERSION_HEX
-#endif
-
- /* essential headers */
-#include <sys/types.h> /* for ssize_t, off_t */
-#include <sys/signal.h> /* for sigset_t */
-
- /* essential values */
-#ifndef FALSE
-#define FALSE (0)
-#endif
-#ifndef TRUE
-#define TRUE (!FALSE)
-#endif
-#ifndef NUL
-#define NUL '\0'
-#endif
-#ifndef NULL
-#define NULL (void *)0
-#endif
-
- /* bitmask generation */
-#define _BIT(n) (1<<(n))
-
- /* C++ support */
-#ifdef __cplusplus
-#define BEGIN_DECLARATION extern "C" {
-#define END_DECLARATION }
-#else
-#define BEGIN_DECLARATION /*nop*/
-#define END_DECLARATION /*nop*/
-#endif
-
-#endif /* _PTH_H_ */
+++ /dev/null
-/*
-** GNU Pth - The GNU Portable Threads
-** Copyright (c) 1999-2001 Ralf S. Engelschall <rse@engelschall.com>
-**
-** This file is part of GNU Pth, a non-preemptive thread scheduling
-** library which can be found at http://www.gnu.org/software/pth/.
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-** USA, or contact Ralf S. Engelschall <rse@engelschall.com>.
-**
-** pth_acmac.h: Autoconf macros
-*/
-
-#ifndef _PTH_ACMAC_H_
-#define _PTH_ACMAC_H_
-
-/* sig{set,long}jmp macros */
-@pth_sigjmpbuf@
-@pth_sigsetjmp@
-@pth_siglongjmp@
-
-/* stack setup macros */
-#define pth_skaddr(func,skaddr,sksize) pth_skaddr_##func(skaddr,sksize)
-#define pth_sksize(func,skaddr,sksize) pth_sksize_##func(skaddr,sksize)
-@pth_skaddr_sigstack@
-@pth_sksize_sigstack@
-@pth_skaddr_sigaltstack@
-@pth_sksize_sigaltstack@
-@pth_skaddr_makecontext@
-@pth_sksize_makecontext@
-
-/* mctx compile defines */
-#define PTH_MCTX_MTH(which) (PTH_MCTX_MTH_use == (PTH_MCTX_MTH_##which))
-#define PTH_MCTX_DSP(which) (PTH_MCTX_DSP_use == (PTH_MCTX_DSP_##which))
-#define PTH_MCTX_STK(which) (PTH_MCTX_STK_use == (PTH_MCTX_STK_##which))
-#define PTH_MCTX_MTH_mcsc 1
-#define PTH_MCTX_MTH_sjlj 2
-#define PTH_MCTX_DSP_sc 1
-#define PTH_MCTX_DSP_ssjlj 2
-#define PTH_MCTX_DSP_sjlj 3
-#define PTH_MCTX_DSP_usjlj 4
-#define PTH_MCTX_DSP_sjlje 5
-#define PTH_MCTX_DSP_sjljlx 6
-#define PTH_MCTX_DSP_sjljisc 7
-#define PTH_MCTX_DSP_sjljw32 8
-#define PTH_MCTX_STK_mc 1
-#define PTH_MCTX_STK_ss 2
-#define PTH_MCTX_STK_sas 3
-#define PTH_MCTX_STK_none 4
-
-#endif /* _PTH_ACMAC_H_ */
-
+++ /dev/null
-/*
-** GNU Pth - The GNU Portable Threads
-** Copyright (c) 1999-2001 Ralf S. Engelschall <rse@engelschall.com>
-**
-** This file is part of GNU Pth, a non-preemptive thread scheduling
-** library which can be found at http://www.gnu.org/software/pth/.
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-** USA, or contact Ralf S. Engelschall <rse@engelschall.com>.
-**
-** pth_debug.c: Pth debugging support
-*/
- /* ``MY HACK: This universe.
- Just one little problem:
- core keeps dumping.''
- -- Unknown */
-#include "pth_p.h"
-
-#if cpp
-
-#ifndef PTH_DEBUG
-
-#define pth_debug1(a1) /* NOP */
-#define pth_debug2(a1, a2) /* NOP */
-#define pth_debug3(a1, a2, a3) /* NOP */
-#define pth_debug4(a1, a2, a3, a4) /* NOP */
-#define pth_debug5(a1, a2, a3, a4, a5) /* NOP */
-#define pth_debug6(a1, a2, a3, a4, a5, a6) /* NOP */
-
-#else
-
-#define pth_debug1(a1) pth_debug(__FILE__, __LINE__, 1, a1)
-#define pth_debug2(a1, a2) pth_debug(__FILE__, __LINE__, 2, a1, a2)
-#define pth_debug3(a1, a2, a3) pth_debug(__FILE__, __LINE__, 3, a1, a2, a3)
-#define pth_debug4(a1, a2, a3, a4) pth_debug(__FILE__, __LINE__, 4, a1, a2, a3, a4)
-#define pth_debug5(a1, a2, a3, a4, a5) pth_debug(__FILE__, __LINE__, 5, a1, a2, a3, a4, a5)
-#define pth_debug6(a1, a2, a3, a4, a5, a6) pth_debug(__FILE__, __LINE__, 6, a1, a2, a3, a4, a5, a6)
-
-#endif /* PTH_DEBUG */
-
-#endif /* cpp */
-
-intern void pth_debug(const char *file, int line, int argc, const char *fmt, ...)
-{
- va_list ap;
- static char str[1024];
- size_t n;
-
- errno_shield {
- va_start(ap, fmt);
- if (file != NULL)
- snprintf(str, sizeof(str), "%d:%s:%04d: ", (int)getpid(), file, line);
- else
- str[0] = NUL;
- n = strlen(str);
- if (argc == 1)
- strncpy (str+n, fmt, sizeof(str)-n);
- else
- vsnprintf(str+n, sizeof(str)-n, fmt, ap);
- va_end(ap);
- n = strlen(str);
- str[n++] = '\n';
- write(STDERR_FILENO, str, n);
- }
- return;
-}
+++ /dev/null
-/*
-** GNU Pth - The GNU Portable Threads
-** Copyright (c) 1999-2001 Ralf S. Engelschall <rse@engelschall.com>
-**
-** This file is part of GNU Pth, a non-preemptive thread scheduling
-** library which can be found at http://www.gnu.org/software/pth/.
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-** USA, or contact Ralf S. Engelschall <rse@engelschall.com>.
-**
-** pth_errno.c: Pth errno support
-*/
- /* Steinbach's Guideline for Systems Programming:
- ``Never test for an error condition
- you don't know how to handle.'' */
-#include "pth_p.h"
-
-#if cpp
-
-/* enclose errno in a block */
-#define errno_shield \
- for ( pth_errno_storage = errno, \
- pth_errno_flag = TRUE; \
- pth_errno_flag; \
- errno = pth_errno_storage, \
- pth_errno_flag = FALSE )
-
-/* return plus setting an errno value */
-#if defined(PTH_DEBUG)
-#define return_errno(return_val,errno_val) \
- do { errno = (errno_val); \
- pth_debug4("return 0x%lx with errno %d(\"%s\")", \
- (unsigned long)(return_val), (errno), strerror((errno))); \
- return (return_val); } while (0)
-#else
-#define return_errno(return_val,errno_val) \
- do { errno = (errno_val); return (return_val); } while (0)
-#endif
-
-#endif /* cpp */
-
-intern int pth_errno_storage = 0;
-intern int pth_errno_flag = 0;
-
+++ /dev/null
-/*
-** GNU Pth - The GNU Portable Threads
-** Copyright (c) 1999-2001 Ralf S. Engelschall <rse@engelschall.com>
-**
-** This file is part of GNU Pth, a non-preemptive thread scheduling
-** library which can be found at http://www.gnu.org/software/pth/.
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-** USA, or contact Ralf S. Engelschall <rse@engelschall.com>.
-**
-** pth_mctx.c: Pth machine context handling
-*/
- /* ``If you can't do it in
- ANSI C, it isn't worth doing.''
- -- Unknown */
-#include "pth_p.h"
-
-#if cpp
-
-/*
- * machine context state structure
- *
- * In `jb' the CPU registers, the program counter, the stack
- * pointer and (usually) the signals mask is stored. When the
- * signal mask cannot be implicitly stored in `jb', it's
- * alternatively stored explicitly in `sigs'. The `error' stores
- * the value of `errno'.
- */
-
-#if PTH_MCTX_MTH(mcsc)
-#include <ucontext.h>
-#endif
-
-typedef struct pth_mctx_st pth_mctx_t;
-struct pth_mctx_st {
-#if PTH_MCTX_MTH(mcsc)
- ucontext_t uc;
-#elif PTH_MCTX_MTH(sjlj)
- pth_sigjmpbuf jb;
-#else
-#error "unknown mctx method"
-#endif
- sigset_t sigs;
-#if PTH_MCTX_DSP(sjlje)
- sigset_t block;
-#endif
- int error;
-};
-
-/*
-** ____ MACHINE STATE SWITCHING ______________________________________
-*/
-
-/*
- * save the current machine context
- */
-#if PTH_MCTX_MTH(mcsc)
-#define pth_mctx_save(mctx) \
- ( (mctx)->error = errno, \
- getcontext(&(mctx)->uc) )
-#elif PTH_MCTX_MTH(sjlj) && PTH_MCTX_DSP(sjlje)
-#define pth_mctx_save(mctx) \
- ( (mctx)->error = errno, \
- sigprocmask(SIG_SETMASK, &((mctx)->block), NULL), \
- pth_sigsetjmp((mctx)->jb) )
-#elif PTH_MCTX_MTH(sjlj)
-#define pth_mctx_save(mctx) \
- ( (mctx)->error = errno, \
- pth_sigsetjmp((mctx)->jb) )
-#else
-#error "unknown mctx method"
-#endif
-
-/*
- * restore the current machine context
- * (at the location of the old context)
- */
-#if PTH_MCTX_MTH(mcsc)
-#define pth_mctx_restore(mctx) \
- ( errno = (mctx)->error, \
- (void)setcontext(&(mctx)->uc) )
-#elif PTH_MCTX_MTH(sjlj)
-#define pth_mctx_restore(mctx) \
- ( errno = (mctx)->error, \
- (void)pth_siglongjmp((mctx)->jb, 1) )
-#else
-#error "unknown mctx method"
-#endif
-
-/*
- * restore the current machine context
- * (at the location of the new context)
- */
-#if PTH_MCTX_MTH(sjlj) && PTH_MCTX_DSP(sjlje)
-#define pth_mctx_restored(mctx) \
- sigprocmask(SIG_SETMASK, &((mctx)->sigs), NULL)
-#else
-#define pth_mctx_restored(mctx) \
- /*nop*/
-#endif
-
-/*
- * switch from one machine context to another
- */
-#define SWITCH_DEBUG_LINE \
- "==== THREAD CONTEXT SWITCH ==========================================="
-#ifdef PTH_DEBUG
-#define _pth_mctx_switch_debug pth_debug(NULL, 0, 1, SWITCH_DEBUG_LINE);
-#else
-#define _pth_mctx_switch_debug /*NOP*/
-#endif
-#if PTH_MCTX_MTH(mcsc)
-#define pth_mctx_switch(old,new) \
- _pth_mctx_switch_debug \
- swapcontext(&((old)->uc), &((new)->uc));
-#elif PTH_MCTX_MTH(sjlj)
-#define pth_mctx_switch(old,new) \
- _pth_mctx_switch_debug \
- if (pth_mctx_save(old) == 0) \
- pth_mctx_restore(new); \
- pth_mctx_restored(old);
-#else
-#error "unknown mctx method"
-#endif
-
-#endif /* cpp */
-
-/*
-** ____ MACHINE STATE INITIALIZATION ________________________________
-*/
-
-#if PTH_MCTX_MTH(mcsc)
-
-/*
- * VARIANT 1: THE STANDARDIZED SVR4/SUSv2 APPROACH
- *
- * This is the preferred variant, because it uses the standardized
- * SVR4/SUSv2 makecontext(2) and friends which is a facility intended
- * for user-space context switching. The thread creation therefore is
- * straight-foreward.
- */
-
-intern int pth_mctx_set(
- pth_mctx_t *mctx, void (*func)(void), char *sk_addr_lo, char *sk_addr_hi)
-{
- /* fetch current context */
- if (getcontext(&(mctx->uc)) != 0)
- return FALSE;
-
- /* remove parent link */
- mctx->uc.uc_link = NULL;
-
- /* configure new stack */
- mctx->uc.uc_stack.ss_sp = pth_skaddr(makecontext, sk_addr_lo, sk_addr_hi-sk_addr_lo);
- mctx->uc.uc_stack.ss_size = pth_sksize(makecontext, sk_addr_lo, sk_addr_hi-sk_addr_lo);
- mctx->uc.uc_stack.ss_flags = 0;
-
- /* configure startup function (with no arguments) */
- makecontext(&(mctx->uc), func, 0+1);
-
- return TRUE;
-}
-
-#elif PTH_MCTX_MTH(sjlj) &&\
- !PTH_MCTX_DSP(sjljlx) &&\
- !PTH_MCTX_DSP(sjljisc) &&\
- !PTH_MCTX_DSP(sjljw32)
-
-/*
- * VARIANT 2: THE SIGNAL STACK TRICK
- *
- * This uses sigstack/sigaltstack() and friends and is really the
- * most tricky part of Pth. When you understand the following
- * stuff you're a good Unix hacker and then you've already
- * understood the gory ingredients of Pth. So, either welcome to
- * the club of hackers, or do yourself a favor and skip this ;)
- *
- * The ingenious fact is that this variant runs really on _all_ POSIX
- * compliant systems without special platform kludges. But be _VERY_
- * carefully when you change something in the following code. The slightest
- * change or reordering can lead to horribly broken code. Really every
- * function call in the following case is intended to be how it is, doubt
- * me...
- *
- * For more details we strongly recommend you to read the companion
- * paper ``Portable Multithreading -- The Signal Stack Trick for
- * User-Space Thread Creation'' from Ralf S. Engelschall. A copy of the
- * draft of this paper you can find in the file rse-pmt.ps inside the
- * GNU Pth distribution.
- */
-
-#if !defined(SA_ONSTACK) && defined(SV_ONSTACK)
-#define SA_ONSTACK SV_ONSTACK
-#endif
-#if !defined(SS_DISABLE) && defined(SA_DISABLE)
-#define SS_DISABLE SA_DISABLE
-#endif
-#if PTH_MCTX_STK(sas) && !defined(HAVE_SS_SP) && defined(HAVE_SS_BASE)
-#define ss_sp ss_base
-#endif
-
-static volatile jmp_buf mctx_trampoline;
-
-static volatile pth_mctx_t mctx_caller;
-static volatile sig_atomic_t mctx_called;
-
-static pth_mctx_t * volatile mctx_creating;
-static void (* volatile mctx_creating_func)(void);
-static volatile sigset_t mctx_creating_sigs;
-
-static void pth_mctx_set_trampoline(int);
-static void pth_mctx_set_bootstrap(void);
-
-/* initialize a machine state */
-intern int pth_mctx_set(
- pth_mctx_t *mctx, void (*func)(void), char *sk_addr_lo, char *sk_addr_hi)
-{
- struct sigaction sa;
- struct sigaction osa;
-#if PTH_MCTX_STK(sas) && defined(HAVE_STACK_T)
- stack_t ss;
- stack_t oss;
-#elif PTH_MCTX_STK(sas)
- struct sigaltstack ss;
- struct sigaltstack oss;
-#elif PTH_MCTX_STK(ss)
- struct sigstack ss;
- struct sigstack oss;
-#else
-#error "unknown mctx stack setup"
-#endif
- sigset_t osigs;
- sigset_t sigs;
-
- pth_debug1("pth_mctx_set: enter");
-
- /*
- * Preserve the SIGUSR1 signal state, block SIGUSR1,
- * and establish our signal handler. The signal will
- * later transfer control onto the signal stack.
- */
- sigemptyset(&sigs);
- sigaddset(&sigs, SIGUSR1);
- sigprocmask(SIG_BLOCK, &sigs, &osigs);
- sa.sa_handler = pth_mctx_set_trampoline;
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = SA_ONSTACK;
- if (sigaction(SIGUSR1, &sa, &osa) != 0)
- return FALSE;
-
- /*
- * Set the new stack.
- *
- * For sigaltstack we're lucky [from sigaltstack(2) on
- * FreeBSD 3.1]: ``Signal stacks are automatically adjusted
- * for the direction of stack growth and alignment
- * requirements''
- *
- * For sigstack we have to decide ourself [from sigstack(2)
- * on Solaris 2.6]: ``The direction of stack growth is not
- * indicated in the historical definition of struct sigstack.
- * The only way to portably establish a stack pointer is for
- * the application to determine stack growth direction.''
- */
-#if PTH_MCTX_STK(sas)
- ss.ss_sp = pth_skaddr(sigaltstack, sk_addr_lo, sk_addr_hi-sk_addr_lo);
- ss.ss_size = pth_sksize(sigaltstack, sk_addr_lo, sk_addr_hi-sk_addr_lo);
- ss.ss_flags = 0;
- if (sigaltstack(&ss, &oss) < 0)
- return FALSE;
-#elif PTH_MCTX_STK(ss)
- ss.ss_sp = pth_skaddr(sigstack, sk_addr_lo, sk_addr_hi-sk_addr_lo);
- ss.ss_onstack = 0;
- if (sigstack(&ss, &oss) < 0)
- return FALSE;
-#else
-#error "unknown mctx stack setup"
-#endif
-
- /*
- * Now transfer control onto the signal stack and set it up.
- * It will return immediately via "return" after the setjmp()
- * was performed. Be careful here with race conditions. The
- * signal can be delivered the first time sigsuspend() is
- * called.
- */
- mctx_called = FALSE;
- kill(getpid(), SIGUSR1);
- sigfillset(&sigs);
- sigdelset(&sigs, SIGUSR1);
- while (!mctx_called)
- sigsuspend(&sigs);
-
- /*
- * Inform the system that we are back off the signal stack by
- * removing the alternative signal stack. Be careful here: It
- * first has to be disabled, before it can be removed.
- */
-#if PTH_MCTX_STK(sas)
- sigaltstack(NULL, &ss);
- ss.ss_flags = SS_DISABLE;
- if (sigaltstack(&ss, NULL) < 0)
- return FALSE;
- sigaltstack(NULL, &ss);
- if (!(ss.ss_flags & SS_DISABLE))
- return_errno(FALSE, EIO);
- if (!(oss.ss_flags & SS_DISABLE))
- sigaltstack(&oss, NULL);
-#elif PTH_MCTX_STK(ss)
- if (sigstack(&oss, NULL))
- return FALSE;
-#endif
-
- /*
- * Restore the old SIGUSR1 signal handler and mask
- */
- sigaction(SIGUSR1, &osa, NULL);
- sigprocmask(SIG_SETMASK, &osigs, NULL);
-
- /*
- * Initialize additional ingredients of the machine
- * context structure.
- */
-#if PTH_MCTX_DSP(sjlje)
- sigemptyset(&mctx->block);
-#endif
- sigemptyset(&mctx->sigs);
- mctx->error = 0;
-
- /*
- * Tell the trampoline and bootstrap function where to dump
- * the new machine context, and what to do afterwards...
- */
- mctx_creating = mctx;
- mctx_creating_func = func;
- memcpy((void *)&mctx_creating_sigs, &osigs, sizeof(sigset_t));
-
- /*
- * Now enter the trampoline again, but this time not as a signal
- * handler. Instead we jump into it directly. The functionally
- * redundant ping-pong pointer arithmentic is neccessary to avoid
- * type-conversion warnings related to the `volatile' qualifier and
- * the fact that `jmp_buf' usually is an array type.
- */
- if (pth_mctx_save((pth_mctx_t *)&mctx_caller) == 0)
- longjmp(*((jmp_buf *)&mctx_trampoline), 1);
-
- /*
- * Ok, we returned again, so now we're finished
- */
- pth_debug1("pth_mctx_set: leave");
- return TRUE;
-}
-
-/* trampoline signal handler */
-static void pth_mctx_set_trampoline(int sig)
-{
- /*
- * Save current machine state and _immediately_ go back with
- * a standard "return" (to stop the signal handler situation)
- * to let him remove the stack again. Notice that we really
- * have do a normal "return" here, or the OS would consider
- * the thread to be running on a signal stack which isn't
- * good (for instance it wouldn't allow us to spawn a thread
- * from within a thread, etc.)
- *
- * The functionally redundant ping-pong pointer arithmentic is again
- * neccessary to avoid type-conversion warnings related to the
- * `volatile' qualifier and the fact that `jmp_buf' usually is an
- * array type.
- *
- * Additionally notice that we INTENTIONALLY DO NOT USE pth_mctx_save()
- * here. Instead we use a plain setjmp(3) call because we have to make
- * sure the alternate signal stack environment is _NOT_ saved into the
- * machine context (which can be the case for sigsetjmp(3) on some
- * platforms).
- */
- if (setjmp(*((jmp_buf *)&mctx_trampoline)) == 0) {
- pth_debug1("pth_mctx_set_trampoline: return to caller");
- mctx_called = TRUE;
- return;
- }
- pth_debug1("pth_mctx_set_trampoline: reentered from caller");
-
- /*
- * Ok, the caller has longjmp'ed back to us, so now prepare
- * us for the real machine state switching. We have to jump
- * into another function here to get a new stack context for
- * the auto variables (which have to be auto-variables
- * because the start of the thread happens later). Else with
- * PIC (i.e. Position Independent Code which is used when PTH
- * is built as a shared library) most platforms would
- * horrible core dump as experience showed.
- */
- pth_mctx_set_bootstrap();
-}
-
-/* boot function */
-static void pth_mctx_set_bootstrap(void)
-{
- pth_mctx_t * volatile mctx_starting;
- void (* volatile mctx_starting_func)(void);
-
- /*
- * Switch to the final signal mask (inherited from parent)
- */
- sigprocmask(SIG_SETMASK, (sigset_t *)&mctx_creating_sigs, NULL);
-
- /*
- * Move startup details from static storage to local auto
- * variables which is necessary because it has to survive in
- * a local context until the thread is scheduled for real.
- */
- mctx_starting = mctx_creating;
- mctx_starting_func = mctx_creating_func;
-
- /*
- * Save current machine state (on new stack) and
- * go back to caller until we're scheduled for real...
- */
- pth_debug1("pth_mctx_set_trampoline_jumpin: switch back to caller");
- pth_mctx_switch((pth_mctx_t *)mctx_starting, (pth_mctx_t *)&mctx_caller);
-
- /*
- * The new thread is now running: GREAT!
- * Now we just invoke its init function....
- */
- pth_debug1("pth_mctx_set_trampoline_jumpin: reentered from scheduler");
- mctx_starting_func();
- abort();
-}
-
-#elif PTH_MCTX_MTH(sjlj) && PTH_MCTX_DSP(sjljlx)
-
-/*
- * VARIANT 3: LINUX SPECIFIC JMP_BUF FIDDLING
- *
- * Oh hell, I really love it when Linux guys talk about their "POSIX
- * compliant system". It's far away from POSIX compliant, IMHO. Autoconf
- * finds sigstack/sigaltstack() on Linux, yes. But it doesn't work. Why?
- * Because on Linux below version 2.2 and glibc versions below 2.1 these
- * two functions are nothing more than silly stub functions which always
- * return just -1. Very useful, yeah...
- */
-
-#include <features.h>
-
-intern int pth_mctx_set(
- pth_mctx_t *mctx, void (*func)(void), char *sk_addr_lo, char *sk_addr_hi)
-{
- pth_mctx_save(mctx);
-#if defined(__GLIBC__) && defined(__GLIBC_MINOR__) \
- && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 0 && defined(JB_PC) && defined(JB_SP)
- mctx->jb[0].__jmpbuf[JB_PC] = (int)func;
- mctx->jb[0].__jmpbuf[JB_SP] = (int)sk_addr_hi;
-#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) \
- && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 0 && defined(__mc68000__)
- mctx->jb[0].__jmpbuf[0].__aregs[0] = (long int)func;
- mctx->jb[0].__jmpbuf[0].__sp = (int *)sk_addr_hi;
-#elif defined(__GNU_LIBRARY__) && defined(__i386__)
- mctx->jb[0].__jmpbuf[0].__pc = (char *)func;
- mctx->jb[0].__jmpbuf[0].__sp = sk_addr_hi;
-#else
-#error "Unsupported Linux (g)libc version and/or platform"
-#endif
- sigemptyset(&mctx->sigs);
- mctx->error = 0;
- return TRUE;
-}
-
-/*
- * VARIANT 4: INTERACTIVE SPECIFIC JMP_BUF FIDDLING
- *
- * No wonder, Interactive Unix (ISC) 4.x contains Microsoft code, so
- * it's clear that this beast lacks both sigstack and sigaltstack (about
- * makecontext we not even have to talk). So our only chance is to
- * fiddle with it's jmp_buf ingredients, of course. We support only i386
- * boxes.
- */
-
-#elif PTH_MCTX_MTH(sjlj) && PTH_MCTX_DSP(sjljisc)
-intern int
-pth_mctx_set(pth_mctx_t *mctx, void (*func)(void),
- char *sk_addr_lo, char *sk_addr_hi)
-{
- pth_mctx_save(mctx);
-#if i386
- mctx->jb[4] = (int)sk_addr_hi - sizeof(mctx->jb);
- mctx->jb[5] = (int)func;
-#else
-#error "Unsupported ISC architecture"
-#endif
- sigemptyset(&mctx->sigs);
- mctx->error = 0;
- return TRUE;
-}
-
-/*
- * VARIANT 5: WIN32 SPECIFIC JMP_BUF FIDDLING
- *
- * Oh hell, Win32 has setjmp(3), but no sigstack(2) or sigaltstack(2).
- * So we have to fiddle around with the jmp_buf here too...
- */
-
-#elif PTH_MCTX_MTH(sjlj) && PTH_MCTX_DSP(sjljw32)
-intern int
-pth_mctx_set(pth_mctx_t *mctx, void (*func)(void),
- char *sk_addr_lo, char *sk_addr_hi)
-{
- pth_mctx_save(mctx);
-#if i386
- mctx->jb[7] = (int)sk_addr_hi;
- mctx->jb[8] = (int)func;
-#else
-#error "Unsupported Win32 architecture"
-#endif
- sigemptyset(&mctx->sigs);
- mctx->error = 0;
- return TRUE;
-}
-
-/*
- * VARIANT X: JMP_BUF FIDDLING FOR ONE MORE ESOTERIC OS
- * Add the jmp_buf fiddling for your esoteric OS here...
- *
-#elif PTH_MCTX_MTH(sjlj) && PTH_MCTX_DSP(sjljeso)
-intern int
-pth_mctx_set(pth_mctx_t *mctx, void (*func)(void),
- char *sk_addr_lo, char *sk_addr_hi)
-{
- pth_mctx_save(mctx);
- sigemptyset(&mctx->sigs);
- mctx->error = 0;
- ...start hacking here...
- mctx->.... = func;
- mctx->.... = sk_addr_hi;
- mctx->.... = sk_addr_lo;
- return TRUE;
-}
-*/
-
-#else
-#error "unknown mctx method"
-#endif
-
+++ /dev/null
-/*
-** GNU Pth - The GNU Portable Threads
-** Copyright (c) 1999-2001 Ralf S. Engelschall <rse@engelschall.com>
-**
-** This file is part of GNU Pth, a non-preemptive thread scheduling
-** library which can be found at http://www.gnu.org/software/pth/.
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-** USA, or contact Ralf S. Engelschall <rse@engelschall.com>.
-**
-** pth_p.h: Pth private API definitions
-*/
-
-#ifndef _PTH_P_H_
-#define _PTH_P_H_
-
-/* mandatory system headers */
-
-#include <errno.h>
-/*
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <setjmp.h>
-#include <signal.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <time.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/wait.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-*/
-
-/* library version */
-#define _PTH_VERS_C_AS_HEADER_
-#include "pth_vers.c"
-#undef _PTH_VERS_C_AS_HEADER_
-
-/* public API headers */
-#define _PTH_PRIVATE
-#include "pth.h"
-#undef _PTH_PRIVATE
-
-/* autoconf defines and macros */
-#include "pth_acdef.h"
-#include "pth_acmac.h"
-
-/* generated contents */
-BEGIN_DECLARATION
-==#==
-END_DECLARATION
-
-#endif /* _PTH_P_H_ */
-
+++ /dev/null
-/*
-** pth_vers.c -- Version Information for GNU Pth (syntax: C/C++)
-** [automatically generated and maintained by GNU shtool]
-*/
-
-#ifdef _PTH_VERS_C_AS_HEADER_
-
-#ifndef _PTH_VERS_C_
-#define _PTH_VERS_C_
-
-#define PTH_INTERNAL_VERSION 0x104200
-
-typedef struct {
- const int v_hex;
- const char *v_short;
- const char *v_long;
- const char *v_tex;
- const char *v_gnu;
- const char *v_web;
- const char *v_sccs;
- const char *v_rcs;
-} pth_internal_version_t;
-
-extern pth_internal_version_t pth_internal_version;
-
-#endif /* _PTH_VERS_C_ */
-
-#else /* _PTH_VERS_C_AS_HEADER_ */
-
-#define _PTH_VERS_C_AS_HEADER_
-#include "pth_vers.c"
-#undef _PTH_VERS_C_AS_HEADER_
-
-pth_internal_version_t pth_internal_version = {
- 0x104200,
- "1.4.0",
- "1.4.0 (24-Mar-2001)",
- "This is GNU Pth, Version 1.4.0 (24-Mar-2001)",
- "GNU Pth 1.4.0 (24-Mar-2001)",
- "GNU Pth/1.4.0",
- "@(#)GNU Pth 1.4.0 (24-Mar-2001)",
- "$Id$"
-};
-
-#endif /* _PTH_VERS_C_AS_HEADER_ */
-
+++ /dev/null
-#!/bin/sh
-##
-## GNU shtool -- The GNU Portable Shell Tool
-## Copyright (c) 1994-2000 Ralf S. Engelschall <rse@engelschall.com>
-##
-## See http://www.gnu.org/software/shtool/ for more information.
-## See ftp://ftp.gnu.org/gnu/shtool/ for latest version.
-##
-## Version: 1.5.0 (01-Jul-2000)
-## Contents: 7/17 available modules
-##
-
-##
-## This program is free software; you can redistribute it and/or modify
-## it under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 2 of the License, or
-## (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-## General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
-## USA, or contact Ralf S. Engelschall <rse@engelschall.com>.
-##
-## Notice: Given that you include this file verbatim into your own
-## source tree, you are justified in saying that it remains separate
-## from your package, and that this way you are simply just using GNU
-## shtool. So, in this situation, there is no requirement that your
-## package itself is licensed under the GNU General Public License in
-## order to take advantage of GNU shtool.
-##
-
-##
-## Usage: shtool [<options>] [<cmd-name> [<cmd-options>] [<cmd-args>]]
-##
-## Available commands:
-## echo Print string with optional construct expansion
-## install Install a program, script or datafile
-## mkdir Make one or more directories
-## fixperm Fix file permissions inside a source tree
-## tarball Roll distribution tarballs
-## scpp Sharing C Pre-Processor
-## version Maintain a version information file
-##
-## Not available commands (because module was not built-in):
-## mdate Pretty-print modification time of a file or dir
-## table Pretty-print a field-separated list as a table
-## prop Display progress with a running propeller
-## move Move files with simultaneous substitution
-## mkln Make link with calculation of relative paths
-## mkshadow Make a shadow tree through symbolic links
-## guessos Simple operating system guesser
-## arx Extended archive command
-## slo Separate linker options by library class
-## path Deal with program paths
-##
-
-if [ $# -eq 0 ]; then
- echo "$0:Error: invalid command line" 1>&2
- echo "$0:Hint: run \`$0 -h' for usage" 1>&2
- exit 1
-fi
-if [ ".$1" = ".-h" -o ".$1" = ".--help" ]; then
- echo "This is GNU shtool, version 1.5.0 (01-Jul-2000)"
- echo "Copyright (c) 1994-2000 Ralf S. Engelschall <rse@engelschall.com>"
- echo "Report bugs to <bug-shtool@gnu.org>"
- echo ''
- echo "Usage: shtool [<options>] [<cmd-name> [<cmd-options>] [<cmd-args>]]"
- echo ''
- echo 'Available global <options>:'
- echo ' -v, --version display shtool version information'
- echo ' -h, --help display shtool usage help page (this one)'
- echo ' -d, --debug display shell trace information'
- echo ' -r, --recreate recreate this shtool script via shtoolize'
- echo ''
- echo 'Available <cmd-name> [<cmd-options>] [<cmd-args>]:'
- echo ' echo [-n] [-e] [<str> ...]'
- echo ' install [-v] [-t] [-c] [-C] [-s] [-m<mode>] [-o<owner>] [-g<group>]'
- echo ' [-e<ext>] <file> [<file> ...] <path>'
- echo ' mkdir [-t] [-f] [-p] [-m<mode>] <dir> [<dir> ...]'
- echo ' fixperm [-v] [-t] <path> [<path> ...]'
- echo ' tarball [-t] [-v] [-o <tarball>] [-c <prog>] [-d <dir>] [-u'
- echo ' <user>] [-g <group>] [-e <pattern>] <path> [<path> ...]'
- echo ' scpp [-v] [-p] [-f<filter>] [-o<ofile>] [-t<tfile>] [-M<mark>]'
- echo ' [-D<dname>] [-C<cname>] <file> [<file> ...]'
- echo ' version [-l<lang>] [-n<name>] [-p<prefix>] [-s<version>] [-e]'
- echo ' [-i<knob>] [-d<type>] <file>'
- echo ''
- echo 'Not available <cmd-name> (because module was not built-in):'
- echo ' mdate [-n] [-z] [-s] [-d] [-f<str>] [-o<spec>] <path>'
- echo ' table [-F<sep>] [-w<width>] [-c<cols>] [-s<strip>] <str><sep><str>...'
- echo ' prop [-p<str>]'
- echo ' move [-v] [-t] [-e] [-p] <src-file> <dst-file>'
- echo ' mkln [-t] [-f] [-s] <src-path> [<src-path> ...] <dst-path>'
- echo ' mkshadow [-v] [-t] [-a] <src-dir> <dst-dir>'
- echo ' guessos '
- echo ' arx [-t] [-C<cmd>] <op> <archive> [<file> ...]'
- echo ' slo [-p<str>] -- -L<dir> -l<lib> [-L<dir> -l<lib> ...]'
- echo ' path [-s] [-r] [-d] [-b] [-m] [-p<path>] <str> [<str> ...]'
- echo ''
- exit 0
-fi
-if [ ".$1" = ".-v" -o ".$1" = ."--version" ]; then
- echo "GNU shtool 1.5.0 (01-Jul-2000)"
- exit 0
-fi
-if [ ".$1" = ".-r" -o ".$1" = ."--recreate" ]; then
- shtoolize -oshtool echo install mkdir fixperm tarball scpp version
- exit 0
-fi
-if [ ".$1" = ".-d" -o ".$1" = ."--debug" ]; then
- shift
- set -x
-fi
-name=`echo "$0" | sed -e 's;.*/\([^/]*\)$;\1;' -e 's;-sh$;;' -e 's;\.sh$;;'`
-case "$name" in
- echo|install|mkdir|fixperm|tarball|scpp|version )
- # implicit tool command selection
- tool="$name"
- ;;
- * )
- # explicit tool command selection
- tool="$1"
- shift
- ;;
-esac
-arg_spec=""
-opt_spec=""
-gen_tmpfile=no
-
-##
-## DISPATCH INTO SCRIPT PROLOG
-##
-
-case $tool in
- echo )
- str_tool="echo"
- str_usage="[-n] [-e] [<str> ...]"
- arg_spec="0+"
- opt_spec="n.e."
- opt_n=no
- opt_e=no
- ;;
- install )
- str_tool="install"
- str_usage="[-v] [-t] [-c] [-C] [-s] [-m<mode>] [-o<owner>] [-g<group>] [-e<ext>] <file> [<file> ...] <path>"
- arg_spec="2+"
- opt_spec="v.t.c.C.s.m:o:g:e:"
- opt_v=no
- opt_t=no
- opt_c=no
- opt_C=no
- opt_s=no
- opt_m=""
- opt_o=""
- opt_g=""
- opt_e=""
- ;;
- mkdir )
- str_tool="mkdir"
- str_usage="[-t] [-f] [-p] [-m<mode>] <dir> [<dir> ...]"
- arg_spec="1+"
- opt_spec="t.f.p.m:"
- opt_t=no
- opt_f=no
- opt_p=no
- opt_m=""
- ;;
- fixperm )
- str_tool="fixperm"
- str_usage="[-v] [-t] <path> [<path> ...]"
- arg_spec="1+"
- opt_spec="v.t."
- opt_v=no
- opt_t=no
- ;;
- tarball )
- str_tool="tarball"
- str_usage="[-t] [-v] [-o <tarball>] [-c <prog>] [-d <dir>] [-u <user>] [-g <group>] [-e <pattern>] <path> [<path> ...]"
- gen_tmpfile=yes
- arg_spec="1+"
- opt_spec="t.v.o:c:d:u:g:e:"
- opt_t=no
- opt_v=no
- opt_o=""
- opt_c=""
- opt_d=""
- opt_u=""
- opt_g=""
- opt_e="CVS,\\.cvsignore,\\.[oa]\$"
- ;;
- scpp )
- str_tool="scpp"
- str_usage="[-v] [-p] [-f<filter>] [-o<ofile>] [-t<tfile>] [-M<mark>] [-D<dname>] [-C<cname>] <file> [<file> ...]"
- gen_tmpfile=yes
- arg_spec="1+"
- opt_spec="v.p.f+o:t:M:D:C:"
- opt_v=no
- opt_p=no
- opt_f=""
- opt_o="lib.h"
- opt_t="lib.h.in"
- opt_M="%%MARK%%"
- opt_D="cpp"
- opt_C="intern"
- ;;
- version )
- str_tool="version"
- str_usage="[-l<lang>] [-n<name>] [-p<prefix>] [-s<version>] [-e] [-i<knob>] [-d<type>] <file>"
- arg_spec="1="
- opt_spec="l:n:p:s:i:e.d:"
- opt_l="txt"
- opt_n="unknown"
- opt_p=""
- opt_s=""
- opt_e="no"
- opt_i=""
- opt_d="short"
- ;;
- -* )
- echo "$0:Error: unknown option \`$tool'" 2>&1
- echo "$0:Hint: run \`$0 -h' for usage" 2>&1
- exit 1
- ;;
- * )
- echo "$0:Error: unknown command \`$tool'" 2>&1
- echo "$0:Hint: run \`$0 -h' for usage" 2>&1
- exit 1
- ;;
-esac
-
-##
-## COMMON UTILITY CODE
-##
-
-# determine name of tool
-if [ ".$tool" != . ]; then
- # used inside shtool script
- toolcmd="$0 $tool"
- toolcmdhelp="shtool $tool"
- msgprefix="shtool:$tool"
-else
- # used as standalone script
- toolcmd="$0"
- toolcmdhelp="sh $0"
- msgprefix="$str_tool"
-fi
-
-# parse argument specification string
-eval `echo $arg_spec |\
- sed -e 's/^\([0-9]*\)\([+=]\)/arg_NUMS=\1; arg_MODE=\2/'`
-
-# parse option specification string
-eval `echo h.$opt_spec |\
- sed -e 's/\([a-zA-Z0-9]\)\([.:+]\)/opt_MODE_\1=\2;/g'`
-
-# interate over argument line
-opt_PREV=''
-while [ $# -gt 0 ]; do
- # special option stops processing
- if [ ".$1" = ".--" ]; then
- shift
- break
- fi
-
- # determine option and argument
- opt_ARG_OK=no
- if [ ".$opt_PREV" != . ]; then
- # merge previous seen option with argument
- opt_OPT="$opt_PREV"
- opt_ARG="$1"
- opt_ARG_OK=yes
- opt_PREV=''
- else
- # split argument into option and argument
- case "$1" in
- -[a-zA-Z0-9]*)
- eval `echo "x$1" |\
- sed -e 's/^x-\([a-zA-Z0-9]\)/opt_OPT="\1";/' \
- -e 's/";\(.*\)$/"; opt_ARG="\1"/'`
- ;;
- -[a-zA-Z0-9])
- opt_OPT=`echo "x$1" | cut -c3-`
- opt_ARG=''
- ;;
- *)
- break
- ;;
- esac
- fi
-
- # eat up option
- shift
-
- # determine whether option needs an argument
- eval "opt_MODE=\$opt_MODE_${opt_OPT}"
- if [ ".$opt_ARG" = . -a ".$opt_ARG_OK" != .yes ]; then
- if [ ".$opt_MODE" = ".:" -o ".$opt_MODE" = ".+" ]; then
- opt_PREV="$opt_OPT"
- continue
- fi
- fi
-
- # process option
- case $opt_MODE in
- '.' )
- # boolean option
- eval "opt_${opt_OPT}=yes"
- ;;
- ':' )
- # option with argument (multiple occurances override)
- eval "opt_${opt_OPT}=\"\$opt_ARG\""
- ;;
- '+' )
- # option with argument (multiple occurances append)
- eval "opt_${opt_OPT}=\"\$opt_${opt_OPT} \$opt_ARG\""
- ;;
- * )
- echo "$msgprefix:Error: unknown option: \`-$opt_OPT'" 1>&2
- echo "$msgprefix:Hint: run \`$toolcmdhelp -h' or \`man shtool' for details" 1>&2
- exit 1
- ;;
- esac
-done
-if [ ".$opt_PREV" != . ]; then
- echo "$msgprefix:Error: missing argument to option \`-$opt_PREV'" 1>&2
- echo "$msgprefix:Hint: run \`$toolcmdhelp -h' or \`man shtool' for details" 1>&2
- exit 1
-fi
-
-# process help option
-if [ ".$opt_h" = .yes ]; then
- echo "Usage: $toolcmdhelp $str_usage"
- exit 0
-fi
-
-# complain about incorrect number of arguments
-case $arg_MODE in
- '=' )
- if [ $# -ne $arg_NUMS ]; then
- echo "$msgprefix:Error: invalid number of arguments (exactly $arg_NUMS expected)" 1>&2
- echo "$msgprefix:Hint: run \`$toolcmd -h' or \`man shtool' for details" 1>&2
- exit 1
- fi
- ;;
- '+' )
- if [ $# -lt $arg_NUMS ]; then
- echo "$msgprefix:Error: invalid number of arguments (at least $arg_NUMS expected)" 1>&2
- echo "$msgprefix:Hint: run \`$toolcmd -h' or \`man shtool' for details" 1>&2
- exit 1
- fi
- ;;
-esac
-
-# establish a temporary file on request
-if [ ".$gen_tmpfile" = .yes ]; then
- if [ ".$TMPDIR" != . ]; then
- tmpdir="$TMPDIR"
- elif [ ".$TEMPDIR" != . ]; then
- tmpdir="$TEMPDIR"
- else
- tmpdir="/tmp"
- fi
- tmpfile="$tmpdir/.shtool.$$"
- rm -f $tmpfile >/dev/null 2>&1
- touch $tmpfile
-fi
-
-##
-## DISPATCH INTO SCRIPT BODY
-##
-
-case $tool in
-
-echo )
- ##
- ## echo -- Print string with optional construct expansion
- ## Copyright (c) 1998-2000 Ralf S. Engelschall <rse@engelschall.com>
- ## Originally written for WML as buildinfo
- ##
-
- text="$*"
-
- # check for broken escape sequence expansion
- seo=''
- bytes=`echo '\1' | wc -c | awk '{ printf("%s", $1); }'`
- if [ ".$bytes" != .3 ]; then
- bytes=`echo -E '\1' | wc -c | awk '{ printf("%s", $1); }'`
- if [ ".$bytes" = .3 ]; then
- seo='-E'
- fi
- fi
-
- # check for existing -n option (to suppress newline)
- minusn=''
- bytes=`echo -n 123 2>/dev/null | wc -c | awk '{ printf("%s", $1); }'`
- if [ ".$bytes" = .3 ]; then
- minusn='-n'
- fi
-
- # determine terminal bold sequence
- term_bold=''
- term_norm=''
- if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%[Bb]'`" != . ]; then
- case $TERM in
- # for the most important terminal types we directly know the sequences
- xterm|xterm*|vt220|vt220*)
- term_bold=`awk 'BEGIN { printf("%c%c%c%c", 27, 91, 49, 109); }' </dev/null 2>/dev/null`
- term_norm=`awk 'BEGIN { printf("%c%c%c", 27, 91, 109); }' </dev/null 2>/dev/null`
- ;;
- vt100|vt100*)
- term_bold=`awk 'BEGIN { printf("%c%c%c%c%c%c", 27, 91, 49, 109, 0, 0); }' </dev/null 2>/dev/null`
- term_norm=`awk 'BEGIN { printf("%c%c%c%c%c", 27, 91, 109, 0, 0); }' </dev/null 2>/dev/null`
- ;;
- # for all others, we try to use a possibly existing `tput' or `tcout' utility
- * )
- paths=`echo $PATH | sed -e 's/:/ /g'`
- for tool in tput tcout; do
- for dir in $paths; do
- if [ -r "$dir/$tool" ]; then
- for seq in bold md smso; do # 'smso' is last
- bold="`$dir/$tool $seq 2>/dev/null`"
- if [ ".$bold" != . ]; then
- term_bold="$bold"
- break
- fi
- done
- if [ ".$term_bold" != . ]; then
- for seq in sgr0 me rmso reset; do # 'reset' is last
- norm="`$dir/$tool $seq 2>/dev/null`"
- if [ ".$norm" != . ]; then
- term_norm="$norm"
- break
- fi
- done
- fi
- break
- fi
- done
- if [ ".$term_bold" != . -a ".$term_norm" != . ]; then
- break;
- fi
- done
- ;;
- esac
- if [ ".$term_bold" = . -o ".$term_norm" = . ]; then
- echo "$msgprefix:Warning: unable to determine terminal sequence for bold mode" 1>&2
- fi
- fi
-
- # determine user name
- username=''
- if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%[uU]'`" != . ]; then
- username="$LOGNAME"
- if [ ".$username" = . ]; then
- username="$USER"
- if [ ".$username" = . ]; then
- username="`(whoami) 2>/dev/null |\
- awk '{ printf("%s", $1); }'`"
- if [ ".$username" = . ]; then
- username="`(who am i) 2>/dev/null |\
- awk '{ printf("%s", $1); }'`"
- if [ ".$username" = . ]; then
- username='unknown'
- fi
- fi
- fi
- fi
- fi
-
- # determine user id
- userid=''
- if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%U'`" != . ]; then
- userid="`(id -u) 2>/dev/null`"
- if [ ".$userid" = . ]; then
- str="`(id) 2>/dev/null`"
- if [ ".`echo $str | grep '^uid[ ]*=[ ]*[0-9]*('`" != . ]; then
- userid=`echo $str | sed -e 's/^uid[ ]*=[ ]*//' -e 's/(.*//'`
- fi
- if [ ".$userid" = . ]; then
- userid=`egrep "^${username}:" /etc/passwd 2>/dev/null | \
- sed -e 's/[^:]*:[^:]*://' -e 's/:.*$//'`
- if [ ".$userid" = . ]; then
- userid=`(ypcat passwd) 2>/dev/null |
- egrep "^${username}:" | \
- sed -e 's/[^:]*:[^:]*://' -e 's/:.*$//'`
- if [ ".$userid" = . ]; then
- userid='?'
- fi
- fi
- fi
- fi
- fi
-
- # determine host name
- hostname=''
- if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%h'`" != . ]; then
- hostname="`(uname -n) 2>/dev/null |\
- awk '{ printf("%s", $1); }'`"
- if [ ".$hostname" = . ]; then
- hostname="`(hostname) 2>/dev/null |\
- awk '{ printf("%s", $1); }'`"
- if [ ".$hostname" = . ]; then
- hostname='unknown'
- fi
- fi
- case $hostname in
- *.* )
- domainname=".`echo $hostname | cut -d. -f2-`"
- hostname="`echo $hostname | cut -d. -f1`"
- ;;
- esac
- fi
-
- # determine domain name
- domainname=''
- if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%d'`" != . ]; then
- if [ ".$domainname" = . ]; then
- if [ -f /etc/resolv.conf ]; then
- domainname="`egrep '^[ ]*domain' /etc/resolv.conf | head -1 |\
- sed -e 's/.*domain//' \
- -e 's/^[ ]*//' -e 's/^ *//' -e 's/^ *//' \
- -e 's/^\.//' -e 's/^/./' |\
- awk '{ printf("%s", $1); }'`"
- if [ ".$domainname" = . ]; then
- domainname="`egrep '^[ ]*search' /etc/resolv.conf | head -1 |\
- sed -e 's/.*search//' \
- -e 's/^[ ]*//' -e 's/^ *//' -e 's/^ *//' \
- -e 's/ .*//' -e 's/ .*//' \
- -e 's/^\.//' -e 's/^/./' |\
- awk '{ printf("%s", $1); }'`"
- fi
- fi
- fi
- fi
-
- # determine current time
- time_day=''
- time_month=''
- time_year=''
- time_monthname=''
- if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%[DMYm]'`" != . ]; then
- time_day=`date '+%d'`
- time_month=`date '+%m'`
- time_year=`date '+%Y' 2>/dev/null`
- if [ ".$time_year" = . ]; then
- time_year=`date '+%y'`
- case $time_year in
- [5-9][0-9]) time_year="19$time_year" ;;
- [0-4][0-9]) time_year="20$time_year" ;;
- esac
- fi
- case $time_month in
- 1|01) time_monthname='Jan' ;;
- 2|02) time_monthname='Feb' ;;
- 3|03) time_monthname='Mar' ;;
- 4|04) time_monthname='Apr' ;;
- 5|05) time_monthname='May' ;;
- 6|06) time_monthname='Jun' ;;
- 7|07) time_monthname='Jul' ;;
- 8|08) time_monthname='Aug' ;;
- 9|09) time_monthname='Sep' ;;
- 10) time_monthname='Oct' ;;
- 11) time_monthname='Nov' ;;
- 12) time_monthname='Dec' ;;
- esac
- fi
-
- # expand special ``%x'' constructs
- if [ ".$opt_e" = .yes ]; then
- text=`echo $seo "$text" |\
- sed -e "s/%B/${term_bold}/g" \
- -e "s/%b/${term_norm}/g" \
- -e "s/%u/${username}/g" \
- -e "s/%U/${userid}/g" \
- -e "s/%h/${hostname}/g" \
- -e "s/%d/${domainname}/g" \
- -e "s/%D/${time_day}/g" \
- -e "s/%M/${time_month}/g" \
- -e "s/%Y/${time_year}/g" \
- -e "s/%m/${time_monthname}/g" 2>/dev/null`
- fi
-
- # create output
- if [ .$opt_n = .no ]; then
- echo $seo "$text"
- else
- # the harder part: echo -n is best, because
- # awk may complain about some \xx sequences.
- if [ ".$minusn" != . ]; then
- echo $seo $minusn "$text"
- else
- echo dummy | awk '{ printf("%s", TEXT); }' TEXT="$text"
- fi
- fi
- ;;
-
-install )
- ##
- ## install -- Install a program, script or datafile
- ## Copyright (c) 1997-2000 Ralf S. Engelschall <rse@engelschall.com>
- ## Originally written for shtool
- ##
-
- # determine source(s) and destination
- argc=$#
- srcs=""
- while [ $# -gt 1 ]; do
- srcs="$srcs $1"
- shift
- done
- dstpath="$1"
-
- # type check for destination
- dstisdir=0
- if [ -d $dstpath ]; then
- dstpath=`echo "$dstpath" | sed -e 's:/$::'`
- dstisdir=1
- fi
-
- # consistency check for destination
- if [ $argc -gt 2 -a $dstisdir = 0 ]; then
- echo "$msgprefix:Error: multiple sources require destination to be directory" 1>&2
- exit 1
- fi
-
- # iterate over all source(s)
- for src in $srcs; do
- dst=$dstpath
-
- # If destination is a directory, append the input filename
- if [ $dstisdir = 1 ]; then
- dstfile=`echo "$src" | sed -e 's;.*/\([^/]*\)$;\1;'`
- dst="$dst/$dstfile"
- fi
-
- # Add a possible extension to src and dst
- if [ ".$opt_e" != . ]; then
- src="$src$opt_e"
- dst="$dst$opt_e"
- fi
-
- # Check for correct arguments
- if [ ".$src" = ".$dst" ]; then
- echo "$msgprefix:Warning: source and destination are the same - skipped" 1>&2
- continue
- fi
- if [ -d "$src" ]; then
- echo "$msgprefix:Warning: source \`$src' is a directory - skipped" 1>&2
- continue
- fi
-
- # Make a temp file name in the destination directory
- dsttmp=`echo $dst |\
- sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;' -e 's;^$;.;' \
- -e "s;\$;/#INST@$$#;"`
-
- # Verbosity
- if [ ".$opt_v" = .yes ]; then
- echo "$src -> $dst" 1>&2
- fi
-
- # Copy or move the file name to the temp name
- # (because we might be not allowed to change the source)
- if [ ".$opt_C" = .yes ]; then
- opt_c=yes
- fi
- if [ ".$opt_c" = .yes ]; then
- if [ ".$opt_t" = .yes ]; then
- echo "cp $src $dsttmp" 1>&2
- fi
- cp $src $dsttmp || exit $?
- else
- if [ ".$opt_t" = .yes ]; then
- echo "mv $src $dsttmp" 1>&2
- fi
- mv $src $dsttmp || exit $?
- fi
-
- # Adjust the target file
- # (we do chmod last to preserve setuid bits)
- if [ ".$opt_s" = .yes ]; then
- if [ ".$opt_t" = .yes ]; then
- echo "strip $dsttmp" 1>&2
- fi
- strip $dsttmp || exit $?
- fi
- if [ ".$opt_o" != . ]; then
- if [ ".$opt_t" = .yes ]; then
- echo "chown $opt_o $dsttmp" 1>&2
- fi
- chown $opt_o $dsttmp || exit $?
- fi
- if [ ".$opt_g" != . ]; then
- if [ ".$opt_t" = .yes ]; then
- echo "chgrp $opt_g $dsttmp" 1>&2
- fi
- chgrp $opt_g $dsttmp || exit $?
- fi
- if [ ".$opt_m" != . ]; then
- if [ ".$opt_t" = .yes ]; then
- echo "chmod $opt_m $dsttmp" 1>&2
- fi
- chmod $opt_m $dsttmp || exit $?
- fi
-
- # Determine whether to do a quick install
- # (has to be done _after_ the strip was already done)
- quick=no
- if [ ".$opt_C" = .yes ]; then
- if [ -r $dst ]; then
- if cmp -s $src $dst; then
- quick=yes
- fi
- fi
- fi
-
- # Finally install the file to the real destination
- if [ $quick = yes ]; then
- if [ ".$opt_t" = .yes ]; then
- echo "rm -f $dsttmp" 1>&2
- fi
- rm -f $dsttmp
- else
- if [ ".$opt_t" = .yes ]; then
- echo "rm -f $dst && mv $dsttmp $dst" 1>&2
- fi
- rm -f $dst && mv $dsttmp $dst
- fi
- done
- ;;
-
-mkdir )
- ##
- ## mkdir -- Make one or more directories
- ## Copyright (c) 1996-2000 Ralf S. Engelschall <rse@engelschall.com>
- ## Originally written for public domain by Noah Friedman <friedman@prep.ai.mit.edu>
- ## Cleaned up and enhanced for shtool
- ##
-
- errstatus=0
- for p in ${1+"$@"}; do
- # if the directory already exists...
- if [ -d "$p" ]; then
- if [ ".$opt_f" = .no ] && [ ".$opt_p" = .no ]; then
- echo "$msgprefix:Error: directory already exists: $p" 1>&2
- errstatus=1
- break
- else
- continue
- fi
- fi
- # if the directory has to be created...
- if [ ".$opt_p" = .no ]; then
- if [ ".$opt_t" = .yes ]; then
- echo "mkdir $p" 1>&2
- fi
- mkdir $p || errstatus=$?
- else
- # the smart situation
- set fnord `echo ":$p" |\
- sed -e 's/^:\//%/' \
- -e 's/^://' \
- -e 's/\// /g' \
- -e 's/^%/\//'`
- shift
- pathcomp=''
- for d in ${1+"$@"}; do
- pathcomp="$pathcomp$d"
- case "$pathcomp" in
- -* ) pathcomp="./$pathcomp" ;;
- esac
- if [ ! -d "$pathcomp" ]; then
- if [ ".$opt_t" = .yes ]; then
- echo "mkdir $pathcomp" 1>&2
- fi
- mkdir $pathcomp || errstatus=$?
- if [ ".$opt_m" != . ]; then
- if [ ".$opt_t" = .yes ]; then
- echo "chmod $opt_m $pathcomp" 1>&2
- fi
- chmod $opt_m $pathcomp || errstatus=$?
- fi
- fi
- pathcomp="$pathcomp/"
- done
- fi
- done
- exit $errstatus
- ;;
-
-fixperm )
- ##
- ## fixperm -- Fix file permissions inside a source tree
- ## Copyright (c) 1996-2000 Ralf S. Engelschall <rse@engelschall.com>
- ## Originally written for ePerl
- ##
-
- paths="$*"
-
- # check whether the test command supports the -x option
- if [ -x /bin/sh ] 2>/dev/null; then
- minusx="-x"
- else
- minusx="-r"
- fi
-
- # iterate over paths
- for p in $paths; do
- for file in `find $p -depth -print`; do
- if [ -f $file ]; then
- if [ $minusx $file ]; then
- if [ ".$opt_v" = .yes ]; then
- echo "-rwxrwxr-x $file" 2>&1
- fi
- if [ ".$opt_t" = .yes ]; then
- echo "chmod 775 $file" 2>&1
- fi
- chmod 775 $file
- else
- if [ ".$opt_v" = .yes ]; then
- echo "-rw-rw-r-- $file" 2>&1
- fi
- if [ ".$opt_t" = .yes ]; then
- echo "chmod 664 $file" 2>&1
- fi
- chmod 664 $file
- fi
- continue
- fi
- if [ -d $file ]; then
- if [ ".$opt_v" = .yes ]; then
- echo "drwxrwxr-x $file" 2>&1
- fi
- if [ ".$opt_t" = .yes ]; then
- echo "chmod 775 $file" 2>&1
- fi
- chmod 775 $file
- continue
- fi
- if [ ".$opt_v" = .yes ]; then
- echo "?????????? $file" 2>&1
- fi
- done
- done
- ;;
-
-tarball )
- ##
- ## tarball -- Roll distribution tarballs
- ## Copyright (c) 1999-2000 Ralf S. Engelschall <rse@engelschall.com>
- ## Originally written for shtool
- ##
-
- srcs="$*"
-
- # check whether the test command supports the -x option
- if [ -x /bin/sh ] 2>/dev/null; then
- minusx="-x"
- else
- minusx="-r"
- fi
-
- # find the tools
- paths="`echo $PATH |\
- sed -e 's%/*:%:%g' -e 's%/*$%%' \
- -e 's/^:/.:/' -e 's/::/:.:/g' -e 's/:$/:./' \
- -e 's/:/ /g'`"
- for spec in find:gfind,find tar:gtar,tar tardy:tardy,tarcust; do
- prg=`echo $spec | sed -e 's/:.*$//'`
- tools=`echo $spec | sed -e 's/^.*://'`
- eval "prg_${prg}=''"
- # iterate over tools
- for tool in `echo $tools | sed -e 's/,/ /g'`; do
- # iterate over paths
- for path in $paths; do
- if [ $minusx "$path/$tool" ] && [ ! -d "$path/$tool" ]; then
- eval "prg_${prg}=\"$path/$tool\""
- break
- fi
- done
- eval "val=\$prg_${prg}"
- if [ ".$val" != . ]; then
- break
- fi
- done
- done
-
- # expand source paths
- exclude=''
- for pat in `echo $opt_e | sed 's/,/ /g'`; do
- exclude="$exclude | grep -v '$pat'"
- done
- if [ ".$opt_t" = .yes ]; then
- echo "cp /dev/null $tmpfile.lst" 1>&2
- fi
- cp /dev/null $tmpfile.lst
- for src in $srcs; do
- if [ -d $src ]; then
- if [ ".$opt_t" = .yes ]; then
- echo "(cd $src && $prg_find . -type f -depth -print) | sed -e 's:^\\.\$::' -e 's:^\\./::' | cat $exclude >>$tmpfile.lst" 1>&2
- fi
- (cd $src && find . -type f -depth -print) |\
- sed -e 's:^\.$::' -e 's:^\./::' | eval cat $exclude >>$tmpfile.lst
- else
- if [ ".$opt_t" = .yes ]; then
- echo "echo $src >>$tmpfile.lst" 1>&2
- fi
- echo $src >>$tmpfile.lst
- fi
- done
- sort <$tmpfile.lst >$tmpfile.lst.n
- mv $tmpfile.lst.n $tmpfile.lst
- if [ ".$opt_v" = .yes ]; then
- cat $tmpfile.lst | sed -e 's/^/ /' 1>&2
- fi
-
- # determine tarball file and directory name
- if [ ".$opt_o" != . ]; then
- tarfile="$opt_o"
- if [ ".$opt_d" != . ]; then
- tarname="$opt_d"
- else
- tarname=`echo $tarfile | sed -e 's/\.tar.*$//' -e 's;.*/\([^/]*\)$;\1;'`
- fi
- else
- if [ ".$opt_d" != . ]; then
- tarname="$opt_d"
- elif [ -d "$from" ]; then
- tarname=`echo $from | sed -e 's;.*/\([^/]*\)$;\1;'`
- else
- tarname="out"
- fi
- tarfile="$tarname.tar"
- fi
-
- # roll the tarball
- compress=''
- if [ ".$opt_c" != . ]; then
- compress="| $opt_c"
- fi
- if [ ".$prg_tardy" != . ]; then
- # the elegant hackers way
- tardy_opt="--prefix=$tarname"
- tardy_opt="$tardy_opt --user_number=0 --group_number=0" # security!
- if [ ".$opt_u" != . ]; then
- tardy_opt="$tardy_opt --user_name=$opt_u"
- fi
- if [ ".$opt_g" != . ]; then
- tardy_opt="$tardy_opt --group_name=$opt_g"
- fi
- if [ ".$opt_t" = .yes ]; then
- echo "cat $tmpfile.lst | xargs $prg_tar cf - | $prg_tardy $tardy_opt | cat $compress >$tmpfile.out" 1>&2
- fi
- cat $tmpfile.lst |\
- xargs $prg_tar cf - |\
- $prg_tardy $tardy_opt |\
- eval cat $compress >$tmpfile.out
- if [ ".$opt_t" = .yes ]; then
- echo "cp $tmpfile.out $tarfile" 1>&2
- fi
- cp $tmpfile.out $tarfile
- else
- # the portable standard way
- if [ ".$opt_t" = .yes ]; then
- echo "mkdir $tmpdir/$tarname" 1>&2
- fi
- mkdir $tmpdir/$tarname || exit 1
- if [ ".$opt_t" = .yes ]; then
- echo "cat $tmpfile.lst | xargs $prg_tar cf - | (cd $tmpdir/$tarname && $prg_tar xf -)" 1>&2
- fi
- cat $tmpfile.lst |\
- xargs $prg_tar cf - |\
- (cd $tmpdir/$tarname && $prg_tar xf -)
- if [ ".$opt_u" != . ]; then
- if [ ".$opt_t" = .yes ]; then
- echo "chown -R $opt_u $tmpdir/$tarname >/dev/null 2>&1" 2>&1
- fi
- chown -R $opt_u $tmpdir/$tarname >/dev/null 2>&1 ||\
- echo "$msgprefix:Warning: cannot set user name \`$opt_u' (would require root priviledges)"
- fi
- if [ ".$opt_g" != . ]; then
- if [ ".$opt_t" = .yes ]; then
- echo "chgrp -R $opt_g $tmpdir/$tarname >/dev/null 2>&1" 2>&1
- fi
- chgrp -R $opt_g $tmpdir/$tarname >/dev/null 2>&1 ||\
- echo "$msgprefix:Warning: cannot set group name \`$opt_g' (would require root priviledges)"
- fi
- if [ ".$opt_t" = .yes ]; then
- echo "(cd $tmpdir && $prg_find $tarname -type f -depth -print | sort | xargs $prg_tar cf -) | cat $compress >$tmpfile.out" 1>&2
- fi
- (cd $tmpdir && $prg_find $tarname -type f -depth -print | sort | xargs $prg_tar cf -) |\
- eval cat $compress >$tmpfile.out
- if [ ".$opt_t" = .yes ]; then
- echo "cp $tmpfile.out $tarfile" 1>&2
- fi
- cp $tmpfile.out $tarfile
- if [ ".$opt_t" = .yes ]; then
- echo "rm -rf $tmpdir/$tarname" 1>&2
- fi
- rm -rf $tmpdir/$tarname
- fi
-
- # cleanup
- if [ ".$opt_t" = .yes ]; then
- echo "rm -f $tmpfile.lst $tmpfile.out" 1>&2
- fi
- rm -f $tmpfile.lst $tmpfile.out
- ;;
-
-scpp )
- ##
- ## scpp -- Sharing C Pre-Processor
- ## Copyright (c) 1999-2000 Ralf S. Engelschall <rse@engelschall.com>
- ## Originally written for GNU Pth
- ##
-
- srcs="$*"
- output="${opt_o}.n"
-
- # find a reasonable Awk
- awk=''
- paths=`echo $PATH |\
- sed -e 's%/*:%:%g' -e 's%/$%%' \
- -e 's/^:/.:/' -e 's/::/:.:/g' -e 's/:$/:./' \
- -e 's/:/ /g'`
- for name in gawk nawk awk; do
- for path in $paths; do
- if [ -r "$path/$name" ]; then
- awk="$path/$name"
- break
- fi
- done
- if [ ".$awk" != . ]; then
- break
- fi
- done
- if [ ".$awk" = . ]; then
- echo "$msgprefix:Error: cannot find a reasonable Awk" 1>&2
- exit 1
- fi
-
- # parse source file(s)
- if [ ".$opt_v" = .yes ]; then
- echo "Parsing:" | $awk '{ printf("%s", $0); }' 1>&2
- fi
- for src in $srcs; do
- if [ ".$opt_v" = .yes ]; then
- echo $src | $awk '{ printf(" %s", $0); }' 1>&2
- fi
- if [ ".$opt_f" = . ]; then
- inputcmd="cat $src"
- else
- inputcmd="sed $opt_f $src"
- fi
- $inputcmd |\
- $awk '
- BEGIN {
- ln = 0;
- fln = 0;
- level = 0;
- mode = "";
- store = "";
- }
- {
- ln++;
- }
- /^#if.*/ {
- level++;
- }
- /^#if [a-zA-Z_][a-zA-Z0-9_]* *$/ {
- if ($2 == define) {
- mode = "D";
- printf("D:#line %d \"%s\"\n", ln, src);
- next;
- }
- }
- /^#endif.*/ {
- level--;
- if (mode == "D" && level == 0) {
- mode = "";
- next;
- }
- }
- /^[a-zA-Z_][a-zA-Z0-9_].*;.*/ {
- if ($1 == class) {
- printf("V:#line %d \"%s\"\n", ln, src);
- printf("V:%s\n", $0);
- printf("J:%s\n", $0);
- next;
- }
- }
- /^[a-zA-Z_][a-zA-Z0-9_].*=.*/ {
- if ($1 == class) {
- printf("V:#line %d \"%s\"\n", ln, src);
- printf("V:%s\n", $0);
- printf("J:%s\n", $0);
- next;
- }
- }
- /^[a-zA-Z_][a-zA-Z0-9_]*/ {
- if ($1 == class) {
- fln = ln;
- store = $0;
- mode = "F";
- next;
- }
- }
- /^\{ *$/ {
- if (mode == "F") {
- printf("F:#line %d \"%s\"\n", fln, src);
- printf("F:%s;\n", store);
- printf("I:%s;\n", store);
- store = "";
- mode = "";
- next;
- }
- }
- {
- if (mode == "D")
- printf("D:%s\n", $0);
- else if (mode == "F")
- store = store " " $0;
- }
- ' "src=$src" "define=$opt_D" "class=$opt_C" >>$tmpfile
- done
- if [ ".$opt_v" = .yes ]; then
- echo "" 1>&2
- fi
-
- # start generating output header
- echo "/* $opt_o -- autogenerated from $opt_t, DO NOT EDIT! */" >$output
- echo "#line 1 \"$opt_t\"" >>$output
- sed <$opt_t -e "1,/^${opt_M} *\$/p" -e 'd' |\
- sed -e "/^${opt_M} *\$/d" >>$output
-
- # merge in the define blocks
- grep '^D:' $tmpfile | sed -e 's/^D://' >>$output
-
- # generate standard prolog
- echo "#line 1 \"_ON_THE_FLY_\"" >>$output
- echo "" >>$output
- echo "/* make sure the scpp source extensions are skipped */" >>$output
- echo "#define $opt_D 0" >>$output
- echo "#define $opt_C /**/" >>$output
-
- # generate namespace hiding for variables
- echo "" >>$output
- echo "/* move intern variables to hidden namespace */" >>$output
- grep '^J:' $tmpfile | sed >>$output \
- -e 's/^J://' \
- -e 's/ */ /g' \
- -e 's/^[^=;]*[ *]\([a-zA-Z0-9_]*\)\[\];.*$/#define \1 __\1/' \
- -e 's/^[^=;]*[ *]\([a-zA-Z0-9_]*\)\[\] =.*$/#define \1 __\1/' \
- -e 's/^[^=;]*[ *]\([a-zA-Z0-9_]*\);.*$/#define \1 __\1/' \
- -e 's/^[^=;]*[ *]\([a-zA-Z0-9_]*\) =.*$/#define \1 __\1/'
-
- # generate namespace hiding for functions
- echo "" >>$output
- echo "/* move intern functions to hidden namespace */" >>$output
- grep '^I:' $tmpfile | sed >>$output \
- -e 's/^I://' \
- -e 's/\([ (]\) */\1/g' \
- -e 's/ *\([),]\)/\1/g' \
- -e 's/^[^(]*[ *]\([a-zA-Z0-9_]*\)(.*$/#define \1 __\1/'
-
- # generate prototypes for variables
- echo "" >>$output
- echo "/* prototypes for intern variables */" >>$output
- grep '^V:' $tmpfile | sed >>$output \
- -e 's/^V://' \
- -e 's/ */ /g' \
- -e 's/^\([^=;]*[ *][a-zA-Z0-9_]*\[\]\);.*$/\1;/' \
- -e 's/^\([^=;]*[ *][a-zA-Z0-9_]*\[\]\) =.*$/\1;/' \
- -e 's/^\([^=;]*[ *][a-zA-Z0-9_]*\);.*$/\1;/' \
- -e 's/^\([^=;]*[ *][a-zA-Z0-9_]*\) =.*$/\1;/' \
- -e 's/ ;/;/g' \
- -e "s/^$opt_C /extern /"
-
- # generate prototypes for functions
- echo "" >>$output
- echo "/* prototypes for intern functions */" >>$output
- grep '^F:' $tmpfile | sed >>$output \
- -e 's/^F://' \
- -e 's/\([ (]\) */\1/g' \
- -e 's/ *\([),]\)/\1/g' \
- -e 's/\([* ]\)[a-zA-Z0-9_]*,/\1,/g' \
- -e 's/\([* ]\)[a-zA-Z0-9_]*);/\1);/g' \
- -e 's/(\*[a-zA-Z0-9_]*)(/(*)(/g' \
- -e 's/\([ (]\) */\1/g' \
- -e 's/ *\([),]\)/\1/g' \
- -e "s/^$opt_C /extern /"
-
- # finish generating output header
- n=`(echo ''; sed <$opt_t -e "1,/^${opt_M} *\$/p" -e 'd') |\
- wc -l | sed -e 's;^ *\([0-9]*\) *$;\1;'`
- echo "#line $n \"$opt_t\"" >>$output
- sed <$opt_t -e "/^${opt_M} *\$/,\$p" -e 'd' |\
- sed -e "/^${opt_M} *\$/d" >>$output
-
- # create final output file
- if [ -f $opt_o ]; then
- if [ ".$opt_p" = .yes ]; then
- grep -v '^#line' $opt_o >$tmpfile.o
- grep -v '^#line' $output >$tmpfile.n
- out_old="$tmpfile.o"
- out_new="$tmpfile.n"
- else
- out_old="$opt_o"
- out_new="$output"
- fi
- if cmp -s $out_old $out_new; then
- :
- else
- cp $output $opt_o
- fi
- else
- cp $output $opt_o
- fi
- rm -f $output
- rm -f $tmpfile $tmpfile.* >/dev/null 2>&1
- ;;
-
-version )
- ##
- ## version -- Maintain a version information file
- ## Copyright (c) 1994-2000 Ralf S. Engelschall <rse@engelschall.com>
- ## Originally written for ePerl, rewritten from scratch for shtool
- ##
-
- file="$1"
-
- # determine prefix and name
- name="$opt_n"
- prefix="$opt_p"
-
- # determine current version
- triple="$opt_s"
- if [ ".$triple" != . ]; then
- # use given triple
- if [ ".`echo $triple | grep '[0-9]*.[0-9]*[sabp.][0-9]*'`" = . ]; then
- echo "$msgprefix:Error: invalid argument to option \`-s': \`$opt_s'" 1>&2
- exit 1
- fi
- eval `echo $triple |\
- sed -e 's%\([0-9]*\)\.\([0-9]*\)\([sabp.]\)\([0-9]*\).*%\
- ver="\1";rev="\2";typ="\3";lev="\4"%'`
- tim=calc
- elif [ -r $file ]; then
- # determine triple from given file
- eval `grep 'Version [0-9]*.[0-9]*[sabp.][0-9]* ([0-9]*-[a-zA-Z]*-[0-9]*)' $file |\
- head -1 | sed -e 's%.*Version \([0-9]*\)\.\([0-9]*\)\([sabp.]\)\([0-9]*\) (\([0-9]*-[a-zA-Z]*-[0-9]*\)).*%\
- ver="\1";rev="\2";typ="\3";lev="\4";tim="\5"%'`
- else
- # intialise to first version
- ver=0
- rev=1
- typ=.
- lev=0
- tim=calc
- fi
-
- # determine new version in batch
- if [ ".$opt_i" != . ]; then
- case $opt_i in
- v ) ver=`expr $ver + 1`
- rev=0
- lev=0
- ;;
- r ) rev=`expr $rev + 1`
- lev=0
- ;;
- l ) lev=`expr $lev + 1`
- ;;
- * ) echo "$msgprefix:Error: invalid argument to option \`-i': \`$opt_i'" 1>&2
- exit 1
- ;;
- esac
- tim=calc
- fi
-
- # determine new version interactively
- if [ ".$opt_e" = .yes ]; then
- echo "old version: ${ver}.${rev}${typ}${lev}"
- while [ 1 ]; do
- echo dummy | awk '{ printf("new version: "); }'
- read triple
- case $triple in
- [0-9]*.[0-9]*[sabp.][0-9]* )
- ;;
- * ) echo "$msgprefix:Error: invalid version string entered: \`$triple'" 1>&2
- continue
- ;;
- esac
- break
- done
- eval `echo $triple |\
- sed -e 's%^\([0-9]*\)\.\([0-9]*\)\([sabp.]\)\([0-9]*\)$%\
- ver="\1";rev="\2";typ="\3";lev="\4"%'`
- tim=calc
- fi
-
- # determine hexadecimal and libtool value of version
- case $typ in
- a ) typnum=0; levnum=$lev ;;
- b ) typnum=1; levnum=$lev ;;
- p | . ) typnum=2; levnum=$lev ;;
- s ) typnum=15; levnum=255 ;; # snapshots are special
- esac
- hex=`echo "$ver:$rev:$typnum:$levnum" |\
- awk -F: '{ printf("0x%X%02X%1X%02X", $1, $2, $3, $4); }'`
- ltv=`echo "$ver:$rev:$typnum:$levnum" |\
- awk -F: '{ printf("%d:%d", $1*10 + $2, $3*10 + $4); }'`
-
- # determine date
- if [ ".$tim" = .calc ]; then
- day=`date '+%d'`
- month=`date '+%m'`
- year=`date '+%Y' 2>/dev/null`
- if [ ".$time_year" = . ]; then
- year=`date '+%y'`
- case $year in
- [5-9][0-9]) year="19$year" ;;
- [0-4][0-9]) year="20$year" ;;
- esac
- fi
- case $month in
- 1|01) month='Jan' ;;
- 2|02) month='Feb' ;;
- 3|03) month='Mar' ;;
- 4|04) month='Apr' ;;
- 5|05) month='May' ;;
- 6|06) month='Jun' ;;
- 7|07) month='Jul' ;;
- 8|08) month='Aug' ;;
- 9|09) month='Sep' ;;
- 10) month='Oct' ;;
- 11) month='Nov' ;;
- 12) month='Dec' ;;
- esac
- tim="${day}-${month}-${year}"
- fi
-
- # perform result actions
- mode=show
- if [ ".$opt_i" != . ]; then
- mode=edit
- elif [ ".$opt_e" = .yes ]; then
- mode=edit
- elif [ ".$opt_s" != . ]; then
- mode=edit
- fi
- if [ ".$mode" = .show ]; then
- # just display the current version
- case $opt_d in
- short )
- echo "${ver}.${rev}${typ}${lev}"
- ;;
- long )
- echo "${ver}.${rev}${typ}${lev} ($tim)"
- ;;
- libtool )
- echo "${ltv}"
- ;;
- hex )
- echo "${hex}"
- ;;
- * ) echo "$msgprefix:Error: invalid argument to option \`-d': \`$opt_d'" 1>&2
- exit 1
- ;;
- esac
- else
- # update the version file
-
- # pre-generate various strings
- triple="${ver}.${rev}${typ}${lev}"
- vHex="$hex"
- vShort="${triple}"
- vLong="${triple} (${tim})"
- vTeX="This is ${name}, Version ${triple} (${tim})"
- vGNU="${name} ${triple} (${tim})"
- vWeb="${name}/${triple}"
- vSCCS="@(#)${name} ${triple} (${tim})"
- vRCS="\$Id${name} ${triple} (${tim}) \$"
-
- # determine string out of filename
- # (do NOT try to optimize this in any way because of portability)
- filestr=`echo $file |\
- tr 'abcdefghijklmnopqrstuvwxyz./%+' \
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZ____' | sed -e 's/-/_/g'`
-
- # generate uppercase prefix
- prefixupper=`echo $prefix |\
- tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
-
- # create the version file according the the selected language
- echo "new version: ${vLong}"
-
- cp /dev/null $file
- case $opt_l in
- txt )
- echo >>$file ""
- echo >>$file " ${file} -- Version Information for ${name} (syntax: Text)"
- echo >>$file " [automatically generated and maintained by GNU shtool]"
- echo >>$file ""
- echo >>$file " $vTeX"
- echo >>$file ""
- ;;
- c )
- echo >>$file "/*"
- echo >>$file "** ${file} -- Version Information for ${name} (syntax: C/C++)"
- echo >>$file "** [automatically generated and maintained by GNU shtool]"
- echo >>$file "*/"
- echo >>$file ""
- echo >>$file "#ifdef _${filestr}_AS_HEADER_"
- echo >>$file ""
- echo >>$file "#ifndef _${filestr}_"
- echo >>$file "#define _${filestr}_"
- echo >>$file ""
- echo >>$file "#define ${prefixupper}VERSION ${vHex}"
- echo >>$file ""
- echo >>$file "typedef struct {"
- echo >>$file " const int v_hex;"
- echo >>$file " const char *v_short;"
- echo >>$file " const char *v_long;"
- echo >>$file " const char *v_tex;"
- echo >>$file " const char *v_gnu;"
- echo >>$file " const char *v_web;"
- echo >>$file " const char *v_sccs;"
- echo >>$file " const char *v_rcs;"
- echo >>$file "} ${prefix}version_t;"
- echo >>$file ""
- echo >>$file "extern ${prefix}version_t ${prefix}version;"
- echo >>$file ""
- echo >>$file "#endif /* _${filestr}_ */"
- echo >>$file ""
- echo >>$file "#else /* _${filestr}_AS_HEADER_ */"
- echo >>$file ""
- echo >>$file "#define _${filestr}_AS_HEADER_"
- echo >>$file "#include \"${file}\""
- echo >>$file "#undef _${filestr}_AS_HEADER_"
- echo >>$file ""
- echo >>$file "${prefix}version_t ${prefix}version = {"
- echo >>$file " ${vHex},"
- echo >>$file " \"${vShort}\","
- echo >>$file " \"${vLong}\","
- echo >>$file " \"${vTeX}\","
- echo >>$file " \"${vGNU}\","
- echo >>$file " \"${vWeb}\","
- echo >>$file " \"${vSCCS}\","
- echo >>$file " \"${vRCS}\""
- echo >>$file "};"
- echo >>$file ""
- echo >>$file "#endif /* _${filestr}_AS_HEADER_ */"
- echo >>$file ""
- ;;
- perl )
- echo >>$file "##"
- echo >>$file "## ${file} -- Version Information for ${name} (syntax: Perl)"
- echo >>$file "## [automatically generated and maintained by GNU shtool]"
- echo >>$file "##"
- echo >>$file ""
- echo >>$file "my \$${prefix}version = {"
- echo >>$file " 'v_hex' => ${vHex},"
- echo >>$file " 'v_short' => \"${vShort}\","
- echo >>$file " 'v_long' => \"${vLong}\","
- echo >>$file " 'v_tex' => \"${vTeX}\","
- echo >>$file " 'v_gnu' => \"${vGNU}\","
- echo >>$file " 'v_web' => \"${vWeb}\","
- echo >>$file " 'v_sccs' => \"${vSCCS}\","
- echo >>$file " 'v_rcs' => \"\\${vRCS}/\""
- echo >>$file "};"
- echo >>$file ""
- echo >>$file "1;"
- echo >>$file ""
- ;;
- * ) echo "$msgprefix:Error: invalid argument to option \`-l': \`$opt_l'" 1>&2
- exit 1
- ;;
- esac
- fi
- ;;
-
-esac
-
-exit 0
-
-##EOF##
+++ /dev/null
-#include <cothreads.h>
-
-#define METHOD COTHREADS_CONFIG_GTHREAD_INITIALIZER
-
-#define NGTHREADS 2
-#define NCOTHREADS 5
-
-//#define USE_GTHREADS
-
-void co_thread (int argc, void **argv)
-{
- int pthreadnum = *(int*)argv[0];
- int cothreadnum = *(int*)argv[1];
- cothread *main = argv[2];
- cothread *self = argv[3];
-
- printf ("%d.%d: sleeping 1s...\n", pthreadnum, cothreadnum);
- sleep (1);
- printf ("%d.%d: returning to cothread 0\n", pthreadnum, cothreadnum);
-
- cothread_switch (self, main);
-}
-
-void *pthread (void* _pthreadnum)
-{
- int pthreadnum = *(int*) _pthreadnum;
- int cothreadnum = 0;
- cothread *main, *new;
- void *argv[4];
-
- main = cothread_create (NULL, 0, NULL);
-
- while (cothreadnum++ < NCOTHREADS) {
- printf ("%d: spawning a new cothread\n", pthreadnum);
-
- argv[0] = &pthreadnum;
- argv[1] = &cothreadnum;
- argv[2] = main;
- argv[3] = cothread_create (co_thread, 4, argv);
- new = argv[3];
-
- printf ("%d: switching to cothread %d...\n", pthreadnum, cothreadnum);
- cothread_switch (main, new);
- }
- return NULL;
-}
-
-int main (int argc, char *argv[])
-{
- GThread *thread[NGTHREADS];
- int pthreadnum[4], i;
- cothreads_config config = METHOD;
-
- g_thread_init(NULL);
-
- cothreads_init(&config);
-
-#ifdef USE_GTHREADS
- cothread_create (NULL, 0, NULL); /* just to see where the stack is */
-#endif
-
-#ifdef USE_GTHREADS
- printf ("0: creating the gthreads\n");
- for (i=0; i<NGTHREADS; i++) {
- pthreadnum[i] = i+1;
- thread[i] = g_thread_create (pthread, &pthreadnum[i], TRUE, NULL);
- }
-
- printf ("0: joining the gthreads\n");
- for (i=0; i<NGTHREADS; i++) {
- g_thread_join (thread[i]);
- }
-#else
- printf ("0: calling the pthread function directly\n");
- pthreadnum[0] = 1;
- pthread (&pthreadnum[0]);
-#endif
-
- printf ("exiting\n");
-
- exit (0);
-}
-
+++ /dev/null
-#include "pth_p.h"
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "linuxthreads.h"
-
-pth_mctx_t main_context;
-int threadnum = 0;
-
-void cothread (void)
-{
- printf ("1.1: current stack frame: %p\n", CURRENT_STACK_FRAME);
- printf ("1.1: sleeping 2s in thread %d...\n", threadnum);
- sleep (2);
- printf ("1.1: current stack frame: %p\n", CURRENT_STACK_FRAME);
- printf ("1.1: returning to cothread 0\n");
- pth_mctx_restore (&main_context);
-}
-
-void *pthread (void* unused)
-{
- pth_mctx_t ctx;
- char *skaddr;
-
- printf ("1: saving the main context\n");
- printf ("1: current stack frame: %p\n", CURRENT_STACK_FRAME);
- pth_mctx_save (&main_context);
-
- while (1) {
- skaddr = alloca (64 * 1024);
-
- printf ("1: current stack frame: %p\n", CURRENT_STACK_FRAME);
- printf ("1: spawning a new cothread\n");
- pth_mctx_set (&ctx, cothread, skaddr, skaddr + 64 * 1024);
- printf ("1: new thread's stack frame will be in the heap at %p\n", skaddr);
-
- printf ("1: current stack frame: %p\n", CURRENT_STACK_FRAME);
- printf ("1: switching to cothread %d...\n", ++threadnum);
-
- printf ("1: current stack frame: %p\n", CURRENT_STACK_FRAME);
- pth_mctx_switch (&main_context, &ctx);
-
- printf ("1: current stack frame: %p\n", CURRENT_STACK_FRAME);
- printf ("1: back now, looping\n");
- }
-}
-
-
-int main (int argc, char *argv[])
-{
- pthread_t tid;
-
- printf ("0: current stack frame: %p\n", CURRENT_STACK_FRAME);
- printf ("0: creating the pthread\n");
-// pthread_create (&tid, NULL, pthread, NULL);
-// printf ("0: %d\n", pthread_self());
- pthread(NULL);
-// printf ("joining the pthread\n");
-// pthread_join (tid, NULL);
-
- printf ("0: current stack frame: %p\n", CURRENT_STACK_FRAME);
- printf ("0: take five...\n");
- sleep(5);
-
- printf ("0 current stack frame: %p\n", CURRENT_STACK_FRAME);
- printf ("exiting\n");
-
- exit (0);
-}
-
+++ /dev/null
-#include <stdio.h>
-#include "linuxthreads.h"
-#include "pth_p.h"
-
-pth_mctx_t main_context;
-int threadnum = 0;
-
-void cothread ()
-{
- printf ("1.%d: current stack frame: %p\n", threadnum, CURRENT_STACK_FRAME);
- printf ("1.%d: sleeping 2s...\n", threadnum);
- sleep (2);
- printf ("1.%d: returning to cothread 1.0\n");
- pth_mctx_restore (&main_context);
-}
-
-void *pthread (void *unused)
-{
- char *sp = CURRENT_STACK_FRAME;
- char *cothread_stack;
- pth_mctx_t ctx;
- _pthread_descr descr;
-
- descr = __linuxthreads_self();
- printf ("sp: %p\n", sp);
- printf ("STACK_SIZE: %p\n", STACK_SIZE);
- printf ("sp | STACK_SIZE: 0x%x\n", (int) sp | STACK_SIZE );
- printf ("(sp | (STACK_SIZE-1))+1 - 1K: 0x%x\n", ((((int)sp | (STACK_SIZE-1))+1) - 1024));
- printf ("*(sp | (STACK_SIZE-1))+1 - 1K: %p\n", *(int*)((((long int)sp | (STACK_SIZE-1))+1) - 1024));
-
- while (threadnum < 10) {
- if (posix_memalign (&cothread_stack, STACK_SIZE, STACK_SIZE)) {
- printf ("could not malloc a chunk of aligned memory\n");
- exit (-1);
- }
-
- printf ("1: setting *%p = %p\n", cothread_stack + STACK_SIZE - 1024, descr);
- memcpy(cothread_stack + STACK_SIZE - 1024, descr, 1024);
-
- pth_mctx_save (&main_context);
- printf ("1: spawning new thread, bottom = %p\n", cothread_stack);
- pth_mctx_set (&ctx, cothread, cothread_stack, cothread_stack + STACK_SIZE - 1024);
- printf ("1: switching to cothread %d...\n", ++threadnum);
- pth_mctx_switch (&main_context, &ctx);
- }
-
- printf ("1: back, returning...\n");
-
- return NULL;
-}
-
-int main (int argc, char *argv[])
-{
- pthread_t tid;
-
- pthread_create (&tid, NULL, pthread, NULL);
- pthread_join (tid, NULL);
-
- __linuxthreads_self();
-
- exit (0);
-}
+++ /dev/null
-#include "pth_p.h"
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-
-pth_mctx_t main_context;
-
-void thread_1 (void)
-{
- printf ("sleeping 5s in thread 1...\n");
- sleep (5);
- printf ("returning to thread 0\n");
- pth_mctx_restore (&main_context);
-}
-
-int main (int argc, char *argv[])
-{
- pth_mctx_t ctx;
- char *skaddr;
-
- pth_mctx_save (&main_context);
-
- skaddr = malloc (64 * 1024);
-
- pth_mctx_set (&ctx, thread_1, skaddr, skaddr + 64 * 1024);
-
- printf ("switching to thread 1...");
-
- pth_mctx_switch (&main_context, &ctx);
-
- printf ("back now, exiting.\n");
-
- exit (0);
-}
-
+++ /dev/null
-#include <stdio.h>
-#include "linuxthreads.h"
-#include <sys/resource.h>
-#include <unistd.h>
-
-/* this function is only really necessary to get the main thread's
- * pthread_descr, as the other threads store the pthread_descr (actually the
- * first member of struct _pthread_descr_struct, which points to itself for the
- * default (non-indirected) case) at the top of the stack. */
-static _pthread_descr linuxthreads_self()
-{
- pthread_mutexattr_t mutexattr;
- pthread_mutex_t mutex;
- _pthread_descr self;
-
- pthread_mutexattr_init (&mutexattr);
- pthread_mutexattr_setkind_np (&mutexattr, PTHREAD_MUTEX_ERRORCHECK_NP);
- pthread_mutex_init (&mutex, &mutexattr);
-
- pthread_mutex_lock (&mutex);
- self = mutex.__m_owner;
- pthread_mutex_unlock (&mutex);
-
- printf ("pthread_self: %d\n", pthread_self());
- printf ("descr: %p\n", self);
- printf ("*descr: %p\n", *(int*)self);
-
- return self;
-}
-
-void *pthread (void *unused)
-{
- char *sp = CURRENT_STACK_FRAME;
-
- linuxthreads_self();
- printf ("sp: %p\n", sp);
- printf ("sp | 0x020000: 0x%x\n", (int) sp | 0x020000 );
- printf ("(sp | (0x020000-1))+1 - 1K: 0x%x\n", ((((int)sp | (STACK_SIZE-1))+1) - 1024));
- printf ("*(sp | (0x020000-1))+1 - 1K: %p\n", *(int*)((((long int)sp | (STACK_SIZE-1))+1) - 1024));
- printf ("(sp &~ (0x020000-1))+1: 0x%x\n", (((int)sp &~ (STACK_SIZE-1))+1));
- return NULL;
-}
-
-int main (int argc, char *argv[])
-{
- pthread_t tid;
- int i;
- struct rlimit limit;
-
- for (i=0; i<5; i++) {
- pthread_create (&tid, NULL, pthread, NULL);
- sleep(1);
- }
-
- linuxthreads_self();
-
- getrlimit (RLIMIT_STACK, &limit);
- printf ("\nstack size: %d\nmax stack sizeL %d\n", limit.rlim_cur, limit.rlim_max);
-
- exit (0);
-}