mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-18 12:15:19 +00:00
removed my cothreads dir in favor of the cothreads/ module
Original commit message from CVS: removed my cothreads dir in favor of the cothreads/ module
This commit is contained in:
parent
53b6bb6242
commit
7ed9201e06
34 changed files with 1 additions and 6683 deletions
2
common
2
common
|
@ -1 +1 @@
|
||||||
Subproject commit d81417a103945ab1c393e74557983b1163e9e353
|
Subproject commit 47d51c3f04e416caa4c43c72a5458df99cf09c3a
|
|
@ -1,25 +0,0 @@
|
||||||
____ _ _
|
|
||||||
| _ \| |_| |__
|
|
||||||
| |_) | __| '_ \ ``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
|
|
|
@ -1,481 +0,0 @@
|
||||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
|
||||||
Version 2, June 1991
|
|
||||||
|
|
||||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
|
||||||
675 Mass Ave, Cambridge, MA 02139, USA
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
[This is the first released version of the library GPL. It is
|
|
||||||
numbered 2 because it goes with version 2 of the ordinary GPL.]
|
|
||||||
|
|
||||||
Preamble
|
|
||||||
|
|
||||||
The licenses for most software are designed to take away your
|
|
||||||
freedom to share and change it. By contrast, the GNU General Public
|
|
||||||
Licenses are intended to guarantee your freedom to share and change
|
|
||||||
free software--to make sure the software is free for all its users.
|
|
||||||
|
|
||||||
This license, the Library General Public License, applies to some
|
|
||||||
specially designated Free Software Foundation software, and to any
|
|
||||||
other libraries whose authors decide to use it. You can use it for
|
|
||||||
your libraries, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
|
||||||
have the freedom to distribute copies of free software (and charge for
|
|
||||||
this service if you wish), that you receive source code or can get it
|
|
||||||
if you want it, that you can change the software or use pieces of it
|
|
||||||
in new free programs; and that you know you can do these things.
|
|
||||||
|
|
||||||
To protect your rights, we need to make restrictions that forbid
|
|
||||||
anyone to deny you these rights or to ask you to surrender the rights.
|
|
||||||
These restrictions translate to certain responsibilities for you if
|
|
||||||
you distribute copies of the library, or if you modify it.
|
|
||||||
|
|
||||||
For example, if you distribute copies of the library, whether gratis
|
|
||||||
or for a fee, you must give the recipients all the rights that we gave
|
|
||||||
you. You must make sure that they, too, receive or can get the source
|
|
||||||
code. If you link a program with the library, you must provide
|
|
||||||
complete object files to the recipients so that they can relink them
|
|
||||||
with the library, after making changes to the library and recompiling
|
|
||||||
it. And you must show them these terms so they know their rights.
|
|
||||||
|
|
||||||
Our method of protecting your rights has two steps: (1) copyright
|
|
||||||
the library, and (2) offer you this license which gives you legal
|
|
||||||
permission to copy, distribute and/or modify the library.
|
|
||||||
|
|
||||||
Also, for each distributor's protection, we want to make certain
|
|
||||||
that everyone understands that there is no warranty for this free
|
|
||||||
library. If the library is modified by someone else and passed on, we
|
|
||||||
want its recipients to know that what they have is not the original
|
|
||||||
version, so that any problems introduced by others will not reflect on
|
|
||||||
the original authors' reputations.
|
|
||||||
|
|
||||||
Finally, any free program is threatened constantly by software
|
|
||||||
patents. We wish to avoid the danger that companies distributing free
|
|
||||||
software will individually obtain patent licenses, thus in effect
|
|
||||||
transforming the program into proprietary software. To prevent this,
|
|
||||||
we have made it clear that any patent must be licensed for everyone's
|
|
||||||
free use or not licensed at all.
|
|
||||||
|
|
||||||
Most GNU software, including some libraries, is covered by the ordinary
|
|
||||||
GNU General Public License, which was designed for utility programs. This
|
|
||||||
license, the GNU Library General Public License, applies to certain
|
|
||||||
designated libraries. This license is quite different from the ordinary
|
|
||||||
one; be sure to read it in full, and don't assume that anything in it is
|
|
||||||
the same as in the ordinary license.
|
|
||||||
|
|
||||||
The reason we have a separate public license for some libraries is that
|
|
||||||
they blur the distinction we usually make between modifying or adding to a
|
|
||||||
program and simply using it. Linking a program with a library, without
|
|
||||||
changing the library, is in some sense simply using the library, and is
|
|
||||||
analogous to running a utility program or application program. However, in
|
|
||||||
a textual and legal sense, the linked executable is a combined work, a
|
|
||||||
derivative of the original library, and the ordinary General Public License
|
|
||||||
treats it as such.
|
|
||||||
|
|
||||||
Because of this blurred distinction, using the ordinary General
|
|
||||||
Public License for libraries did not effectively promote software
|
|
||||||
sharing, because most developers did not use the libraries. We
|
|
||||||
concluded that weaker conditions might promote sharing better.
|
|
||||||
|
|
||||||
However, unrestricted linking of non-free programs would deprive the
|
|
||||||
users of those programs of all benefit from the free status of the
|
|
||||||
libraries themselves. This Library General Public License is intended to
|
|
||||||
permit developers of non-free programs to use free libraries, while
|
|
||||||
preserving your freedom as a user of such programs to change the free
|
|
||||||
libraries that are incorporated in them. (We have not seen how to achieve
|
|
||||||
this as regards changes in header files, but we have achieved it as regards
|
|
||||||
changes in the actual functions of the Library.) The hope is that this
|
|
||||||
will lead to faster development of free libraries.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow. Pay close attention to the difference between a
|
|
||||||
"work based on the library" and a "work that uses the library". The
|
|
||||||
former contains code derived from the library, while the latter only
|
|
||||||
works together with the library.
|
|
||||||
|
|
||||||
Note that it is possible for a library to be covered by the ordinary
|
|
||||||
General Public License rather than by this special one.
|
|
||||||
|
|
||||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
||||||
|
|
||||||
0. This License Agreement applies to any software library which
|
|
||||||
contains a notice placed by the copyright holder or other authorized
|
|
||||||
party saying it may be distributed under the terms of this Library
|
|
||||||
General Public License (also called "this License"). Each licensee is
|
|
||||||
addressed as "you".
|
|
||||||
|
|
||||||
A "library" means a collection of software functions and/or data
|
|
||||||
prepared so as to be conveniently linked with application programs
|
|
||||||
(which use some of those functions and data) to form executables.
|
|
||||||
|
|
||||||
The "Library", below, refers to any such software library or work
|
|
||||||
which has been distributed under these terms. A "work based on the
|
|
||||||
Library" means either the Library or any derivative work under
|
|
||||||
copyright law: that is to say, a work containing the Library or a
|
|
||||||
portion of it, either verbatim or with modifications and/or translated
|
|
||||||
straightforwardly into another language. (Hereinafter, translation is
|
|
||||||
included without limitation in the term "modification".)
|
|
||||||
|
|
||||||
"Source code" for a work means the preferred form of the work for
|
|
||||||
making modifications to it. For a library, complete source code means
|
|
||||||
all the source code for all modules it contains, plus any associated
|
|
||||||
interface definition files, plus the scripts used to control compilation
|
|
||||||
and installation of the library.
|
|
||||||
|
|
||||||
Activities other than copying, distribution and modification are not
|
|
||||||
covered by this License; they are outside its scope. The act of
|
|
||||||
running a program using the Library is not restricted, and output from
|
|
||||||
such a program is covered only if its contents constitute a work based
|
|
||||||
on the Library (independent of the use of the Library in a tool for
|
|
||||||
writing it). Whether that is true depends on what the Library does
|
|
||||||
and what the program that uses the Library does.
|
|
||||||
|
|
||||||
1. You may copy and distribute verbatim copies of the Library's
|
|
||||||
complete source code as you receive it, in any medium, provided that
|
|
||||||
you conspicuously and appropriately publish on each copy an
|
|
||||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
|
||||||
all the notices that refer to this License and to the absence of any
|
|
||||||
warranty; and distribute a copy of this License along with the
|
|
||||||
Library.
|
|
||||||
|
|
||||||
You may charge a fee for the physical act of transferring a copy,
|
|
||||||
and you may at your option offer warranty protection in exchange for a
|
|
||||||
fee.
|
|
||||||
|
|
||||||
2. You may modify your copy or copies of the Library or any portion
|
|
||||||
of it, thus forming a work based on the Library, and copy and
|
|
||||||
distribute such modifications or work under the terms of Section 1
|
|
||||||
above, provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
a) The modified work must itself be a software library.
|
|
||||||
|
|
||||||
b) You must cause the files modified to carry prominent notices
|
|
||||||
stating that you changed the files and the date of any change.
|
|
||||||
|
|
||||||
c) You must cause the whole of the work to be licensed at no
|
|
||||||
charge to all third parties under the terms of this License.
|
|
||||||
|
|
||||||
d) If a facility in the modified Library refers to a function or a
|
|
||||||
table of data to be supplied by an application program that uses
|
|
||||||
the facility, other than as an argument passed when the facility
|
|
||||||
is invoked, then you must make a good faith effort to ensure that,
|
|
||||||
in the event an application does not supply such function or
|
|
||||||
table, the facility still operates, and performs whatever part of
|
|
||||||
its purpose remains meaningful.
|
|
||||||
|
|
||||||
(For example, a function in a library to compute square roots has
|
|
||||||
a purpose that is entirely well-defined independent of the
|
|
||||||
application. Therefore, Subsection 2d requires that any
|
|
||||||
application-supplied function or table used by this function must
|
|
||||||
be optional: if the application does not supply it, the square
|
|
||||||
root function must still compute square roots.)
|
|
||||||
|
|
||||||
These requirements apply to the modified work as a whole. If
|
|
||||||
identifiable sections of that work are not derived from the Library,
|
|
||||||
and can be reasonably considered independent and separate works in
|
|
||||||
themselves, then this License, and its terms, do not apply to those
|
|
||||||
sections when you distribute them as separate works. But when you
|
|
||||||
distribute the same sections as part of a whole which is a work based
|
|
||||||
on the Library, the distribution of the whole must be on the terms of
|
|
||||||
this License, whose permissions for other licensees extend to the
|
|
||||||
entire whole, and thus to each and every part regardless of who wrote
|
|
||||||
it.
|
|
||||||
|
|
||||||
Thus, it is not the intent of this section to claim rights or contest
|
|
||||||
your rights to work written entirely by you; rather, the intent is to
|
|
||||||
exercise the right to control the distribution of derivative or
|
|
||||||
collective works based on the Library.
|
|
||||||
|
|
||||||
In addition, mere aggregation of another work not based on the Library
|
|
||||||
with the Library (or with a work based on the Library) on a volume of
|
|
||||||
a storage or distribution medium does not bring the other work under
|
|
||||||
the scope of this License.
|
|
||||||
|
|
||||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
|
||||||
License instead of this License to a given copy of the Library. To do
|
|
||||||
this, you must alter all the notices that refer to this License, so
|
|
||||||
that they refer to the ordinary GNU General Public License, version 2,
|
|
||||||
instead of to this License. (If a newer version than version 2 of the
|
|
||||||
ordinary GNU General Public License has appeared, then you can specify
|
|
||||||
that version instead if you wish.) Do not make any other change in
|
|
||||||
these notices.
|
|
||||||
|
|
||||||
Once this change is made in a given copy, it is irreversible for
|
|
||||||
that copy, so the ordinary GNU General Public License applies to all
|
|
||||||
subsequent copies and derivative works made from that copy.
|
|
||||||
|
|
||||||
This option is useful when you wish to copy part of the code of
|
|
||||||
the Library into a program that is not a library.
|
|
||||||
|
|
||||||
4. You may copy and distribute the Library (or a portion or
|
|
||||||
derivative of it, under Section 2) in object code or executable form
|
|
||||||
under the terms of Sections 1 and 2 above provided that you accompany
|
|
||||||
it with the complete corresponding machine-readable source code, which
|
|
||||||
must be distributed under the terms of Sections 1 and 2 above on a
|
|
||||||
medium customarily used for software interchange.
|
|
||||||
|
|
||||||
If distribution of object code is made by offering access to copy
|
|
||||||
from a designated place, then offering equivalent access to copy the
|
|
||||||
source code from the same place satisfies the requirement to
|
|
||||||
distribute the source code, even though third parties are not
|
|
||||||
compelled to copy the source along with the object code.
|
|
||||||
|
|
||||||
5. A program that contains no derivative of any portion of the
|
|
||||||
Library, but is designed to work with the Library by being compiled or
|
|
||||||
linked with it, is called a "work that uses the Library". Such a
|
|
||||||
work, in isolation, is not a derivative work of the Library, and
|
|
||||||
therefore falls outside the scope of this License.
|
|
||||||
|
|
||||||
However, linking a "work that uses the Library" with the Library
|
|
||||||
creates an executable that is a derivative of the Library (because it
|
|
||||||
contains portions of the Library), rather than a "work that uses the
|
|
||||||
library". The executable is therefore covered by this License.
|
|
||||||
Section 6 states terms for distribution of such executables.
|
|
||||||
|
|
||||||
When a "work that uses the Library" uses material from a header file
|
|
||||||
that is part of the Library, the object code for the work may be a
|
|
||||||
derivative work of the Library even though the source code is not.
|
|
||||||
Whether this is true is especially significant if the work can be
|
|
||||||
linked without the Library, or if the work is itself a library. The
|
|
||||||
threshold for this to be true is not precisely defined by law.
|
|
||||||
|
|
||||||
If such an object file uses only numerical parameters, data
|
|
||||||
structure layouts and accessors, and small macros and small inline
|
|
||||||
functions (ten lines or less in length), then the use of the object
|
|
||||||
file is unrestricted, regardless of whether it is legally a derivative
|
|
||||||
work. (Executables containing this object code plus portions of the
|
|
||||||
Library will still fall under Section 6.)
|
|
||||||
|
|
||||||
Otherwise, if the work is a derivative of the Library, you may
|
|
||||||
distribute the object code for the work under the terms of Section 6.
|
|
||||||
Any executables containing that work also fall under Section 6,
|
|
||||||
whether or not they are linked directly with the Library itself.
|
|
||||||
|
|
||||||
6. As an exception to the Sections above, you may also compile or
|
|
||||||
link a "work that uses the Library" with the Library to produce a
|
|
||||||
work containing portions of the Library, and distribute that work
|
|
||||||
under terms of your choice, provided that the terms permit
|
|
||||||
modification of the work for the customer's own use and reverse
|
|
||||||
engineering for debugging such modifications.
|
|
||||||
|
|
||||||
You must give prominent notice with each copy of the work that the
|
|
||||||
Library is used in it and that the Library and its use are covered by
|
|
||||||
this License. You must supply a copy of this License. If the work
|
|
||||||
during execution displays copyright notices, you must include the
|
|
||||||
copyright notice for the Library among them, as well as a reference
|
|
||||||
directing the user to the copy of this License. Also, you must do one
|
|
||||||
of these things:
|
|
||||||
|
|
||||||
a) Accompany the work with the complete corresponding
|
|
||||||
machine-readable source code for the Library including whatever
|
|
||||||
changes were used in the work (which must be distributed under
|
|
||||||
Sections 1 and 2 above); and, if the work is an executable linked
|
|
||||||
with the Library, with the complete machine-readable "work that
|
|
||||||
uses the Library", as object code and/or source code, so that the
|
|
||||||
user can modify the Library and then relink to produce a modified
|
|
||||||
executable containing the modified Library. (It is understood
|
|
||||||
that the user who changes the contents of definitions files in the
|
|
||||||
Library will not necessarily be able to recompile the application
|
|
||||||
to use the modified definitions.)
|
|
||||||
|
|
||||||
b) Accompany the work with a written offer, valid for at
|
|
||||||
least three years, to give the same user the materials
|
|
||||||
specified in Subsection 6a, above, for a charge no more
|
|
||||||
than the cost of performing this distribution.
|
|
||||||
|
|
||||||
c) If distribution of the work is made by offering access to copy
|
|
||||||
from a designated place, offer equivalent access to copy the above
|
|
||||||
specified materials from the same place.
|
|
||||||
|
|
||||||
d) Verify that the user has already received a copy of these
|
|
||||||
materials or that you have already sent this user a copy.
|
|
||||||
|
|
||||||
For an executable, the required form of the "work that uses the
|
|
||||||
Library" must include any data and utility programs needed for
|
|
||||||
reproducing the executable from it. However, as a special exception,
|
|
||||||
the source code distributed need not include anything that is normally
|
|
||||||
distributed (in either source or binary form) with the major
|
|
||||||
components (compiler, kernel, and so on) of the operating system on
|
|
||||||
which the executable runs, unless that component itself accompanies
|
|
||||||
the executable.
|
|
||||||
|
|
||||||
It may happen that this requirement contradicts the license
|
|
||||||
restrictions of other proprietary libraries that do not normally
|
|
||||||
accompany the operating system. Such a contradiction means you cannot
|
|
||||||
use both them and the Library together in an executable that you
|
|
||||||
distribute.
|
|
||||||
|
|
||||||
7. You may place library facilities that are a work based on the
|
|
||||||
Library side-by-side in a single library together with other library
|
|
||||||
facilities not covered by this License, and distribute such a combined
|
|
||||||
library, provided that the separate distribution of the work based on
|
|
||||||
the Library and of the other library facilities is otherwise
|
|
||||||
permitted, and provided that you do these two things:
|
|
||||||
|
|
||||||
a) Accompany the combined library with a copy of the same work
|
|
||||||
based on the Library, uncombined with any other library
|
|
||||||
facilities. This must be distributed under the terms of the
|
|
||||||
Sections above.
|
|
||||||
|
|
||||||
b) Give prominent notice with the combined library of the fact
|
|
||||||
that part of it is a work based on the Library, and explaining
|
|
||||||
where to find the accompanying uncombined form of the same work.
|
|
||||||
|
|
||||||
8. You may not copy, modify, sublicense, link with, or distribute
|
|
||||||
the Library except as expressly provided under this License. Any
|
|
||||||
attempt otherwise to copy, modify, sublicense, link with, or
|
|
||||||
distribute the Library is void, and will automatically terminate your
|
|
||||||
rights under this License. However, parties who have received copies,
|
|
||||||
or rights, from you under this License will not have their licenses
|
|
||||||
terminated so long as such parties remain in full compliance.
|
|
||||||
|
|
||||||
9. You are not required to accept this License, since you have not
|
|
||||||
signed it. However, nothing else grants you permission to modify or
|
|
||||||
distribute the Library or its derivative works. These actions are
|
|
||||||
prohibited by law if you do not accept this License. Therefore, by
|
|
||||||
modifying or distributing the Library (or any work based on the
|
|
||||||
Library), you indicate your acceptance of this License to do so, and
|
|
||||||
all its terms and conditions for copying, distributing or modifying
|
|
||||||
the Library or works based on it.
|
|
||||||
|
|
||||||
10. Each time you redistribute the Library (or any work based on the
|
|
||||||
Library), the recipient automatically receives a license from the
|
|
||||||
original licensor to copy, distribute, link with or modify the Library
|
|
||||||
subject to these terms and conditions. You may not impose any further
|
|
||||||
restrictions on the recipients' exercise of the rights granted herein.
|
|
||||||
You are not responsible for enforcing compliance by third parties to
|
|
||||||
this License.
|
|
||||||
|
|
||||||
11. If, as a consequence of a court judgment or allegation of patent
|
|
||||||
infringement or for any other reason (not limited to patent issues),
|
|
||||||
conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot
|
|
||||||
distribute so as to satisfy simultaneously your obligations under this
|
|
||||||
License and any other pertinent obligations, then as a consequence you
|
|
||||||
may not distribute the Library at all. For example, if a patent
|
|
||||||
license would not permit royalty-free redistribution of the Library by
|
|
||||||
all those who receive copies directly or indirectly through you, then
|
|
||||||
the only way you could satisfy both it and this License would be to
|
|
||||||
refrain entirely from distribution of the Library.
|
|
||||||
|
|
||||||
If any portion of this section is held invalid or unenforceable under any
|
|
||||||
particular circumstance, the balance of the section is intended to apply,
|
|
||||||
and the section as a whole is intended to apply in other circumstances.
|
|
||||||
|
|
||||||
It is not the purpose of this section to induce you to infringe any
|
|
||||||
patents or other property right claims or to contest validity of any
|
|
||||||
such claims; this section has the sole purpose of protecting the
|
|
||||||
integrity of the free software distribution system which is
|
|
||||||
implemented by public license practices. Many people have made
|
|
||||||
generous contributions to the wide range of software distributed
|
|
||||||
through that system in reliance on consistent application of that
|
|
||||||
system; it is up to the author/donor to decide if he or she is willing
|
|
||||||
to distribute software through any other system and a licensee cannot
|
|
||||||
impose that choice.
|
|
||||||
|
|
||||||
This section is intended to make thoroughly clear what is believed to
|
|
||||||
be a consequence of the rest of this License.
|
|
||||||
|
|
||||||
12. If the distribution and/or use of the Library is restricted in
|
|
||||||
certain countries either by patents or by copyrighted interfaces, the
|
|
||||||
original copyright holder who places the Library under this License may add
|
|
||||||
an explicit geographical distribution limitation excluding those countries,
|
|
||||||
so that distribution is permitted only in or among countries not thus
|
|
||||||
excluded. In such case, this License incorporates the limitation as if
|
|
||||||
written in the body of this License.
|
|
||||||
|
|
||||||
13. The Free Software Foundation may publish revised and/or new
|
|
||||||
versions of the Library General Public License from time to time.
|
|
||||||
Such new versions will be similar in spirit to the present version,
|
|
||||||
but may differ in detail to address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the Library
|
|
||||||
specifies a version number of this License which applies to it and
|
|
||||||
"any later version", you have the option of following the terms and
|
|
||||||
conditions either of that version or of any later version published by
|
|
||||||
the Free Software Foundation. If the Library does not specify a
|
|
||||||
license version number, you may choose any version ever published by
|
|
||||||
the Free Software Foundation.
|
|
||||||
|
|
||||||
14. If you wish to incorporate parts of the Library into other free
|
|
||||||
programs whose distribution conditions are incompatible with these,
|
|
||||||
write to the author to ask for permission. For software which is
|
|
||||||
copyrighted by the Free Software Foundation, write to the Free
|
|
||||||
Software Foundation; we sometimes make exceptions for this. Our
|
|
||||||
decision will be guided by the two goals of preserving the free status
|
|
||||||
of all derivatives of our free software and of promoting the sharing
|
|
||||||
and reuse of software generally.
|
|
||||||
|
|
||||||
NO WARRANTY
|
|
||||||
|
|
||||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
|
||||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
|
||||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
|
||||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
|
||||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
|
||||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
|
||||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
|
||||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
|
||||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
|
||||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
|
||||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
|
||||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
|
||||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
|
||||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
|
||||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
|
||||||
DAMAGES.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
Appendix: How to Apply These Terms to Your New Libraries
|
|
||||||
|
|
||||||
If you develop a new library, and you want it to be of the greatest
|
|
||||||
possible use to the public, we recommend making it free software that
|
|
||||||
everyone can redistribute and change. You can do so by permitting
|
|
||||||
redistribution under these terms (or, alternatively, under the terms of the
|
|
||||||
ordinary General Public License).
|
|
||||||
|
|
||||||
To apply these terms, attach the following notices to the library. It is
|
|
||||||
safest to attach them to the start of each source file to most effectively
|
|
||||||
convey the exclusion of warranty; and each file should have at least the
|
|
||||||
"copyright" line and a pointer to where the full notice is found.
|
|
||||||
|
|
||||||
<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!
|
|
|
@ -1,2 +0,0 @@
|
||||||
This package has been modified for use with GStreamer. Go to the root gstreamer
|
|
||||||
directory to install.
|
|
|
@ -1,36 +0,0 @@
|
||||||
## 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
|
|
|
@ -1 +0,0 @@
|
||||||
no gnus here
|
|
|
@ -1,5 +0,0 @@
|
||||||
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
|
|
|
@ -1,61 +0,0 @@
|
||||||
/*
|
|
||||||
** 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_ */
|
|
|
@ -1,204 +0,0 @@
|
||||||
#!/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."
|
|
|
@ -1,306 +0,0 @@
|
||||||
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
|
|
||||||
)
|
|
|
@ -1,236 +0,0 @@
|
||||||
/* 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;
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
/* 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__ */
|
|
|
@ -1,203 +0,0 @@
|
||||||
/* 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");
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,84 +0,0 @@
|
||||||
/* 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__ */
|
|
|
@ -1,33 +0,0 @@
|
||||||
#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;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,196 +0,0 @@
|
||||||
# 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
|
|
||||||
])
|
|
|
@ -1,182 +0,0 @@
|
||||||
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"
|
|
||||||
])
|
|
|
@ -1,15 +0,0 @@
|
||||||
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
|
|
||||||
])
|
|
|
@ -1,56 +0,0 @@
|
||||||
|
|
||||||
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
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,73 +0,0 @@
|
||||||
/*
|
|
||||||
** 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_ */
|
|
|
@ -1,64 +0,0 @@
|
||||||
/*
|
|
||||||
** 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_ */
|
|
||||||
|
|
|
@ -1,78 +0,0 @@
|
||||||
/*
|
|
||||||
** 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;
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
/*
|
|
||||||
** 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;
|
|
||||||
|
|
|
@ -1,557 +0,0 @@
|
||||||
/*
|
|
||||||
** 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
|
|
||||||
|
|
|
@ -1,70 +0,0 @@
|
||||||
/*
|
|
||||||
** 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_ */
|
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
/*
|
|
||||||
** 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_ */
|
|
||||||
|
|
1492
gst/cothreads/shtool
1492
gst/cothreads/shtool
File diff suppressed because it is too large
Load diff
|
@ -1,83 +0,0 @@
|
||||||
#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);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,70 +0,0 @@
|
||||||
#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);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,62 +0,0 @@
|
||||||
#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);
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
#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);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
#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);
|
|
||||||
}
|
|
Loading…
Reference in a new issue