The core code from pth has been taken out and included in gstreamer.

Original commit message from CVS:
The core code from pth has been taken out and included in gstreamer.
This code is documented, more or less, in http://www-124.ibm.com/pthreads/docs/rse-pmt.ps.

This code is designed to replace cothreads.[ch], eventually.
This commit is contained in:
Andy Wingo 2002-01-21 00:20:29 +00:00
parent debf06d4b9
commit 1bc541f213
19 changed files with 5309 additions and 0 deletions

25
gst/cothreads/AUTHORS Normal file
View file

@ -0,0 +1,25 @@
____ _ _
| _ \| |_| |__
| |_) | __| '_ \ ``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

481
gst/cothreads/COPYING Normal file
View file

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

0
gst/cothreads/ChangeLog Normal file
View file

2
gst/cothreads/INSTALL Normal file
View file

@ -0,0 +1,2 @@
This package has been modified for use with GStreamer. Go to the root gstreamer
directory to install.

49
gst/cothreads/Makefile.am Normal file
View file

@ -0,0 +1,49 @@
##
## NGPT - Next Generation Threading
## Copyright (c) 2001 IBM Corporation <babt@us.ibm.com>
## Portions Copyright (c) 1999-2000 Ralf S. Engelschall <rse@engelschall.com>
##
## This file is part of NGPT, a non-preemptive thread scheduling
## library which can be found at http://www.ibm.com/developer
##
## 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.
##
## 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
libpth_mctx_la_SOURCES = pth_mctx.c pth_p.h pth_vers.c pth.h pth_acdef.h pth_acmac.h
noinst_PROGRAMS = test-pth
test_pth_LDADD = libpth-mctx.la
#pth_mctx_a_DEPENDENCIES = shtool
BUILT_SOURCES = pth_p.h
HSRCS = $(srcdir)/pth_debug.c $(srcdir)/pth_errno.c $(srcdir)/pth_mctx.c
# build the private shared header file
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)
#shtool:
# shtoolize -o shtool scpp

1
gst/cothreads/NEWS Normal file
View file

@ -0,0 +1 @@
no gnus here

5
gst/cothreads/README Normal file
View file

@ -0,0 +1,5 @@
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

59
gst/cothreads/acconfig.h Normal file
View file

@ -0,0 +1,59 @@
/*
** 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
@BOTTOM@
#endif /* _PTH_ACDEF_H_ */

1766
gst/cothreads/acinclude.m4 Normal file

File diff suppressed because it is too large Load diff

409
gst/cothreads/configure.ac Normal file
View file

@ -0,0 +1,409 @@
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
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 sys/time.h sys/wait.h sys/socket.h sys/socketcall.h)
AC_CHECK_FUNCTIONS(dnl
gettimeofday select 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 header:sys/time.h header:sys/wait.h header:sys/socket.h dnl
func:gettimeofday func:select 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 for the number of signals
dnl AC_CHECK_NSIG(PTH_NSIG)
dnl # check whether poll(2)'s input stuff has to be faked
AC_CHECK_FUNCTIONS(poll)
AC_CHECK_DEFINE(POLLIN, poll.h)
AC_MSG_CHECKING(whether poll(2) facility has to be faked)
AC_IFALLYES(func:poll define:POLLIN, PTH_FAKE_POLL=0, PTH_FAKE_POLL=1)
if test .$PTH_FAKE_POLL = .1; then
msg="yes"
else
msg="no"
fi
AC_SUBST(PTH_FAKE_POLL)
AC_MSG_RESULT([$msg])
dnl # check for readv/writev environment
AC_HAVE_HEADERS(sys/uio.h)
AC_CHECK_FUNCTIONS(readv writev)
AC_MSG_CHECKING(whether readv(2)/writev(2) facility has to be faked)
AC_IFALLYES(func:readv func:writev header:sys/uio.h, PTH_FAKE_RWV=0, PTH_FAKE_RWV=1)
if test .$PTH_FAKE_RWV = .1; then
msg="yes"
else
msg="no"
fi
AC_SUBST(PTH_FAKE_RWV)
AC_MSG_RESULT([$msg])
dnl # check for various other functions which would be nice to have
AC_CHECK_FUNCTIONS(usleep strerror)
dnl # check for various other headers which we might need
AC_HAVE_HEADERS(sys/resource.h net/errno.h)
dnl # check whether we've to use a non-standard #include <sys/select.h> to get
dnl # the definition for fd_set under AIX and other brain-dead platforms.
AC_HAVE_HEADERS(sys/select.h)
EXTRA_INCLUDE_SYS_SELECT_H="#include <sys/select.h>"
if test ".$ac_cv_header_sys_select_h" != .yes; then
EXTRA_INCLUDE_SYS_SELECT_H="/* $EXTRA_INCLUDE_SYS_SELECT_H */"
fi
AC_SUBST(EXTRA_INCLUDE_SYS_SELECT_H)
dnl # check whether we've to define sig_atomic_t
AC_CHECK_TYPEDEF(sig_atomic_t, signal.h)
FALLBACK_SIG_ATOMIC_T="typedef int sig_atomic_t;"
if test ".$ac_cv_typedef_sig_atomic_t" = .yes; then
FALLBACK_SIG_ATOMIC_T="/* $FALLBACK_SIG_ATOMIC_T */"
fi
AC_SUBST(FALLBACK_SIG_ATOMIC_T)
dnl # check whether we've to define pid_t
AC_CHECK_TYPEDEF(pid_t, sys/types.h)
FALLBACK_PID_T="typedef int pid_t;"
if test ".$ac_cv_typedef_pid_t" = .yes; then
FALLBACK_PID_T="/* $FALLBACK_PID_T */"
fi
AC_SUBST(FALLBACK_PID_T)
dnl # check whether we've to define size_t
AC_CHECK_TYPEDEF(size_t, stdlib.h)
FALLBACK_SIZE_T="typedef unsigned int size_t;"
if test ".$ac_cv_typedef_size_t" = .yes; then
FALLBACK_SIZE_T="/* $FALLBACK_SIZE_T */"
fi
AC_SUBST(FALLBACK_SIZE_T)
dnl # check whether we've to define ssize_t
AC_CHECK_TYPEDEF(ssize_t, sys/types.h)
FALLBACK_SSIZE_T="typedef unsigned int ssize_t;"
if test ".$ac_cv_typedef_ssize_t" = .yes; then
FALLBACK_SSIZE_T="/* $FALLBACK_SSIZE_T */"
fi
AC_SUBST(FALLBACK_SSIZE_T)
dnl # check whether we've to define off_t
AC_CHECK_TYPEDEF(off_t, sys/types.h)
FALLBACK_OFF_T="typedef int off_t;"
if test ".$ac_cv_typedef_off_t" = .yes; then
FALLBACK_OFF_T="/* $FALLBACK_OFF_T */"
fi
AC_SUBST(FALLBACK_OFF_T)
dnl # check whether stack_t exists instead of sigaltstack
AC_CHECK_TYPEDEF(stack_t, signal.h)
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 # check for gettimeofday() variant
AC_MSG_CHECKING(for a single-argument based gettimeofday)
cross_compile=no
AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>
],[
struct timeval tv;
(void)gettimeofday(&tv);
],
msg="yes"
,
msg="no"
)
case $PLATFORM in
*-*-mvs* ) msg="no" ;; # on OS/390 the compiler test doesn't work
*-*-aix4* ) msg="no" ;; # on AIX the compiler test doesn't work
*-*-isc* ) msg="no" ;; # on ISC the compiler test doesn't work
esac
if test ".$msg" = .yes; then
AC_DEFINE(HAVE_GETTIMEOFDAY_ARGS1)
fi
AC_MSG_RESULT([$msg])
dnl # check for struct timespec
AC_MSG_CHECKING(for struct timespec)
cross_compile=no
AC_TRY_COMPILE([
#include <time.h>
#include <sys/time.h>
],[
struct timespec ts;
],
msg="yes"
,
msg="no"
)
if test ".$msg" = .yes; then
AC_DEFINE(HAVE_STRUCT_TIMESPEC)
fi
AC_MSG_RESULT([$msg])
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])
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
)

74
gst/cothreads/pth.h.in Normal file
View file

@ -0,0 +1,74 @@
/*
** 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 */
@EXTRA_INCLUDE_SYS_SELECT_H@
/* 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_ */

View file

@ -0,0 +1,64 @@
/*
** 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_ */

78
gst/cothreads/pth_debug.c Normal file
View file

@ -0,0 +1,78 @@
/*
** 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;
}

56
gst/cothreads/pth_errno.c Normal file
View file

@ -0,0 +1,56 @@
/*
** 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;

557
gst/cothreads/pth_mctx.c Normal file
View file

@ -0,0 +1,557 @@
/*
** 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

109
gst/cothreads/pth_p.h.in Normal file
View file

@ -0,0 +1,109 @@
/*
** 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 <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <setjmp.h>
#include <signal.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.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"
/* optional system headers */
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
#ifdef HAVE_NET_ERRNO_H
#include <net/errno.h>
#endif
/* dmalloc support */
#ifdef PTH_DMALLOC
#include <dmalloc.h>
#endif
/* paths */
#ifdef HAVE_PATHS_H
#include <paths.h>
#endif
#ifdef _PATH_BSHELL
#define PTH_PATH_BINSH _PATH_BSHELL
#else
#define PTH_PATH_BINSH "/bin/sh"
#endif
/* non-blocking flags */
#ifdef O_NONBLOCK
#define O_NONBLOCKING O_NONBLOCK
#else
#ifdef O_NDELAY
#define O_NONBLOCKING O_NDELAY
#else
#ifdef FNDELAY
#define O_NONBLOCKING FNDELAY
#else
#error "No O_NONBLOCK, O_NDELAY or FNDELAY flag available!"
#endif
#endif
#endif
/* compiler happyness: avoid ``empty compilation unit'' problem */
#define COMPILER_HAPPYNESS(name) \
int __##name##_unit = 0;
/* generated contents */
BEGIN_DECLARATION
==#==
END_DECLARATION
#endif /* _PTH_P_H_ */

46
gst/cothreads/pth_vers.c Normal file
View file

@ -0,0 +1,46 @@
/*
** 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 Executable file

File diff suppressed because it is too large Load diff

36
gst/cothreads/test-pth.c Normal file
View file

@ -0,0 +1,36 @@
#include "pth_p.h"
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
pth_mctx_t main_context;
void thread_1 (char *str)
{
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);
}